patch: global -u on win32 with src root at drive root

Kai Tetzlaff <[email protected]> Sun, 18 Oct 2009 21:00:05 +0200
Newsgroups gmane.comp.gnu.global.general
Message-ID <[email protected]>
Hi,

i compiled global on win32 and tried it with a source tree which starts
directly at the drive level (root='D:'). In this case the chdir which
takes care that the search in 'global -u' starts at the root of the src
tree does not work on windows if there's no '/' at the end of the path.
If you change root='D:' to root='D:/' its working. So i changed
chdir(root) to chdir(get_root_with_slash()) in order to fix this. I
don't think this will cause problems for unix systems.

Could you consider adding the attached patch to the global sources?

BR,
Kai

_______________________________________________
Help-global mailing list
[email protected]
http://lists.gnu.org/mailman/listinfo/help-global
w32_root_drv.patch (text/plain, 1.3 KB)
? depcomp
? install-sh
? missing
? w32_root_drv.patch
? doc/mdate-sh
Index: global/global.c
===================================================================
RCS file: /sources/global/global/global/global.c,v
retrieving revision 1.198
diff -u -w -r1.198 global.c
--- global/global.c	29 Jan 2009 09:30:09 -0000	1.198
+++ global/global.c	18 Oct 2009 18:51:30 -0000
@@ -430,7 +430,7 @@
 
 		if (!gtags)
 			die("gtags command not found.");
-		if (chdir(root) < 0)
+		if (chdir(get_root_with_slash()) < 0)
 			die("cannot change directory to '%s'.", root);
 		strbuf_puts(sb, gtags);
 		strbuf_puts(sb, " -i");
@@ -509,21 +509,21 @@
 	 * exec lid(idutils).
 	 */
 	if (Iflag) {
-		chdir(root);
+		chdir(get_root_with_slash());
 		idutils(av, dbpath);
 	}
 	/*
 	 * search pattern (regular expression).
 	 */
 	else if (gflag) {
-		chdir(root);
+		chdir(get_root_with_slash());
 		grep(av, dbpath);
 	}
 	/*
 	 * locate paths including the pattern.
 	 */
 	else if (Pflag) {
-		chdir(root);
+		chdir(get_root_with_slash());
 		pathlist(av, dbpath);
 	}
 	/*
@@ -937,7 +937,7 @@
 		/*
 		 * Execute parser in the root directory of source tree.
 		 */
-		if (chdir(root) < 0)
+		if (chdir(get_root_with_slash()) < 0)
 			die("cannot move to '%s' directory.", root);
 		xp = xargs_open_with_strbuf(strbuf_value(comline), 0, path_list);
 		if (format == FORMAT_PATH) {