summaryrefslogtreecommitdiff
path: root/bin
diff options
context:
space:
mode:
authorTheo de Raadt <deraadt@cvs.openbsd.org>1999-05-01 23:54:49 +0000
committerTheo de Raadt <deraadt@cvs.openbsd.org>1999-05-01 23:54:49 +0000
commitb45ac52cfe23f8d70993cc18d39cdd5c3f8f7a8c (patch)
tree60ab162631e87233243e388944c3211492d4c76e /bin
parentf2404a66800283ab007babadc7d3f0edf63770d9 (diff)
defer conversion of unprintable filenames till final display, permitting
badly named symbolic links to be handled; bug noted by dm@ fixed by d@
Diffstat (limited to 'bin')
-rw-r--r--bin/ls/extern.h4
-rw-r--r--bin/ls/ls.c6
-rw-r--r--bin/ls/ls.h3
-rw-r--r--bin/ls/print.c11
-rw-r--r--bin/ls/util.c20
5 files changed, 21 insertions, 23 deletions
diff --git a/bin/ls/extern.h b/bin/ls/extern.h
index 5126f0057d0..3a206c4c534 100644
--- a/bin/ls/extern.h
+++ b/bin/ls/extern.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: extern.h,v 1.3 1999/02/20 18:59:24 deraadt Exp $ */
+/* $OpenBSD: extern.h,v 1.4 1999/05/01 23:54:47 deraadt Exp $ */
/* $NetBSD: extern.h,v 1.5 1995/03/21 09:06:24 cgd Exp $ */
/*-
@@ -48,7 +48,7 @@ int sizecmp __P((const FTSENT *, const FTSENT *));
int revsizecmp __P((const FTSENT *, const FTSENT *));
char *flags_to_string __P((u_long, char *));
-void prcopy __P((char *, char *, int));
+int putname __P((char *));
void printcol __P((DISPLAY *));
void printacol __P((DISPLAY *));
void printlong __P((DISPLAY *));
diff --git a/bin/ls/ls.c b/bin/ls/ls.c
index feb5a43ac6e..f44230a3e00 100644
--- a/bin/ls/ls.c
+++ b/bin/ls/ls.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: ls.c,v 1.12 1999/02/24 16:48:02 aaron Exp $ */
+/* $OpenBSD: ls.c,v 1.13 1999/05/01 23:54:47 deraadt Exp $ */
/* $NetBSD: ls.c,v 1.18 1996/07/09 09:16:29 mycroft Exp $ */
/*
@@ -47,7 +47,7 @@ static char copyright[] =
#if 0
static char sccsid[] = "@(#)ls.c 8.7 (Berkeley) 8/5/94";
#else
-static char rcsid[] = "$OpenBSD: ls.c,v 1.12 1999/02/24 16:48:02 aaron Exp $";
+static char rcsid[] = "$OpenBSD: ls.c,v 1.13 1999/05/01 23:54:47 deraadt Exp $";
#endif
#endif /* not lint */
@@ -466,8 +466,6 @@ display(p, list)
continue;
}
}
- if (f_nonprint)
- prcopy(cur->fts_name, cur->fts_name, cur->fts_namelen);
if (cur->fts_namelen > maxlen)
maxlen = cur->fts_namelen;
if (needstats) {
diff --git a/bin/ls/ls.h b/bin/ls/ls.h
index 3152a15bd23..3818cdd1221 100644
--- a/bin/ls/ls.h
+++ b/bin/ls/ls.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: ls.h,v 1.3 1999/02/20 18:59:25 deraadt Exp $ */
+/* $OpenBSD: ls.h,v 1.4 1999/05/01 23:54:47 deraadt Exp $ */
/* $NetBSD: ls.h,v 1.7 1995/03/21 09:06:33 cgd Exp $ */
/*
@@ -47,6 +47,7 @@ extern int f_accesstime; /* use time of last access */
extern int f_flags; /* show flags associated with a file */
extern int f_inode; /* print inode */
extern int f_longform; /* long listing format */
+extern int f_nonprint; /* show unprintables as ? */
extern int f_sectime; /* print the real time for all files */
extern int f_size; /* list size in short listing */
extern int f_statustime; /* use time of last mode change */
diff --git a/bin/ls/print.c b/bin/ls/print.c
index fe64e5024a2..f8eb7390d75 100644
--- a/bin/ls/print.c
+++ b/bin/ls/print.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: print.c,v 1.10 1999/02/20 18:59:25 deraadt Exp $ */
+/* $OpenBSD: print.c,v 1.11 1999/05/01 23:54:48 deraadt Exp $ */
/* $NetBSD: print.c,v 1.15 1996/12/11 03:25:39 thorpej Exp $ */
/*
@@ -41,7 +41,7 @@
#if 0
static char sccsid[] = "@(#)print.c 8.5 (Berkeley) 7/28/94";
#else
-static char rcsid[] = "$OpenBSD: print.c,v 1.10 1999/02/20 18:59:25 deraadt Exp $";
+static char rcsid[] = "$OpenBSD: print.c,v 1.11 1999/05/01 23:54:48 deraadt Exp $";
#endif
#endif /* not lint */
@@ -127,7 +127,7 @@ printlong(dp)
printtime(sp->st_ctime);
else
printtime(sp->st_mtime);
- (void)printf("%s", p->fts_name);
+ (void)putname(p->fts_name);
if (f_type || (f_typedir && S_ISDIR(sp->st_mode)))
(void)printtype(sp->st_mode);
if (S_ISLNK(sp->st_mode))
@@ -221,7 +221,7 @@ printaname(p, inodefield, sizefield)
if (f_size)
chcnt += printf("%*qd ",
(int)sizefield, howmany(sp->st_blocks, blocksize));
- chcnt += printf("%s", p->fts_name);
+ chcnt += putname(p->fts_name);
if (f_type || (f_typedir && S_ISDIR(sp->st_mode)))
chcnt += printtype(sp->st_mode);
return (chcnt);
@@ -376,5 +376,6 @@ printlink(p)
return;
}
path[lnklen] = '\0';
- (void)printf(" -> %s", path);
+ (void)printf(" -> ");
+ (void)putname(path);
}
diff --git a/bin/ls/util.c b/bin/ls/util.c
index 16ad4e9c159..dc116406ee2 100644
--- a/bin/ls/util.c
+++ b/bin/ls/util.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: util.c,v 1.4 1999/02/20 18:59:26 deraadt Exp $ */
+/* $OpenBSD: util.c,v 1.5 1999/05/01 23:54:48 deraadt Exp $ */
/* $NetBSD: util.c,v 1.12 1995/09/07 06:43:02 jtc Exp $ */
/*
@@ -41,7 +41,7 @@
#if 0
static char sccsid[] = "@(#)util.c 8.5 (Berkeley) 4/28/95";
#else
-static char rcsid[] = "$OpenBSD: util.c,v 1.4 1999/02/20 18:59:26 deraadt Exp $";
+static char rcsid[] = "$OpenBSD: util.c,v 1.5 1999/05/01 23:54:48 deraadt Exp $";
#endif
#endif /* not lint */
@@ -57,17 +57,15 @@ static char rcsid[] = "$OpenBSD: util.c,v 1.4 1999/02/20 18:59:26 deraadt Exp $"
#include "ls.h"
#include "extern.h"
-void
-prcopy(src, dest, len)
- char *src, *dest;
- int len;
+int
+putname(name)
+ char *name;
{
- int ch;
+ int len;
- while (len--) {
- ch = *src++;
- *dest++ = isprint(ch) ? ch : '?';
- }
+ for(len = 0; *name; len++, name++)
+ putchar((!isprint(*name) && f_nonprint) ? '?' : *name);
+ return len;
}
void