[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [bug-gnulib] New GNULIB glob module?

From: Paul Eggert
Subject: Re: [bug-gnulib] New GNULIB glob module?
Date: Tue, 31 May 2005 22:34:06 -0700
User-agent: Gnus/5.1006 (Gnus v5.10.6) Emacs/21.4 (gnu/linux)

Derek Price <address@hidden> writes:

>    1. Corrects an incorrect check for a successful return from
>       getlogin_r to assume only 0 means success, per the POSIX2 spec:
> <http://www.opengroup.org/onlinepubs/009695399/functions/getlogin_r.html>.
>    2. Moves the check for GLOB_MARK directory status (and the append of
>       `/') into glob_in_dir, where it is more efficient than performing
>       a second pass and sometimes calling stat a second time on each
>       file or directory.  All calls to stat are avoided when
>       dirent->d_type is available.  No call to realloc of the directory
>       name is ever necessary since room for the slash can be allocated
>       in the first pass.

These changes sound reasonable, though we should submit them as
separate patches.

Is (2) independent of (3)?  (Please see below for why this is important.)

>    3. Ignores broken links only when GLOB_ONLYDIR is set.  With glibc
>       versions 2.3.3 through 2.3.5, the following in an empty directory
>       would return nothing:
>           ln -s doesnt-exist linkname
>           glob ("*", ...)
>       This fix syncs with the comments in the file, syncs with the
>       POSIX2 spec, restores the pre-glibc-2.3.3 behavior, and simply
>       makes more sense - why should `ls *' fail to list broken links?

This change sounds controversial to me.  glibc 2.3.5 behaves similarly
to Solaris 8 and to Solaris 10 -- I just checked, with the following
program and with the working directory containing only a dangling

  #include <glob.h>
  #include <stdio.h>

  main (void)
    glob_t g;
    int r = glob ("*", 0, NULL, &g);
    int i;

    if (r != 0)
        fprintf (stderr, "glob failed (%s)\n",
                 r == GLOB_NOMATCH ? "GLOB_NOMATCH"
                 : r == GLOB_NOSPACE ? "GLOB_NOSPACE"
                 : "other glob failure");
        return 1;

    for (i = 0; i < g.gl_pathc; i++)
      puts (g.gl_pathv[i]);
    return 0;

Solaris 8 and 10 both report "glob failed (GLOB_NOMATCH)".

Let's separate (3) into a separate patch and think about it more
carefully before submitting it.

Have you investigated with FreeBSD glob does?  It seems to use
gl_lstat, which our glob doesn't.  That's odd.  What's the point of
having a gl_lstat if it's never used?

reply via email to

[Prev in Thread] Current Thread [Next in Thread]