diff options
author | 2004-11-19 20:00:57 +0000 | |
---|---|---|
committer | 2004-11-19 20:00:57 +0000 | |
commit | ede002814f0643a2c8c7303885342df26c92089d (patch) | |
tree | c044531da39666f3f39391358224aeb5f2096933 /usr.bin/patch/util.c | |
parent | repair display.focus pokus; from janjaap@ in pr#3990 (diff) | |
download | wireguard-openbsd-ede002814f0643a2c8c7303885342df26c92089d.tar.xz wireguard-openbsd-ede002814f0643a2c8c7303885342df26c92089d.zip |
Allow for path names containing spaces and other funny chars (except
tab) by scanning for the tab that separates the date from the
pathname. If no tab is found, revert back to the old behaviour.
Posix says there should be a space between the pathname and the
date, but all known implementations of diff(1) use a tab.
ok kurt@ deraadt@
Diffstat (limited to 'usr.bin/patch/util.c')
-rw-r--r-- | usr.bin/patch/util.c | 10 |
1 files changed, 6 insertions, 4 deletions
diff --git a/usr.bin/patch/util.c b/usr.bin/patch/util.c index 871b3b958dc..d34ba182ade 100644 --- a/usr.bin/patch/util.c +++ b/usr.bin/patch/util.c @@ -1,4 +1,4 @@ -/* $OpenBSD: util.c,v 1.28 2004/08/05 21:47:24 deraadt Exp $ */ +/* $OpenBSD: util.c,v 1.29 2004/11/19 20:00:57 otto Exp $ */ /* * patch - a program to apply diffs to original files @@ -27,7 +27,7 @@ */ #ifndef lint -static const char rcsid[] = "$OpenBSD: util.c,v 1.28 2004/08/05 21:47:24 deraadt Exp $"; +static const char rcsid[] = "$OpenBSD: util.c,v 1.29 2004/11/19 20:00:57 otto Exp $"; #endif /* not lint */ #include <sys/param.h> @@ -333,7 +333,7 @@ char * fetchname(const char *at, bool *exists, int strip_leading) { char *fullname, *name, *t; - int sleading; + int sleading, tab; struct stat filestat; if (at == NULL || *at == '\0') @@ -349,8 +349,10 @@ fetchname(const char *at, bool *exists, int strip_leading) return NULL; name = fullname = t = savestr(at); + tab = strchr(t, '\t') != NULL; /* Strip off up to `strip_leading' path components and NUL terminate. */ - for (sleading = strip_leading; *t != '\0' && !isspace(*t); t++) { + for (sleading = strip_leading; *t != '\0' && ((tab && *t != '\t') || + !isspace(*t)); t++) { if (t[0] == '/' && t[1] != '/' && t[1] != '\0') if (--sleading >= 0) name = t + 1; |