Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>I was wondering the same thing - <em>"What is the purpose of this lstat? Does it affect the glob()s return?"</em></p> <p>Within bsd_glob.c glob2() I noticed a g_stat call within an if branch that required the GLOB_MARK flag to be set, I also noticed a call to g_lstat just before that was not guarded by a flag check. Both are within an if branch for when the end of pattern is reached. If I remove these 2 lines in the glob2 function in perl-5.12.4/ext/File-Glob/bsd_glob.c</p> <pre><code>- if (g_lstat(pathbuf, &amp;sb, pglob)) - return(0); </code></pre> <p>the only perl test (make test) that fails is test 5 in ext/File-Glob/t/basic.t with:</p> <pre><code>not ok 5 # Failed test at ../ext/File-Glob/t/basic.t line 92. # Structures begin differing at: # $got-&gt;[0] = 'asdfasdf' # $expected-&gt;[0] = Does not exist </code></pre> <p>Test 5 in t/basic.t is</p> <pre><code># check nonexistent checks # should return an empty list # XXX since errfunc is NULL on win32, this test is not valid there @a = bsd_glob("asdfasdf", 0); SKIP: { skip $^O, 1 if $^O eq 'MSWin32' || $^O eq 'NetWare'; is_deeply(\@a, []); } </code></pre> <p>If I replace the 2 lines removed with:</p> <pre><code>+ if (!((pglob-&gt;gl_flags &amp; GLOB_NOCHECK) || + ((pglob-&gt;gl_flags &amp; GLOB_NOMAGIC) &amp;&amp; + !(pglob-&gt;gl_flags &amp; GLOB_MAGCHAR)))){ + if (g_lstat(pathbuf, &amp;sb, pglob)) + return(0); + } </code></pre> <p>I don't see any failures from "make test" for perl-5.12.4 on linux x86_64 (RHEL6.3 2.6.32-358.11.1.el6.x86_64) and when using:</p> <pre><code>strace -fe trace=lstat perl -e 'use File::Glob q{:glob}; print scalar bsd_glob(q{/var/log/*},GLOB_NOCHECK)' </code></pre> <p>I no longer see the lstat calls for each file in the dir. I don't mean to suggest that the perl tests for glob (File-Glob) are comprehensive (they are not), or that a change such as this will not break existing behaviour (this seems likely). As far as I can tell the code with this (g_l)stat call existed in original-bsd/lib/libc/gen/glob.c 24 years ago in 1990.</p> <p>Also see:</p> <ul> <li>Chapter 6. Benchmarking Perl of "Mastering Perl" By brian d foy, Randal L. Schwartz contains a section on comparing code where code using glob() and opendir() is compared.</li> <li>"future globs (was "UNIX mindset...")" in comp.unix.wizards from Dick Dunn in 1991.</li> <li>Usenet newsgroup mod.sources "'Globbing' library routine (glob)" from Guido van Rossum in July 1986 - I don't see a reference to "stat" in this code.</li> </ul>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload