diff --git a/ccc.c b/ccc.c index 44fe635..cc8bf58 100644 --- a/ccc.c +++ b/ccc.c @@ -268,6 +268,7 @@ int main(int argc, char** argv) case 'i': file_details = !file_details; change_dir(cwd, 0, 0); + break; /* mark one file */ case SPACE: diff --git a/file.c b/file.c index e954dd3..30439e1 100644 --- a/file.c +++ b/file.c @@ -132,15 +132,27 @@ char *get_line(ArrayList *list, long index, bool detail) { file file = list->items[index]; char *name = strdup(file.path); - char *stats = strdup(file.stats); - size_t length = strlen(name) + strlen(stats) + 2; /* one for space and one for null */ + char *stats = NULL; + size_t length; + if (detail) { + stats = strdup(file.stats); + length = strlen(name) + strlen(stats) + 2; /* one for space and one for null */ + if (stats == NULL) { + perror("ccc"); + } + } else { + length = strlen(name) + 2; /* one for space and one for null */ + } char *line = memalloc(length * sizeof(char)); name = basename(name); - if (name == NULL || stats == NULL) + if (name == NULL) perror("ccc"); - - snprintf(line, length, "%s %s", stats, name); + if (detail) { + snprintf(line, length, "%s %s", stats, name); + } else { + snprintf(line, length, "%s", name); + } return line; }