CVS update: /ccvs/lib/

[email protected] 17 May 2005 19:19:11 -0000
Newsgroups gmane.comp.version-control.cvs.cvs
Message-ID <[email protected]>
User: dprice  
Date: 05/05/17 12:19:11

Modified:
 /ccvs/lib/
  ChangeLog, glob.c, glob_.h

Log:
 More misc cleanup for compatibility with GNULIB & glibc, mostly
 suggested by Paul Eggert <[email protected]>.
 * glob.c: Improve comments.  
 (GETPW_R_SIZE_MAX): New macro to avoid undefined sysconf macros.
 (glob): Use new macro.
 * glob_.h: Define __const, __restrict, and __USE_GNU when necessary.
 Protect use of __BEGIN_DECLS & __END_DECLS.  Remove include of
 <sys/types.h>.  Reorganize definitions for GNULIB.  Remove #undefs
 which work around what is now probably a non-existant problem.

File Changes:

Directory: /ccvs/lib/
=====================

File [changed]: ChangeLog
Url: https://ccvs.cvshome.org/source/browse/ccvs/lib/ChangeLog?r1=1.425&r2=1.426
Delta lines:  +12 -0
--------------------
--- ChangeLog	15 May 2005 16:44:04 -0000	1.425
+++ ChangeLog	17 May 2005 19:19:09 -0000	1.426
@@ -1,3 +1,15 @@
+2005-05-17  Derek Price  <[email protected]>
+
+	More misc cleanup for compatibility with GNULIB & glibc, mostly
+	suggested by Paul Eggert <[email protected]>.
+	* glob.c: Improve comments.  
+	(GETPW_R_SIZE_MAX): New macro to avoid undefined sysconf macros.
+	(glob): Use new macro.
+	* glob_.h: Define __const, __restrict, and __USE_GNU when necessary.
+	Protect use of __BEGIN_DECLS & __END_DECLS.  Remove include of
+	<sys/types.h>.  Reorganize definitions for GNULIB.  Remove #undefs
+	which work around what is now probably a non-existant problem.
+
 2005-05-15  Derek Price  <[email protected]>
 
 	* glob_.h, glob.c: More misc cleanup for compatibility with GNULIB &

File [changed]: glob.c
Url: https://ccvs.cvshome.org/source/browse/ccvs/lib/glob.c?r1=1.5&r2=1.6
Delta lines:  +10 -4
--------------------
--- glob.c	15 May 2005 16:44:04 -0000	1.5
+++ glob.c	17 May 2005 19:19:09 -0000	1.6
@@ -196,9 +196,15 @@
 extern char *getlogin (void);
 #endif
 
+#ifdef _SC_GETPW_R_SIZE_MAX
+# define GETPW_R_SIZE_MAX()	sysconf (_SC_GETPW_R_SIZE_MAX)
+#else
+# define GETPW_R_SIZE_MAX()	-1;
+#endif
+
 static const char *next_brace_sub (const char *begin, int flags) __THROW;
 
-#endif /* GLOB_ONLY_P */
+#endif /* !_LIBC || !GLOB_ONLY_P */
 
 static int glob_in_dir (const char *pattern, const char *directory,
 			int flags, int (*errfunc) (const char *, int),
@@ -233,7 +239,7 @@
   return *cp != '\0' ? cp : NULL;
 }
 
-#endif /* !GLOB_ONLY_P */
+#endif /* !_LIBC || !GLOB_ONLY_P */
 
 /* Do glob searching for PATTERN, placing results in PGLOB.
    The bits defined above may be set in FLAGS.
@@ -555,7 +561,7 @@
 		{
 		  struct passwd *p;
 #   if defined HAVE_GETPWNAM_R || defined _LIBC
-		  long int pwbuflen = sysconf (_SC_GETPW_R_SIZE_MAX);
+		  long int pwbuflen = GETPW_R_SIZE_MAX();
 		  char *pwtmpbuf;
 		  struct passwd pwbuf;
 		  int save = errno;
@@ -636,7 +642,7 @@
 	  {
 	    struct passwd *p;
 #  if defined HAVE_GETPWNAM_R || defined _LIBC
-	    long int buflen = sysconf (_SC_GETPW_R_SIZE_MAX);
+	    long int buflen = GETPW_R_SIZE_MAX();
 	    char *pwtmpbuf;
 	    struct passwd pwbuf;
 	    int save = errno;

File [changed]: glob_.h
Url: https://ccvs.cvshome.org/source/browse/ccvs/lib/glob_.h?r1=1.5&r2=1.6
Delta lines:  +19 -18
---------------------
--- glob_.h	15 May 2005 16:44:04 -0000	1.5
+++ glob_.h	17 May 2005 19:19:09 -0000	1.6
@@ -19,19 +19,14 @@
 #ifndef	_GLOB_H
 #define	_GLOB_H	1
 
-#ifdef _LIBC
+#if defined _LIBC
 # include <sys/cdefs.h>
-#else
-# include <sys/types.h>
-# include <stddef.h>
-# undef __size_t
-# define __size_t size_t
 #endif
 
-__BEGIN_DECLS
-
 /* We need `size_t' for the following definitions.  */
 #ifdef _LIBC
+__BEGIN_DECLS
+
 # ifndef __size_t
 typedef __SIZE_TYPE__ __size_t;
 #  ifdef __USE_XOPEN
@@ -43,18 +38,22 @@
 #  undef __size_t
 #  define __size_t size_t
 # endif
+#else /* !_LIBC */
+# include <stddef.h>
+# undef __size_t
+# define __size_t	size_t
+/* The following are necessary with MSVC and who knows where else.  */
+# ifndef __const
+#  define __const	const
+# endif
+# ifndef __restrict
+#  define __restrict	restrict
+# endif
+# ifndef __USE_GNU
+#  define __USE_GNU	1
+# endif
 #endif /* _LIBC */
 
-/* Some system libraries erroneously define these.  */
-#undef	GLOB_ERR
-#undef	GLOB_MARK
-#undef	GLOB_NOSORT
-#undef	GLOB_DOOFFS
-#undef	GLOB_NOCHECK
-#undef	GLOB_APPEND
-#undef	GLOB_NOESCAPE
-#undef	GLOB_PERIOD
-
 /* Bits set in the FLAGS argument to `glob'.  */
 #define	GLOB_ERR	(1 << 0)/* Return on read errors.  */
 #define	GLOB_MARK	(1 << 1)/* Append a slash to each name.  */
@@ -213,6 +212,8 @@
 extern int glob_pattern_p (__const char *__pattern, int __quote) __THROW;
 #endif
 
+#ifdef _LIBC
 __END_DECLS
+#endif
 
 #endif /* glob.h  */