comparison toys/posix/ls.c @ 916:b92cb3cc9696

Stat cleanup. lib: rename format_mode() to mode_to_string() (echoing string_to_mode), make it take a normal char * argument. stat: collapse big switch/case statements that only have one line each into if/else staircase (much fewer lines of code). Remove return type (other stat implementations print ? for unknown escapes, so do that here). Inline do_stat() and do_statfs(). Set default string in normal local variable "format". Remove unnecessary struct d. Restructure stat logic to "if (flagf && !statfs()) else if (!flagf && !stat()) else perror_msg();" Teach %N to add -> symlink. Judicious use of putchar() instead of xputc to let FILE * do its job collating output.
author Rob Landley <rob@landley.net>
date Sun, 02 Jun 2013 00:24:24 -0500
parents beb32d780164
children 871c68a35e95
comparison
equal deleted inserted replaced
915:463a7b796e61 916:b92cb3cc9696
335 335
336 if (flags & (FLAG_l|FLAG_o|FLAG_n|FLAG_g)) { 336 if (flags & (FLAG_l|FLAG_o|FLAG_n|FLAG_g)) {
337 struct tm *tm; 337 struct tm *tm;
338 char perm[11], thyme[64], *usr, *upad, *grp, *grpad; 338 char perm[11], thyme[64], *usr, *upad, *grp, *grpad;
339 339
340 format_mode(&perm, mode); 340 mode_to_string(mode, perm);
341 341
342 tm = localtime(&(st->st_mtime)); 342 tm = localtime(&(st->st_mtime));
343 strftime(thyme, sizeof(thyme), "%F %H:%M", tm); 343 strftime(thyme, sizeof(thyme), "%F %H:%M", tm);
344 344
345 if (flags&FLAG_o) grp = grpad = toybuf+256; 345 if (flags&FLAG_o) grp = grpad = toybuf+256;