Re: gnulib-tool: fix a detail in tests/Makefile.am

2007-12-26 Thread Bruno Haible
Ralf Wildenhues wrote:
> > * gnulib-tool (func_emit_tests_Makefile_am): Expand references to
> > the build-aux directory.
> 
> FWIW, I think this would do the wrong thing (namely, missing `../') for
> substitutions that matched with `gnulib-tool --with-tests --test'.
> (i.e., for the case where func_emit_tests_Makefile_am is called from
> func_create_testdir).

You're right. Well seen! This patch fixes it (tested).

2007-12-22  Bruno Haible  <[EMAIL PROTECTED]>

* gnulib-tool (func_create_testdir): Change $auxdir while generating
the contents of $testsbase.
Reported by Ralf Wildenhues.

--- gnulib-tool.orig2007-12-22 17:11:15.0 +0100
+++ gnulib-tool 2007-12-22 17:08:20.0 +0100
@@ -3483,6 +3483,9 @@
 
   if test -n "$inctests"; then
 test -d "$testdir/$testsbase" || mkdir "$testdir/$testsbase"
+# Viewed from the $testsbase subdirectory, $auxdir is different.
+saved_auxdir="$auxdir"
+auxdir=`echo "$testsbase/"|sed 's%[^/][^/]*//*%../%g'`"$auxdir"
 # Create $testsbase/Makefile.am.
 use_libtests=false
 func_emit_tests_Makefile_am > "$testdir/$testsbase/Makefile.am"
@@ -3490,7 +3493,7 @@
 # Create $testsbase/configure.ac.
 (echo "# Process this file with autoconf to produce a configure script."
  echo "AC_INIT([dummy], [0])"
- echo "AC_CONFIG_AUX_DIR([../$auxdir])"
+ echo "AC_CONFIG_AUX_DIR([$auxdir])"
  echo "AM_INIT_AUTOMAKE"
  echo
  echo "AM_CONFIG_HEADER([config.h])"
@@ -3531,7 +3534,7 @@
  sed_replace_build_aux='
:a
/AC_CONFIG_FILES(.*:build-aux\/.*)/{
- 
s|AC_CONFIG_FILES(\(.*\):build-aux/\(.*\))|AC_CONFIG_FILES(\1:../'"$auxdir"'/\2)|
+ 
s|AC_CONFIG_FILES(\(.*\):build-aux/\(.*\))|AC_CONFIG_FILES(\1:'"$auxdir"'/\2)|
  ba
}'
  func_emit_initmacro_start $macro_prefix
@@ -3575,6 +3578,7 @@
  echo
  echo "AC_OUTPUT([Makefile])"
 ) > "$testdir/$testsbase/configure.ac"
+auxdir="$saved_auxdir"
 func_append subdirs " $testsbase"
 subdirs_with_configure_ac="$subdirs_with_configure_ac $testsbase"
   fi





Re: no license on some test modules

2007-12-26 Thread Bruno Haible
Eric Blake wrote:
> If libtests.a is listed first, progname.o is not included.  But if it 
> is listed second only, then gl_array_list.o generates a missing link to 
> xmalloc 
> and friends.  The only solution is repeating the LDADD.  I'm committing the 
> following:
> 
> From: Eric Blake <[EMAIL PROTECTED]>
> Date: Mon, 10 Dec 2007 09:54:54 -0700
> Subject: [PATCH] Avoid link failures with separate libtests.a.
> 
> * gnulib-tool (func_emit_tests_Makefile_am): Also list local_ldadd
> last, to satisfy circular dependencies.

Thanks for dealing with this so quickly. Two tweaks, though:
  - It's not needed to mention the dependencies of libm4.a twice; once
is enough.
  - Adjust the comments: There's nothing wrong with the 'progname' module.
The problem is in the 'error' module.

Bruno

2007-12-22  Bruno Haible  <[EMAIL PROTECTED]>

* gnulib-tool (func_emit_tests_Makefile_am): Replace local_ldadd with
two variables local_ldadd_before, local_ldadd_last.

*** gnulib-tool.orig2007-12-22 17:09:13.0 +0100
--- gnulib-tool 2007-12-22 17:09:13.0 +0100
***
*** 1919,1932 
echo "  -I${testsbase_inverse} -I\$(srcdir)/${testsbase_inverse} \\"
echo "  -I${testsbase_inverse}/${sourcebase-lib} 
-I\$(srcdir)/${testsbase_inverse}/${sourcebase-lib}"
echo
!   local_ldadd=''
if $use_libtests; then
! local_ldadd=' libtests.a $(LIBTESTS_LIBDEPS)'
fi
!   # local_ldadd must be listed first, since it often depends on non-test
!   # modules; it must also be listed last, since it can include modules
!   # such as progname that satisfy dependencies of non-test modules.
!   echo "LDADD =${local_ldadd} 
${testsbase_inverse}/${sourcebase-lib}/${libname}.${libext}${local_ldadd}"
echo
if $use_libtests; then
  echo "libtests_a_SOURCES ="
--- 1919,1939 
echo "  -I${testsbase_inverse} -I\$(srcdir)/${testsbase_inverse} \\"
echo "  -I${testsbase_inverse}/${sourcebase-lib} 
-I\$(srcdir)/${testsbase_inverse}/${sourcebase-lib}"
echo
!   local_ldadd_before=''
!   local_ldadd_after=''
if $use_libtests; then
! # All test programs need to be linked with libtests.a.
! # It needs to be passed to the linker before ${libname}.${libext}, since
! # the tests-related modules depend on the main modules.
! # It also needs to be passed to the linker after ${libname}.${libext}
! # because the latter might contain incomplete modules (such as the 'error'
! # module whose dependency to 'progname' is voluntarily omitted).
! # The LIBTESTS_LIBDEPS can be passed to the linker once or twice, it does
! # not matter.
! local_ldadd_before=' libtests.a'
! local_ldadd_after=' libtests.a $(LIBTESTS_LIBDEPS)'
fi
!   echo "LDADD =${local_ldadd_before} 
${testsbase_inverse}/${sourcebase-lib}/${libname}.${libext}${local_ldadd_after}"
echo
if $use_libtests; then
  echo "libtests_a_SOURCES ="





comments about Knuth-Morris-Pratt algorithm

2007-12-26 Thread Bruno Haible
Hi,

Some of the comments in the KMP algorithm implementation were insufficient
to understand and verify the correctness of the code. I'm adding better
comments.

2007-12-23  Bruno Haible  <[EMAIL PROTECTED]>

* lib/c-strcasestr.c: Add more comments.
* lib/c-strstr.c: Likewise.
* lib/mbscasestr.c: Likewise.
* lib/mbsstr.c: Likewise.
* lib/strcasestr.c: Likewise.
* lib/memmem.c: Likewise.

*** lib/c-strcasestr.c.orig 2007-12-23 21:06:01.0 +0100
--- lib/c-strcasestr.c  2007-12-23 21:02:06.0 +0100
***
*** 43,76 
/* Fill the table.
   For 0 < i < m:
 0 < table[i] <= i is defined such that
!rhaystack[0..i-1] == needle[0..i-1] and rhaystack[i] != needle[i]
!implies
!forall 0 <= x < table[i]: rhaystack[x..x+m-1] != needle[0..m-1],
 and table[i] is as large as possible with this property.
   table[0] remains uninitialized.  */
{
  size_t i, j;
  
  table[1] = 1;
  j = 0;
  for (i = 2; i < m; i++)
{
unsigned char b = c_tolower ((unsigned char) needle[i - 1]);
  
for (;;)
  {
if (b == c_tolower ((unsigned char) needle[j]))
  {
table[i] = i - ++j;
break;
  }
if (j == 0)
  {
table[i] = i;
break;
  }
j = j - table[j];
  }
}
}
  
--- 43,109 
/* Fill the table.
   For 0 < i < m:
 0 < table[i] <= i is defined such that
!forall 0 < x < table[i]: needle[x..i-1] != needle[0..i-1-x],
 and table[i] is as large as possible with this property.
+  This implies:
+  1) For 0 < i < m:
+   If table[i] < i,
+   needle[table[i]..i-1] = needle[0..i-1-table[i]].
+  2) For 0 < i < m:
+   rhaystack[0..i-1] == needle[0..i-1]
+   and exists h, i <= h < m: rhaystack[h] != needle[h]
+   implies
+   forall 0 <= x < table[i]: rhaystack[x..x+m-1] != needle[0..m-1].
   table[0] remains uninitialized.  */
{
  size_t i, j;
  
+ /* i = 1: Nothing to verify for x = 0.  */
  table[1] = 1;
  j = 0;
+ 
  for (i = 2; i < m; i++)
{
+   /* Here: j = i-1 - table[i-1].
+  The inequality needle[x..i-1] != needle[0..i-1-x] is known to hold
+  for x < table[i-1], by induction.
+  Furthermore, if j>0: needle[i-1-j..i-2] = needle[0..j-1].  */
unsigned char b = c_tolower ((unsigned char) needle[i - 1]);
  
for (;;)
  {
+   /* Invariants: The inequality needle[x..i-1] != needle[0..i-1-x]
+  is known to hold for x < i-1-j.
+  Furthermore, if j>0: needle[i-1-j..i-2] = needle[0..j-1].  */
if (b == c_tolower ((unsigned char) needle[j]))
  {
+   /* Set table[i] := i-1-j.  */
table[i] = i - ++j;
break;
  }
+   /* The inequality needle[x..i-1] != needle[0..i-1-x] also holds
+  for x = i-1-j, because
+needle[i-1] != needle[j] = needle[i-1-x].  */
if (j == 0)
  {
+   /* The inequality holds for all possible x.  */
table[i] = i;
break;
  }
+   /* The inequality needle[x..i-1] != needle[0..i-1-x] also holds
+  for i-1-j < x < i-1-j+table[j], because for these x:
+needle[x..i-2]
+= needle[x-(i-1-j)..j-1]
+!= needle[0..j-1-(x-(i-1-j))]  (by definition of table[j])
+   = needle[0..i-2-x],
+  hence needle[x..i-1] != needle[0..i-1-x].
+  Furthermore
+needle[i-1-j+table[j]..i-2]
+= needle[table[j]..j-1]
+= needle[0..j-1-table[j]]  (by definition of table[j]).  */
j = j - table[j];
  }
+   /* Here: j = i - table[i].  */
}
}
  
*** lib/c-strstr.c.orig 2007-12-23 21:06:01.0 +0100
--- lib/c-strstr.c  2007-12-23 20:57:17.0 +0100
***
*** 42,75 
/* Fill the table.
   For 0 < i < m:
 0 < table[i] <= i is defined such that
!rhaystack[0..i-1] == needle[0..i-1] and rhaystack[i] != needle[i]
!implies
!forall 0 <= x < table[i]: rhaystack[x..x+m-1] != needle[0..m-1],
 and table[i] is as large as possible with this property.
   table[0] remains uninitialized.  */
{
  size_t i, j;
  
  table[1] = 1;
  j = 0;
  for (i = 2; i < m; i++)
{
unsigned char b = (unsigned char) needle[i - 1];
  
for (;;)
  {
if (b == (unsigned char) needle[j])
  {
table[i] = i - ++j;
break;
  }
if (j == 0)
  {
table[i] = i;
   

Re: memmem issues

2007-12-26 Thread Bruno Haible
Eric Blake wrote:
> + Fix memmem to avoid O(n^2) worst-case complexity.
> + * lib/memmem.c (knuth_morris_pratt): New function.
> + (memmem): Use it if first few naive iterations fail.

While considering to submit a modified version of this code to glibc
for inclusion, I found it good to make the code adhere better to
GNU coding conventions:
  - use lower cased local variable names,
  - use tab indentation (my fault).


2007-12-23  Bruno Haible  <[EMAIL PROTECTED]>

* lib/memmem.c (memmem): Use lowercase variable names. Tab
indentation.

*** lib/memmem.c.orig   2007-12-23 21:31:31.0 +0100
--- lib/memmem.c2007-12-23 21:31:03.0 +0100
***
*** 154,167 
 if NEEDLE_LEN is 0, otherwise NULL if NEEDLE is not found in
 HAYSTACK.  */
  void *
! memmem (const void *haystack, size_t haystack_len,
! const void *needle, size_t needle_len)
  {
/* Operating with void * is awkward.  */
!   const char *Haystack = (const char *) haystack;
!   const char *Needle = (const char *) needle;
!   const char *last_haystack = Haystack + haystack_len;
!   const char *last_needle = Needle + needle_len;
  
if (needle_len == 0)
  /* The first occurrence of the empty string is deemed to occur at
--- 154,167 
 if NEEDLE_LEN is 0, otherwise NULL if NEEDLE is not found in
 HAYSTACK.  */
  void *
! memmem (const void *haystack_start, size_t haystack_len,
!   const void *needle_start, size_t needle_len)
  {
/* Operating with void * is awkward.  */
!   const char *haystack = (const char *) haystack_start;
!   const char *needle = (const char *) needle_start;
!   const char *last_haystack = haystack + haystack_len;
!   const char *last_needle = needle + needle_len;
  
if (needle_len == 0)
  /* The first occurrence of the empty string is deemed to occur at
***
*** 175,181 
  
/* Use optimizations in memchr when possible.  */
if (__builtin_expect (needle_len == 1, 0))
! return memchr (haystack, (unsigned char) *Needle, haystack_len);
  
/* Minimizing the worst-case complexity:
   Let n = haystack_len, m = needle_len.
--- 175,181 
  
/* Use optimizations in memchr when possible.  */
if (__builtin_expect (needle_len == 1, 0))
! return memchr (haystack, (unsigned char) *needle, haystack_len);
  
/* Minimizing the worst-case complexity:
   Let n = haystack_len, m = needle_len.
***
*** 198,252 
  
  /* Speed up the following searches of needle by caching its first
 byte.  */
! char b = *Needle++;
  
! for (;; Haystack++)
{
! if (Haystack == last_haystack)
!   /* No match.  */
!   return NULL;
! 
! /* See whether it's advisable to use an asymptotically faster
!algorithm.  */
! if (try_kmp
! && outer_loop_count >= 10
! && comparison_count >= 5 * outer_loop_count)
!   {
! /* See if needle + comparison_count now reaches the end of
!needle.  */
! if (comparison_count >= needle_len)
!   {
! /* Try the Knuth-Morris-Pratt algorithm.  */
! const char *result;
! if (knuth_morris_pratt (Haystack, last_haystack,
! Needle - 1, needle_len, &result))
!   return (void *) result;
! try_kmp = false;
!   }
!   }
! 
! outer_loop_count++;
! comparison_count++;
! if (*Haystack == b)
!   /* The first byte matches.  */
!   {
! const char *rhaystack = Haystack + 1;
! const char *rneedle = Needle;
! 
! for (;; rhaystack++, rneedle++)
!   {
! if (rneedle == last_needle)
!   /* Found a match.  */
!   return (void *) Haystack;
! if (rhaystack == last_haystack)
!   /* No match.  */
!   return NULL;
! comparison_count++;
! if (*rhaystack != *rneedle)
!   /* Nothing in this round.  */
!   break;
!   }
!   }
}
}
  
--- 198,252 
  
  /* Speed up the following searches of needle by caching its first
 byte.  */
! char b = *needle++;
  
! for (;; haystack++)
{
!   if (haystack == last_haystack)
! /* No match.  */
! return NULL;
! 
!   /* See whether it's advisable to use an asymptotically faster
!  algorithm.  */
!   if (try_kmp
!   && outer_loop_count >= 10
!   && comparison_count >= 5 * outer_loop_count)
! {
!   /* See if needle + comparison_count now reaches the end of
!  needle.  */
!   if (comparison_count >= needle_len)
! {
!   /* Try the Knuth-Morris-Pratt algorithm.  */
!

setenv, unsetenv fixes

2007-12-26 Thread Bruno Haible
Hi,

It was reported in [1] that there is a conflict between the unsetenv()
declarations on MacOS X and in gnulib under some conditions. The error message
is this:

  In file included from ../gnulib-lib/relocwrapper.c:56:
  ../gnulib-lib/setenv.h:47: error: conflicting types for `unsetenv'
  /usr/include/stdlib.h:248: error: previous declaration of `unsetenv'

This occurs in a package that uses the setenv() function but not the
unsetenv() function. setenv.h contains the declaration of unsetenv, but
since gl_FUNC_UNSETENV has not been called, HAVE_UNSETENV is not set; this
leads to the error.

The fix is to use a @GNULIB_UNSETENV@ macro. While at it, I also
  - move the declaration to , getting rid of setenv.h,
  - update the documentation about unsetenv,
  - split the module into a 'setenv' module and an 'unsetenv' module.

This is a backward-incompatible change; please see the NEWS entry.


2007-12-24  Bruno Haible  <[EMAIL PROTECTED]>

Split setenv module into setenv and unsetenv. Get rid of setenv.h.
* lib/setenv.h: Remove file.
* lib/stdlib.in.h (setenv, unsetenv): New declarations, moved here from
lib/setenv.h.
* modules/setenv (Files): Remove lib/setenv.h, lib/unsetenv.c.
(Depends-on): Add stdlib.
(configure.ac): Invoke gl_STDLIB_MODULE_INDICATOR. Don't invoke
gl_FUNC_UNSETENV.
(Include): Replace setenv.h with .
* modules/unsetenv: New file.
* lib/setenv.c: Include  first, after alloca.h.
* lib/unsetenv.c: Include  first.
* m4/setenv.m4 (gl_FUNC_SETENV, gl_FUNC_SETENV_SEPARATE): Require
gl_STDLIB_H_DEFAULTS. Conditionally set HAVE_SETENV to 0.
(gl_FUNC_UNSETENV): Require gl_STDLIB_H_DEFAULTS. Conditionally set
HAVE_UNSETENV to 0. Set VOID_UNSETENV as an AC_SUBSTed variable.
* modules/stdlib (Makefile.am): Substitute also GNULIB_SETENV,
HAVE_SETENV, GNULIB_UNSETENV, HAVE_UNSETENV, VOID_UNSETENV.
* m4/stdlib_h.m4 (gl_STDLIB_H_DEFAULTS): Initialize GNULIB_SETENV,
HAVE_SETENV, GNULIB_UNSETENV, HAVE_UNSETENV, VOID_UNSETENV.
* doc/functions/unsetenv.texi: Update.
* modules/xsetenv (Depends-on): Add unsetenv.
* modules/getdate (Depends-on): Likewise.
* lib/xsetenv.h: Include  instead of setenv.h.
* lib/xsetenv.c: Don't include setenv.h.
* lib/getdate.y: Likewise.
* lib/relocwrapper.c: Likewise.
* modules/relocatable-prog-wrapper (Files): Remove lib/setenv.h.
(Depends-on): Add stdlib.
* NEWS: Mention the changes.
Reported by Левашев Иван <[EMAIL PROTECTED]>.

*** NEWS.orig   2007-12-24 22:46:29.0 +0100
--- NEWS2007-12-24 20:50:38.0 +0100
***
*** 6,11 
--- 6,16 
  
  DateModules Changes
  
+ 2007-12-24  setenv  The include file is changed from "setenv.h" to
+ . Also, the unsetenv function is no
+ longer declared in this module; use the 'unsetenv'
+ module if you need it.
+ 
  2007-12-03  getpagesize The include file is changed from "getpagesize.h"
  to .
  
*** doc/functions/unsetenv.texi.orig2007-12-24 22:46:29.0 +0100
--- doc/functions/unsetenv.texi 2007-12-24 22:33:48.0 +0100
***
*** 11,21 
  @item
  This function is missing on some platforms:
  AIX 5.1, HP-UX 11, IRIX 6.5, Solaris 9, mingw, BeOS.
  @end itemize
  
  Portability problems not fixed by Gnulib:
  @itemize
- @item
- This function has the return type @samp{void} instead of @samp{int} on some
- platforms.
  @end itemize
--- 11,22 
  @item
  This function is missing on some platforms:
  AIX 5.1, HP-UX 11, IRIX 6.5, Solaris 9, mingw, BeOS.
+ @item
+ This function has the return type @samp{void} instead of @samp{int} on some
+ platforms:
+ MacOS X 10.3, FreeBSD 6.0, NetBSD 1.6, OpenBSD 3.8, OSF/1 5.1.
  @end itemize
  
  Portability problems not fixed by Gnulib:
  @itemize
  @end itemize
*** lib/getdate.y.orig  2007-12-24 22:46:29.0 +0100
--- lib/getdate.y   2007-12-24 21:12:22.0 +0100
***
*** 66,72 
  #include 
  #include 
  
- #include "setenv.h"
  #include "xalloc.h"
  
  
--- 66,71 
*** lib/relocwrapper.c.orig 2007-12-24 22:46:29.0 +0100
--- lib/relocwrapper.c  2007-12-24 21:12:40.0 +0100
***
*** 53,59 
  
  #include "progname.h"
  #include "relocatable.h"
- #include "setenv.h"
  #include "c-ctype.h"
  
  /* Return a copy of the filename, with an extra ".bin" at the end.
--- 53,58 
*** lib/setenv.c.orig   2007-12-24 22:46:29.0 +0100
--- lib/setenv.c2007-12-24 20:51:48.0 +0100
***
*** 19,30 
  #endif
  #include 
  
  #include 
  #ifndef __set_errno
  # define __set_errno(ev) ((errno) = (ev))
  #endif
  
- #include 
  #include 
  #if _LIBC || HAVE_UNISTD_H
  # inclu

relocatable-prog-wrapper fixes

2007-12-26 Thread Bruno Haible
Hi,

It was reported in [1] that the relocatable-prog-wrapper fails to compile
due to an undefined xalloc_die() symbol. It is caused by the use of xreadlink().
Since the wrapper is compiled with NO_XMALLOC defined, xreadlink should be
avoided.

2007-12-24  Bruno Haible  <[EMAIL PROTECTED]>

Fix link error due to xalloc_die().
* lib/progreloc.c: When NO_XMALLOC is defined, use areadlink instead
of xreadlink.
* lib/relocwrapper.c: Update comments.
* build-aux/install-reloc: Remove xreadlink.c from file list.
* modules/relocatable-prog-wrapper (Files): Remove xreadlink.h and
xreadlink.c.
Reported by Левашев Иван <[EMAIL PROTECTED]>.

*** build-aux/install-reloc.orig2007-12-24 23:12:22.0 +0100
--- build-aux/install-reloc 2007-12-24 23:07:24.0 +0100
***
*** 131,137 
   "$srcdir"/relocwrapper.c \
   "$srcdir"/progname.c \
   "$srcdir"/progreloc.c \
-  "$srcdir"/xreadlink.c \
   "$srcdir"/areadlink.c \
   "$srcdir"/readlink.c \
   "$srcdir"/canonicalize-lgpl.c \
--- 131,136 
*** lib/progreloc.c.orig2007-12-24 23:12:22.0 +0100
--- lib/progreloc.c 2007-12-24 23:04:19.0 +0100
***
*** 1,5 
  /* Provide relocatable programs.
!Copyright (C) 2003-2006 Free Software Foundation, Inc.
 Written by Bruno Haible <[EMAIL PROTECTED]>, 2003.
  
 This program is free software: you can redistribute it and/or modify
--- 1,5 
  /* Provide relocatable programs.
!Copyright (C) 2003-2007 Free Software Foundation, Inc.
 Written by Bruno Haible <[EMAIL PROTECTED]>, 2003.
  
 This program is free software: you can redistribute it and/or modify
***
*** 43,53 
  # include 
  #endif
  
- #include "xreadlink.h"
  #include "canonicalize.h"
  #include "relocatable.h"
  
  #ifdef NO_XMALLOC
  # define xmalloc malloc
  # define xstrdup strdup
  #else
--- 43,59 
  # include 
  #endif
  
  #include "canonicalize.h"
  #include "relocatable.h"
  
  #ifdef NO_XMALLOC
+ # include "areadlink.h"
+ # define xreadlink areadlink
+ #else
+ # include "xreadlink.h"
+ #endif
+ 
+ #ifdef NO_XMALLOC
  # define xmalloc malloc
  # define xstrdup strdup
  #else
*** lib/relocwrapper.c.orig 2007-12-24 23:12:22.0 +0100
--- lib/relocwrapper.c  2007-12-24 23:06:49.0 +0100
***
*** 19,29 
 relocwrapper
  -> progname
  -> progreloc
! -> xreadlink
!-> areadlink
!   -> readlink
  -> canonicalize-lgpl
 -> malloca
  -> relocatable
  -> setenv
 -> malloca
--- 19,29 
 relocwrapper
  -> progname
  -> progreloc
! -> areadlink
!-> readlink
  -> canonicalize-lgpl
 -> malloca
+-> readlink
  -> relocatable
  -> setenv
 -> malloca
*** modules/relocatable-prog-wrapper.orig   2007-12-24 23:12:22.0 
+0100
--- modules/relocatable-prog-wrapper2007-12-24 23:07:05.0 +0100
***
*** 8,15 
  lib/progname.h
  lib/progname.c
  lib/progreloc.c
- lib/xreadlink.h
- lib/xreadlink.c
  lib/areadlink.h
  lib/areadlink.c
  lib/readlink.c
--- 8,13 


[1] http://lists.gnu.org/archive/html/bug-gnu-utils/2007-12/msg1.html





Re: mingw isnanl-nolibm failure

2007-12-26 Thread Bruno Haible
Eric Blake wrote on 2007-12-11:
>  2007-12-11  Eric Blake  <[EMAIL PROTECTED]>
>  
> + Fix bug with -0.0L in previous patch.
> + * lib/isnan.c (rpl_isnanl): Make robust to -0.0L and pad bits.
> + * tests/test-isnan.c (main): Also test on zeroes.
> + * tests/test-isnanf.c (main): Likewise.
> + * tests/test-isnanl.h (main): Likewise.

Thanks a lot for this patch. I like it better than the original plan to
determine the exponent bit 0 location at runtime.

Bruno





Re: no license on some test modules

2007-12-26 Thread Bruno Haible
Eric Blake wrote:
>  2007-12-11  Eric Blake  <[EMAIL PROTECTED]>
> +
> + Avoid link failures with separate libtests.a.
> + * gnulib-tool (func_emit_tests_Makefile_am): Also list local_ldadd
> + last, to satisfy circular dependencies.
> +

Thanks. I'm applying this additional patch,
  1) to minimize the -l options that are added in LDFLAGS,
  2) change comments to make it clear that 'progname' is not the culprit,
 it's the 'error' module.

2007-12-22  Bruno Haible  <[EMAIL PROTECTED]>

* gnulib-tool (func_emit_tests_Makefile_am): Replace local_ldadd with
two variables local_ldadd_before, local_ldadd_last.

*** gnulib-tool.orig2007-12-22 17:09:13.0 +0100
--- gnulib-tool 2007-12-22 17:09:13.0 +0100
***
*** 1919,1932 
echo "  -I${testsbase_inverse} -I\$(srcdir)/${testsbase_inverse} \\"
echo "  -I${testsbase_inverse}/${sourcebase-lib} 
-I\$(srcdir)/${testsbase_inverse}/${sourcebase-lib}"
echo
!   local_ldadd=''
if $use_libtests; then
! local_ldadd=' libtests.a $(LIBTESTS_LIBDEPS)'
fi
!   # local_ldadd must be listed first, since it often depends on non-test
!   # modules; it must also be listed last, since it can include modules
!   # such as progname that satisfy dependencies of non-test modules.
!   echo "LDADD =${local_ldadd} 
${testsbase_inverse}/${sourcebase-lib}/${libname}.${libext}${local_ldadd}"
echo
if $use_libtests; then
  echo "libtests_a_SOURCES ="
--- 1919,1939 
echo "  -I${testsbase_inverse} -I\$(srcdir)/${testsbase_inverse} \\"
echo "  -I${testsbase_inverse}/${sourcebase-lib} 
-I\$(srcdir)/${testsbase_inverse}/${sourcebase-lib}"
echo
!   local_ldadd_before=''
!   local_ldadd_after=''
if $use_libtests; then
! # All test programs need to be linked with libtests.a.
! # It needs to be passed to the linker before ${libname}.${libext}, since
! # the tests-related modules depend on the main modules.
! # It also needs to be passed to the linker after ${libname}.${libext}
! # because the latter might contain incomplete modules (such as the 'error'
! # module whose dependency to 'progname' is voluntarily omitted).
! # The LIBTESTS_LIBDEPS can be passed to the linker once or twice, it does
! # not matter.
! local_ldadd_before=' libtests.a'
! local_ldadd_after=' libtests.a $(LIBTESTS_LIBDEPS)'
fi
!   echo "LDADD =${local_ldadd_before} 
${testsbase_inverse}/${sourcebase-lib}/${libname}.${libext}${local_ldadd_after}"
echo
if $use_libtests; then
  echo "libtests_a_SOURCES ="




Re: memmem issues

2007-12-26 Thread Bruno Haible
Eric Blake wrote:
> + * tests/test-memmem.c: Rewrite, borrowing ideas from
> + test-mbsstr1.c; the old version wouldn't even compile!

After the rewrite, there's no code left from the original test. I committed
this, to correct the attribution:


2007-12-23  Bruno Haible  <[EMAIL PROTECTED]>

* tests/test-memmem.c: Include  first.

*** tests/test-memmem.c.orig2007-12-23 11:24:15.0 +0100
--- tests/test-memmem.c 2007-12-23 11:21:20.0 +0100
***
*** 1,6 
  /*
   * Copyright (C) 2004, 2007 Free Software Foundation
!  * Written by Simon Josefsson
   *
   * 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,6 
  /*
   * Copyright (C) 2004, 2007 Free Software Foundation
!  * Written by Bruno Haible and Eric Blake
   *
   * 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
***
*** 17,24 
  
  #include 
  
- #include 
  #include 
  #include 
  
  #define ASSERT(expr) \
--- 17,25 
  
  #include 
  
  #include 
+ 
+ #include 
  #include 
  
  #define ASSERT(expr) \




make --enable-relocatable work with DESTDIR

2007-12-26 Thread Bruno Haible
Левашев Иван also reported [1] that --enable-relocatable does not work when
DESTDIR is used. This fixes it.

2007-12-24  Bruno Haible  <[EMAIL PROTECTED]>

Make --enable-relocatable work with DESTDIR.
* build-aux/install-reloc: Accept another argument 'destdir'. Use it
to compute installdir from destprog.
* m4/relocatable.m4 (gl_RELOCATABLE_BODY): In INSTALL_PROGRAM_ENV,
also set the RELOC_DESTDIR variable.
Reported by Левашев Иван <[EMAIL PROTECTED]>.

*** build-aux/install-reloc.orig2007-12-25 01:05:27.0 +0100
--- build-aux/install-reloc 2007-12-25 00:55:31.0 +0100
***
*** 17,23 
  # along with this program.  If not, see .
  
  # Usage:
! #   install-reloc library_path_var library_path_value prefix \
  # compile_command srcdir config_h_dir exeext \
  # install_command... destprog
  # where
--- 17,23 
  # along with this program.  If not, see .
  
  # Usage:
! #   install-reloc library_path_var library_path_value prefix destdir \
  # compile_command srcdir config_h_dir exeext \
  # install_command... destprog
  # where
***
*** 25,30 
--- 25,33 
  #   - library_path_value is a colon separated list of directories that contain
  # the libraries at installation time (use this instead of -rpath)
  #   - prefix is the base directory at installation time
+ #   - destdir is a string that is prepended to all file names at installation
+ # time; it is already prepended to destprog but not to library_path_value
+ # and prefix
  #   - compile_command is a C compiler compilation and linking command
  #   - srcdir is the directory where to find relocwrapper.c and its 
dependencies
  #   - builddir is the directory where to find built dependencies (namely,
***
*** 43,48 
--- 46,52 
library_path_var=$RELOC_LIBRARY_PATH_VAR
library_path_value=$RELOC_LIBRARY_PATH_VALUE
prefix=$RELOC_PREFIX
+   destdir=$RELOC_DESTDIR
compile_command=$RELOC_COMPILE_COMMAND
srcdir=$RELOC_SRCDIR
builddir=$RELOC_BUILDDIR
***
*** 50,66 
exeext=$RELOC_EXEEXT
install_prog=$RELOC_INSTALL_PROG # including the "-c" option
  else
!   if test $# -ge 9; then
  # Get fixed position arguments.
  library_path_var=$1
  library_path_value=$2
  prefix=$3
! compile_command=$4
! srcdir=$5
! builddir=$6
! config_h_dir=$7
! exeext=$8
! install_prog=$9 # maybe not including the "-c" option
  shift
  shift
  shift
--- 54,70 
exeext=$RELOC_EXEEXT
install_prog=$RELOC_INSTALL_PROG # including the "-c" option
  else
!   if test $# -ge 10; then
  # Get fixed position arguments.
  library_path_var=$1
  library_path_value=$2
  prefix=$3
! destdir=$4
! compile_command=$5
! srcdir=$6
! builddir=$7
! config_h_dir=$8
! exeext=$9
  shift
  shift
  shift
***
*** 70,77 
  shift
  shift
  shift
else
! echo "Usage: $0 library_path_var library_path_value prefix" \
   "compile_command srcdir builddir config_h_dir exeext" \
   "install_command... destprog" 1>&2
  exit 1
--- 74,83 
  shift
  shift
  shift
+ install_prog=$1 # maybe not including the "-c" option
+ shift
else
! echo "Usage: $0 library_path_var library_path_value prefix destdir" \
   "compile_command srcdir builddir config_h_dir exeext" \
   "install_command... destprog" 1>&2
  exit 1
***
*** 86,93 
  done
  # Remove trailing $exeext, if present.
  if test -n "$exeext"; then
!   sedexpr='s|'`echo "$exeext" | sed -e 's,\.,\\\.,g'`'$||'
!   destprog=`echo "$destprog" | sed -e "$sedexpr"`
  fi
  
  # Outputs a command and runs it.
--- 92,100 
  done
  # Remove trailing $exeext, if present.
  if test -n "$exeext"; then
!   sed_quote='s,\.,\\.,g'
!   sed_remove_exeext='s|'`echo "$exeext" | sed -e "$sed_quote"`'$||'
!   destprog=`echo "$destprog" | sed -e "$sed_remove_exeext"`
  fi
  
  # Outputs a command and runs it.
***
*** 120,127 
  # wrapper.
  test -n "$libdirs" || exit 0
  
! # Compile wrapper.
  installdir=`echo "$destprog" | sed -e 's,/[^/]*$,,'`
  func_verbose $compile_command \
   -I"$builddir" -I"$srcdir" -I"$config_h_dir" \
   -DHAVE_CONFIG_H -DIN_RELOCWRAPPER -DNO_XMALLOC \
--- 127,141 
  # wrapper.
  test -n "$libdirs" || exit 0
  
! # Determine installdir from destprog, removing a leading destdir if present.
  installdir=`echo "$destprog" | sed -e 's,/[^/]*$,,'`
+ if test -n "$destdir"; then
+   sed_quote='s,\([|.\*^$[]\),\\\1,g'
+   sed_remove_destdir='s|^'`echo "$destdir" | sed -e "$sed_quote"`'||'
+   installdir=`echo "$installdir" | sed -e "$sed_remove_destdir"`
+ fi
+ 
+ # Compile wrapper.
  func_verbose $comp

Re: Incompatible module license.

2007-12-26 Thread Bruno Haible
Hi Jim,

I haven't seen progress on this topic for a week, so permit me to jump in.

> FYI, it happened two months ago, with this change:
> 
> http://git.sv.gnu.org/gitweb/?p=gnulib.git;a=commitdiff;h=12a195113bbb3
> 
> 2007-10-17  Paul Eggert  <[EMAIL PROTECTED]>
> 
>   Modify glob.c to use fstatat and dirfd, to simplify it.
>   Suggested by Eric Blake.
>   * lib/glob.c (__fxstatat64) [!_LIBC]: New macro.
>   Don't include ; not used.
>   (link_exists2_p, glob_in_dir) [!_LIBC]: No longer a special case.
>   (link_exists_p): Simplify implementation, since we can now assume
>   dirfd and fstatat.
>   * modules/glob (Depends-on): Add dirfd, openat.  Remove stdbool.

Yes, confirmed.

> It'd be a shame to revert such a change, just to keep the license
> the same.  Yet, I'm reluctant even to attempt to relicense so much code.

I understand that you want to keep the 'openat' module under GPL.

But reverting Paul's change fixes the problem. Why should it be a shame?
It's just 15 lines of code. The link_exists2_p function has code to
concatenate a directory and a file name; this is exactly what we need
when the 'fstatat' function does not exist.

Eric Blake wrote:
> Sounds like we need to split openat into two modules - an LGPL one that
> does the detection, and a GPL one that provides the replacement; then make
> glob depend on openat-detect instead of openat.

The lib/glob.c code needs only the fstatat() function; its detection is only
one line of *.m4 code. So it's not worth making a separate module for it.

I propose this change. Jim, this also include a license change of the 'dirfd'
module from LGPL to LGPLv2+. The dirfd.[hc] code is trivial; the dirfd.m4
macros are already under an all-permissive license.


2007-12-25  Bruno Haible  <[EMAIL PROTECTED]>

Fixup after 2007-10-17 commit. Ensure that 'glob' stays under LGPLv2+.
* lib/glob.c: Don't include openat.h.
(link_exists2_p): Add back the code that deals with the
!GLOB_ALTDIRFUNC case.
(link_exists_p) [!_LIBC && !HAVE_FSTATAT]: Just call link_exists2_p and
let it do the filename concatenation.
* m4/glob.m4 (gl_PREREQ_GLOB): Add check for fstatat.
* modules/glob (Depends-on): Remove openat.

* modules/dirfd (License): Change to LGPLv2+.

*** lib/glob.c.orig 2007-12-25 07:21:06.0 +0100
--- lib/glob.c  2007-12-25 07:20:23.0 +0100
***
*** 147,153 
  
  #ifndef _LIBC
  # include "dirfd.h"
- # include "openat.h"
  #endif
  
  #ifdef _SC_GETPW_R_SIZE_MAX
--- 147,152 
***
*** 1218,1230 
  #endif /* !GLOB_ONLY_P */
  
  
  /* We put this in a separate function mainly to allow the memory
 allocated with alloca to be recycled.  */
- #if !defined _LIBC || !defined GLOB_ONLY_P
  static int
  __attribute_noinline__
  link_exists2_p (const char *dir, size_t dirlen, const char *fname,
!   glob_t *pglob)
  {
size_t fnamelen = strlen (fname);
char *fullname = __alloca (dirlen + 1 + fnamelen + 1);
--- 1217,1233 
  #endif /* !GLOB_ONLY_P */
  
  
+ #if !defined _LIBC || !defined GLOB_ONLY_P
  /* We put this in a separate function mainly to allow the memory
 allocated with alloca to be recycled.  */
  static int
  __attribute_noinline__
  link_exists2_p (const char *dir, size_t dirlen, const char *fname,
!   glob_t *pglob
! # if !defined _LIBC && !HAVE_FSTATAT
!   , int flags
! # endif
!   )
  {
size_t fnamelen = strlen (fname);
char *fullname = __alloca (dirlen + 1 + fnamelen + 1);
***
*** 1233,1238 
--- 1236,1248 
mempcpy (mempcpy (mempcpy (fullname, dir, dirlen), "/", 1),
   fname, fnamelen + 1);
  
+ # if !defined _LIBC && !HAVE_FSTATAT
+   if (__builtin_expect ((flags & GLOB_ALTDIRFUNC) == 0, 1))
+ {
+   struct_stat64 st64;
+   return __stat64 (fullname, &st64) == 0;
+ }
+ # endif
return (*pglob->gl_stat) (fullname, &st) == 0;
  }
  
***
*** 1241,1246 
--- 1251,1257 
  link_exists_p (int dfd, const char *dir, size_t dirlen, const char *fname,
   glob_t *pglob, int flags)
  {
+ # if defined _LIBC || HAVE_FSTATAT
if (__builtin_expect (flags & GLOB_ALTDIRFUNC, 0))
  return link_exists2_p (dir, dirlen, fname, pglob);
else
***
*** 1248,1253 
--- 1259,1267 
struct_stat64 st64;
return __fxstatat64 (_STAT_VER, dfd, fname, &st64, 0) == 0;
  }
+ # else
+   return link_exists2_p (dir, dirlen, fname, pglob, flags);
+ # endif
  }
  #endif
  
*** m4/glob.m4.orig 2007-12-25 07:21:06.0 +0100
--- m4/glob.m4  2007-12-25 07:15:19.0 +0100
***
*** 1,4 
! # glob.m4 serial 9
  dnl Copyright (C) 2005-2007 Free Software Foundation, Inc.
  dnl This file is free software; the Free Software Foundation
  dnl gives unlimited permission to copy and/or distribute it,
--- 1,4 
! # glob.m4 serial 

Re: Patch for the getpagesize module

2007-12-26 Thread Bruno Haible
Martin Lambers wrote:
> > The function from libgcc.a is maybe not correct in all
> > situations (think of 64-bit Windows), therefore I would use the
> > replacement also on mingw.
> 
> OK, I attached a patch. 

Thanks. I applied your patch, adding a lib/getpagesize.c file ("git diff"
omits added files, so one often forgets to send them) and a ChangeLog entry.

Bruno

2007-12-10  Martin Lambers <[EMAIL PROTECTED]>

Override getpagesize on mingw.
* lib/getpagesize.c: New file.
* m4/getpagesize.m4 (gl_FUNC_GETPAGESIZE): Enable replacement on mingw.
* modules/getpagesize (Files): Add lib/getpagesize.c.
* lib/unistd.in.h (getpagesize): Declare if we are using a replacement.
* m4/unistd_h.m4 (gl_UNISTD_H_DEFAULTS): Initialize
REPLACE_GETPAGESIZE.
* modules/unistd (Makefile.am): Substitute REPLACE_GETPAGESIZE.





Re: CHARSETALIASDIR in TESTS_ENVIRONMENT?

2007-12-26 Thread Bruno Haible
Ben Pfaff wrote:
> The localcharset module has a dependency on "make install" that I
> didn't realize until recently: until "make install" is run,
> locale_charset cannot resolve character set aliases.  For PSPP at
> least, this makes "make check" before "make install" fail, unless
> CHARSETALIASDIR is explicitly set in the environment.

Yes. The same problem also hit the libiconv test suite.

> This makes me wonder whether localcharset should recommend that a
> TESTS_ENVIRONMENT something like this should be used:
> TESTS_ENVIRONMENT = CHARSETALIASDIR='$(abs_top_builddir)/gl'
> This fixes the problem for PSPP.
>
> localcharset could go one step further by defining a substitution
> variable for use in TESTS_ENVIRONMENT, e.g. for use like this:
> TEST_ENVIRONMENT = @LOCALCHARSET_TESTENV@
> This is analogous to @FLOOR_LIBM@ etc.

Good points, both of them. I'm applying it, like you say:

2007-12-25  Bruno Haible  <[EMAIL PROTECTED]>

* modules/localcharset (Notice): New field.
(configure.ac): Define LOCALCHARSET_TESTS_ENVIRONMENT.
Suggested by Ben Pfaff <[EMAIL PROTECTED]>.

*** modules/localcharset.orig   2007-12-26 02:27:12.0 +0100
--- modules/localcharset2007-12-26 02:24:47.0 +0100
***
*** 1,6 
--- 1,12 
  Description:
  Return current locale's character encoding.
  
+ Notice:
+ If your package's tests make use of the locale_charset() function directly or
+ indirectly, you may need to define the CHARSETALIASDIR environment variable,
+ so that "make check" works before "make install". In Makefile.am syntax:
+ TESTS_ENVIRONMENT += @LOCALCHARSET_TESTS_ENVIRONMENT@
+ 
  Files:
  lib/localcharset.h
  lib/localcharset.c
***
*** 16,21 
--- 22,29 
  
  configure.ac:
  gl_LOCALCHARSET
+ 
LOCALCHARSET_TESTS_ENVIRONMENT="CHARSETALIASDIR=\"\$(top_builddir)/$gl_source_base\""
+ AC_SUBST([LOCALCHARSET_TESTS_ENVIRONMENT])
  
  Makefile.am:
  lib_SOURCES += localcharset.h localcharset.c





Re: Compiler warning in glob

2007-12-26 Thread Bruno Haible
Paul Eggert wrote:
> 2007-10-16  Paul Eggert  <[EMAIL PROTECTED]>
> 
>   Merge glibc changes into lib/glob.c.
> 
>   * lib/glob.c (glob_in_dir): Sync with glibc/posix/glob.c, dated
>   2007-10-15 04:59:03 UTC.  Here are the changes:
> 
>   2007-10-14  Ulrich Drepper  <[EMAIL PROTECTED]>
> 
>   * lib/glob.c: Reimplement link_exists_p to use fstatat64.
> 
>   * lib/glob.c: Add some branch prediction throughout.
> 
>   2007-10-07  Ulrich Drepper  <[EMAIL PROTECTED]>
> 
>   [BZ #5103]
>   * lib/glob.c (glob): Recognize patterns starting \/.
> 
>   2007-02-14  Jakub Jelinek  <[EMAIL PROTECTED]>
> 
>   [BZ #3996]
>   * lib/glob.c (attribute_hidden): Define if not defined.
>   (glob): Unescape dirname, filename or username when needed and not
>   GLOB_NOESCAPE.  Handle \/ correctly.  Handle GLOB_MARK if filename
>   is NULL.  Handle unescaped [ in pattern without closing ].
>   Don't pass GLOB_CHECK down to recursive glob for directories.
>   (__glob_pattern_type): New function.
>   (__glob_pattern_p): Implement using __glob_pattern_type.
>   (glob_in_dir): Handle GLOB_NOCHECK patterns containing no meta
>   characters and backslashes if not GLOB_NOESCAPE or unterminated [.
>   Remove unreachable code.
> 
>   2006-09-30  Ulrich Drepper  <[EMAIL PROTECTED]>
> 
>   * lib/glob.c (glob_in_dir): Add some comments and asserts to
>   explain why there are no leaks.
> 
>   2006-09-25  Jakub Jelinek  <[EMAIL PROTECTED]>
> 
>   [BZ #3253]
>   * lib/glob.c (glob_in_dir): Don't alloca one struct globlink at a
>   time, rather allocate increasingly bigger arrays of pointers, if
>   possible with alloca, if too large with malloc.

This does not compile with an ANSI C compiler any more. I'm committing this
fix:

2007-12-25  Bruno Haible  <[EMAIL PROTECTED]>

Fixup after 2007-10-16 commit.
* lib/glob.c (glob_in_dir): Don't use ISO C99 syntax.

*** lib/glob.c.orig 2007-12-25 07:21:06.0 +0100
--- lib/glob.c  2007-12-25 07:20:23.0 +0100
***
*** 1443,1449 
  while (1)
{
  struct globnames *old = names;
! for (size_t i = 0; i < cur; ++i)
free (names->name[i]);
  names = names->next;
  /* NB: we will not leak memory here if we exit without
--- 1457,1464 
  while (1)
{
  struct globnames *old = names;
! size_t i;
! for (i = 0; i < cur; ++i)
free (names->name[i]);
  names = names->next;
  /* NB: we will not leak memory here if we exit without
***
*** 1468,1474 
  while (1)
{
  struct globnames *old = names;
! for (size_t i = 0; i < cur; ++i)
new_gl_pathv[pglob->gl_offs + pglob->gl_pathc++]
  = names->name[i];
  names = names->next;
--- 1483,1490 
  while (1)
{
  struct globnames *old = names;
! size_t i;
! for (i = 0; i < cur; ++i)
new_gl_pathv[pglob->gl_offs + pglob->gl_pathc++]
  = names->name[i];
  names = names->next;





Re: removing empty parens after function names

2007-12-26 Thread Bruno Haible
Here's what I'm committing.

2007-12-25  Paul Eggert  <[EMAIL PROTECTED]>
Bruno Haible  <[EMAIL PROTECTED]>

Avoid using the syntax symbol() in formatted documentation.
* MODULES.html.sh (func_module): When replacing symbol() with a
hyperlink, remove the parentheses. Show an error if some remain.
Recognize and render the '...' syntax.
* doc/alloca-opt.texi: Remove parentheses from symbol reference.
Rework. Add paragraph about GCC's inlining.
* doc/alloca.texi: Likewise.
* doc/error.texi: Remove parentheses from symbol reference.
* doc/gnulib-intro.texi: Likewise.
* doc/gnulib.texi (alloca, alloca-opt): New nodes.
* modules/fnmatch (Description): Reword to say "the ... function".
* modules/full-read (Description): Likewise.
* modules/full-write (Description): Likewise.
* modules/safe-read (Description): Likewise.
* modules/safe-write (Description): Likewise.
* modules/strchrnul (Description): Likewise.
* modules/trim (Description): Likewise.
* modules/error (Description): Remove parentheses from symbol
references.
* modules/verror (Description): Likewise.
Reported by Karl Berry.

*** MODULES.html.sh.orig2007-12-25 22:38:04.0 +0100
--- MODULES.html.sh 2007-12-25 22:08:19.0 +0100
***
*** 1406,1416 
  element=''$1''
  func_echo "$element"
  
  element=`gnulib-tool --extract-description $1 \
   | sed -e "$sed_lt" -e "$sed_gt" -e 
"$sed_remove_trailing_empty_line" \
!-e 's,^, ,' \
!-e 's,\([^a-zA-Z_]\)'"${posix_functions}"'(),\1\2(),g' \
!-e 's,^ ,,'`
  func_echo "$element"
  
  func_end TR
--- 1406,1426 
  element=''$1''
  func_echo "$element"
  
+ # Rendering the description:
+ # - Change the symbol() syntax as suitable for documentation, removing the
+ #   parentheses (as per GNU standards, section "GNU Manuals").
+ # - Flag the remaining symbol() constructs as errors.
+ # - Change 'xxx' to xxx.
  element=`gnulib-tool --extract-description $1 \
   | sed -e "$sed_lt" -e "$sed_gt" -e 
"$sed_remove_trailing_empty_line" \
!-e 's,^, ,' -e 's,$, ,' \
!-e 's,\([^a-zA-Z_]\)'"${posix_functions}"'() 
\(function\|macro\),\1\2 \3,g' \
!-e 's,\([^a-zA-Z_]\)'"${posix_functions}"' 
\(function\|macro\),\1\2 \3,g' \
!-e 's,\([^a-zA-Z_]\)'"${posix_functions}"'(),\1\2 what?? 
If you mean a function\, please say so.,g' \
!-e 's,\([^a-zA-Z_]\)\([a-zA-Z_][a-zA-Z0-9_]*\)() 
\(function\|macro\),\1\2 \3,g' \
!-e 's,\([^a-zA-Z_]\)\([a-zA-Z_][a-zA-Z0-9_]*\)(),\1\2 
what?? If you mean a function\, please say 
so.,g' \
!-e 's, '"'"'\([a-zA-Z0-9_ -]*\)'"'"'\([^a-zA-Z0-9_]\), 
\1\2,g' \
!-e 's,^ ,,' -e 's, $,,'`
  func_echo "$element"
  
  func_end TR
*** doc/alloca-opt.texi.orig2007-12-25 22:38:04.0 +0100
--- doc/alloca-opt.texi 2007-12-25 21:39:34.0 +0100
***
*** 1,6 
  @c Documentation of gnulib module 'alloca-opt'.
  
! @c Copyright (C) 2004 Free Software Foundation, Inc.
  
  @c Permission is granted to copy, distribute and/or modify this document
  @c under the terms of the GNU Free Documentation License, Version 1.2 or
--- 1,6 
  @c Documentation of gnulib module 'alloca-opt'.
  
! @c Copyright (C) 2004, 2007 Free Software Foundation, Inc.
  
  @c Permission is granted to copy, distribute and/or modify this document
  @c under the terms of the GNU Free Documentation License, Version 1.2 or
***
*** 9,25 
  @c Texts.  A copy of the license is included in the ``GNU Free
  @c Documentation License'' file as part of this distribution.
  
! The alloca-opt module provides for a function alloca() which allocates memory
! on the stack, where the system allows it. A memory block allocated with 
alloca()
! exists only until the function that calls alloca() returns or exits abruptly.
  
  There are a few systems where this is not possible: HP-UX systems, and some
! other platforms when the C++ compiler is used. On these platforms the 
alloca-opt
! module provides no replacement, just a preprocessor macro HAVE_ALLOCA.
  
! The user can #include  on all platforms, and use alloca() on those
! platforms where the preprocessor macro HAVE_ALLOCA evaluates to true. If
! HAVE_ALLOCA is false, the code should use a heap-based memory allocation
! based on malloc() or - in C++ - 'new'. Note that the #include  must 
be
! the first one after the autoconf-generated config.h. Thanks to AIX for this 
nice
! restriction!
--- 9,41 
  @c Texts.  A copy of the license is included in the ``GNU Free
  @c Documentation License'' file as part of this distribution.
  
! The alloca-opt mod

Re: Problem with yacc rebuild rules

2007-12-26 Thread Bruno Haible
Larry Jones wrote:
> I'm having a problem building the Gnulib getdate module as part of CVS
> when building in a directory other than the source directory:
> 
>   test -f getdate.c || /bin/sh 
> /u/scjones/cvs-nightly/build-aux/ylwrap /u/scjones/cvs-nightly/lib/getdate.y 
> y.tab.c getdate.c y.tab.h getdate.h y.output getdate.output -- bison -y  
>   /u/scjones/cvs-nightly/build-aux/ylwrap[111]: bison:  not found.
>   *** Error exit code 1
> 
> The problem is that getdate.c does exist, but over in $(srcdir), not in
> the current directory.  I'm not sure whether the problem is in
> automake's yacc.am, Gnulib's use of it, CVS's use of the Gnulib module,
> or some combination.  Anyone care to point fingers?  :-)

'care' or 'dare' to point a finger? :-)

I tried to reproduce your problem like this:
  1) $ ./gnulib-tool --create-testdir --dir=/dev/shm/testdir1 getdate
  2) added AM_MAINTAINER_MODE to configure.ac (since you're apparently
 using automake-1.10, and its yacc.am shows that the "test -f" comes
 in only when AM_MAINTAINER_MODE is used),
  3) build in a separate directory with GNU make.

What I see is:
  - When getdate.c is newer than getdate.y, "make getdate.c" does nothing.
  - When getdate.y is newer than getdate.c, "make getdate.c" shows a command
like this:
   test -f ../../testdir1/gllib/getdate.c || /bin/sh ...

So my finger points back to you:
  * Are you sure that you are using GNU make? VPATH builds require GNU make.
  * The error message that you got indicates that the command 'bison' was
not found. When building sources from a git or CVS repository (as opposed
to a distributed tarball), you must have more than the usual tools
(sh, [g]awk, tr, [g]cc, etc.) installed. Depending on the gnulib modules
that you use, you may also need bison, gperf, etc.

Bruno





Re: memmem issues

2007-12-26 Thread Bruno Haible
Hi Paul,

Most of your comments apply to all copies of the KMP code in gnulib.

> Eric Blake <[EMAIL PROTECTED]> writes:
> > +  size_t *table = (size_t *) malloca (m * sizeof (size_t));
> > +  if (table == NULL)
> > +return false;
>
> Shouldn't this check for overflow in the multiplication?

Yes, it should. I'm always lazy about this.

> > +   unsigned char b = (unsigned char) needle[i - 1];
> > ...
> > +   if (b == (unsigned char) needle[j])
>
> Would it be cleaner to declare 'b' to be of type 'char' and avoid the
> casts?

No; ISO C 99 section 7.21.4 says that when byte strings are compared the
elements are considered as 'unsigned char' values. Why risk bugs when the
approach is very simple: after fetching any 'char' from any of the strings,
cast it to 'unsigned char'. Simple rule, simple to remember, works fine.

> > +  if ((unsigned char) needle[j] == (unsigned char) *phaystack)
>
> Can both casts be omitted?

Same answer.

> > +return memchr (haystack, (unsigned char) *Needle, haystack_len);
>
> Can the cast be omitted?

Same answer.

> > +return (void *) haystack;
>
> How about "return Haystack;"?  That avoids a cast.

... but will not compile when a C++ compiler is used.

> (As you can tell, I prefer to avoid casts)

As you can tell, I prefer to write code in the intersection of C and C++.

> > +  if (needle_len == 0)
>
> Perhaps a __builtin_expect would be helpful here?

Hardly. Nowadays gcc knows that comparison with == against a particular
value is "unlikely", AFAIK. No need to help it with __builtin_expect here.

Bruno





Re: Gnulib needed in AC_CHECK_HEADERS

2007-12-26 Thread Bruno Haible
Sylvain Beucler wrote:
> it seems alloca.h is not yet present at ./configure time
> (there's only gnulib/lib/alloca.in.h). So AC_CHECK_HEADERS fails
> anyway:
> 
> configure:14417: checking SDL.h usability
> configure:14434: i586-mingw32msvc-gcc -c -g -O2
> -I/usr/local/cross-tools/i386-mingw32/include/SDL -D_GNU_SOURCE=1 
> -Dmain=SDL_main 
> -I/usr/local/cross-tools/i386-mingw32/include/SDL -D_GNU_SOURCE=1 
> -Dmain=SDL_main
> -I../gnulib/lib -I./gnulib/lib conftest.c >&5
> In file included from 
> /usr/local/cross-tools/i386-mingw32/include/SDL/SDL_main.h:26,
>  from 
> /usr/local/cross-tools/i386-mingw32/include/SDL/SDL.h:28,
>  from conftest.c:117:
> /usr/local/cross-tools/i386-mingw32/include/SDL/SDL_stdinc.h:169:22: error: 
> alloca.h: No such
> file or directory

This should be fixable by using AH_VERBATIM instead of AC_DEFINE to define
HAVE_ALLOCA_H. As I understand it, AC_DEFINE makes the macro available
immediately, at configure time, whereas AH_VERBATIM makes it available only
after configuration, when config.h is created. See patch below (untested).

Paul Eggert wrote:
> Well, it _has_ been 3 years.  If the backward-compatibility gorp is
> causing real problems, perhaps it's time to bite the bullet and drop
> it, something like the following.  This won't affect coreutils or
> diffutils or tar or any modernish program.  What would it hurt?

The problems mentioned in the 2004 thread
  http://lists.gnu.org/archive/html/bug-gnulib/2004-04/threads.html#00021
have not gone away.
  - The autoconf manual still recommends to include  only if
HAVE_ALLOCA_H.
  - fnmatch.c and regex.c are still included in gcc's libiberty. Its regex.c
also includes  only if HAVE_ALLOCA_H.

So, if AH_VERBATIM solves Sylvain's problem, I would prefer to not disturb
all the sources which follow the advice in the autoconf manual.

Paul, what do you think?

Bruno



*** m4/alloca.m4.orig
--- m4/alloca.m4
***
*** 1,4 
! # alloca.m4 serial 7
  dnl Copyright (C) 2002-2004, 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,
--- 1,4 
! # alloca.m4 serial 8
  dnl Copyright (C) 2002-2004, 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,
***
*** 40,48 
fi
AC_SUBST([ALLOCA_H])
  
!   AC_DEFINE(HAVE_ALLOCA_H, 1,
! [Define HAVE_ALLOCA_H for backward compatibility with older code
!  that includes  only if HAVE_ALLOCA_H is defined.])
  ])
  
  # Prerequisites of lib/alloca.c.
--- 40,55 
fi
AC_SUBST([ALLOCA_H])
  
!   dnl Use AH_VERBATIM here, not AC_DEFINE, so that the HAVE_ALLOCA_H
!   dnl is still undefined at configuration time. This is needed for
!   dnl AC_CHECK_HEADER tests that look for include files that use the idiom:
!   dnl #if HAVE_ALLOCA_H
!   dnl # include 
!   dbl #endif
!   AH_VERBATIM([gl_FUNC_ALLOCA], [
! /* Define HAVE_ALLOCA_H for backward compatibility with older code
!that includes  only if HAVE_ALLOCA_H is defined.  */
! #define HAVE_ALLOCA_H 1])
  ])
  
  # Prerequisites of lib/alloca.c.




Re: memmem issues

2007-12-26 Thread Ben Pfaff
>> > +  unsigned char b = (unsigned char) needle[i - 1];
>> > ...
>> > +  if (b == (unsigned char) needle[j])
>>
>> Would it be cleaner to declare 'b' to be of type 'char' and avoid the
>> casts?
>
> No; ISO C 99 section 7.21.4 says that when byte strings are compared the
> elements are considered as 'unsigned char' values.

The first cast to unsigned char quoted above seems to be
unnecessary: assigning a value to an object of type unsigned char
will implicitly convert it to unsigned char.
-- 
Ben Pfaff 
http://benpfaff.org





Re: Gnulib needed in AC_CHECK_HEADERS

2007-12-26 Thread Sylvain Beucler
On Wed, Dec 26, 2007 at 06:24:35PM +0100, Bruno Haible wrote:
> Sylvain Beucler wrote:
> > it seems alloca.h is not yet present at ./configure time
> > (there's only gnulib/lib/alloca.in.h). So AC_CHECK_HEADERS fails
> > anyway:
> > 
> > configure:14417: checking SDL.h usability
> > configure:14434: i586-mingw32msvc-gcc -c -g -O2
> > -I/usr/local/cross-tools/i386-mingw32/include/SDL -D_GNU_SOURCE=1 
> > -Dmain=SDL_main 
> > -I/usr/local/cross-tools/i386-mingw32/include/SDL -D_GNU_SOURCE=1 
> > -Dmain=SDL_main
> > -I../gnulib/lib -I./gnulib/lib conftest.c >&5
> > In file included from 
> > /usr/local/cross-tools/i386-mingw32/include/SDL/SDL_main.h:26,
> >  from 
> > /usr/local/cross-tools/i386-mingw32/include/SDL/SDL.h:28,
> >  from conftest.c:117:
> > /usr/local/cross-tools/i386-mingw32/include/SDL/SDL_stdinc.h:169:22: error: 
> > alloca.h: No such
> > file or directory
> 
> This should be fixable by using AH_VERBATIM instead of AC_DEFINE to define
> HAVE_ALLOCA_H. As I understand it, AC_DEFINE makes the macro available
> immediately, at configure time, whereas AH_VERBATIM makes it available only
> after configuration, when config.h is created.

Hi,

It seems to me that somehow alloca.h should be available for the tests
(since we will use alloca.h during the actual compilation). Not using
alloca.h during tests would make the test environment different than
the compilation environment. alloca.h could be pre-created or provided
in a temporary include path. Just my 2c :)

> See patch below (untested).

I get:
/usr/bin/m4:configure.ac:90: recursion limit of 1024 exceeded, use -L to 
change it


> Paul Eggert wrote:
> > Well, it _has_ been 3 years.  If the backward-compatibility gorp is
> > causing real problems, perhaps it's time to bite the bullet and drop
> > it, something like the following.  This won't affect coreutils or
> > diffutils or tar or any modernish program.  What would it hurt?
> 
> The problems mentioned in the 2004 thread
>   http://lists.gnu.org/archive/html/bug-gnulib/2004-04/threads.html#00021
> have not gone away.
>   - The autoconf manual still recommends to include  only if
> HAVE_ALLOCA_H.
>   - fnmatch.c and regex.c are still included in gcc's libiberty. Its regex.c
> also includes  only if HAVE_ALLOCA_H.
> 
> So, if AH_VERBATIM solves Sylvain's problem, I would prefer to not disturb
> all the sources which follow the advice in the autoconf manual.
> 
> Paul, what do you think?
> 
> Bruno




Some free()s in module 'relocatable'

2007-12-26 Thread Sylvain Beucler
Hello,

Attached is a small patch to fix a couple non-fred memory blocks. They
are not a big deal, but they do produce noise when analyzing programs
with memory checkers such as Valgrind.


Another thing:, the relocatable module documentation recommends using:
  bindtextdomain (PACKAGE, relocate (LOCALEDIR));
however, the result of relocate may be LOCALEDIR itself (no
relocation) or a newly allocated string. Currently I need to use
tricks to properly free() the result of relocate():
  default_data_dir = strdup(DEFAULT_DATA_DIR); /* no '!=' with constants */
  datadir_relocatable = relocate(default_data_dir);
  ... use datadir_relocatable ...
  if (datadir_relocatable != default_data_dir)
free((char *)datadir_relocatable); /* force non-const variable */
Maybe it would be cleaner to always return a newly allocated string?

Cheers,

-- 
Sylvain




Re: Gnulib needed in AC_CHECK_HEADERS

2007-12-26 Thread Sylvain Beucler
> I get:
> /usr/bin/m4:configure.ac:90: recursion limit of 1024 exceeded, use -L to 
> change it

configure.ac:90 being:
  gl_INIT

-- 
Sylvain




Re: Some free()s in module 'relocatable'

2007-12-26 Thread Ben Pfaff
Sylvain Beucler <[EMAIL PROTECTED]> writes:

> Attached is a small patch to fix a couple non-fred memory blocks. They
> are not a big deal, but they do produce noise when analyzing programs
> with memory checkers such as Valgrind.

I do not see the attachment.

> Another thing:, the relocatable module documentation recommends using:
>   bindtextdomain (PACKAGE, relocate (LOCALEDIR));
> however, the result of relocate may be LOCALEDIR itself (no
> relocation) or a newly allocated string. 
[...]
> Maybe it would be cleaner to always return a newly allocated string?

This does seem reasonable to me, but I will wait to hear Bruno's
opinion before I do anything.
-- 
Ben Pfaff 
http://benpfaff.org