Skip to content

Commit

Permalink
Use while c != -1 loop pattern
Browse files Browse the repository at this point in the history
  • Loading branch information
Sigmanificient committed Apr 24, 2024
1 parent 752e6b7 commit 0f3f56e
Showing 1 changed file with 3 additions and 5 deletions.
8 changes: 3 additions & 5 deletions src/ls/ls_main.c
Original file line number Diff line number Diff line change
Expand Up @@ -30,12 +30,9 @@ static const struct option LONG_OPTIONS[] = {

static char compose_flaglist(int argc, char **argv) {
char flags = 0;
int c;

for (;;) {
int c = getopt_long(argc, argv, "alRdrt", LONG_OPTIONS, NULL);

if (c == -1)
return flags;
while ((c = getopt_long(argc, argv, "alRdrt", LONG_OPTIONS, NULL)) != -1) {
switch (c) {
case 'a':
flags |= F_ALL_FILES;
Expand Down Expand Up @@ -68,6 +65,7 @@ static char compose_flaglist(int argc, char **argv) {
return -2;
}
}
return flags;
}

static bool list_dirs(dirbuff_t *db, int argc, char **argv, char flags) {
Expand Down

0 comments on commit 0f3f56e

Please sign in to comment.