Re: [bug-gnulib] snprintf fixes in gnulib

2006-08-28 Thread Bruno Haible
Hi,

Paul Eggert noted that vasnprintf should be able to return strings of length
 INT_MAX. Here's a patch to that effect.

Yoann, is the vsnprintf.c patch OK with you? It corresponds to Paul's fixes
to snprintf.c a week ago.


2006-08-26  Bruno Haible  [EMAIL PROTECTED]

* vasnprintf.c (EOVERFLOW): Remove definition.
(VASNPRINTF): Return a string of length  INT_MAX without failing.
* vasprintf.c: Include errno.h, limits.h.
(EOVERFLOW): New fallback definition.
(vasprintf): Test here whether the string length is  INT_MAX.
* vsnprintf.c: Include errno.h, limits.h.
(EOVERFLOW): New fallback definition.
(vsnprintf): Fix bug when generated string was too long for the buffer.
Test here whether the string length is  INT_MAX.

*** gnulib-20060823/lib/vasnprintf.c2006-01-23 16:01:57.0 +0100
--- gnulib-20060823-modified/lib/vasnprintf.c   2006-08-26 22:43:23.0 
+0200
***
*** 40,46 
  #include stdlib.h   /* abort(), malloc(), realloc(), free() */
  #include string.h   /* memcpy(), strlen() */
  #include errno.h/* errno */
! #include limits.h   /* CHAR_BIT, INT_MAX */
  #include float.h/* DBL_MAX_EXP, LDBL_MAX_EXP */
  #if WIDE_CHAR_VERSION
  # include wprintf-parse.h
--- 40,46 
  #include stdlib.h   /* abort(), malloc(), realloc(), free() */
  #include string.h   /* memcpy(), strlen() */
  #include errno.h/* errno */
! #include limits.h   /* CHAR_BIT */
  #include float.h/* DBL_MAX_EXP, LDBL_MAX_EXP */
  #if WIDE_CHAR_VERSION
  # include wprintf-parse.h
***
*** 51,61 
  /* Checked size_t computations.  */
  #include xsize.h
  
- /* Some systems, like OSF/1 4.0 and Woe32, don't have EOVERFLOW.  */
- #ifndef EOVERFLOW
- # define EOVERFLOW E2BIG
- #endif
- 
  #ifdef HAVE_WCHAR_T
  # ifdef HAVE_WCSLEN
  #  define local_wcslen wcslen
--- 51,56 
***
*** 869,887 
free (buf_malloced);
  CLEANUP ();
  *lengthp = length;
! if (length  INT_MAX)
!   goto length_overflow;
  return result;
  
-   length_overflow:
- /* We could produce such a big string, but its length doesn't fit into
-an 'int'.  POSIX says that snprintf() fails with errno = EOVERFLOW in
-this case.  */
- if (result != resultbuf)
-   free (result);
- errno = EOVERFLOW;
- return NULL;
- 
out_of_memory:
  if (!(result == resultbuf || result == NULL))
free (result);
--- 864,875 
free (buf_malloced);
  CLEANUP ();
  *lengthp = length;
! /* Note that we can produce a big string of a length  INT_MAX.  POSIX
!says that snprintf() fails with errno = EOVERFLOW in this case, but
!that's only because snprintf() returns an 'int'.  This function does
!not have this limitation.  */
  return result;
  
out_of_memory:
  if (!(result == resultbuf || result == NULL))
free (result);
*** gnulib-20060823/lib/vasprintf.c 2005-05-14 08:03:58.0 +0200
--- gnulib-20060823-modified/lib/vasprintf.c2006-08-26 22:41:56.0 
+0200
***
*** 1,5 
  /* Formatted output to strings.
!Copyright (C) 1999, 2002 Free Software Foundation, Inc.
  
 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
--- 1,5 
  /* Formatted output to strings.
!Copyright (C) 1999, 2002, 2006 Free Software Foundation, Inc.
  
 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
***
*** 22,31 
--- 22,38 
  /* Specification.  */
  #include vasprintf.h
  
+ #include errno.h
+ #include limits.h
  #include stdlib.h
  
  #include vasnprintf.h
  
+ /* Some systems, like OSF/1 4.0 and Woe32, don't have EOVERFLOW.  */
+ #ifndef EOVERFLOW
+ # define EOVERFLOW E2BIG
+ #endif
+ 
  int
  vasprintf (char **resultp, const char *format, va_list args)
  {
***
*** 34,42 
if (result == NULL)
  return -1;
  
*resultp = result;
!   /* Return the number of resulting bytes, excluding the trailing NUL.
!  If it wouldn't fit in an 'int', vasnprintf() would have returned NULL
!  and set errno to EOVERFLOW.  */
return length;
  }
--- 41,54 
if (result == NULL)
  return -1;
  
+   if (length  INT_MAX)
+ {
+   free (result);
+   errno = EOVERFLOW;
+   return -1;
+ }
+ 
*resultp = result;
!   /* Return the number of resulting bytes, excluding the trailing NUL.  */
return length;
  }
*** gnulib-20060823/lib/vsnprintf.c 2005-05-14 08:03:58.0 +0200
--- gnulib-20060823-modified/lib/vsnprintf.c2006-08-26 22:36:24.0 
+0200
***
*** 1,5 
  /* Formatted output to strings.
!Copyright (C) 2004 Free Software Foundation, Inc.
 Written by Simon Josefsson and Yoann Vandoorselaere 

Re: [bug-gnulib] reduce compiler warnings during configure

2006-08-28 Thread Bruno Haible
Eric Blake wrote:
 Paul's latest updates to module dependencies pulled in several .m4 files
 that trigger gcc compiler warnings, breaking the configuration of m4 with
 '-Werror' where it had previously been working.  Paul, Bruno, are these
 okay to install?

I installed the remaining patch to codeset.m4.

 Is bh_C_SIGNED still needed, now that we assume C89?

Good point. I think we're on ANSI C for sufficiently long time now. I'll
remove it in gettext-0.15.1.

 This does not do anything about the fact that AM_LANGINFO_CODESET (and
 other gettext macros) collides with the AM_ namespace.  Libtool has
 recently made the move to use its own namespace LT_, rather than
 potentially conflicting with automake/autoconf by reusing AC_/AM_, while
 providing backwards-compatible aliases to avoid breaking existing
 configure.ac files.  It would be something to consider for the next
 gettext release.

Most users would view such a renaming as a gratuitous hassle; therefore
I'm not doing such a renaming.

Bruno




Re: coreutils-6.0 on BeOS (6)

2006-08-28 Thread Bruno Haible
Simon Josefsson wrote:
  The reason is that BeOS does not have PF_INET, only AF_INET, but usually 
  they
  have the same values. Also it doesn't have PF_UNSPEC.
 
 Does it AF_UNSPEC?  Did you grep the entire /usr/include tree to find
 PF_INET or PF_UNSPEC?  Maybe they are in some non-standard header.

It has neither AF_UNSPEC nor PF_UNSPEC, in no header.

  + #ifdef PF_UNSPEC /* BeOS lacks PF_UNSPEC. */
 if (family == PF_UNSPEC)
   return true;
  + #endif
 
 I'm not sure this will do the right thing.  Usually getaddrinfo is
 called with hints structure that is zeroed out, and only the relevant
 flags asserted.  If family isn't asserted, it usually means take any
 family.

I see. Then what about this patch? It compiles fine on BeOS.


2006-08-26  Bruno Haible  [EMAIL PROTECTED]
Simon Josefsson  [EMAIL PROTECTED]

* getaddrinfo.c (PF_INET, PF_UNSPEC): New macros.

*** coreutils-6.2-cvs/lib/getaddrinfo.c 2006-08-26 21:52:06.0 +0200
--- coreutils-6.2-beos/lib/getaddrinfo.c2006-08-26 23:35:16.0 
+0200
***
*** 42,47 
--- 42,56 
  #include snprintf.h
  #include strdup.h
  
+ /* BeOS has AF_INET, but not PF_INET.  */
+ #ifndef PF_INET
+ # define PF_INET AF_INET
+ #endif
+ /* BeOS also lacks PF_UNSPEC.  */
+ #ifndef PF_UNSPEC
+ # define PF_UNSPEC 0
+ #endif
+ 
  #if defined _WIN32 || defined __WIN32__
  # define WIN32_NATIVE
  #endif





Re: coreutils-6.0 on BeOS (6)

2006-08-28 Thread Simon Josefsson
Bruno Haible [EMAIL PROTECTED] writes:

 Simon Josefsson wrote:
  The reason is that BeOS does not have PF_INET, only AF_INET, but usually 
  they
  have the same values. Also it doesn't have PF_UNSPEC.
 
 Does it AF_UNSPEC?  Did you grep the entire /usr/include tree to find
 PF_INET or PF_UNSPEC?  Maybe they are in some non-standard header.

 It has neither AF_UNSPEC nor PF_UNSPEC, in no header.

Ok, thanks.

  + #ifdef PF_UNSPEC /* BeOS lacks PF_UNSPEC. */
 if (family == PF_UNSPEC)
   return true;
  + #endif
 
 I'm not sure this will do the right thing.  Usually getaddrinfo is
 called with hints structure that is zeroed out, and only the relevant
 flags asserted.  If family isn't asserted, it usually means take any
 family.

 I see. Then what about this patch? It compiles fine on BeOS.

Looks good to me.  Please install it.

/Simon


 2006-08-26  Bruno Haible  [EMAIL PROTECTED]
 Simon Josefsson  [EMAIL PROTECTED]

   * getaddrinfo.c (PF_INET, PF_UNSPEC): New macros.

 *** coreutils-6.2-cvs/lib/getaddrinfo.c   2006-08-26 21:52:06.0 
 +0200
 --- coreutils-6.2-beos/lib/getaddrinfo.c  2006-08-26 23:35:16.0 
 +0200
 ***
 *** 42,47 
 --- 42,56 
   #include snprintf.h
   #include strdup.h
   
 + /* BeOS has AF_INET, but not PF_INET.  */
 + #ifndef PF_INET
 + # define PF_INET AF_INET
 + #endif
 + /* BeOS also lacks PF_UNSPEC.  */
 + #ifndef PF_UNSPEC
 + # define PF_UNSPEC 0
 + #endif
 + 
   #if defined _WIN32 || defined __WIN32__
   # define WIN32_NATIVE
   #endif




Re: [bug-gnulib] snprintf fixes in gnulib

2006-08-28 Thread Yoann Vandoorselaere
On Mon, 2006-08-28 at 14:54 +0200, Bruno Haible wrote:
 Hi,
 
 Paul Eggert noted that vasnprintf should be able to return strings of length
  INT_MAX. Here's a patch to that effect.
 
 Yoann, is the vsnprintf.c patch OK with you? It corresponds to Paul's fixes
 to snprintf.c a week ago.

Hi Bruno,

Look good to me.

Regards,

-- 
Yoann Vandoorselaere | Responsable RD / CTO | PreludeIDS Technologies
Tel: +33 (0)8 70 70 21 58  Fax: +33(0)4 78 42 21 58
http://www.prelude-ids.com





gnulib-tool: better error handling

2006-08-28 Thread Bruno Haible
This makes for a better error handling during patch.

2006-08-26  Bruno Haible  [EMAIL PROTECTED]

* gnulib-tool (func_verify_module): Check against misapplying patch.

*** gnulib-20060823/gnulib-tool 2006-08-24 03:52:14.0 +0200
--- gnulib-20060823-modified/gnulib-tool2006-08-26 23:21:27.0 
+0200
***
*** 639,645 
test TEMPLATE != $module \
test TEMPLATE-TESTS != $module; then
  # OK, $module is a correct module name.
! :
else
  echo gnulib-tool: module $module doesn't exist 12
  module=
--- 639,646 
test TEMPLATE != $module \
test TEMPLATE-TESTS != $module; then
  # OK, $module is a correct module name.
! # Verify that building the module description with 'patch' succeeds.
! func_lookup_file modules/$module
else
  echo gnulib-tool: module $module doesn't exist 12
  module=




Re: working with locally modified or augmented gnulib repositories

2006-08-28 Thread Bruno Haible
Hello Simon,

 Except that I have to specify --local-dir every time I use --import.
 Is this the intended behaviour?  Maybe the --local-dir value could be
 cached, just like --source-base etc.  What do you think?

You're right, it's cumbersome for --import. Also, --update would not do
the right thing if it doesn't know about the local-dir. The patch below
should fix it.

Bruno


2006-08-26  Bruno Haible  [EMAIL PROTECTED]

* gnulib-tool (func_relativize, func_relconcat): New functions.
Give an error if --local-dir is given with --update.
Remove trailing slashes from $local_gnulib_dir.
(func_import): Store the relativized $local_gnulib_dir in
gnulib-cache.m4, and read it from there if not specified explicitly.

*** gnulib-tool.bak 2006-08-26 23:21:27.0 +0200
--- gnulib-tool 2006-08-27 01:48:40.0 +0200
***
*** 246,251 
--- 246,344 
fi
  }
  
+ # func_relativize DIR1 DIR2
+ # computes a relative pathname RELDIR such that DIR1/RELDIR = DIR2.
+ # Input:
+ # - DIR1relative pathname, relative to the current directory
+ # - DIR2relative pathname, relative to the current directory
+ # Output:
+ # - reldir  relative pathname of DIR2, relative to DIR1
+ func_relativize ()
+ {
+   dir0=`pwd`
+   dir1=$1
+   dir2=$2
+   sed_first='s,^\([^/]*\)/.*$,\1,'
+   sed_rest='s,^[^/]*/*,,'
+   sed_last='s,^.*/\([^/]*\)$,\1,'
+   sed_butlast='s,/*[^/]*$,,'
+   while test -n $dir1; do
+ first=`echo $dir1 | sed -e $sed_first`
+ if test $first != .; then
+   if test $first = ..; then
+ dir2=`echo $dir0 | sed -e $sed_last`/$dir2
+ dir0=`echo $dir0 | sed -e $sed_butlast`
+   else
+ first2=`echo $dir2 | sed -e $sed_first`
+ if test $first2 = $first; then
+   dir2=`echo $dir2 | sed -e $sed_rest`
+ else
+   dir2=../$dir2
+ fi
+ dir0=$dir0/$first
+   fi
+ fi
+ dir1=`echo $dir1 | sed -e $sed_rest`
+   done
+   reldir=$dir2
+ }
+ 
+ # func_relconcat DIR1 DIR2
+ # computes a relative pathname DIR1/DIR2, with obvious simplifications.
+ # Input:
+ # - DIR1relative pathname, relative to the current directory
+ # - DIR2relative pathname, relative to DIR1
+ # Output:
+ # - relconcat   DIR1/DIR2, relative to the current directory
+ func_relconcat ()
+ {
+   dir1=$1
+   dir2=$2
+   sed_first='s,^\([^/]*\)/.*$,\1,'
+   sed_rest='s,^[^/]*/*,,'
+   sed_last='s,^.*/\([^/]*\)$,\1,'
+   sed_butlast='s,/*[^/]*$,,'
+   while true; do
+ first=`echo $dir2 | sed -e $sed_first`
+ if test $first = .; then
+   dir2=`echo $dir2 | sed -e $sed_rest`
+   if test -z $dir2; then
+ relconcat=$dir1
+ break
+   fi
+ else
+   last=`echo $dir1 | sed -e $sed_last`
+   while test $last = .; do
+ dir1=`echo $dir1 | sed -e $sed_butlast`
+ last=`echo $dir1 | sed -e $sed_last`
+   done
+   if test -z $dir1; then
+ relconcat=$dir2
+ break
+   fi
+   if test $first = ..; then
+ if test $last = ..; then
+   relconcat=$dir1/$dir2
+   break
+ fi
+ dir1=`echo $dir1 | sed -e $sed_butlast`
+ dir2=`echo $dir2 | sed -e $sed_rest`
+ if test -z $dir1; then
+   relconcat=$dir2
+   break
+ fi
+ if test -z $dir2; then
+   relconcat=$dir1
+   break
+ fi
+   else
+ relconcat=$dir1/$dir2
+ break
+   fi
+ fi
+   done
+ }
+ 
  # Command-line option processing.
  # Removes the OPTIONS from the arguments. Sets the variables:
  # - modelist or import or create-testdir or create-megatestdir
***
*** 465,471 
echo you need to use 'gnulib --import' - at your own risk! 12
exit 1
  fi
! if test -n $supplied_libname || test -n $sourcebase || test -n 
$m4base \
 || test -n $docbase || test -n $testsbase || test -n $auxdir \
 || test -n $inctests || test -n $avoidlist || test -n $lgpl \
 || test -n $macro_prefix; then
--- 558,565 
echo you need to use 'gnulib --import' - at your own risk! 12
exit 1
  fi
! if test -n $local_gnulib_dir || test -n $supplied_libname \
!|| test -n $sourcebase || test -n $m4base \
 || test -n $docbase || test -n $testsbase || test -n $auxdir \
 || test -n $inctests || test -n $avoidlist || test -n $lgpl \
 || test -n $macro_prefix; then
***
*** 530,535 
--- 624,632 
# Remove trailing slashes from the directory names. This is necessary for
# m4base (to avoid an error in func_import) and optional for the others.
sed_trimtrailingslashes='s,\([^/]\)//*$,\1,'
+   case $local_gnulib_dir in
+ */ ) sourcebase=`echo $local_gnulib_dir | sed -e 
$sed_trimtrailingslashes` ;;
+   esac
case $sourcebase in
  */ ) sourcebase=`echo $sourcebase | sed 

gnulib-tool: a small fix

2006-08-28 Thread Bruno Haible
Mostly comment updates.

2006-08-27  Bruno Haible  [EMAIL PROTECTED]

* gnulib-tool (func_get_tests_module): Don't assume that $gnulib_dir
is the current directory. Respect also $local_gnulib_dir.

*** gnulib-20060823/gnulib-tool 2006-08-27 01:48:40.0 +0200
--- gnulib-20060823-modified/gnulib-tool2006-08-27 16:24:50.0 
+0200
***
*** 675,680 
--- 675,682 
  # func_lookup_file file
  # looks up a file in $local_gnulib_dir or $gnulib_dir, or combines it through
  # 'patch'.
+ # Input:
+ # - local_gnulib_dir  from --local-dir
  # Output:
  # - lookedup_file   name of the merged (combined) file
  # - lookedup_tmptrue if it is located in the tmp directory, blank 
otherwise
***
*** 705,710 
--- 707,714 
  }
  
  # func_all_modules
+ # Input:
+ # - local_gnulib_dir  from --local-dir
  func_all_modules ()
  {
# Filter out metainformation files like README, which are not modules.
***
*** 724,729 
--- 728,736 
  
  # func_verify_module
  # verifies a module name
+ # Input:
+ # - local_gnulib_dir  from --local-dir
+ # - module  module name argument
  func_verify_module ()
  {
if { test -f $gnulib_dir/modules/$module \
***
*** 746,751 
--- 753,761 
  
  # func_verify_nontests_module
  # verifies a module name, excluding tests modules
+ # Input:
+ # - local_gnulib_dir  from --local-dir
+ # - module  module name argument
  func_verify_nontests_module ()
  {
case $module in
***
*** 756,761 
--- 766,774 
  
  # func_verify_tests_module
  # verifies a module name, considering only tests modules
+ # Input:
+ # - local_gnulib_dir  from --local-dir
+ # - module  module name argument
  func_verify_tests_module ()
  {
case $module in
***
*** 782,787 
--- 795,802 
  }'
  
  # func_get_description module
+ # Input:
+ # - local_gnulib_dir  from --local-dir
  func_get_description ()
  {
func_lookup_file modules/$1
***
*** 789,794 
--- 804,811 
  }
  
  # func_get_filelist module
+ # Input:
+ # - local_gnulib_dir  from --local-dir
  func_get_filelist ()
  {
func_lookup_file modules/$1
***
*** 802,807 
--- 819,826 
  }
  
  # func_get_dependencies module
+ # Input:
+ # - local_gnulib_dir  from --local-dir
  func_get_dependencies ()
  {
# ${module}-tests always implicitly depends on ${module}.
***
*** 812,817 
--- 831,838 
  }
  
  # func_get_autoconf_snippet module
+ # Input:
+ # - local_gnulib_dir  from --local-dir
  func_get_autoconf_snippet ()
  {
func_lookup_file modules/$1
***
*** 819,824 
--- 840,847 
  }
  
  # func_get_automake_snippet module
+ # Input:
+ # - local_gnulib_dir  from --local-dir
  func_get_automake_snippet ()
  {
func_lookup_file modules/$1
***
*** 826,831 
--- 849,856 
  }
  
  # func_get_include_directive module
+ # Input:
+ # - local_gnulib_dir  from --local-dir
  func_get_include_directive ()
  {
func_lookup_file modules/$1
***
*** 834,839 
--- 859,866 
  }
  
  # func_get_license module
+ # Input:
+ # - local_gnulib_dir  from --local-dir
  func_get_license ()
  {
func_lookup_file modules/$1
***
*** 841,846 
--- 868,875 
  }
  
  # func_get_maintainer module
+ # Input:
+ # - local_gnulib_dir  from --local-dir
  func_get_maintainer ()
  {
func_lookup_file modules/$1
***
*** 848,857 
  }
  
  # func_get_tests_module module
  func_get_tests_module ()
  {
# The naming convention for tests modules is hardwired: ${module}-tests.
!   if test -f modules/$1-tests; then
  echo $1-tests
fi
  }
--- 877,890 
  }
  
  # func_get_tests_module module
+ # Input:
+ # - local_gnulib_dir  from --local-dir
  func_get_tests_module ()
  {
# The naming convention for tests modules is hardwired: ${module}-tests.
!   if test -f $gnulib_dir/modules/$1-tests \
!  || { test -n $local_gnulib_dir  test -d $local_gnulib_dir/modules \
!test -f $local_gnulib_dir/modules/$1-tests; }; then
  echo $1-tests
fi
  }
***
*** 872,877 
--- 905,911 
  
  # func_modules_transitive_closure
  # Input:
+ # - local_gnulib_dir  from --local-dir
  # - modules list of specified modules
  # - incteststrue if tests should be included, blank otherwise
  # - avoidlist   list of modules to avoid
***
*** 922,927 
--- 956,962 
  
  # func_modules_add_dummy
  # Input:
+ # - local_gnulib_dir  from --local-dir
  # - modules list of modules, including dependencies
  # Output:
  # - modules list of modules, including 'dummy' if needed
***
*** 956,961 
--- 991,997 
  
  # func_modules_to_filelist
  # Input:
+ # - local_gnulib_dir  from --local-dir
  # - modules list of modules, including dependencies
  # Output:
  # - files   list of 

Re: working with locally modified or augmented gnulib repositories

2006-08-28 Thread Simon Josefsson
Bruno Haible [EMAIL PROTECTED] writes:

 Hello Simon,

 Except that I have to specify --local-dir every time I use --import.
 Is this the intended behaviour?  Maybe the --local-dir value could be
 cached, just like --source-base etc.  What do you think?

 You're right, it's cumbersome for --import. Also, --update would not do
 the right thing if it doesn't know about the local-dir. The patch below
 should fix it.

Works fine here, thanks!

/Simon




Re: coreutils-6.0 on BeOS (9)

2006-08-28 Thread Bruno Haible
Paul Eggert wrote:
 2006-08-23  Paul Eggert  [EMAIL PROTECTED]
 
   * src/stat.c (HAVE_STRUCT_STATXFS_F_FSID___VAL): Define.  This
   macro was being used without being defined.

Compiling the current coreutils CVS on MacOS X 10.3.9 now gives this error:

stat.c: In function `print_statfs':
stat.c:416: error: incompatible types in initialization


Preprocessed output snippet:

# 416 stat.c
unsigned long long int fsid = statfsbuf-f_fsid;


The reason is that fsid_t is defined like this:

typedef struct fsid { int32_t val[2]; } fsid_t;

The code that tests HAVE_STRUCT_STATXFS_F_FSID___VAL should also have an
alternative that tests HAVE_STRUCT_STATXFS_F_FSID_VAL (and augment stat-prog.m4
accordingly).

Bruno




Re: gnulib-tool: new option --makefile-name

2006-08-28 Thread Simon Josefsson
Bruno Haible [EMAIL PROTECTED] writes:

 While doing the coreutils changes, Paul found the answer to the long-standing
 question how gnulib-tool could be used without requiring a lib/ directory of
 its own and while still maintaining a clear separation between hand-maintained
 files and autogenerated files. Namely, rename the gnulib Makefile.am to some
 other name and include it from the real Makefile.am.

 This patch adds an option --makefile-name that does this.

I mentioned that approach earlier in:

http://article.gmane.org/gmane.comp.lib.gnulib.bugs/1969
http://article.gmane.org/gmane.comp.lib.gnulib.bugs/2021

The problem in automake that would had to be fixed was this:

http://thread.gmane.org/gmane.comp.sysutils.automake.bugs/1659

Briefly, the gnulib Makefile.am snippet uses += to add contents to
variables, such as EXTRA_DIST, which are also useful to use in the
Makefile.am that includes the gnulib Makefile.am snippet.  But
automake doesn't permit += without an earlier 'EXTRA_DIST = ...'
definition.

One solution to this, that I see now, is to have a early makefile.am
snippet too.  I.e., add a gnulib-early.mk that contains:

AUTOMAKE_OPTIONS = 1.5 gnits no-dependencies
noinst_HEADERS =
EXTRA_DIST =
BUILT_SOURCES =
SUFFIXES =
MOSTLYCLEANFILES = core *.stackdump
MOSTLYCLEANDIRS =
CLEANFILES =
DISTCLEANFILES =
MAINTAINERCLEANFILES =
AM_CPPFLAGS =

And then require that users write Makefile.am that follows this
structure:

include gnulib-early.mk
...there own stuff...
include gnulib.mk
...possibly more stuff...

This seems somewhat inflexible, though.  I'd rather change automake to
permit += for variables that haven't been defined yet, but that didn't
seem to happen.  I'm not sure there are other solutions.

Am I missing something?

/Simon




Re: rewritten inttypes module

2006-08-28 Thread Eric Blake
Bruno Haible bruno at clisp.org writes:

 
 So here's the patch I'm committing.
 
 2006-08-26  Bruno Haible  bruno at clisp.org
 
   * modules/inttypes (Files): Add lib/inttypes_.h, remove lib/inttypes.h.
   Add m4/inttypes.m4, remove m4/_inttypes_h.m4 and m4/include_next.m4.
   (Makefile.am): Create inttypes.h from inttypes_.h.

On platforms with a lacking header, I now get:

make[2]: Entering directory `/home/eblake/tar/lib'
sed -e 's/@''HAVE_INTTYPES_H''@/1/g' \
-e 's/@''ABSOLUTE_INTTYPES_H''@usr/include/inttypes.h/g' \
-e 's/@''PRI_MACROS_BROKEN''@//g' \
-e 's/@''HAVE_LONG_LONG_INT''@/1/g' \
-e 's/@''PRIPTR_PREFIX''@/l/g' \
-e 's/@''HAVE_DECL_IMAXABS''@/1/g' \
-e 's/@''HAVE_DECL_IMAXDIV''@/1/g' \
-e 's/@''HAVE_DECL_STRTOIMAX''@/1/g' \
-e 's/@''HAVE_DECL_STRTOUMAX''@/1/g' \
 ./inttypes_.h  inttypes.h-t
sed: -e expression #2, char 27: unknown option to `s'

Committing this obvious fix:

2006-08-28  Eric Blake  [EMAIL PROTECTED]

* modules/inttypes (Depends-on): Fix sed error when inttypes.h
needs wrapper.

Index: modules/inttypes
===
RCS file: /sources/gnulib/gnulib/modules/inttypes,v
retrieving revision 1.6
diff -u -r1.6 inttypes
--- modules/inttypes28 Aug 2006 12:54:47 -  1.6
+++ modules/inttypes28 Aug 2006 15:59:03 -
@@ -21,7 +21,7 @@
 # doesn't have one that works with the given compiler.
 inttypes.h: inttypes_.h
sed -e 's/@''HAVE_INTTYPES_H''@/$(HAVE_INTTYPES_H)/g' \
-   -e 's/@''ABSOLUTE_INTTYPES_H''@/$(ABSOLUTE_INTTYPES_H)/g' \
+   -e 's|@''ABSOLUTE_INTTYPES_H''@|$(ABSOLUTE_INTTYPES_H)|g' \
-e 's/@''PRI_MACROS_BROKEN''@/$(PRI_MACROS_BROKEN)/g' \
-e 's/@''HAVE_LONG_LONG_INT''@/$(HAVE_LONG_LONG_INT)/g' \
-e 's/@''PRIPTR_PREFIX''@/$(PRIPTR_PREFIX)/g' \






Re: gnulib-tool: new option --makefile-name

2006-08-28 Thread Bruno Haible
Simon Josefsson wrote:
  This patch adds an option --makefile-name that does this.
 
 I mentioned that approach earlier in:
 
 http://article.gmane.org/gmane.comp.lib.gnulib.bugs/1969

Sorry, I missed or forgot that.

 The problem in automake that would had to be fixed was this:
 
 http://thread.gmane.org/gmane.comp.sysutils.automake.bugs/1659
 
 Briefly, the gnulib Makefile.am snippet uses += to add contents to
 variables, such as EXTRA_DIST, which are also useful to use in the
 Makefile.am that includes the gnulib Makefile.am snippet.  But
 automake doesn't permit += without an earlier 'EXTRA_DIST = ...'
 definition.

As a workaround, you can include gnulib.mk first, and add your own
file lists afterwards.

Bruno




Re: new config-h module, to remove the need for -DHAVE_CONFIG_H

2006-08-28 Thread Ralf Wildenhues
[ no need to discuss this on libtool rather than -patches ]

* Eric Blake wrote on Mon, Aug 28, 2006 at 02:55:21PM CEST:
 According to Paul Eggert on 8/26/2006 12:43 AM:
  
  The basic idea is that source files should include config.h
  unconditionally, so that we needn't clutter make output with
  -DHAVE_CONFIG_H.

 This doesn't work for the argz module, which uses #if
 defined(HAVE_CONFIG_H) from upstream libtool.  And projects using libtool
 also have this issue with lt__alloc.c.  Maybe the libtool headers need to
 be tweaked a bit?

I have applied the following patch to CVS HEAD Libtool, changing all
instances of HAVE_CONFIG_H.

Before syncinc argz* with gnulib: why does gnulib/config/srclist.txt
list these files as GPL, as do the gnulib file headers, but modules/argz
says LGPL, and libltdl is distributed with LGPL + special exception?

Cheers,
Ralf

* libltdl/argz.c: Use `#ifdef HAVE_CONFIG_H', to facilitate code
sharing with gnulib.  Report by Eric Blake.
* libltdl/lt__alloc.c, libltdl/libltdl/lt__dirent.h,
libltdl/libltdl/lt__glibc.h, libltdl/libltdl/lt__private.h,
libltdl/libltdl/lt__strl.h: Likewise.
* HACKING: Update.

Index: HACKING
===
RCS file: /cvsroot/libtool/libtool/HACKING,v
retrieving revision 1.28
diff -u -r1.28 HACKING
--- HACKING 5 Feb 2006 17:06:39 -   1.28
+++ HACKING 28 Aug 2006 16:00:28 -
@@ -291,7 +291,7 @@
   to various system libc interfaces that differ between hosts supported
   by libtool.  Typically, the files that implement this layer begin:
 
-  #if defined(HAVE_CONFIG_H)
+  #ifdef HAVE_CONFIG_H
   #  if defined(LT_CONFIG_H)
   #include LT_CONFIG_H
   #  else
@@ -300,6 +300,8 @@
   #endif
   #include lt_system.h
 
+  The `ifdef HAVE_CONFIG_H' helps facilitate code sharing with gnulib.
+
   Or if they are installed headers that must work outside the libtool
   source tree, simply:
 
@@ -615,7 +617,7 @@
 
 
 -- 
-Copyright (C) 2004, 2005 Free Software Foundation, Inc.
+Copyright (C) 2004, 2005, 2006 Free Software Foundation, Inc.
 
 The canonical source of this file is maintained with the
 GNU Libtool package.  Report bugs to [EMAIL PROTECTED]
Index: libltdl/argz.c
===
RCS file: /cvsroot/libtool/libtool/libltdl/argz.c,v
retrieving revision 1.7
diff -u -r1.7 argz.c
--- libltdl/argz.c  17 Sep 2005 07:29:03 -  1.7
+++ libltdl/argz.c  28 Aug 2006 16:00:28 -
@@ -1,5 +1,5 @@
 /* argz.c -- argz implementation for non-glibc systems
-   Copyright (C) 2004 Free Software Foundation, Inc.
+   Copyright (C) 2004, 2006 Free Software Foundation, Inc.
Originally by Gary V. Vaughan  [EMAIL PROTECTED]
 
NOTE: The canonical source of this file is maintained with the
@@ -27,7 +27,7 @@
 
 */
 
-#if defined(HAVE_CONFIG_H)
+#ifdef HAVE_CONFIG_H
 #  if defined(LTDL)  defined LT_CONFIG_H
 #include LT_CONFIG_H
 #  else
Index: libltdl/lt__alloc.c
===
RCS file: /cvsroot/libtool/libtool/libltdl/lt__alloc.c,v
retrieving revision 1.6
diff -u -r1.6 lt__alloc.c
--- libltdl/lt__alloc.c 17 Sep 2005 07:29:03 -  1.6
+++ libltdl/lt__alloc.c 28 Aug 2006 16:00:28 -
@@ -1,5 +1,5 @@
 /* lt__alloc.c -- internal memory management interface
-   Copyright (C) 2004 Free Software Foundation, Inc.
+   Copyright (C) 2004, 2006 Free Software Foundation, Inc.
Originally by Gary V. Vaughan  [EMAIL PROTECTED]
 
NOTE: The canonical source of this file is maintained with the
@@ -27,7 +27,7 @@
 
 */
 
-#if defined(HAVE_CONFIG_H)
+#ifdef HAVE_CONFIG_H
 #  if defined(LT_CONFIG_H)
 #include LT_CONFIG_H
 #  else
Index: libltdl/libltdl/lt__dirent.h
===
RCS file: /cvsroot/libtool/libtool/libltdl/libltdl/lt__dirent.h,v
retrieving revision 1.4
diff -u -r1.4 lt__dirent.h
--- libltdl/libltdl/lt__dirent.h22 Aug 2006 17:51:03 -  1.4
+++ libltdl/libltdl/lt__dirent.h28 Aug 2006 16:00:29 -
@@ -30,7 +30,7 @@
 #if !defined(LT__DIRENT_H)
 #define LT__DIRENT_H 1
 
-#if defined(HAVE_CONFIG_H)
+#ifdef HAVE_CONFIG_H
 #  if defined(LT_CONFIG_H)
 #include LT_CONFIG_H
 #  else
Index: libltdl/libltdl/lt__glibc.h
===
RCS file: /cvsroot/libtool/libtool/libltdl/libltdl/lt__glibc.h,v
retrieving revision 1.4
diff -u -r1.4 lt__glibc.h
--- libltdl/libltdl/lt__glibc.h 17 Sep 2005 07:29:03 -  1.4
+++ libltdl/libltdl/lt__glibc.h 28 Aug 2006 16:00:29 -
@@ -1,5 +1,5 @@
 /* lt__glibc.h -- support for non glibc environments
-   Copyright (C) 2004 Free Software Foundation, Inc.
+   Copyright (C) 2004, 2006 Free Software Foundation, Inc.
Originally by Gary V. Vaughan  [EMAIL PROTECTED]
 
NOTE: The canonical source of this file is maintained with the
@@ -30,7 +30,7 @@
 #if 

Re: gnulib-tool: new option --makefile-name

2006-08-28 Thread Simon Josefsson
Bruno Haible [EMAIL PROTECTED] writes:

 The problem in automake that would had to be fixed was this:
 
 http://thread.gmane.org/gmane.comp.sysutils.automake.bugs/1659
 
 Briefly, the gnulib Makefile.am snippet uses += to add contents to
 variables, such as EXTRA_DIST, which are also useful to use in the
 Makefile.am that includes the gnulib Makefile.am snippet.  But
 automake doesn't permit += without an earlier 'EXTRA_DIST = ...'
 definition.

 As a workaround, you can include gnulib.mk first, and add your own
 file lists afterwards.

Yes.  You'll also have to keep track of which variables that gnulib.mk
uses, so you don't accidentally use 'FOO = ' on them, and
respectively, doesn't use 'FOO +=' on a variable that gnulib.mk did
not define.

/Simon




Re: [bug-gnulib] rewritten inttypes module

2006-08-28 Thread Bruno Haible
Eric Blake wrote:
 Committing this obvious fix:
 
 2006-08-28  Eric Blake  [EMAIL PROTECTED]
 
   * modules/inttypes (Depends-on): Fix sed error when inttypes.h
   needs wrapper.

Thanks. Of course.

Bruno




Re: [bug-gnulib] Re: rewritten inttypes module

2006-08-28 Thread Bruno Haible
Eric Blake wrote:
 Cygwin is currently failing the inttypes check because it does not provide 
 SCNX8, among others.  POSIX does not require the existence of SCNX*, so 
 cygwin 
 does not provide them.

Oops. I missed the fact that the PRI* and SCN* macros are not symmetric.
SCNX* makes no sense (as you can parse hexadecimal numbers without knowing
in advance whether to look for uppercase or lowercase hexadecimal digits).
I remove the SCNX* from the inttypes module. Thanks for reporting it!

Bruno




Re: rewritten inttypes module

2006-08-28 Thread Paul Eggert
Bruno Haible [EMAIL PROTECTED] writes:

 If our replacement stdint.h includes simply inttypes.h, not
 @ABSOLUTE_INTTYPES_H@, then a simple
   #include stdint.h
 will do the wrong thing: It will

- start including our stdint.h,
- include the system's stdint.h,
- start including our inttypes.h,
  - include the system's inttypes.h,
  - include our stdint.h, but this has no effect due to the 
 double-inclusion
guard,
  - go on testing various macros like UINT32_MAX or INT64_MAX
which have not been defined yet!
- end including our inttypes.h,
- define the various *_MIN and *_MAX macros
- end including our stdint.h.

Thanks for explaining it.  If you don't mind, I'd like to fix the
problem in a different way, so that programs that use the stdint
module but not the inttypes module don't need to find the absolute
name of inttypes.h.  It seems a bit cleaner to me to have
the inttypes module be the only module that needs to figure out
the absolute name of inttypes.h.  I installed the following
to do that:

2006-08-28  Paul Eggert  [EMAIL PROTECTED]

* lib/inttypes_.h [defined _GL_JUST_INCLUDE_ABSOLUTE_INTTYPES_H]:
Include @ABSOLUTE_INTTYPES_H@ if available, but do nothing else.
* lib/stdint_.h (_GL_JUST_INCLUDE_ABSOLUTE_INTTYPES_H): Define
just before including inttypes.h, to avoid circular inclusion.
* m4/inttypes.m4 (gl_INTTYPES_H): Move ABSOLUTE_INTTYPES_H code here...
* m4/stdint.m4 (gl_STDINT_H): ... from here.  This undoes the most
recent change to stdint.m4, since we're now addressing the problem in a
different way.
* modules/stdint (Makefile.am): Do not substitute ABSOLUTE_INTTYPES_H.

Index: lib/inttypes_.h
===
RCS file: /cvsroot/gnulib/gnulib/lib/inttypes_.h,v
retrieving revision 1.2
diff -p -u -r1.2 inttypes_.h
--- lib/inttypes_.h 28 Aug 2006 16:57:52 -  1.2
+++ lib/inttypes_.h 28 Aug 2006 20:36:22 -
@@ -16,7 +16,16 @@
along with this program; if not, write to the Free Software Foundation,
Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.  */
 
-#ifndef INTTYPES_H
+/* Include the original inttypes.h if it exists, and if this file
+   has not been included yet or if this file includes gnulib stdint.h
+   which in turn includes this file.  */
+#if ! defined INTTYPES_H || defined _GL_JUST_INCLUDE_ABSOLUTE_INTTYPES_H
+# if @HAVE_INTTYPES_H@
+#  include @ABSOLUTE_INTTYPES_H@
+# endif
+#endif
+
+#if ! defined INTTYPES_H  ! defined _GL_JUST_INCLUDE_ABSOLUTE_INTTYPES_H
 #define INTTYPES_H
 
 /*
@@ -24,10 +33,6 @@
  * http://www.opengroup.org/susv3xbd/inttypes.h.html
  */
 
-/* Include the original inttypes.h if it exists.  */
-#if @HAVE_INTTYPES_H@
-# include @ABSOLUTE_INTTYPES_H@
-#endif
 /* Include stdint.h or the gnulib replacement.  */
 #include stdint.h
 /* Get CHAR_BIT.  */
Index: lib/stdint_.h
===
RCS file: /cvsroot/gnulib/gnulib/lib/stdint_.h,v
retrieving revision 1.32
diff -p -u -r1.32 stdint_.h
--- lib/stdint_.h   28 Aug 2006 12:54:47 -  1.32
+++ lib/stdint_.h   28 Aug 2006 20:36:22 -
@@ -62,7 +62,9 @@
   /* In OpenBSD 3.8, inttypes.h includes machine/types.h, which defines
  int{8,16,32,64}_t, uint{8,16,32,64}_t and __BIT_TYPES_DEFINED__.
  inttypes.h also defines intptr_t and uintptr_t.  */
-# include @ABSOLUTE_INTTYPES_H@
+# define _GL_JUST_INCLUDE_ABSOLUTE_INTTYPES_H
+# include inttypes.h
+# undef _GL_JUST_INCLUDE_ABSOLUTE_INTTYPES_H
 #elif @HAVE_SYS_INTTYPES_H@
   /* Solaris 7 sys/inttypes.h has the types except the *_fast*_t types, and
  the macros except for *_FAST*_*, INTPTR_MIN, PTRDIFF_MIN, PTRDIFF_MAX.  */
Index: m4/inttypes.m4
===
RCS file: /cvsroot/gnulib/gnulib/m4/inttypes.m4,v
retrieving revision 1.11
diff -p -u -r1.11 inttypes.m4
--- m4/inttypes.m4  28 Aug 2006 16:57:51 -  1.11
+++ m4/inttypes.m4  28 Aug 2006 20:36:22 -
@@ -1,4 +1,4 @@
-# inttypes.m4 serial 2
+# inttypes.m4 serial 3
 dnl Copyright (C) 2006 Free Software Foundation, Inc.
 dnl This file is free software; the Free Software Foundation
 dnl gives unlimited permission to copy and/or distribute it,
@@ -135,6 +135,15 @@ const char *l = /* implicit string conca
 INTTYPES_H=''
   else
 
+dnl AC_INCLUDES_DEFAULT defines $ac_cv_header_inttypes_h.
+if test $ac_cv_header_inttypes_h = yes; then
+  gl_ABSOLUTE_HEADER([inttypes.h])
+  ABSOLUTE_INTTYPES_H=\$gl_cv_absolute_inttypes_h\
+else
+  ABSOLUTE_INTTYPES_H=\no/such/file/inttypes.h\
+fi
+AC_SUBST([ABSOLUTE_INTTYPES_H])
+
 PRIPTR_PREFIX=
 if test -n $STDINT_H; then
   dnl Using the gnulib stdint.h. It always defines intptr_t to 'long'.
Index: m4/stdint.m4
===

Re: new config-h module, to remove the need for -DHAVE_CONFIG_H

2006-08-28 Thread Paul Eggert
Ralf Wildenhues [EMAIL PROTECTED] writes:

 Before syncinc argz* with gnulib: why does gnulib/config/srclist.txt
 list these files as GPL, as do the gnulib file headers, but modules/argz
 says LGPL, and libltdl is distributed with LGPL + special exception?

For the same reason libc files are listed as GPL.  The upstream source
says it's LGPL, but by convention gnulib says GPL.  gnulib-tool
changes it back to LGPL when you import from gnulib.