diff options
author | Jim Meyering <jim@meyering.net> | 1997-01-05 03:18:49 +0000 |
---|---|---|
committer | Jim Meyering <jim@meyering.net> | 1997-01-05 03:18:49 +0000 |
commit | 783bace690e9e4c6076424d433616369073f45cc (patch) | |
tree | 646af9a1c8e56940ee6df6840cac38fa0156b36b /src | |
parent | 31d836282b499e094562c99342b4eef249e08006 (diff) | |
download | coreutils-783bace690e9e4c6076424d433616369073f45cc.tar.xz |
(print_long_format): Clean up vestiges of legacy
ctime-oriented code. With internationalization and strftime,
you can't presume that %a expands to a 3-byte string.
Reported by Ross Ridge.
Diffstat (limited to 'src')
-rw-r--r-- | src/ls.c | 24 |
1 files changed, 14 insertions, 10 deletions
@@ -131,7 +131,6 @@ struct bin_str }; #ifndef STDC_HEADERS -char *ctime (); time_t time (); void free (); #endif @@ -2047,6 +2046,7 @@ print_long_format (const struct fileinfo *f) char bigbuf[7 * 20 + 10 + 24 + 9 + 1]; char *p; time_t when; + const char *fmt; #ifdef HAVE_ST_DM_MODE mode_string (f->stat.st_dm_mode, modebuf); @@ -2069,12 +2069,10 @@ print_long_format (const struct fileinfo *f) break; } - /* Use strftime rather than ctime, because the former can produce - locale-dependent names for the weekday (%a) and month (%b). */ - strftime (timebuf, TIMEBUF_SIZE, "%a %b %d %H:%M:%S %Y", localtime (&when)); - if (full_time) - timebuf[24] = '\0'; + { + fmt = "%a %b %d %H:%M:%S %Y"; + } else { if (current_time > when + 6L * 30L * 24L * 60L * 60L /* Old. */ @@ -2086,11 +2084,18 @@ print_long_format (const struct fileinfo *f) Allow a 1 hour slop factor for what is considered "the future", to allow for NFS server/client clock disagreement. Show the year instead of the time of day. */ - strcpy (timebuf + 11, timebuf + 19); + fmt = "%b %e %Y"; + } + else + { + fmt = "%b %e %H:%M"; } - timebuf[16] = 0; } + /* Use strftime rather than ctime, because the former can produce + locale-dependent names for the weekday (%a) and month (%b). */ + strftime (timebuf, TIMEBUF_SIZE, fmt, localtime (&when)); + p = bigbuf; if (print_inode) @@ -2134,8 +2139,7 @@ print_long_format (const struct fileinfo *f) sprintf (p, "%8lu ", (unsigned long) f->stat.st_size); p += strlen (p); - sprintf (p, "%s ", full_time ? timebuf : timebuf + 4); - p += strlen (p); + p = stpcpy (stpcpy (p, timebuf), " "); DIRED_INDENT (); FPUTS (bigbuf, stdout, p - bigbuf); |