diff options
author | Assar Westerlund <assar@FreeBSD.org> | 2000-07-04 23:09:23 +0000 |
---|---|---|
committer | Assar Westerlund <assar@FreeBSD.org> | 2000-07-04 23:09:23 +0000 |
commit | ee579ffbeaeacc901b05fd8b1b7765772c9f8bad (patch) | |
tree | 3c5345bf2175d3ff9872775daae197159b47b8a5 /bin/ls/util.c | |
parent | 950ec7e473bcf100cfac2fd9339d5bd9ab8b4003 (diff) | |
download | src-ee579ffbeaeacc901b05fd8b1b7765772c9f8bad.tar.gz src-ee579ffbeaeacc901b05fd8b1b7765772c9f8bad.zip |
make sure we do not write out non-printable characters in file names
and symbolic links (by default)
PR: bin/19354
Reviewed by: silence on -current
Notes
Notes:
svn path=/head/; revision=62597
Diffstat (limited to 'bin/ls/util.c')
-rw-r--r-- | bin/ls/util.c | 24 |
1 files changed, 13 insertions, 11 deletions
diff --git a/bin/ls/util.c b/bin/ls/util.c index 7239d9776abf..1f839c59d02b 100644 --- a/bin/ls/util.c +++ b/bin/ls/util.c @@ -56,17 +56,19 @@ static const char rcsid[] = #include "ls.h" #include "extern.h" -void -prcopy(src, dest, len) - char *src, *dest; - int len; +int +prn_printable(s) + const char *s; { - unsigned char ch; + unsigned char c; + int n; - while (len--) { - ch = *src++; - *dest++ = isprint(ch) ? ch : '?'; - } + for (n = 0; (c = *s) != '\0'; ++s, ++n) + if (isprint(c)) + putchar(c); + else + putchar('?'); + return n; } /* @@ -84,7 +86,7 @@ prcopy(src, dest, len) int len_octal(s, len) - char *s; + const char *s; int len; { int r = 0; @@ -96,7 +98,7 @@ len_octal(s, len) int prn_octal(s) - char *s; + const char *s; { unsigned char ch; int len = 0; |