1
0
mirror of https://github.com/openbsd/src.git synced 2025-01-04 23:35:36 -08:00
Commit Graph

41 Commits

Author SHA1 Message Date
millert
ba906cc60a printtime: use the Unix epoch if the file's timestamp is invalid
Fixes a crash in "ls -l" for files with bogus timestamp values.
OK miod@ denis@
2024-03-27 14:44:52 +00:00
schwarze
09b34e9cf9 Improve horizontal alignment in long format when printing minor
device numbers greater than 999 by measuring the two widths needed
for device numbers just like it is already done for other numbers.
In the output, this only changes whitespace, but not the text.

Ugly formatting reported by
Crystal Kolipe <kolipe dot c at exoticsilicon dot com>.

OK millert.  Also tested by Crystal Kolipe.
2023-10-07 11:51:08 +00:00
millert
bc2593c5af If we are asked to print the total number of blocks, do so even if
we have no entries to print (either due to an empty directory or
an error).  This makes the -l and -s options more consistent, and
matches the behavior of AT&T and GNU ls.  From FreeBSD (das).
OK kn@
2020-10-07 21:03:09 +00:00
deraadt
7aa9f692dc dev_t is signed to permit passing -1 as an invalid condition, but the
decomposition into major and minor is unsigned, so we should print them
with %u instead of %d.
ok guenther
2019-02-05 02:17:32 +00:00
krw
4442fdb76b Bring types of variables used with struct stat into the modern world.
Replace a couple of u_long paramaters with int as they were only passed int
values and the function re-cast them to (int) anyway. Weird.

ok tedu@
2016-08-16 16:09:24 +00:00
krw
7e8a4e4e69 %*qd -> %*lld + (long long) for off_t.
Avoid some casts by changing printsize() to take an int (the only
type actually passed via that parameter) instead of size_t.

Tweaks & ok guenther@
2016-08-15 16:57:53 +00:00
schwarze
b6203726b0 Support UTF-8: use wcwidth(3) for column adjustment and replace
non-printable Unicode codepoints and invalid bytes with ASCII
question marks.  No change for the SMALL version.

Using ideas developed by tedu@, phessler@, bentley@ and feedback from many.
OK yasuoka@ czarkoff@ sthen@.
2015-12-01 18:36:13 +00:00
millert
f7055df57d tzfile.h is an internal header that should never have been installed.
What's worse, the tzfile.h that gets installed is over 20 years old
and doesn't match the real tzfile.h in libc/time.  This makes the
tree safe for /usr/include/tzfile.h removal.  The TM_YEAR_BASE
define has been moved to time.h temporarily until its usage is
replaced by 1900 in the tree.  Actual removal of tzfile.h is pending
a ports build.  Based on a diff from deraadt@
2015-03-15 00:41:27 +00:00
deraadt
b9fc9a728f Replace <sys/param.h> with <limits.h> and other less dirty headers where
possible.  Annotate <sys/param.h> lines with their current reasons.  Switch
to PATH_MAX, NGROUPS_MAX, HOST_NAME_MAX+1, LOGIN_NAME_MAX, etc.  Change
MIN() and MAX() to local definitions of MINIMUM() and MAXIMUM() where
sensible to avoid pulling in the pollution.  These are the files confirmed
through binary verification.
ok guenther, millert, doug (helped with the verification protocol)
2015-01-16 06:39:28 +00:00
tedu
c0bbadaa95 reallocarray 2014-05-06 20:55:10 +00:00
guenther
64a7b209fc Per POSIX, times in the future should be reported with the year
like files more than six months old.  Use strftime() directly instead
of breaking down the ctime() output on character positions.

ok millert@
2014-01-09 03:07:52 +00:00
guenther
3e12fe88c8 Fix column padding of inode numbers and block counts >2^32, as well as
display of directory block totals >2^32

ok tedu@
2013-05-30 16:34:32 +00:00
deraadt
6be702bba0 handle large ino_t; ok millert 2013-04-23 18:08:40 +00:00
guenther
bb325d81bc With the -l option, only call time() once per run instead of once per file
ok deraadt@
2012-07-12 09:41:09 +00:00
sobrado
8e74991cd6 remove trailing spaces and tabs from source code; no binary change. 2010-09-12 20:16:29 +00:00
deraadt
043fbe51c1 rcsid[] and sccsid[] and copyright[] are essentially unmaintained (and
unmaintainable).  these days, people use source.  these id's do not provide
any benefit, and do hurt the small install media
(the 33,000 line diff is essentially mechanical)
ok with the idea millert, ok dms
2009-10-27 23:59:19 +00:00
millert
947f7ba6d0 Change the -g flag from a no-op to be POSIX conforming. We allow the
-l flag to override -g regardless of its position on the command line
for backwards compat with 4.3BSD.  From NetBSD.
OK jmc@, tom@, sobrado@
2007-05-07 18:39:28 +00:00
millert
0278adda01 remove whiteout support 2005-06-15 17:47:17 +00:00
otto
abf96da08a Remove unneccesary cast to long long and %llu format; print using %lu.
Spotted by tom@, ok millert@
2005-01-10 20:16:15 +00:00
deraadt
c624956833 free(NULL) is valid 2003-09-26 00:48:44 +00:00
deraadt
381b91eb3f realloc fixes: unallocate for next use if realloc fixes; do not incr size;
do not p = realloc(p, ...; ok from ho, cloder
2003-09-24 20:36:36 +00:00
tedu
91ea06e0c5 -h, human readable sizes. from a jonathon gray mail to tech@
ok ian@ millert@
2003-08-06 19:09:09 +00:00
deraadt
28416801cb ansification, art ok 2003-06-11 23:42:12 +00:00
millert
29295d1c5c Remove the advertising clause in the UCB license which Berkeley
rescinded 22 July 1999.  Proofed by myself and Theo.
2003-06-02 23:27:43 +00:00
deraadt
3cc9ab5fae utmp.h not needed 2002-08-01 21:49:57 +00:00
millert
c72b5b24e1 Part one of userland __P removal. Done with a simple regexp with some minor hand editing to make comments line up correctly. Another pass is forthcoming that handles the cases that could not be done automatically. 2002-02-16 21:27:05 +00:00
espie
b60c9e496b In multi-column output, don't bother filling up last column before '\n'.
As a result, we gain one extra position to format multi-column output,
since there is no added space at the end of the last column. For instance,
26 long filenames now print in 3 columns instead of 2.

At first, both millert@ and I thought that ending the line on the last
column might trigger trouble on some terminals, but then I realized that
current ls may already fill the last column with a space, with no apparent
grief anywhere, and Todd agreed.
2000-01-06 21:32:40 +00:00
espie
3273519501 Remove bogus chcnt assignments. 2000-01-05 16:02:11 +00:00
espie
78803e9c1b Perform colwidth computation sooner, as there's no need for random
access if we end up doing one column output.
2000-01-05 16:00:19 +00:00
espie
f296455f59 Factor column width computation out. 2000-01-05 15:58:27 +00:00
deraadt
413925e680 defer conversion of unprintable filenames till final display, permitting
badly named symbolic links to be handled; bug noted by dm@ fixed by d@
1999-05-01 23:54:47 +00:00
deraadt
b94f2f8772 add -x, -p, and -m options, based on netbsd work 1999-02-20 18:59:24 +00:00
deraadt
e2adce4c0e realloc bug fix and two other bugs found at the same time 1998-08-15 20:23:20 +00:00
deraadt
81b1fe40f2 MAXPATHLEN not MAXPATHLEN+1 1998-05-18 20:36:31 +00:00
deraadt
31e4d01529 i am bored enough to fix terminal space/tab uglies 1997-09-01 18:29:12 +00:00
millert
4bd83475bd From NetBSD:
- Correct sorting behaviour.
    - Do multicolumn output in a way that's a more likely to line up evenly.
      From D'Arcy J.M. Cain <darcy@druid.com>, NetBSD PR #2965.
1997-01-03 22:36:07 +00:00
tholo
c91959fe36 Get TAB expansion right 1996-12-17 18:52:52 +00:00
mickey
764064c4bd -Wall'ing. 1996-12-14 12:17:33 +00:00
deraadt
fcee33874f extra utmp.h goes away; tom@haven.uniserve.com in freebsd 1996-08-02 11:45:01 +00:00
deraadt
09e94acb64 update rcsid 1996-06-23 14:18:58 +00:00
deraadt
df930be708 initial import of NetBSD tree 1995-10-18 08:37:01 +00:00