Skip site navigation (1)Skip section navigation (2)
Date:      Tue, 2 Apr 2002 15:30:14 +0200
From:      Roman Neuhauser <neuhauser@mobil.cz>
To:        freebsd-questions <freebsd-questions@freebsd.org>
Subject:   glob(3)/POSIX.2 question
Message-ID:  <20020402133014.GB389@roman.mobil.cz>

next in thread | raw e-mail | index | archive | help
Hi there,

GNU <glob.h> lists GLOB_NOMATCH as the return value from the glob()
macro when it finds zero matches.

FreeBSD <glob.h> doesn't define GLOB_NOMATCH.

GNU <glob.h> defines glob_t thus:

typedef struct
  {
    __size_t gl_pathc;          /* Count of paths matched by the pattern.  */
    char **gl_pathv;            /* List of matched pathnames.  */
    __size_t gl_offs;           /* Slots to reserve in `gl_pathv'.  */
    int gl_flags;               /* Set to FLAGS, maybe | GLOB_MAGCHAR.  */

    /* If the GLOB_ALTDIRFUNC flag is set, the following functions
       are used instead of the normal file access functions.  */
    void (*gl_closedir) __PMT ((void *));
    struct dirent *(*gl_readdir) __PMT ((void *));
    __ptr_t (*gl_opendir) __PMT ((__const char *));
    int (*gl_lstat) __PMT ((__const char *__restrict,
                            struct stat *__restrict));
    int (*gl_stat) __PMT ((__const char *__restrict, struct stat *__restrict));
  } glob_t;

FreeBSD <glob.h> defines it thus:

typedef struct {
        int gl_pathc;           /* Count of total paths so far. */
        int gl_matchc;          /* Count of paths matching pattern. */
        int gl_offs;            /* Reserved at beginning of gl_pathv. */
        int gl_flags;           /* Copy of flags parameter to glob. */
        char **gl_pathv;        /* List of paths matching pattern. */
                                /* Copy of errfunc parameter to glob. */
        int (*gl_errfunc) __P((const char *, int));

        /*
         * Alternate filesystem access methods for glob; replacement
         * versions of closedir(3), readdir(3), opendir(3), stat(2)
         * and lstat(2).
         */
        void (*gl_closedir) __P((void *));
        struct dirent *(*gl_readdir) __P((void *));
        void *(*gl_opendir) __P((const char *));
        int (*gl_lstat) __P((const char *, struct stat *));
        int (*gl_stat) __P((const char *, struct stat *));
} glob_t;

Both glob(3) pages claim that their respective implementations are POSIX.2
compliant (FBSD glob(3) admits it's not completely POSIX-y).


My question is: is the GNU <glob.h> (and especially GLOB_NOMATCH)
strictly POSIX? If so, shouldn't the FreeBSD glob() macro also return 
GLOB_NOMATCH (and <glob.h> define it)? And irregardless of the previous
answer: how can one *portably* check for zero matches? And lastly: what
is the *common* way for doing this on FreeBSD?

Thanks a lot,

Roman

-- 
FreeBSD 4.4-STABLE
2:52PM up 8 days, 21:38, 30 users, load averages: 0.13, 0.06, 0.06

To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe freebsd-questions" in the body of the message




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20020402133014.GB389>