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

Kai Tetzlaff <[email protected]> Tue, 20 Oct 2009 09:15:13 +0200
Newsgroups gmane.comp.gnu.global.general
Message-ID <[email protected]>
Hi Shigio,

thanks for looking into it. This slightly modified version is working
for win32:

diff -w -u -r1.25 getdbpath.c
--- libutil/getdbpath.c	6 Oct 2009 15:39:32 -0000	1.25
+++ libutil/getdbpath.c	20 Oct 2009 07:07:47 -0000
@@ -268,13 +268,17 @@
 		strlimcpy(root, cwd, MAXPATHLEN);
 		p = root + strlen(root);
 		while (!gtagsexist(root, dbpath, MAXPATHLEN, verbose)) {
-			while (*--p != '/' && p > root)
+			if (!strcmp(root+ROOT, "/")) { 	/* reached the system's root
directory */
+				*(root+ROOT) = '\0';
+				break;
+			}
+			while (*--p != '/' && p > (root+ROOT))
 				;
+			if (p == (root+ROOT))
+				p++;
 			*p = 0;
-			if (root == p)	/* reached root directory */
-				break;
 		}
-		if (*root == 0)
+		if (*(root+ROOT) == 0)
 			die_with_code(3, "GTAGS not found.");
 		/*
 		 * If file 'GTAGSROOT' found without environment variable


> Hi Kai
> 
> It seems that there is no problem in acceptance of tag files in system's
> root directory.
> 
> Here is a patch for it.
> I don't know whether or not this code works in Windows environment.
> If you can modify this for Windows, I will accept it. Thanks.
> 
> diff -c -r1.25 getdbpath.c
> *** libutil/getdbpath.c	6 Oct 2009 15:39:32 -0000	1.25
> --- libutil/getdbpath.c	20 Oct 2009 05:34:31 -0000
> ***************
> *** 268,278 ****
>   		strlimcpy(root, cwd, MAXPATHLEN);
>   		p = root + strlen(root);
>   		while (!gtagsexist(root, dbpath, MAXPATHLEN, verbose)) {
>   			while (*--p != '/' && p > root)
>   				;
>   			*p = 0;
> - 			if (root == p)	/* reached root directory */
> - 				break;
>   		}
>   		if (*root == 0)
>   			die_with_code(3, "GTAGS not found.");
> --- 268,282 ----
>   		strlimcpy(root, cwd, MAXPATHLEN);
>   		p = root + strlen(root);
>   		while (!gtagsexist(root, dbpath, MAXPATHLEN, verbose)) {
> + 			if (!strcmp(root, "/")) { 	/* reached the system's root directory */
> + 				*root = '\0';
> + 				break;
> + 			}
>   			while (*--p != '/' && p > root)
>   				;
> + 			if (p == root)
> + 				p++;
>   			*p = 0;
>   		}
>   		if (*root == 0)
>   			die_with_code(3, "GTAGS not found.");
> --
> Shigio YAMAGUCHI <[email protected]>
> PGP fingerprint: D1CB 0B89 B346 4AB6 5663  C4B6 3CA5 BBB3 57BE DDA3
> 
>