summaryrefslogtreecommitdiffstats
path: root/usr.bin/patch/util.c
diff options
context:
space:
mode:
Diffstat (limited to 'usr.bin/patch/util.c')
-rw-r--r--usr.bin/patch/util.c10
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;