From a455b5dd6ddc2cf49c52967f8cf00fd98a954b41 Mon Sep 17 00:00:00 2001 From: assar Date: Tue, 4 Jul 2000 23:09:23 +0000 Subject: 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 --- bin/ls/util.c | 24 +++++++++++++----------- 1 file changed, 13 insertions(+), 11 deletions(-) (limited to 'bin/ls/util.c') diff --git a/bin/ls/util.c b/bin/ls/util.c index 7239d97..1f839c5 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; -- cgit v1.1