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

View: New views
11 Messages — Rating Filter:   Alert me  

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

by Kai Tetzlaff-2 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

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

? 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) {

_______________________________________________
Help-global mailing list
Help-global@...
http://lists.gnu.org/mailman/listinfo/help-global

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

by Shigio YAMAGUCHI-2 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Hi,
Changing the source code for Windows environment is OK.
But I am anxious why the directory name is not included
in the variable 'root'. Should not we fix the cause?

> 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?

Regards,
Shigio
--
Shigio YAMAGUCHI <shigio@...>
PGP fingerprint: D1CB 0B89 B346 4AB6 5663  C4B6 3CA5 BBB3 57BE DDA3


_______________________________________________
Help-global mailing list
Help-global@...
http://lists.gnu.org/mailman/listinfo/help-global

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

by Kai Tetzlaff-2 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Hi Shigio,

> Hi,
> Changing the source code for Windows environment is OK.
> But I am anxious why the directory name is not included
> in the variable 'root'. Should not we fix the cause?
so far i was just looking at an easy fix for the problem at hand. But
yes, maybe it's worth it having a closer look. So i started doing this
and actually found that on unix, there's also a problem with having
GTAGS at /GTAGS. setupdbpath in getdbpath.c bails out with GTAGS not
found (line 277).

Now, on unix it might be questionable to have a GTAGS db at the root of
the file system. But on the other hand there's nothing which really
forbids this setup. So, if you think that this should be fixed too, i
guess i could have a closer look. Even though the fix which will result
out of this will probably have to change some more parts of the
root/dbpath detection code.

My first idea would be to try to change the code so that root (and maybe
also dbpath) would be setup to always end with a '/'.

/Kai

>
>> 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?
>
> Regards,
> Shigio
> --
> Shigio YAMAGUCHI <shigio@...>
> PGP fingerprint: D1CB 0B89 B346 4AB6 5663  C4B6 3CA5 BBB3 57BE DDA3



_______________________________________________
Help-global mailing list
Help-global@...
http://lists.gnu.org/mailman/listinfo/help-global

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

by Shigio YAMAGUCHI-2 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Hi Kai,
> so far i was just looking at an easy fix for the problem at hand. But
> yes, maybe it's worth it having a closer look. So i started doing this
> and actually found that on unix, there's also a problem with having
> GTAGS at /GTAGS. setupdbpath in getdbpath.c bails out with GTAGS not
> found (line 277).

I also confirmed it. It seems that setupdbpath() does not look for GTAGS
in the system's root directory. In a word, it does not admit tag files
to be put in the system's root directory.

> Now, on unix it might be questionable to have a GTAGS db at the root of
> the file system.

Window version should also do the same behavior as UNIX version.
That is, it should die with the following message:

        global: GTAGS not found.

>                  But on the other hand there's nothing which really
> forbids this setup. So, if you think that this should be fixed too, i
> guess i could have a closer look. Even though the fix which will result
> out of this will probably have to change some more parts of the
> root/dbpath detection code.

Do you need to put tag files on the system's root directory?

--
Shigio YAMAGUCHI <shigio@...>
PGP fingerprint: D1CB 0B89 B346 4AB6 5663  C4B6 3CA5 BBB3 57BE DDA3


_______________________________________________
Help-global mailing list
Help-global@...
http://lists.gnu.org/mailman/listinfo/help-global

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

by Kai Tetzlaff-2 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Hi Shigio

> Hi Kai,
>> so far i was just looking at an easy fix for the problem at hand. But
>> yes, maybe it's worth it having a closer look. So i started doing this
>> and actually found that on unix, there's also a problem with having
>> GTAGS at /GTAGS. setupdbpath in getdbpath.c bails out with GTAGS not
>> found (line 277).
>
> I also confirmed it. It seems that setupdbpath() does not look for GTAGS
> in the system's root directory. In a word, it does not admit tag files
> to be put in the system's root directory.
>
>> Now, on unix it might be questionable to have a GTAGS db at the root of
>> the file system.
>
> Window version should also do the same behavior as UNIX version.
> That is, it should die with the following message:
>
>         global: GTAGS not found.
Yes, that's what my first patch was supposed to fix (well, it actually
does).

>
>>                  But on the other hand there's nothing which really
>> forbids this setup. So, if you think that this should be fixed too, i
>> guess i could have a closer look. Even though the fix which will result
>> out of this will probably have to change some more parts of the
>> root/dbpath detection code.
>
> Do you need to put tag files on the system's root directory?
I don't need it for unix based systems (actually i'm not working on unix -
but
even if i would - there's no need to put sources at '/'). But under
windows,
the typical setup here at work is that a drive letter gets mapped to the
source
tree. We're using clearcase here, and on Windows this is the default
behaviour.
Of course there are ways around this, but i'm not sure i can convince
myself (and
co-workers) to switch to a different setup. So i would rather like to get a
fix
implemented in global (even if it finally means to maintain a set of
private
patches).

I played with this a bit this morning. I think i already have a working
version
which changes the behaviour of setupdbpath so that all paths it generates
(cwd,
root, dbpath) end with a '/'. It requires some additional changes to the
current
code. But then it solves both problems (windows and unix) with GTAGS at the
fs
root and actually does not require any platform dependent switches (so
far). But
it needs some more analysis and testing ... I can provide this to you if
you like
to have a look at it. Otherwise i would just play around it for a couple of
days
before sending it to the list.

>
> --
> Shigio YAMAGUCHI <shigio@...>
> PGP fingerprint: D1CB 0B89 B346 4AB6 5663  C4B6 3CA5 BBB3 57BE DDA3
>


_______________________________________________
Help-global mailing list
Help-global@...
http://lists.gnu.org/mailman/listinfo/help-global

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

by Shigio YAMAGUCHI-2 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Hi Kai,
> even if i would - there's no need to put sources at '/'). But under
> windows,
> the typical setup here at work is that a drive letter gets mapped to the
> source
> tree. We're using clearcase here, and on Windows this is the default
> behaviour.

I understood.

> I played with this a bit this morning. I think i already have a working
> version
> which changes the behaviour of setupdbpath so that all paths it generates
> (cwd,
> root, dbpath) end with a '/'. It requires some additional changes to the
> current
> code. But then it solves both problems (windows and unix) with GTAGS at t=
> he
> fs
> root and actually does not require any platform dependent switches (so
> far).

What I should do is to decide whether to change the specification,
that is, whether or not tag files in the system's root directory
are accepted.  For this issure, please give me some time to decide it.
If the specification is changed, your problem will be solved.
I won't accept code which works by accident.

It seems that this topic has come off from this mailing list.

Regards,
Shigio
--
Shigio YAMAGUCHI <shigio@...>
PGP fingerprint: D1CB 0B89 B346 4AB6 5663  C4B6 3CA5 BBB3 57BE DDA3


_______________________________________________
Help-global mailing list
Help-global@...
http://lists.gnu.org/mailman/listinfo/help-global

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

by Shigio YAMAGUCHI-2 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

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 <shigio@...>
PGP fingerprint: D1CB 0B89 B346 4AB6 5663  C4B6 3CA5 BBB3 57BE DDA3


_______________________________________________
Help-global mailing list
Help-global@...
http://lists.gnu.org/mailman/listinfo/help-global

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

by Kai Tetzlaff-2 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

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 <shigio@...>
> PGP fingerprint: D1CB 0B89 B346 4AB6 5663  C4B6 3CA5 BBB3 57BE DDA3
>
>



_______________________________________________
Help-global mailing list
Help-global@...
http://lists.gnu.org/mailman/listinfo/help-global

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

by Shigio YAMAGUCHI-2 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Hi Kai,
> thanks for looking into it. This slightly modified version is working
> for win32:

Committed. Thank you for your cooperation.
--
Shigio YAMAGUCHI <shigio@...>
PGP fingerprint: D1CB 0B89 B346 4AB6 5663  C4B6 3CA5 BBB3 57BE DDA3


_______________________________________________
Help-global mailing list
Help-global@...
http://lists.gnu.org/mailman/listinfo/help-global

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

by Kai Tetzlaff-2 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Shigio YAMAGUCHI wrote:
> Hi Kai,
>> thanks for looking into it. This slightly modified version is working
>> for win32:
>
> Committed. Thank you for your cooperation.

Thanks Shigio for taking the time to look into this.

Since, as a side-effect of trying to fix this problem, i now have win32
binaries for the current global release - would you be interested to get
a tar/zip package which can be provided for public download?

BR,
Kai



_______________________________________________
Help-global mailing list
Help-global@...
http://lists.gnu.org/mailman/listinfo/help-global

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

by Shigio YAMAGUCHI-2 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Hi
> Since, as a side-effect of trying to fix this problem, i now have win32
> binaries for the current global release - would you be interested to get
> a tar/zip package which can be provided for public download?

No, thank you.
Since GLOBAL doesn't support Windows environment, it is not scheduled
to be distributed. Please see Q1 in the FAQ file.
However, if you do it, I would like to introduce your site in the GLOBAL's site.
Anyway, thank you for your offer.
--
Shigio YAMAGUCHI <shigio@...>
PGP fingerprint: D1CB 0B89 B346 4AB6 5663  C4B6 3CA5 BBB3 57BE DDA3


_______________________________________________
Help-global mailing list
Help-global@...
http://lists.gnu.org/mailman/listinfo/help-global