|
View:
New views
6 Messages
—
Rating Filter:
Alert me
|
|
|
gtags and symbolic linksHi list,
I have some questions and maybe some suggestions about global treatment of symbolic links. I know there was some discussion about this [1] some time ago, but in my opinion some issues still remain. First of all, I'm thinking about implementing the nofollow option for gtags, as proposed on [2]. My question is, how exactly should this behave: should that only omit symbolic links that point to a directory or should that ignore symbolic links completely (e.g. ./foo.c pointing to ./bar.c) ? When thinking about it and looking into the code, I don't quite understand the following part of find_read_traverse() (libutil/find.c): 522 for (;;) { 523 while (curp->p < curp->end) { 524 char type = *(curp->p); 525 const char *unit = curp->p + 1; 526 527 curp->p += strlen(curp->p) + 1; 528 529 /* 530 * Skip files described in the skip list. 531 */ 532 /* makepath() returns unsafe module local area. */ 533 strlimcpy(path, makepath(dir, unit, NULL), sizeof(path)); 534 if (type == 'd') 535 strcat(path, "/"); 536 if (skipthisfile(path)) 537 continue; 538 if (type == 'f') { 539 /* 540 * Skip the following: 541 * o directory 542 * o file which does not exist 543 * o dead symbolic link 544 */ 545 if (!test("f", path)) { 546 if (test("d", path)) 547 warning("'%s' is a directory. (Ignored)", path); 548 else 549 warning("'%s' not found. (Ignored)", path); 550 continue; 551 } 552 /* 553 * GLOBAL cannot treat path which includes blanks. 554 * It will be improved in the future. 555 */ 556 if (locatestring(path, " ", MATCH_FIRST)) { 557 warning("'%s' ignored, because it includes blank.", &path[2]); 558 continue; 559 } <SNIP> To be specific, what's the purpose of lines 539-551? If I'm not mistaken, the test at line 545 can never succeed because it is the opposite of the test at line 538. Next, is there any benefit of determining the type of a file in getdirs() function (I mean prefixing the filename with f,d) instead of determining the type directly in the find_read_traverse() function? And finally: what actually made me start thinking about this is fact that gtags can not treat recursive links, like in [3]. This actually makes it difficult to use gtags on directories created by quilt setup, because quilt creates exactly this type of directory structure (for a good reason). This could be worked around by the nofollow option, but IMHO the recursive link detection should be done also in default mode - what do you think? Thanks in advance, [1] http://lists.gnu.org/archive/html/bug-global/2008-01/msg00000.html [2] http://www.gnu.org/software/global/plans.html [3] http://lists.gnu.org/archive/html/bug-global/2008-01/msg00001.html -- Best regards / s pozdravem Petr Uzel, Packages maintainer --------------------------------------------------------------------- SUSE LINUX, s.r.o. e-mail: puzel@... Lihovarská 1060/12 tel: +420 284 028 964 190 00 Prague 9 fax: +420 284 028 951 Czech Republic http://www.suse.cz _______________________________________________ Bug-global mailing list Bug-global@... http://lists.gnu.org/mailman/listinfo/bug-global |
|
|
Re: gtags and symbolic linksHi,
> First of all, I'm thinking about implementing the nofollow option for gtags, as > proposed on [2]. My question is, how exactly should this behave: should that > only omit symbolic links that point to a directory or should that ignore > symbolic links completely (e.g. ./foo.c pointing to ./bar.c) ? I have not thought about details yet. Is there something proposal? > When thinking about it and looking into the code, I don't quite understand the > following part of find_read_traverse() (libutil/find.c): ... > To be specific, what's the purpose of lines 539-551? If I'm not mistaken, the > test at line 545 can never succeed because it is the opposite of the test at > line 538. It might be so. But at present, this code is harmless. > Next, is there any benefit of determining the type of a file in getdirs() > function (I mean prefixing the filename with f,d) instead of determining = > the > type directly in the find_read_traverse() function? This is due to a historical reason. In some systems like BSD, dirent structure has a member named 'd_type' which describes file type. Determining type by it, we can avoid to calling stat(2) for each files. But another systems like GNU/Linux doesn't has it. I wanted to hide the difference in a basic function, getdirs(). By the way, GLOBAL doesn't use the 'd_type' currently due to the following bug: [http://lists.gnu.org/archive/html/bug-global/2003-08/msg00002.html] > And finally: what actually made me start thinking about this is fact that gtags > can not treat recursive links, like in [3]. This actually makes it difficult to > use gtags on directories created by quilt setup, because quilt creates exactly > this type of directory structure (for a good reason). This could be worked > around by the nofollow option, but IMHO the recursive link detection should be > done also in default mode - what do you think? What is quilt setup? What should GLOBAL do? -- Shigio YAMAGUCHI <shigio@...> PGP fingerprint: D1CB 0B89 B346 4AB6 5663 C4B6 3CA5 BBB3 57BE DDA3 _______________________________________________ Bug-global mailing list Bug-global@... http://lists.gnu.org/mailman/listinfo/bug-global |
|
|
Re: gtags and symbolic linksHi again,
On Thu, May 14, 2009 at 07:44:50PM +0900, Shigio YAMAGUCHI wrote: > Hi, > > First of all, I'm thinking about implementing the nofollow option for gtags, as > > proposed on [2]. My question is, how exactly should this behave: should that > > only omit symbolic links that point to a directory or should that ignore > > symbolic links completely (e.g. ./foo.c pointing to ./bar.c) ? > > I have not thought about details yet. > Is there something proposal? My proposal is to introduce new 'nofollow' option for gtags that would make gtags not to descend to symbolic links pointing to directories. > > > When thinking about it and looking into the code, I don't quite understand the > > following part of find_read_traverse() (libutil/find.c): > ... > > To be specific, what's the purpose of lines 539-551? If I'm not mistaken, the > > test at line 545 can never succeed because it is the opposite of the test at > > line 538. > > It might be so. But at present, this code is harmless. OK, that's what I've thought. > > > Next, is there any benefit of determining the type of a file in getdirs() > > function (I mean prefixing the filename with f,d) instead of determining = > > the > > type directly in the find_read_traverse() function? > > This is due to a historical reason. > In some systems like BSD, dirent structure has a member named 'd_type' which > describes file type. Determining type by it, we can avoid to calling stat(2) > for each files. But another systems like GNU/Linux doesn't has it. > I wanted to hide the difference in a basic function, getdirs(). > > By the way, GLOBAL doesn't use the 'd_type' currently due to the following bug: > [http://lists.gnu.org/archive/html/bug-global/2003-08/msg00002.html] Thanks for clarifiction. Manpage for linux readdir states that the d_type isn't supported by all filesystems, so it IMHO means that you can't rely on that (IOW it's not a bug but a feature). Is the performance gain of using d_type on BSD's worth the trouble with maintaining getdirs() ? > > > And finally: what actually made me start thinking about this is fact that gtags > > can not treat recursive links, like in [3]. This actually makes it difficult to > > use gtags on directories created by quilt setup, because quilt creates exactly > > this type of directory structure (for a good reason). This could be worked > > around by the nofollow option, but IMHO the recursive link detection should be > > done also in default mode - what do you think? > > What is quilt setup? http://linux.die.net/man/1/quilt quilt setup is a 'quilt subcommand' intended to help maintaining RPM's. Given a specfile and a tarball with sources, it extracts the tarball, cds to this directory and creates symbolic link pointing to '..' -> so running gtags in the directory with sources fails. > What should GLOBAL do? It should detect and ignore recursive links (like find,ctags,cscope,.... do). Thanks, -- Best regards / s pozdravem Petr Uzel, Packages maintainer --------------------------------------------------------------------- SUSE LINUX, s.r.o. e-mail: puzel@... Lihovarská 1060/12 tel: +420 284 028 964 190 00 Prague 9 fax: +420 284 028 951 Czech Republic http://www.suse.cz _______________________________________________ Bug-global mailing list Bug-global@... http://lists.gnu.org/mailman/listinfo/bug-global |
|
|
Re: gtags and symbolic links> My proposal is to introduce new 'nofollow' option for gtags that would
> make gtags not to descend to symbolic links pointing to directories. ... > It should detect and ignore recursive links (like find,ctags,cscope,.... do). What is the 'recursive links'? (I understand that it is a symbolic link to a directory.) Does it mean a symbolic link which points to '.' or one of the parent directories? For example, making a symbolic link '/home/user/src/lib/recursive', Current directory: /home/user/src/lib parent directories: /, /home, /home/user, /home/user/src Otherwise, the "ignoring recursive links" means simply not to trace same directory twice? -- Shigio YAMAGUCHI <shigio@...> PGP fingerprint: D1CB 0B89 B346 4AB6 5663 C4B6 3CA5 BBB3 57BE DDA3 _______________________________________________ Bug-global mailing list Bug-global@... http://lists.gnu.org/mailman/listinfo/bug-global |
|
|
Re: gtags and symbolic linksHi Shigio,
On Fri, May 15, 2009 at 07:43:05AM +0900, Shigio YAMAGUCHI wrote: > > My proposal is to introduce new 'nofollow' option for gtags that would > > make gtags not to descend to symbolic links pointing to directories. > ... > > It should detect and ignore recursive links (like find,ctags,cscope,.... do). > > What is the 'recursive links'? > (I understand that it is a symbolic link to a directory.) > > Does it mean a symbolic link which points to '.' or one of the parent directories? By recursive link, I mean a link (pointing to a directory) which creates a loop in directory structure, like this: ls -lR dir/ dir/: total 0 lrwxrwxrwx 1 puzel users 2 May 15 09:32 link -> .. -rw-r--r-- 1 puzel users 0 May 15 09:32 main.c Try running 'strace gtags' in 'dir' to see what happens. > > For example, making a symbolic link '/home/user/src/lib/recursive', > > Current directory: /home/user/src/lib > parent directories: /, /home, /home/user, /home/user/src Sorry, I'm afraid I don't understand this example. > Otherwise, the "ignoring recursive links" means simply not to trace same > directory twice? With proposed nofollow option, which I've describe in previous post, the recursive links should not make any troubles at all. When following symbolic links to directories (now default), gtags should detect the loop somehow. If I'm not mistaken, ctags does this by checking that a directory we are going into isn't parent of the current directory. -- Best regards / s pozdravem Petr Uzel, Packages maintainer --------------------------------------------------------------------- SUSE LINUX, s.r.o. e-mail: puzel@... Lihovarská 1060/12 tel: +420 284 028 964 190 00 Prague 9 fax: +420 284 028 951 Czech Republic http://www.suse.cz _______________________________________________ Bug-global mailing list Bug-global@... http://lists.gnu.org/mailman/listinfo/bug-global |
|
|
Re: gtags and symbolic linksHi Petr
> By recursive link, I mean a link (pointing to a directory) which creates = > a loop in > directory structure, like this: > ls -lR dir/ > dir/: > total 0 > lrwxrwxrwx 1 puzel users 2 May 15 09:32 link -> .. > -rw-r--r-- 1 puzel users 0 May 15 09:32 main.c I have roughly understood it. > When following symbolic links to directories (now default), gtags > should detect the loop somehow. I agree with you. I will put this into the TODO list. I think that this function should be active unless the --nofollow option is specified. -- Shigio YAMAGUCHI <shigio@...> PGP fingerprint: D1CB 0B89 B346 4AB6 5663 C4B6 3CA5 BBB3 57BE DDA3 _______________________________________________ Bug-global mailing list Bug-global@... http://lists.gnu.org/mailman/listinfo/bug-global |
| Free embeddable forum powered by Nabble | Forum Help |