Teach mtree(8) to handle whitespace in filenames. Uses strvis(3).
PR: bin/3246 Submitted by: Eugene M. Kim <astralblue@usa.net> Reviewed by: jkoshy, wollman
This commit is contained in:
parent
26ccf6d24a
commit
610481bce5
@ -36,7 +36,7 @@
|
||||
static char sccsid[] = "@(#)create.c 8.1 (Berkeley) 6/6/93";
|
||||
#endif
|
||||
static const char rcsid[] =
|
||||
"$Id: create.c,v 1.10 1998/06/05 14:43:39 peter Exp $";
|
||||
"$Id: create.c,v 1.11 1998/08/02 14:41:34 bde Exp $";
|
||||
#endif /* not lint */
|
||||
|
||||
#include <sys/param.h>
|
||||
@ -52,6 +52,7 @@ static const char rcsid[] =
|
||||
#include <stdio.h>
|
||||
#include <time.h>
|
||||
#include <unistd.h>
|
||||
#include <vis.h>
|
||||
#include "mtree.h"
|
||||
#include "extern.h"
|
||||
|
||||
@ -138,11 +139,19 @@ statf(indent, p)
|
||||
struct passwd *pw;
|
||||
u_long len, val;
|
||||
int fd, offset;
|
||||
char *escaped_name;
|
||||
|
||||
escaped_name = calloc(1, p->fts_namelen * 4 + 1);
|
||||
if (escaped_name == NULL)
|
||||
errx(1, "statf(): calloc() failed");
|
||||
strvis(escaped_name, p->fts_name, VIS_WHITE);
|
||||
|
||||
if (iflag || S_ISDIR(p->fts_statp->st_mode))
|
||||
offset = printf("%*s%s", indent, "", p->fts_name);
|
||||
offset = printf("%*s%s", indent, "", escaped_name);
|
||||
else
|
||||
offset = printf("%*s %s", indent, "", p->fts_name);
|
||||
offset = printf("%*s %s", indent, "", escaped_name);
|
||||
|
||||
free(escaped_name);
|
||||
|
||||
if (offset > (INDENTNAMELEN + indent))
|
||||
offset = MAXLINELEN;
|
||||
|
@ -36,7 +36,7 @@
|
||||
static char sccsid[] = "@(#)spec.c 8.1 (Berkeley) 6/6/93";
|
||||
#endif
|
||||
static const char rcsid[] =
|
||||
"$Id: spec.c,v 1.7 1997/10/01 06:30:02 charnier Exp $";
|
||||
"$Id: spec.c,v 1.8 1998/12/16 04:54:08 imp Exp $";
|
||||
#endif /* not lint */
|
||||
|
||||
#include <sys/types.h>
|
||||
@ -49,6 +49,7 @@ static const char rcsid[] =
|
||||
#include <pwd.h>
|
||||
#include <stdio.h>
|
||||
#include <unistd.h>
|
||||
#include <vis.h>
|
||||
#include "mtree.h"
|
||||
#include "extern.h"
|
||||
|
||||
@ -143,10 +144,14 @@ noparent: errx(1, "line %d: no parent node", lineno);
|
||||
if ((centry = calloc(1, sizeof(NODE) + strlen(p))) == NULL)
|
||||
errx(1, "calloc");
|
||||
*centry = ginfo;
|
||||
(void)strcpy(centry->name, p);
|
||||
#define MAGIC "?*["
|
||||
if (strpbrk(p, MAGIC))
|
||||
centry->flags |= F_MAGIC;
|
||||
if (strunvis(centry->name, p) == -1) {
|
||||
warnx("filename %s is ill-encoded and literally used",
|
||||
p);
|
||||
strcpy(centry->name, p);
|
||||
}
|
||||
set(NULL, centry);
|
||||
|
||||
if (!root) {
|
||||
|
Loading…
Reference in New Issue
Block a user