Hello, Thank you for your suggestions. Your explanation made it very clear what the problem was.
The original purpose of this option (--path-style=through) was to allow external programs to do the path manipulation that global(1) does. I think it would be easier for them to use it without referencing GTAGSLIBPATH. How about this? else if (!strcmp(path_style, "through")) { type = PATH_THROUGH; unsetenv("GTAGSLIBPATH"); <== add } global(1) ... ´through´ means the relative path from the project root directory (internal format of GPATH). When this style is used, GTAGSLIBPATH is ignored. <== add Regards, Shigio On Fri, May 2, 2025 at 1:25 AM Aymeric Agon-Rambosson <aymeric.a...@yandex.com> wrote: > > > Hello, > > First of all, thank you very much for this very useful software. > > There is a potential issue I wanted to bring to your attention. > > The documentation relative to the --path-style option of global > states the following : > > ´through´ means the relative path from the project root directory > (internal format of GPATH) > > Global will indeed print the path to the source file containing > some definition relatively to the project root directory, but only > if the symbol was found in the GTAGS file of the current project. > However, if the definition happens to be found in the GTAGS file > of some other out-of-tree directory pointed to by the GTAGSLIBPATH > environment variable, then the path printed by global is relative > to that out-of-tree directory, and NOT relative to the project > root directory the user finds itself in when it calls global. > > Is this intended behaviour ? > > If it is intended behaviour, I think it would be desirable to > stress this a little bit more in the documentation. > > I agree that the phrase "(internal format of GPATH)" should make > the reader understand that global is going to print the path > exactly how it is written in the GPATH file *of the directory > pointed by GTAGSLIBPATH*, and draw the conclusions. Nonetheless, > making this consequence a little more obvious in the documentation > would not be amiss. I propose something along the lines of : > > ´through´ means the internal format of GPATH, that is the relative > path from the > GTAGS file in which the symbol was found. In particular, if the > symbol was found > in the GTAGS file of some directory pointed to by GTAGSLIBPATH, > then the path > will have to be interpreted as coming from that last directory, > and not the root > directory of the project you called global from. > > It would also make sense that it is not intended behaviour : > invoking global with --path-style=through while having > GTAGSLIBPATH set to some out-of-tree directory makes it impossible > for the caller to know what directory the output path is relative > to. > > In this case, would it not be better to have some behaviour like > the one from abslib, something like "throughabslib" : relative to > the project root directory for the definitions found in the > project, and absolute for the definitions found in library > directories pointed to by GTAGSLIBPATH. If I am not mistaken, this > could be done trivially by doing the following : > > > Let me know what you think. > > Best, > > Aymeric Agon-Rambosson > -- Shigio YAMAGUCHI <shi...@gnu.org> PGP fingerprint: 26F6 31B4 3D62 4A92 7E6F 1C33 969C 3BE3 89DD A6EB