From owner-freebsd-questions Tue Apr 2 5:15:47 2002 Delivered-To: freebsd-questions@freebsd.org Received: from mobil.cz (diana.mobil.cz [194.228.200.160]) by hub.freebsd.org (Postfix) with ESMTP id 20A2C37B41A for ; Tue, 2 Apr 2002 05:15:39 -0800 (PST) Received: from ester.mobil.cz (ester.mobil.cz [194.213.62.23]) by mobil.cz (8.11.6/8.11.0) with ESMTP id g32DFKm01596 for ; Tue, 2 Apr 2002 15:15:20 +0200 Received: from roman.mobil.cz ([10.2.0.89]) by ester.mobil.cz (Lotus Domino Release 5.0.9a) with ESMTP id 2002040215145409:10353 ; Tue, 2 Apr 2002 15:14:54 +0200 Received: (from roman@localhost) by roman.mobil.cz (8.11.6/8.11.6) id g32DUE762092 for freebsd-questions@freebsd.org; Tue, 2 Apr 2002 15:30:14 +0200 (CEST) (envelope-from neuhauser@mobil.cz) X-Authentication-Warning: roman.mobil.cz: roman set sender to neuhauser@mobil.cz using -f Date: Tue, 2 Apr 2002 15:30:14 +0200 From: Roman Neuhauser To: freebsd-questions Subject: glob(3)/POSIX.2 question Message-ID: <20020402133014.GB389@roman.mobil.cz> Mail-Followup-To: freebsd-questions Mime-Version: 1.0 User-Agent: Mutt/1.3.26i X-MIMETrack: Itemize by SMTP Server on ester/Mobil(Release 5.0.9a |January 7, 2002) at 04/02/2002 03:14:54 PM, Serialize by Router on ester/Mobil(Release 5.0.9a |January 7, 2002) at 04/02/2002 03:15:00 PM, Serialize complete at 04/02/2002 03:15:00 PM Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Sender: owner-freebsd-questions@FreeBSD.ORG Precedence: bulk List-ID: List-Archive: (Web Archive) List-Help: (List Instructions) List-Subscribe: List-Unsubscribe: X-Loop: FreeBSD.ORG Hi there, GNU lists GLOB_NOMATCH as the return value from the glob() macro when it finds zero matches. FreeBSD doesn't define GLOB_NOMATCH. GNU 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 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 (and especially GLOB_NOMATCH) strictly POSIX? If so, shouldn't the FreeBSD glob() macro also return GLOB_NOMATCH (and 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