[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
grep: isdir1-slash-fix.diff
From: |
Dimitar Zhekov |
Subject: |
grep: isdir1-slash-fix.diff |
Date: |
Fri, 18 Apr 2003 13:22:01 +0300 (EEST) |
The slash check "dirlen = strlen (dir); ... strcpy (path, dir);
... if (path[dirlen] != '/') ..." is buggy: that's the same as
dir[strlen(dir)], which is always '\0'. A path[dirlen - 1] will
do better, but if grep is to support MSDOS/WIN32 more or less
natively, the needs_slash check from grep.c should be used, as
shown below. Note: the patch requires a -I../src in the lib
INCLUDES, but I can't test such a change in lib/Makefile.am due
to the lack of working WIN32 autoconf/automake on my system.
--- grep-2.5.orig/lib/savedir.c Sun Mar 4 04:33:12 2001
+++ grep-2.5/lib/savedir.c Mon Apr 14 10:51:54 2003
@@ -67,6 +67,7 @@
#endif
#include <fnmatch.h>
+#include "system.h"
#include "savedir.h"
char *path;
@@ -85,7 +86,8 @@
pathlen = dirlen + filelen + 2;
}
strcpy (path, dir);
- slash = (path[dirlen] != '/');
+ slash = ! (dirlen == FILESYSTEM_PREFIX_LEN (dir)
+ || IS_SLASH (dir[dirlen - 1]));
path[dirlen] = '/';
strcpy (path + dirlen + slash , file);
status = isdir (path);
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- grep: isdir1-slash-fix.diff,
Dimitar Zhekov <=