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 :
--- global.c 2024-12-11 07:44:34.000000000 +0100
+++ globalnew.c 2025-05-01 12:07:48.990171720 +0200
@@ -949,9 +949,10 @@
type = PATH_RELATIVE;
else if (!strcmp(path_style, "absolute"))
type = PATH_ABSOLUTE;
- else if (!strcmp(path_style, "through"))
+ else if (!strcmp(path_style, "through")) {
type = PATH_THROUGH;
- else if (!strcmp(path_style, "shorter"))
+ abslib++;
+ } else if (!strcmp(path_style, "shorter"))
type = PATH_SHORTER;
else if (!strcmp(path_style, "abslib")) {
type = PATH_RELATIVE;
Let me know what you think.
Best,
Aymeric Agon-Rambosson