bug-global
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Global blocks for a few sec under MS Windows


From: Whity Pig
Subject: Global blocks for a few sec under MS Windows
Date: Thu, 25 Nov 2010 20:30:07 +0900

Hello, everyone.


Under MS Windows and Cygwin, global blocks for a few seconds if there
is no GTAGS on the path from the current directory to the root
directory.


The following is what I did.

% /usr/bin/time global foo
global: GTAGS not found.
Command exited with non-zero status 3
0.03user 0.03system 0:09.04elapsed 0%CPU (0avgtext+0avgdata 353792maxresident)k
0inputs+0outputs (1380major+0minor)pagefaults 0swaps


This is probably because global does stat(2) with an argument of
"//GTAGS" when it comes to the root directory.


In MS Windows, path names prefixed with "//" mean someplace on the
network, though I don't know for sure.  Anyway, global stops for about
10 seconds on my environment, presumably because of searching for tag
on the network TWO times.

I think the problem is in libutil/getdbpath.c, around line 150.
The below is the diff I created, maybe botched up(--;


% diff -u getdbpath.c.org  getdbpath.c
--- getdbpath.c.org     2010-08-30 21:19:04.000000000 +0900
+++ getdbpath.c 2010-11-25 20:19:18.987375000 +0900
@@ -147,7 +147,13 @@
        if (makeobjdir == NULL)
                setupvariables(verbose);
 
-       snprintf(path, sizeof(path), "%s/%s", candidate, dbname(GTAGS));
+       if ((strnlen(candidate, MAXPATHLEN) == 1) && (*candidate == '/')) {
+               snprintf(path, sizeof(path), "%s%s", candidate, dbname(GTAGS));
+       }
+       else {
+               snprintf(path, sizeof(path), "%s/%s", candidate, dbname(GTAGS));
+       }
+
        if (verbose)
                fprintf(stderr, "checking %s\n", path);
        if (test("fr", path)) {
@@ -156,8 +162,16 @@
                snprintf(dbpath, size, "%s", candidate);
                return 1;
        }
-       snprintf(path, sizeof(path),
-               "%s/%s/%s", candidate, makeobjdir, dbname(GTAGS));
+
+       if ((strnlen(candidate, MAXPATHLEN) == 1) && (*candidate == '/')) {
+               snprintf(path, sizeof(path),
+                                                "%s%s/%s", candidate, 
makeobjdir, dbname(GTAGS));
+       }
+       else {
+               snprintf(path, sizeof(path),
+                                                "%s/%s/%s", candidate, 
makeobjdir, dbname(GTAGS));
+       }
+
        if (verbose)
                fprintf(stderr, "checking %s\n", path);
        if (test("fr", path)) {
@@ -167,8 +181,14 @@
                return 1;
        }
 #if !defined(_WIN32) && !defined(__DJGPP__)
-       snprintf(path, sizeof(path),
-               "%s%s/%s", makeobjdirprefix, candidate, dbname(GTAGS));
+       if ((strnlen(candidate, MAXPATHLEN) == 1) && (*candidate == '/')) {
+               snprintf(path, sizeof(path),
+                                                "%s%s/%s", candidate, 
makeobjdir, dbname(GTAGS));
+       }
+       else {
+               snprintf(path, sizeof(path),
+                                                "%s/%s/%s", candidate, 
makeobjdir, dbname(GTAGS));
+       }
        if (verbose)
                fprintf(stderr, "checking %s\n", path);
        if (test("fr", path)) {


My environment:
Global version: 5.9.2
Cygwin 1.7.7
Windows XP SP3


Best regards,
whitypig


-- 
whitypig <address@hidden>




reply via email to

[Prev in Thread] Current Thread [Next in Thread]