Re: glob_.h glibc

2005-09-12 Thread Derek Price
Paul Eggert wrote:

OK, but in that case shouldn't the AC_REQUIRE([AC_GNU_SOURCE]) be in
gl_GLOB rather than gl_PREREQ_GLOB?
  


I don't think so.  gl_GLOB tests for the _GNU_GLOB_INTERFACE_VERSION
macro from gnu-versions.h  a known bug in GNU glob's POSIX support. 
Neither requires the GNU extensions enabled.

Also, gl_GLOB_SUBSTITUTE can enable the glob module without a call to
gl_GLOB at all, so at the least, a call to AC_REQUIRE([AC_GNU_SOURCE])
would still need to remain in gl_GLOB_PREREQ.

Regards,

Derek

-- 
Derek R. Price
CVS Solutions Architect
Ximbiot http://ximbiot.com
v: +1 717.579.6168
f: +1 717.234.3125
mailto:[EMAIL PROTECTED]




___
bug-gnulib mailing list
bug-gnulib@gnu.org
http://lists.gnu.org/mailman/listinfo/bug-gnulib


Re: glob_.h glibc

2005-09-12 Thread Derek Price
Okay, I've committed the glob-min-glibc-h-changes2.diff patch.  The 
glob.h-glibc-to-gnulib2.diff should be the new minimal patch for submission to 
glibc.


2005-09-12  Derek Price  [EMAIL PROTECTED]
Paul Eggert  [EMAIL PROTECTED]

* modules/glob (Files): Add glob-libc.h.
* lib/glob-libc.h: Renamed from glob_.h.  The new version is
taken from libc's glob.h, except with '#ifdef __GLOB_GNULIB'
protecting things that should be done only in gnulib contexts.
* lib/glob_.h: New file, containing only the glob things needed for
gnulib.
(GLOB_PREFIX): Remove.  All uses changed to look for __GLOB_GNULIB.
(__GLOB_CONCAT, __GLOB_XCONCAT, __GLOB_ID): Remove; no longer needed.
(glob, globfree, glob_pattern_p): Now defined simply in terms of
rpl_glob, rpl_globfree, rpl_glob_pattern_p.
(__GLOB_GNULIB): New macro, to keep the glob.h changes clearer
and to respect the namespace rules better.
* m4/glob.m4 (gl_GLOB_SUBSTITUTE): AC_LIBSOURCES for glob.c,
glob_.h, glob-libc.h.
(gl_PREREQ_GLOB): Remove _SYS_CDEFS_H hack; no longer needed.


2005-09-12  Derek Price  [EMAIL PROTECTED]
Paul Eggert  [EMAIL PROTECTED]

* posix/glob.h: Avoid a header and some largefile support when
compiled as part of GNULIB.

Regards,

Derek

-- 
Derek R. Price
CVS Solutions Architect
Ximbiot http://ximbiot.com
v: +1 717.579.6168
f: +1 717.234.3125
mailto:[EMAIL PROTECTED]

Index: lib/glob-libc.h
===
RCS file: lib/glob-libc.h
diff -N lib/glob-libc.h
--- /dev/null   1 Jan 1970 00:00:00 -
+++ lib/glob-libc.h 13 Sep 2005 03:40:13 -
@@ -0,0 +1,196 @@
+/* Copyright (C) 1991,92,95-98,2000,2001,2004 Free Software Foundation, Inc.
+   This file is part of the GNU C Library.
+
+   The GNU C Library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Lesser General Public
+   License as published by the Free Software Foundation; either
+   version 2.1 of the License, or (at your option) any later version.
+
+   The GNU C Library is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public
+   License along with the GNU C Library; if not, write to the Free
+   Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+   02111-1307 USA.  */
+
+#ifndef_GLOB_H
+#define_GLOB_H 1
+
+#ifndef __GLOB_GNULIB
+# include sys/cdefs.h
+#endif
+
+__BEGIN_DECLS
+
+/* We need `size_t' for the following definitions.  */
+#ifndef __size_t
+# if defined __GNUC__  __GNUC__ = 2
+typedef __SIZE_TYPE__ __size_t;
+#  ifdef __USE_XOPEN
+typedef __SIZE_TYPE__ size_t;
+#  endif
+# else
+#  include stddef.h
+#  ifndef __size_t
+#   define __size_t size_t
+#  endif
+# endif
+#else
+/* The GNU CC stddef.h version defines __size_t as empty.  We need a real
+   definition.  */
+# undef __size_t
+# define __size_t size_t
+#endif
+
+/* Bits set in the FLAGS argument to `glob'.  */
+#defineGLOB_ERR(1  0)/* Return on read errors.  */
+#defineGLOB_MARK   (1  1)/* Append a slash to each name.  */
+#defineGLOB_NOSORT (1  2)/* Don't sort the names.  */
+#defineGLOB_DOOFFS (1  3)/* Insert PGLOB-gl_offs NULLs.  */
+#defineGLOB_NOCHECK(1  4)/* If nothing matches, return the 
pattern.  */
+#defineGLOB_APPEND (1  5)/* Append to results of a previous 
call.  */
+#defineGLOB_NOESCAPE   (1  6)/* Backslashes don't quote 
metacharacters.  */
+#defineGLOB_PERIOD (1  7)/* Leading `.' can be matched by 
metachars.  */
+
+#if !defined __USE_POSIX2 || defined __USE_BSD || defined __USE_GNU
+# define GLOB_MAGCHAR   (1  8)/* Set in gl_flags if any metachars seen.  */
+# define GLOB_ALTDIRFUNC (1  9)/* Use gl_opendir et al functions.  */
+# define GLOB_BRACE (1  10)/* Expand {a,b} to a b.  */
+# define GLOB_NOMAGIC   (1  11)/* If no magic chars, return the pattern.  */
+# define GLOB_TILDE (1  12)/* Expand ~user and ~ to home directories. */
+# define GLOB_ONLYDIR   (1  13)/* Match only directories.  */
+# define GLOB_TILDE_CHECK (1  14)/* Like GLOB_TILDE but return an error
+ if the user name is not available.  */
+# define __GLOB_FLAGS  (GLOB_ERR|GLOB_MARK|GLOB_NOSORT|GLOB_DOOFFS| \
+GLOB_NOESCAPE|GLOB_NOCHECK|GLOB_APPEND| \
+GLOB_PERIOD|GLOB_ALTDIRFUNC|GLOB_BRACE| \
+GLOB_NOMAGIC|GLOB_TILDE|GLOB_ONLYDIR|GLOB_TILDE_CHECK)
+#else
+# define __GLOB_FLAGS  (GLOB_ERR|GLOB_MARK|GLOB_NOSORT|GLOB_DOOFFS| \
+

Re: glob_.h glibc

2005-09-09 Thread Paul Eggert
Derek Price [EMAIL PROTECTED] writes:

 It's late, I'm tired.  Patches actually attached now.

Thanks.  A few comments.  First, that SYS_CDEFS_H thing is really confusing.
Also, I worry that the GLOB_PREFIX thing doesn't respect the POSIX name
space rules.  How about if we use a new symbol __GLOB_GNULIB to address
both issues?  That will make the glibc glob.h file clearer.

Second, I prefer the name glob-libc.h to glob-glibc.h.  glibc and libc
are both common names, but libc is one less character.

Third, we can lessen the number of changes to libc glob.h by #defining
dirent to direct as needed in glob_.h.

Fourth, we can AC_REQUIRE AC_GNU_SOURCE, so that we needn't worry about
__USE_GNU.

In summary, how about the following patch instead?  (Please note that
I haven't tested it.)

2005-09-09  Derek Price  [EMAIL PROTECTED]
Paul Eggert  [EMAIL PROTECTED]

* modules/glob (Files): Add glob-libc.h.
* lib/glob-libc.h: Renamed from glob_.h.  The new version is
taken from libc's glob.h, except with '#ifdef __GLOB_GNULIB'
protecting things that should be done only in gnulib contexts.
* lib/glob_.h: New file, containing only the glob things needed for
gnulib.
(GLOB_PREFIX): Remove.  All uses changed to look for __GLOB_GNULIB.
(__GLOB_CONCAT, __GLOB_XCONCAT, __GLOB_ID): Remove; no longer needed.
(glob, globfree, glob_pattern_p): Now defined simply in terms of
rpl_glob, rpl_globfree, rpl_glob_pattern_p.
(__GLOB_GNULIB): New macro, to keep the glob.h changes clearer
and to respect the namespace rules better.
* m4/glob.m4 (gl_GLOB_SUBSTITUTE): AC_LIBSOURCES for glob.c,
glob_.h, glob-libc.h.
(gl_PREREQ_GLOB): Remove _SYS_CDEFS_H hack; no longer needed.

--- lib/glob_.h 7 Jun 2005 14:58:46 -   1.3
+++ lib/glob_.h 9 Sep 2005 17:54:51 -
@@ -1,33 +1,32 @@
-/* Copyright (C) 1991,92,95-98,2000,2001,2004 Free Software Foundation, Inc.
-   This file is part of the GNU C Library.
+/* glob_.h -- Find a path matching a pattern.
 
-   The GNU C Library is free software; you can redistribute it and/or
-   modify it under the terms of the GNU Lesser General Public
-   License as published by the Free Software Foundation; either
-   version 2.1 of the License, or (at your option) any later version.
+   Copyright (C) 2005 Free Software Foundation, Inc.
 
-   The GNU C Library is distributed in the hope that it will be useful,
+   Written by Derek Price [EMAIL PROTECTED]  Paul Eggert [EMAIL PROTECTED]
+
+   This program is free software; you can redistribute it and/or modify
+   it under the terms of the GNU General Public License as published by
+   the Free Software Foundation; either version 2, or (at your option)
+   any later version.
+
+   This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
-   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
-   Lesser General Public License for more details.
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+   GNU General Public License for more details.
+
+   You should have received a copy of the GNU General Public License
+   along with this program; if not, write to the Free Software Foundation,
+   Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.  */
 
-   You should have received a copy of the GNU Lesser General Public
-   License along with the GNU C Library; if not, write to the Free
-   Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
-   02111-1307 USA.  */
-
-#ifndef_GLOB_H
-#define_GLOB_H 1
-
-/* Note the reversal of the common HAVE_SYS_CDEFS_H idiom below.  In this
-   way, #ifndef _SYS_CDEFS_H may be used to include sys/cdefs.h both when
-   it has been checked for via the GNULIB configure test and found and when
-   it has not been checked for, which we can presume means that the glob.h
-   GNULIB shares with GLIBC is being included as a system header and not as
-   part of GNULIB, in which case sys/cdefs.h may be assumed.  */
-#ifndef _SYS_CDEFS_H
+#ifndef GLOB_H
+#define GLOB_H 1
+
+#ifdef HAVE_SYS_CDEFS_H
 # include sys/cdefs.h
 #endif
+
+#include stddef.h
+
 #ifndef __BEGIN_DECLS
 # define __BEGIN_DECLS
 # define __END_DECLS
@@ -36,209 +35,27 @@
 # define __THROW
 #endif
 
-__BEGIN_DECLS
-
-/* We need `size_t' for the following definitions.  */
-#ifndef GLOB_PREFIX
-# ifndef __size_t
-#  if defined __GNUC__  __GNUC__ = 2
-typedef __SIZE_TYPE__ __size_t;
-#   ifdef __USE_XOPEN
-typedef __SIZE_TYPE__ size_t;
-#   endif
-#  else
-#   include stddef.h
-#   ifndef __size_t
-#define __size_t size_t
-#   endif
-#  endif
-# else
-/* The GNU CC stddef.h version defines __size_t as empty.  We need a real
-   definition.  */
-#  undef __size_t
-#  define __size_t size_t
-# endif
-#else /* GLOB_PREFIX */
-# include stddef.h
-# undef __size_t
+#ifndef __size_t
 # define __size_t 

Re: glob_.h glibc

2005-09-09 Thread Paul Eggert
Derek Price [EMAIL PROTECTED] writes:

Fourth, we can AC_REQUIRE AC_GNU_SOURCE, so that we needn't worry about
__USE_GNU.

 We ran into this problem the first time we went through this:
 http://lists.gnu.org/archive/html/bug-gnulib/2005-05/msg00144.html. 

Ouch.  Sorry I forgot that.

I assume you fixed this by removing the AC_REQUIRE([AC_GNU_SOURCE])
from glob.m4 and restoring the condtional #define __USE_GNU 1 to
glob_.h?  If it's more complicated than that, please let me know.


___
bug-gnulib mailing list
bug-gnulib@gnu.org
http://lists.gnu.org/mailman/listinfo/bug-gnulib


Re: glob_.h glibc

2005-09-08 Thread Paul Eggert
Derek Price [EMAIL PROTECTED] writes:

 Re: http://sourceware.org/bugzilla/show_bug.cgi?id=1060, glibc
 objected to the extent of our changes to an installed header (glob.h) to
 bring the file into sync with GNULIB. (They did accept the glob.c
 changes, though they have yet to apply them.)

Hmm, actually they provisionally accepted the bug-1060 changes except
for the part about using prototypes when defining external functions.
I wonder why they don't like that?  Anyway, I just submitted a revised
patch in bug 1060 that does that.

 It is true, as Roland says, that we could put most of our changes into a
 second header included before glob_.h, but I am wondering if this is
 desireable?  This would be a new structure for GNULIB.  Should I work on
 writing a header that defines the necessary macros and then includes a
 sync'd glob_.h, or would it be easier just to fork such a small file?

I'd rather not fork.  I think the former solution would be fine.  As I
understand it, you'd write a glob_.h file that does this:

...define our own stuff...
#include glob-libc.h

where glob-libc.h is an unmodified copy of the glibc glob.h.

Or perhaps the ...define our own stuff... could all be in config.h,
which would mean we wouldn't need two files.

Could you please follow up on this in bug-gnulib first?  I'd rather
not burden Roland with gnulib issues more than I can help it.  Thanks.

I installed the following patch into gnulib to sync it with the
newly-proposed glibc patches.

2005-09-08  Paul Eggert  [EMAIL PROTECTED]

* glob.c (glob, globfree, __glob_pattern_p): Use old-style function
definitions, since that's the preferred style in glibc.
Fix a minor spacing issue, and update copyright notice to match glibc's.
* config/srclist.txt: Remove glibc bug 1061; it's been fixed.

--- lib/glob.c  1 Sep 2005 22:36:04 -   1.2
+++ lib/glob.c  8 Sep 2005 20:18:48 -   1.3
@@ -1,4 +1,4 @@
-/* Copyright (C) 1991-2002, 2003, 2004, 2005 Free Software Foundation, Inc.
+/* Copyright (C) 1991-2002,2003,2004,2005 Free Software Foundation, Inc.
This file is part of the GNU C Library.
 
The GNU C Library is free software; you can redistribute it and/or
@@ -240,9 +240,11 @@ int
 #ifdef GLOB_ATTRIBUTE
 GLOB_ATTRIBUTE
 #endif
-glob (const char *pattern, int flags,
-  int (*errfunc) (const char *, int),
-  glob_t *pglob)
+glob (pattern, flags, errfunc, pglob)
+ const char *pattern;
+ int flags;
+ int (*errfunc) (const char *, int);
+ glob_t *pglob;
 {
   const char *filename;
   const char *dirname;
@@ -531,7 +533,7 @@ glob (const char *pattern, int flags,
{
  int success;
  char *name;
- size_t buflen = GET_LOGIN_NAME_MAX() + 1;
+ size_t buflen = GET_LOGIN_NAME_MAX () + 1;
 
  if (buflen == 0)
/* `sysconf' does not support _SC_LOGIN_NAME_MAX.  Try
@@ -888,7 +890,8 @@ libc_hidden_def (glob)
 
 /* Free storage allocated in PGLOB by a previous `glob' call.  */
 void
-globfree (register glob_t *pglob)
+globfree (pglob)
+ register glob_t *pglob;
 {
   if (pglob-gl_pathv != NULL)
 {
@@ -986,7 +989,9 @@ prefix_array (const char *dirname, char 
 /* Return nonzero if PATTERN contains any metacharacters.
Metacharacters can be quoted with backslashes if QUOTE is nonzero.  */
 int
-__glob_pattern_p (const char *pattern, int quote)
+__glob_pattern_p (pattern, quote)
+ const char *pattern;
+ int quote;
 {
   register const char *p;
   int open = 0;
--- config/srclist.txt  6 Sep 2005 07:36:48 -   1.103
+++ config/srclist.txt  8 Sep 2005 20:18:48 -   1.104
@@ -1,4 +1,4 @@
-# $Id: srclist.txt,v 1.103 2005/09/06 07:36:48 eggert Exp $
+# $Id: srclist.txt,v 1.104 2005/09/08 20:18:48 eggert Exp $
 # Files for which we are not the source.  See ./srclistvars.sh for the
 # variable definitions.
 
@@ -212,7 +212,6 @@ $LIBCSRC/sysdeps/generic/memmem.c   lib gp
 #$LIBCSRC/string/strverscmp.c  lib gpl
 #
 # http://sources.redhat.com/bugzilla/show_bug.cgi?id=1060
-# http://sources.redhat.com/bugzilla/show_bug.cgi?id=1061
 # http://sources.redhat.com/bugzilla/show_bug.cgi?id=1062
 #$LIBCSRC/sysdeps/generic/glob.c   lib gpl
 #


___
bug-gnulib mailing list
bug-gnulib@gnu.org
http://lists.gnu.org/mailman/listinfo/bug-gnulib


Re: glob_.h glibc

2005-09-08 Thread Derek Price
It's late, I'm tired.  Patches actually attached now.

2005-09-08  Derek Price  [EMAIL PROTECTED]

* m4/glob.m4 (gl_GLOB_SUBSTITUTE): AC_LIBSOURCE C files.
* lib/glob_.h: Move most code forked from glibc here, then include...
* lib/glob-glibc.h: ...this new file, which is the original glibc
header minus
a few unavoidable changes.
* modules/glob (Files): Add glob-glibc.h.
(Makefile.am [EXTRA_DIST]): Remove macro.


2005-09-08  Derek Price  [EMAIL PROTECTED]

* posix/glob.h: Avoid a header and some largefile support when compiled
as part of GNULIB.  Use struct direct when necessary.


Regards,

Derek


Derek Price wrote:

Paul Eggert wrote:

  

Hmm, actually they provisionally accepted the bug-1060 changes except
for the part about using prototypes when defining external functions.
 




Oh, that's what that meant.  I was hoping someone else would say
something if it was important.  Thanks.  :)

  

where glob-libc.h is an unmodified copy of the glibc glob.h.

Or perhaps the ...define our own stuff... could all be in config.h,
which would mean we wouldn't need two files.
 




Well, there were 3 #include statements that needed to be in glob_.h,
before including glob-glibc.h, so I went with the extra include file. 
I've attached a gnulib patch for review.  It compiles here, in Linux CVS.

There was also a small subset of changes that I can't see how to remove
from glob-glibc.h.  I've attached the new glibc-gnulib patch.  It is
much smaller now, so perhaps Roland will find it acceptable.  (Actually,
4 lines, the dirent/direct change, might also be avoidable with
something like a global #define dirent direct.  It would be a small
GNULIB module, but a module that did this, included a few header files,
and defined a few macros like D_NAMLEN could replace 10-15 lines in each
of five or six modules.)

  

Could you please follow up on this in bug-gnulib first?  I'd rather
not burden Roland with gnulib issues more than I can help it.  Thanks.
 




That's why I started this thread on bug-gnulib in the first place.  :)

Regards,

Derek
  


-- 
Derek R. Price
CVS Solutions Architect
Ximbiot http://ximbiot.com
v: +1 717.579.6168
f: +1 717.234.3125
mailto:[EMAIL PROTECTED]

Index: m4/glob.m4
===
RCS file: /cvsroot/gnulib/gnulib/m4/glob.m4,v
retrieving revision 1.4
diff -u -p -r1.4 glob.m4
--- m4/glob.m4  14 Jul 2005 15:53:30 -  1.4
+++ m4/glob.m4  9 Sep 2005 03:39:14 -
@@ -1,4 +1,4 @@
-# glob.m4 serial 2
+# glob.m4 serial 3
 dnl Copyright (C) 2005 Free Software Foundation, Inc.
 dnl This file is free software; the Free Software Foundation
 dnl gives unlimited permission to copy and/or distribute it,
@@ -13,6 +13,7 @@ AC_DEFUN([gl_GLOB_SUBSTITUTE],
   gl_PREREQ_GLOB
 
   GLOB_H=glob.h
+  AC_LIBSOURCES([glob.c, glob_.h, glob-glibc.h])
   AC_LIBOBJ([glob])
   AC_DEFINE([GLOB_PREFIX], [[rpl_]],
 [Define to rpl_ if the glob replacement functions and variables
Index: lib/glob_.h
===
RCS file: /cvsroot/gnulib/gnulib/lib/glob_.h,v
retrieving revision 1.3
diff -u -p -r1.3 glob_.h
--- lib/glob_.h 7 Jun 2005 14:58:46 -   1.3
+++ lib/glob_.h 9 Sep 2005 03:39:14 -
@@ -1,73 +1,46 @@
-/* Copyright (C) 1991,92,95-98,2000,2001,2004 Free Software Foundation, Inc.
-   This file is part of the GNU C Library.
+/* glob_.h -- Find a path matching a pattern.
 
-   The GNU C Library is free software; you can redistribute it and/or
-   modify it under the terms of the GNU Lesser General Public
-   License as published by the Free Software Foundation; either
-   version 2.1 of the License, or (at your option) any later version.
+   Copyright (C) 2005 Free Software Foundation, Inc.
 
-   The GNU C Library is distributed in the hope that it will be useful,
+   Written by Derek Price [EMAIL PROTECTED]  Paul Eggert [EMAIL PROTECTED]
+
+   This program is free software; you can redistribute it and/or modify
+   it under the terms of the GNU General Public License as published by
+   the Free Software Foundation; either version 2, or (at your option)
+   any later version.
+
+   This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
-   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
-   Lesser General Public License for more details.
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+   GNU General Public License for more details.
+
+   You should have received a copy of the GNU General Public License
+   along with this program; if not, write to the Free Software Foundation,
+   Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.  */
+
+#ifndef GLOB_H
+# define GLOB_H
 
-   You should have received a copy of the GNU Lesser General Public
-   License along with the GNU C Library; if not, write to the Free
-   Software Foundation,