summaryrefslogtreecommitdiffstats
path: root/bin/ls/util.c
diff options
context:
space:
mode:
authorassar <assar@FreeBSD.org>2000-07-04 23:09:23 +0000
committerassar <assar@FreeBSD.org>2000-07-04 23:09:23 +0000
commita455b5dd6ddc2cf49c52967f8cf00fd98a954b41 (patch)
tree0d4a5bad7fa80152da315496f1057126adbaddd0 /bin/ls/util.c
parent6fb1a7674a2e1084efc85cbed4d02844bf276d61 (diff)
downloadFreeBSD-src-a455b5dd6ddc2cf49c52967f8cf00fd98a954b41.zip
FreeBSD-src-a455b5dd6ddc2cf49c52967f8cf00fd98a954b41.tar.gz
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
Diffstat (limited to 'bin/ls/util.c')
-rw-r--r--bin/ls/util.c24
1 files changed, 13 insertions, 11 deletions
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;
OpenPOWER on IntegriCloud