Index: libutil/getdbpath.c
===================================================================
RCS file: /sources/global/global/libutil/getdbpath.c,v
retrieving revision 1.39
diff -u -r1.39 getdbpath.c
--- libutil/getdbpath.c	27 Mar 2017 23:25:18 -0000	1.39
+++ libutil/getdbpath.c	16 Mar 2026 21:48:40 -0000
@@ -47,6 +47,20 @@
 #include "test.h"
 
 /**
+ * normalize backslashes in paths to forward slashes
+ */
+#if defined(_WIN32) || defined(__DJGPP__)
+#define back2slash_str(str) do {	\
+	char *p = str;				\
+	for (; *p; p++)			\
+		if (*p == '\\')             \
+			*p = '/';               \
+} while (0)
+#else
+#define back2slash_str(str)
+#endif
+
+/**
  * define the position of the root slash.
  */
 #if defined(_WIN32) || defined(__DJGPP__)
@@ -59,6 +73,20 @@
 static const char *gtagsobjdir;		/**< tag directory	*/
 char const *gtags_dbpath_error;		/**< error message	*/
 
+#if defined(_WIN32) || defined(__DJGPP__)
+static const char *
+strip_drive_colon(const char *path, char *buf, size_t bufsize)
+{
+    char *dst = buf;
+    const char *src = path;
+    for (; *src && dst - buf < bufsize - 1; src++)
+        if (*src != ':')
+            *dst++ = *src;
+    *dst = '\0';
+    return buf;
+}
+#endif
+
 /**
  * setupvariables: load variables regard to BSD OBJ directory.
  */
@@ -102,8 +130,9 @@
 	 * setup gtagsobjdir and gtagsobjdirprefix (only first time).
 	 */
 	if (gtagsobjdir == NULL)
-		setupvariables(0);
+		setupvariables(verbose);
 	snprintf(path, sizeof(path), "%s/%s", candidate, gtagsobjdir);
+	back2slash_str(path);
 	if (test("d", path)) {
 		if (!test("drw", path))
 			die("Found objdir '%s', but you don't have read/write permission for it.", path);
@@ -127,6 +156,25 @@
 			fprintf(stderr, "Using objdir '%s'.\n", path);
 		return path;
 	}
+#else // WIN
+	if (test("d", gtagsobjdirprefix)) {
+		    char stripped[MAXPATHLEN];
+    strip_drive_colon(candidate, stripped, sizeof(stripped));
+		snprintf(path, sizeof(path), "%s%s", gtagsobjdirprefix, stripped);
+		if (test("d", path)) {
+			if (!test("drw", path))
+				die("Found objdir '%s', but you don't have read/write permission for it.", path);
+			if (verbose)
+				fprintf(stderr, "Using objdir '%s'.\n", path);
+			return path;
+		}
+		if (makedirectories(gtagsobjdirprefix, stripped, verbose) < 0)
+			die("Found the base for objdir '%s', but you cannot create new directory in it.", path);
+		if (verbose)
+			fprintf(stderr, "Using objdir '%s'.\n", path);
+		return path;
+	}
+
 #endif
 	return NULL;
 }
@@ -189,6 +237,20 @@
 		snprintf(dbpath, size, "%s%s", gtagsobjdirprefix, candidate_without_slash);
 		return 1;
 	}
+#else // WIN
+	char stripped[MAXPATHLEN];
+	strip_drive_colon(candidate_without_slash, stripped, sizeof(stripped));
+	snprintf(path, sizeof(path), "%s/%s/%s", gtagsobjdirprefix, stripped, dbname(GTAGS));
+	back2slash_str(path);
+	if (verbose)
+		fprintf(stderr, "checking %s\n", path);
+	if (test("fr", path)) {
+		if (verbose)
+			fprintf(stderr, "GTAGS found at '%s'.\n", path);
+		snprintf(dbpath, size, "%s/%s", gtagsobjdirprefix, stripped);
+		back2slash_str(dbpath);
+		return 1;
+	}
 #endif
 	return 0;
 }
Index: global/global.c
===================================================================
RCS file: /sources/global/global/global/global.c,v
retrieving revision 1.323
diff -u -r1.323 global.c
--- global/global.c	8 May 2025 08:40:01 -0000	1.323
+++ global/global.c	16 Mar 2026 21:48:41 -0000
@@ -951,7 +951,7 @@
 			type = PATH_ABSOLUTE;
 		else if (!strcmp(path_style, "through")) {
 			type = PATH_THROUGH;
-			unsetenv("GTAGSLIBPATH");
+			putenv("GTAGSLIBPATH=");
 		} else if (!strcmp(path_style, "shorter"))
 			type = PATH_SHORTER;
 		else if (!strcmp(path_style, "abslib")) {
