savannah gnuploads (was [PATCH] gnupload: corrected SFTP connection URL)

2023-03-23 Thread Sergey Poznyakoff
Hi Bruno,

While at it, I wonder if the following two upload targets in gnupload
are still valid:

savannah.gnu.org:DIRECTORY
savannah.nongnu.org:DIRECTORY

First, both of them cause anonymous ftp uploads whereas neither host
listens on ftp port.  Secondly, the savannah.nongnu.org docs [1] say
that the uploads are to be performed via scp to dl.sv.nongnu.org.  And,
last but not least, the purpose of savannah.gnu.org:DIRECTORY is
unclear, since distribution of all software hosted on savannah.gnu.org
is covered by ftp.gnu.org:DIRECTORY and alpha.gnu.org:DIRECTORY.

Regards,
Sergey

[1] http://savannah.nongnu.org/maintenance/DownloadArea/



Re: [PATCH] gnupload: corrected SFTP connection URL

2023-03-21 Thread Sergey Poznyakoff
Hi Bruno,

> Can you please review this proposed patch?

Yes, the patch is correct.  Please apply it.

>   - The documentation of this script says that download.gnu.org.ua is
> supported, but the actual upload happens to puszcza.gnu.org.ua.

To make the long story short, the two names used to point to the same IP
in the past.  However, it is no longer the case.

>   - The two machines have different IP addresses:

Right.

>   - Both appear to be located in the same data center in Falkenstein
> (Germany).

That's true.  I relocated the servers to Hetzner.

Best regards,
Sergey



Re: [PATCH] gendocs.sh: don't overwrite existing index.html

2021-03-01 Thread Sergey Poznyakoff
Hi Bernhard,

> If the point is to avoid a dangling symlink, then shouldn't this
> (also) check for "${PACKAGE}.html"?

Actually, the main point is to avoid destroying the existing file with
a meaningless dangling symlink.  That being said, I have nothing
against checking for existence of "${PACKAGE}.html" as well.  Like that:

diff --git a/build-aux/gendocs.sh b/build-aux/gendocs.sh
index 1872de9..a5e5905 100755
--- a/build-aux/gendocs.sh
+++ b/build-aux/gendocs.sh
@@ -2,7 +2,7 @@
 # gendocs.sh -- generate a GNU manual in many formats.  This script is
 #   mentioned in maintain.texi.  See the help message below for usage details.
 
-scriptversion=2021-01-01.00
+scriptversion=2021-03-01.13
 
 # Copyright 2003-2021 Free Software Foundation, Inc.
 #
@@ -346,7 +346,13 @@ html_split()
   split_html_dir=$PACKAGE.html
   (
 cd ${split_html_dir} || exit 1
-ln -sf ${PACKAGE}.html index.html
+if [ ! -f index.html ]; then
+  if [ -f ${PACKAGE}.html ]; then  
+ln -sf ${PACKAGE}.html index.html
+  else
+echo "$0: no index.html and ${PACKAGE}.html in $split_html_dir" >&2
+  fi
+fi
 tar -czf "$abs_outdir/${PACKAGE}.html_$1.tar.gz" -- *.html
   )
   eval html_$1_tgz_size=`calcsize "$outdir/${PACKAGE}.html_$1.tar.gz"`


Best regards,
Sergey




[PATCH] gendocs.sh: don't overwrite existing index.html

2021-03-01 Thread Sergey Poznyakoff
When generating html output, texi2html 5.0 creates index.html
file, instead of $PORJECT.html.  Don't overwrite it with dangling
symlink.
---
 build-aux/gendocs.sh | 6 --
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/build-aux/gendocs.sh b/build-aux/gendocs.sh
index 1872de9..0828905 100755
--- a/build-aux/gendocs.sh
+++ b/build-aux/gendocs.sh
@@ -2,7 +2,7 @@
 # gendocs.sh -- generate a GNU manual in many formats.  This script is
 #   mentioned in maintain.texi.  See the help message below for usage details.
 
-scriptversion=2021-01-01.00
+scriptversion=2021-03-01.13
 
 # Copyright 2003-2021 Free Software Foundation, Inc.
 #
@@ -346,7 +346,9 @@ html_split()
   split_html_dir=$PACKAGE.html
   (
 cd ${split_html_dir} || exit 1
-ln -sf ${PACKAGE}.html index.html
+if [ ! -f index.html ]; then
+   ln -sf ${PACKAGE}.html index.html
+fi
 tar -czf "$abs_outdir/${PACKAGE}.html_$1.tar.gz" -- *.html
   )
   eval html_$1_tgz_size=`calcsize "$outdir/${PACKAGE}.html_$1.tar.gz"`
-- 
2.9.0




parse-datetime.y reports integer overflow when compiled with gcc 5.5.0

2021-01-08 Thread Sergey Poznyakoff
Hello,

With recent gnulib (v0.1-4336-gbdae9a5), attempting to compile
parse-datetime.c fails with:

$ make -k parse-datetime.o V=1
gcc -DHAVE_CONFIG_H -I. -I.. -Wall -ggdb -MT parse-datetime.o -MD -MP -MF 
.deps/parse-datetime.Tpo -c -o parse-datetime.o parse-datetime.c
In file included from parse-datetime.y:39:0:
parse-datetime.y: In function 'to_tm_year':
intprops.h:578:17: warning: integer overflow in expression [-Woverflow]
   || (tmax) + (b) < (a)))
 ^
intprops.h:524:4: note: in expansion of macro '_GL_INT_SUBTRACT_RANGE_OVERFLOW'
   (overflow (a, b, tmin, tmax) \
^
intprops.h:491:10: note: in expansion of macro '_GL_INT_OP_CALC'
? _GL_INT_OP_CALC (a, b, r, op, overflow, unsigned int, \
  ^
intprops.h:389:4: note: in expansion of macro '_GL_INT_OP_WRAPV'
_GL_INT_OP_WRAPV (a, b, r, -, _GL_INT_SUBTRACT_RANGE_OVERFLOW)
^
parse-datetime.y:1274:9: note: in expansion of macro 'INT_SUBTRACT_WRAPV'
   : INT_SUBTRACT_WRAPV (year, TM_YEAR_BASE, tm_year))
 ^
parse-datetime.y: In function 'yylex':
intprops.h:578:17: warning: integer overflow in expression [-Woverflow]
   || (tmax) + (b) < (a)))
 ^
intprops.h:524:4: note: in expansion of macro '_GL_INT_SUBTRACT_RANGE_OVERFLOW'
   (overflow (a, b, tmin, tmax) \
^
intprops.h:500:11: note: in expansion of macro '_GL_INT_OP_CALC'
 ? _GL_INT_OP_CALC (a, b, r, op, overflow, unsigned long int, \
   ^
intprops.h:495:7: note: in expansion of macro '_GL_INT_OP_WRAPV_LONGISH'
 : _GL_INT_OP_WRAPV_LONGISH(a, b, r, op, overflow))
   ^
intprops.h:389:4: note: in expansion of macro '_GL_INT_OP_WRAPV'
_GL_INT_OP_WRAPV (a, b, r, -, _GL_INT_SUBTRACT_RANGE_OVERFLOW)
^
parse-datetime.y:1469:23: note: in expansion of macro 'INT_SUBTRACT_WRAPV'
   if (INT_SUBTRACT_WRAPV (s, 1, ))
   ^

Bisecting shows that the bug was introduced by commit 
55168f5fa7b3b95fbaa2be525b15f6ecd5500c02
   
Regards,
Sergey



Re: argp failure on macOS

2020-03-29 Thread Sergey Poznyakoff
Hi Bruno,

> Do you have time to look into this?

Sure. I'll take a look.

Regards,
Sergey




Re: Would timevar be accepted in gnulib?

2018-09-21 Thread Sergey Poznyakoff
Paul Eggert  ha escrit:

> It might be helpful to have it, though I don't offhand know of
> programs other than Bison and GCC that use that sort of thing.

GNU dico is another one (although it uses its own implementation).

Regards,
Sergey



git-log-fix is missing

2014-03-24 Thread Sergey Poznyakoff
Hello,

It has been reported that the commit 1589a8ab broke bootstrapping of the
projects that use the gitlog-to-changelog module, because git-log-fix
file listed in its module file is not present anywhere in the
repository:

   http://lists.gnu.org/archive/html/bug-tar/2014-03/msg00082.html

Regards,
Sergey



exclude: support posix regexps

2014-02-15 Thread Sergey Poznyakoff
Hello,

I'm currently implementing in GNU tar exclusion lists based on various
VCS ignore files (.gitignore, .hgignore, etc.).  To do so, I needed to
extend the existing exclude module to support posix extended regexps.
Attached is the patch that implements it.  I tried not to disturb the
existing API, so that the module can be used by existing code without
modifications.

Is it OK to push?

Regards,
Sergey

From 8341b9150246b1a6dfcf71946fa701294f0e3ada Mon Sep 17 00:00:00 2001
From: Sergey Poznyakoff g...@gnu.org.ua
Date: Sat, 15 Feb 2014 19:21:04 +0200
Subject: [PATCH] exclude: add support for posix regexps

This commit adds support for POSIX extended regular expressions
and fixes a long-standing memory leak (pattern buffer was never
freed).  It also implements a new interface function to read
exclude patterns from a FILE, which passes an additional parameter
to its callback function, thereby allowing to preserve its state
between invocations.

* lib/exclude.c (struct patopts): Pack regex and pattern into union.
(pattern_buffer): New struct.
(exclude): New member patbuf.
(exclude_add_pattern_buffer): New function.
(free_exclude_segment): Free regexps.
(free_exclude): Free allocated pattern buffers.
(exclude_patopts): New function.
(file_pattern_matches): Use exclude_patopts.
(add_exclude): support regexps.
(add_exclude_fp): New function.
(add_exclude_file): Rewrite using add_exclude_fp.
* lib/exclude.h (EXCLUDE_REGEX, EXCLUDE_ALLOC): New flags.
(add_exclude_fp)
(exclude_add_pattern_buffer): New prototypes.
* modules/exclude: Depends on regex and filename.
---
 lib/exclude.c   | 191 +---
 lib/exclude.h   |  12 +++-
 modules/exclude |   2 +
 3 files changed, 169 insertions(+), 36 deletions(-)

diff --git a/lib/exclude.c b/lib/exclude.c
index 0865cee..be386bc 100644
--- a/lib/exclude.c
+++ b/lib/exclude.c
@@ -32,6 +32,7 @@
 #include stdlib.h
 #include string.h
 #include wctype.h
+#include regex.h

 #include exclude.h
 #include hash.h
@@ -39,6 +40,7 @@
 #include fnmatch.h
 #include xalloc.h
 #include verify.h
+#include filename.h

 #if USE_UNLOCKED_IO
 # include unlocked-io.h
@@ -73,8 +75,12 @@ verify (((EXCLUDE_ANCHORED | EXCLUDE_INCLUDE | EXCLUDE_WILDCARDS)

 struct patopts
   {
-char const *pattern;
 int options;
+union
+{
+  char const *pattern;
+  regex_t re;
+} v;
   };

 /* An array of pattern-options pairs.  */
@@ -104,13 +110,33 @@ struct exclude_segment
 } v;
   };

+struct pattern_buffer
+  {
+struct pattern_buffer *next;
+char *base;
+  };
+
 /* The exclude structure keeps a singly-linked list of exclude segments,
maintained in reverse order.  */
 struct exclude
   {
 struct exclude_segment *head;
+struct pattern_buffer *patbuf;
   };

+/* Register BUF in the pattern buffer list of EX.  ADD_FUNC (see
+   add_exclude_file and add_exclude_fp below) can use this function
+   if it modifies the pattern, to ensure the allocated memory will be
+   properly reclaimed upon calling free_exclude. */
+void
+exclude_add_pattern_buffer (struct exclude *ex, char *buf)
+{
+  struct pattern_buffer *pbuf = xmalloc (sizeof *pbuf);
+  pbuf-base = buf;
+  pbuf-next = ex-patbuf;
+  ex-patbuf = pbuf;
+}
+
 /* Return true if STR has or may have wildcards, when matched with OPTIONS.
Return false if STR definitely does not have wildcards.  */
 bool
@@ -243,9 +269,16 @@ new_exclude_segment (struct exclude *ex, enum exclude_type type, int options)
 static void
 free_exclude_segment (struct exclude_segment *seg)
 {
+  size_t i;
+
   switch (seg-type)
 {
 case exclude_pattern:
+  for (i = 0; i  seg-v.pat.exclude_count; i++)
+	{
+	  if (seg-v.pat.exclude[i].options  EXCLUDE_REGEX)
+	regfree (seg-v.pat.exclude[i].v.re);
+	}
   free (seg-v.pat.exclude);
   break;

@@ -261,12 +294,23 @@ void
 free_exclude (struct exclude *ex)
 {
   struct exclude_segment *seg;
+  struct pattern_buffer *pbuf;
+
   for (seg = ex-head; seg; )
 {
   struct exclude_segment *next = seg-next;
   free_exclude_segment (seg);
   seg = next;
 }
+
+  for (pbuf = ex-patbuf; pbuf; )
+{
+  struct pattern_buffer *next = pbuf-next;
+  free (pbuf-base);
+  free (pbuf);
+  pbuf = next;
+}
+
   free (ex);
 }

@@ -327,14 +371,24 @@ exclude_fnmatch (char const *pattern, char const *f, int options)
  : fnmatch_no_wildcards);
   bool matched = ((*matcher) (pattern, f, options) == 0);
   char const *p;
-
+
   if (! (options  EXCLUDE_ANCHORED))
 for (p = f; *p  ! matched; p++)
   if (*p == '/'  p[1] != '/')
-matched = ((*matcher) (pattern, p + 1, options) == 0);
+	matched = ((*matcher) (pattern, p + 1, options) == 0);

   return matched;
 }
+
+bool
+exclude_patopts (struct patopts const *opts, char const *f)
+{
+  int options = opts-options;
+
+  return (options  EXCLUDE_REGEX)
+  ? regexec (opts-v.re, f, 0, NULL, 0) == 0
+  : exclude_fnmatch (opts-v.pattern, f

Re: [PATCH] savedir: optionally produce ordered directory list

2014-02-13 Thread Sergey Poznyakoff
Hi Ludovic,

 FWIW I think it’s very important that tar --sort=name remains the
 default, as it guarantees that archive production is deterministic.

Actually, the default is not to sort directory entries at all: tar
stores them in the same order as returned by the underlying system calls.
I don't think changing this will be a good idea.

Regards,
Sergey



Re: [PATCH] savedir: optionally produce ordered directory list

2014-02-13 Thread Sergey Poznyakoff
Hi,

Any objections to pushing the latest version of this patch to git head?

Regards,
Sergey



Re: [PATCH] savedir: optionally produce ordered directory list

2014-02-12 Thread Sergey Poznyakoff
Hi Paul,

 It simplifies things by removing the obsolescent function
 fdsavedir, and omitting the static variable that stores internal
 state.

Great, thank you.  It passed the test successfully.  While at it,
it appeared to me that we can also avoid some memory reallocations
and one iteration over the entries array.  The attached patch
implements that idea and shows a slight improvement in the speed.

Regards,
Sergey

diff --git a/ChangeLog b/ChangeLog
index 96c544e..5aba801 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,21 @@
+2014-02-11  Sergey Poznyakoff  g...@gnu.org.ua
+	Paul Eggert  egg...@cs.ucla.edu
+
+	savedir: add sorting arg to savedir, streamsavedir; remove fdsavedir
+	Patch based on an idea by Dick Streefland in
+	ttps://savannah.gnu.org/patch/?7892.
+	* NEWS: Document this.
+	* lib/savedir.c (NAME_SIZE_DEFAULT): Remove.
+	(direntry_t, comparison_function): New types.
+	(direntry_cmp_name): New function.
+	(direntry_cmp_inode) [D_INO_IN_DIRENT]: New function.
+	(streamsavedir, savedir): New arg OPTION.
+	(streamsavedir): Simplify memory allocation.
+	(fdsavedir): Remove.
+	* lib/savedir.h (enum savedir_option): New type.
+	(streamsavedir, savedir): New arg OPTION.
+	(fdsavedir): Remove.
+
 2014-02-05  Paul Eggert  egg...@cs.ucla.edu

 	file-type: add support for doors and other less-common file types
diff --git a/NEWS b/NEWS
index 2e7a518..4b02a5a 100644
--- a/NEWS
+++ b/NEWS
@@ -3,6 +3,10 @@ Important notes

 DateModules Changes

+2014-02-11  savedir The savedir and streamsavedir functions have a
+new argument specifying how to sort the result.
+The fdsavedir function is removed.
+
 2013-04-24  gettext If your project uses 'gettextize --intl' it is now
 your responsibility to put -I$(top_builddir)/intl
 into the Makefile.am for gnulib.
diff --git a/lib/savedir.c b/lib/savedir.c
index 6e9c66c..badf602 100644
--- a/lib/savedir.c
+++ b/lib/savedir.c
@@ -37,29 +37,72 @@

 #include xalloc.h

-#ifndef NAME_SIZE_DEFAULT
-# define NAME_SIZE_DEFAULT 512
+typedef struct
+{
+  char *name;
+  size_t size;
+#if D_INO_IN_DIRENT
+  ino_t ino;
+#endif
+} direntry_t;
+
+/* Compare the names of two directory entries */
+
+static int
+direntry_cmp_name (void const *a, void const *b)
+{
+  direntry_t const *dea = a;
+  direntry_t const *deb = b;
+
+  return strcmp (dea-name, deb-name);
+}
+
+#if D_INO_IN_DIRENT
+/* Compare the inode numbers of two directory entries */
+
+static int
+direntry_cmp_inode (void const *a, void const *b)
+{
+  direntry_t const *dea = a;
+  direntry_t const *deb = b;
+
+  return dea-ino  deb-ino ? -1 : dea-ino  deb-ino;
+}
+#endif
+
+typedef int (*comparison_function) (void const *, void const *);
+
+static comparison_function const comparison_function_table[] =
+  {
+0,
+direntry_cmp_name
+#if D_INO_IN_DIRENT
+, direntry_cmp_inode
 #endif
+  };

 /* Return a freshly allocated string containing the file names
in directory DIRP, separated by '\0' characters;
the end is marked by two '\0' characters in a row.
+   Returned values are sorted according to OPTION.
Return NULL (setting errno) if DIRP cannot be read.
If DIRP is NULL, return NULL without affecting errno.  */

 char *
-streamsavedir (DIR *dirp)
+streamsavedir (DIR *dirp, enum savedir_option option)
 {
-  char *name_space;
-  size_t allocated = NAME_SIZE_DEFAULT;
+  char *name_space = NULL;
+  size_t allocated = 0;
+  direntry_t *entries = NULL;
+  size_t entries_allocated = 0;
+  size_t entries_used = 0;
   size_t used = 0;
-  int save_errno;
+  int readdir_errno;
+  comparison_function cmp = comparison_function_table[option];

   if (dirp == NULL)
 return NULL;

-  name_space = xmalloc (allocated);
-
   for (;;)
 {
   struct dirent const *dp;
@@ -76,48 +119,65 @@ streamsavedir (DIR *dirp)
   if (entry[entry[0] != '.' ? 0 : entry[1] != '.' ? 1 : 2] != '\0')
 {
   size_t entry_size = _D_EXACT_NAMLEN (dp) + 1;
-  if (used + entry_size  used)
-xalloc_die ();
-  if (allocated = used + entry_size)
+  if (cmp)
 {
-  do
+  if (entries_allocated == entries_used)
 {
-  if (2 * allocated  allocated)
-xalloc_die ();
-  allocated *= 2;
+  size_t n = entries_allocated;
+  entries = x2nrealloc (entries, n, sizeof *entries);
+  entries_allocated = n;
 }
-  while (allocated = used + entry_size);
-
-  name_space = xrealloc (name_space, allocated);
+  entries[entries_used].name = xstrdup (entry);
+	  entries[entries_used].size = entry_size;
+#if D_INO_IN_DIRENT
+  entries[entries_used].ino = dp-d_ino;
+#endif
+  entries_used++;
 }
-  memcpy (name_space

[PATCH] savedir: optionally produce ordered directory list

2014-02-11 Thread Sergey Poznyakoff
Hello,

According to [1], using directory lists ordered by inode can speed up
tar archivation by up to 40% on ext[34] filesystems (confirmed by my own
measurements).  Please take a look at the attached patch.  Is it OK
to apply?

Regards,
Sergey

[1] https://savannah.gnu.org/patch/?7892

From 92ddbfb74f05e5cded933f760cddd0ce007001ae Mon Sep 17 00:00:00 2001
From: Sergey Poznyakoff g...@gnu.org.ua
Date: Tue, 11 Feb 2014 10:52:44 +0200
Subject: [PATCH] savedir: optionally produce ordered directory list

New function streamsavedir_ordered returns directory
entries ordered by names or inode numbers.  This can
be used by archivers to store archive members in reproducible
order (when sorted by name) or to speed-up archivation on
some filesystems (when sorted by inode).

Patch based on an idea by Dick Streefland.

* lib/savedir.h (SAVEDIR_SORT_NONE, SAVEDIR_SORT_NAME)
(SAVEDIR_SORT_INODE): New constants.
(streamsavedir_ordered)
(set_savedir_sort_order): New prototypes.
* lib/savedir.c (streamsavedir_ordered): New function.
(set_savedir_sort_order): New function.
(streamsavedir): Rewrite as an entry point to
streamsavedir_ordered.
---
 lib/savedir.c | 133 --
 lib/savedir.h |  10 +
 2 files changed, 140 insertions(+), 3 deletions(-)

diff --git a/lib/savedir.c b/lib/savedir.c
index 6d5ed7f..5fc2ff2 100644
--- a/lib/savedir.c
+++ b/lib/savedir.c
@@ -41,25 +41,92 @@
 # define NAME_SIZE_DEFAULT 512
 #endif

+typedef struct
+{
+  union
+  {
+char *ptr;
+size_t off;
+  } name;
+#if D_INO_IN_DIRENT
+  ino_t ino;
+#endif
+} direntry_t;
+
+/* Compare the names of two directory entries */
+
+static int
+direntry_cmp_name (const void *a, const void *b)
+{
+  const direntry_t *dea = (const direntry_t *) a;
+  const direntry_t *deb = (const direntry_t *) b;
+
+  return strcmp(dea-name.ptr, deb-name.ptr);
+}
+
+#if D_INO_IN_DIRENT
+/* Compare the inode numbers of two directory entries */
+
+static int
+direntry_cmp_inode (const void *a, const void *b)
+{
+  const direntry_t *dea = (const direntry_t *) a;
+  const direntry_t *deb = (const direntry_t *) b;
+
+  return (int) (dea-ino - deb-ino);
+}
+#endif
+
 /* Return a freshly allocated string containing the file names
in directory DIRP, separated by '\0' characters;
the end is marked by two '\0' characters in a row.
-   Return NULL (setting errno) if DIRP cannot be read.
-   If DIRP is NULL, return NULL without affecting errno.  */
+   Returned values are sorted according to ORDER.
+
+   Return NULL (setting errno) if DIRP cannot be read or ORDER
+   is invalid.
+
+   If DIRP is NULL, return NULL without affecting errno.
+ */

 char *
-streamsavedir (DIR *dirp)
+streamsavedir_ordered (DIR *dirp, int order)
 {
   char *name_space;
+  char *sorted;
   size_t allocated = NAME_SIZE_DEFAULT;
+  direntry_t *entries = NULL;
+  size_t entries_allocated = 0;
+  size_t entries_used = 0;
+  size_t i;
   size_t used = 0;
   int save_errno;
+  int (*cmp) (const void *a, const void *b) = NULL;

   if (dirp == NULL)
 return NULL;

   name_space = xmalloc (allocated);

+  switch (order)
+{
+case SAVEDIR_SORT_NONE:
+  break;
+
+case SAVEDIR_SORT_NAME:
+  cmp = direntry_cmp_name;
+  break;
+
+#if D_INO_IN_DIRENT
+case SAVEDIR_SORT_INODE:
+  cmp = direntry_cmp_inode;
+  break;
+#endif
+
+default:
+  errno = EINVAL;
+  return NULL;
+}
+
   for (;;)
 {
   struct dirent const *dp;
@@ -91,9 +158,41 @@ streamsavedir (DIR *dirp)
   name_space = xrealloc (name_space, allocated);
 }
   memcpy (name_space + used, entry, entry_size);
+  if (cmp)
+{
+  if (entries_allocated == entries_used)
+{
+		  if (entries_allocated == 0)
+		entries_allocated = NAME_SIZE_DEFAULT / sizeof (direntry_t);
+		  entries = x2nrealloc (entries, entries_allocated,
+	sizeof (entries[0]));
+}
+  entries[entries_used].name.off = used;
+#if D_INO_IN_DIRENT
+  entries[entries_used].ino = dp-d_ino;
+#endif
+  entries_used++;
+}
   used += entry_size;
 }
 }
+
+  if (cmp)
+{
+  for (i = 0; i  entries_used; i++)
+	entries[i].name.ptr = name_space + entries[i].name.off;
+  qsort (entries, entries_used, sizeof (direntry_t), cmp);
+  sorted = xmalloc (used + 1);
+  used = 0;
+  for (i = 0; i  entries_used; i++)
+{
+  strcpy (sorted + used, entries[i].name.ptr);
+  used += strlen (sorted + used) + 1;
+}
+  free (entries);
+  free (name_space);
+  name_space = sorted;
+}
   name_space[used] = '\0';
   save_errno = errno;
   if (save_errno != 0)
@@ -105,6 +204,34 @@ streamsavedir (DIR *dirp)
   return name_space;
 }

+static int default_sort_order;
+
+int
+set_savedir_sort_order (int order)
+{
+  switch (order)
+{
+case SAVEDIR_SORT_NONE:
+case

Re: [Bug-tar] [PATCH 0/1] Notes for wordsplit (was: Allow tar to usecommand for compressing consisiting of multiple words.)

2013-02-20 Thread Sergey Poznyakoff
Hi Paul,

 Developers are assumed to have up-to-date systems where -Werror is
 appropriate.

Frankly, I cannot imagine a situation where treaing a warning as an
error can be appropriate.  That's why I consider it unfortunate.

 I'm surprised you didn't run into this.

That's quite simple.  Configure enables -Werror only if gcc's version is
4.6 or newer.  Mine is not.

Regards,
Sergey



Re: [Bug-tar] Documentation bug

2012-07-27 Thread Sergey Poznyakoff
Jim Meyering j...@meyering.net ha escrit:

 (BTW, the second sentence seems incorrect:
 I saw no makefile rule for ChangeLog in tar.)

It is in Make.rules, which is imported from Paxutils.

Regards,
Sergey



Re: [bug-inetutils] inetutils-1.8: ftp build error

2010-07-25 Thread Sergey Poznyakoff
Alfred M. Szmidt a...@gnu.org ha escrit:

 This is a known bug, the reason if I recall is that readline exports
 xmalloc and xrealloc is to allow programs to hook their own version
 into readline.  So the readline maintainer has declined any fixes for
 this.

This is a severe bug. It makes readline useless for any project that
uses gnulib.

Regards,
Sergey




Re: [Bug-tar] exclude wildcards with backslash

2010-05-06 Thread Sergey Poznyakoff
Jean-Louis Martineau martin...@zmanda.com ha escrit:

 $ tar xf file.tar --wildcards --exclude 't\*s'
 It worked for all tar version up to 1.22
 With tar-1.23, it extract everything except the file 't\*s.

There was a bug in the `exclude' module. I have installed the
attached patch.

Regards,
Sergey

From abe9c758009394a09d0cb84cdaae37e5752953f2 Mon Sep 17 00:00:00 2001
From: Sergey Poznyakoff g...@gnu.org.ua
Date: Thu, 6 May 2010 23:18:34 +0300
Subject: [PATCH] exclude: Unescape hashed patterns in wildcard mode.

* lib/exclude.c (add_exclude): Unescape the pattern before adding it
to the hash list.
* tests/test-exclude8.sh: New test case.
* modules/exclude-tests: Add new test.
---
 ChangeLog  |8 
 lib/exclude.c  |   22 ++
 modules/exclude-tests  |4 +++-
 tests/test-exclude8.sh |   40 
 4 files changed, 73 insertions(+), 1 deletions(-)
 create mode 100755 tests/test-exclude8.sh

diff --git a/ChangeLog b/ChangeLog
index b92862f..4581ef9 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,11 @@
+2010-05-06  Sergey Poznyakoff  g...@gnu.org.ua
+
+   exclude: Unescape hashed patterns in wildcard mode.
+   * lib/exclude.c (add_exclude): Unescape the pattern before adding it
+   to the hash list.
+   * tests/test-exclude8.sh: New test case.
+   * modules/exclude-tests: Add new test.
+
 2010-05-05  Eric Blake  ebl...@redhat.com
 
verify: automate tests
diff --git a/lib/exclude.c b/lib/exclude.c
index 34b5636..a68f3cb 100644
--- a/lib/exclude.c
+++ b/lib/exclude.c
@@ -134,6 +134,26 @@ fnmatch_pattern_has_wildcards (const char *str, int 
options)
   return false;
 }
 
+static void
+unescape_pattern (char *str)
+{
+  int inset = 0;
+  char *q = str;
+  do
+{
+  if (inset)
+   {
+ if (*q == ']')
+   inset = 0;
+   }
+  else if (*q == '[')
+   inset = 1;
+  else if (*q == '\\')
+   q++;
+}
+  while ((*str++ = *q++));
+}
+
 /* Return a newly allocated and empty exclude list.  */
 
 struct exclude *
@@ -480,6 +500,8 @@ add_exclude (struct exclude *ex, char const *pattern, int 
options)
 seg = new_exclude_segment (ex, exclude_hash, options);
 
   str = xstrdup (pattern);
+  if (options  EXCLUDE_WILDCARDS)
+   unescape_pattern (str);
   p = hash_insert (seg-v.table, str);
   if (p != str)
 free (str);
diff --git a/modules/exclude-tests b/modules/exclude-tests
index ba265ed..3dd0225 100644
--- a/modules/exclude-tests
+++ b/modules/exclude-tests
@@ -7,6 +7,7 @@ tests/test-exclude4.sh
 tests/test-exclude5.sh
 tests/test-exclude6.sh
 tests/test-exclude7.sh
+tests/test-exclude8.sh
 
 Depends-on:
 progname
@@ -21,7 +22,8 @@ TESTS += \
  test-exclude4.sh\
  test-exclude5.sh\
  test-exclude6.sh\
- test-exclude7.sh
+ test-exclude7.sh\
+ test-exclude8.sh

 check_PROGRAMS += test-exclude
 test_exclude_LDADD = $(LDADD) @LIBINTL@
diff --git a/tests/test-exclude8.sh b/tests/test-exclude8.sh
new file mode 100755
index 000..ee14bbc
--- /dev/null
+++ b/tests/test-exclude8.sh
@@ -0,0 +1,40 @@
+#! /bin/sh
+# Test suite for exclude.
+# Copyright (C) 2010 Free Software Foundation, Inc.
+# This file is part of the GNUlib Library.
+#
+# 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 3 of the License, 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 General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program.  If not, see http://www.gnu.org/licenses/.
+
+TMP=excltmp.$$
+LIST=flist.$$
+ERR=0
+
+# Test escaped metacharacters.
+
+cat  $LIST 'EOT'
+f\*e
+b[a\*]r
+EOT
+
+cat  $TMP 'EOT'
+f*e: 1
+file: 0
+bar: 1
+EOT
+
+./test-exclude$EXEEXT -wildcards $LIST -- 'f*e' 'file' 'bar' |
+ tr -d '\015' | diff -c $TMP - || ERR=1
+
+rm -f $TMP $LIST
+exit $ERR
-- 
1.6.0.3



Re: [Bug-tar] exclude wildcards with backslash

2010-05-06 Thread Sergey Poznyakoff
Eric Blake ebl...@redhat.com ha escrit:

 This doesn't handle: []\a] as the set that recognizes '\\', 'a', or ']'.
  Should it?

No, it should not.  This function is applied to strings that
failed the fnmatch_pattern_has_wildcards test, i.e. which are not
(valid) globbing patterns.  Your example, however, is a valid pattern
and will be handled by fnmatch instead.

Regards,
Sergey




Christian Weisgerber: [Bug-tar] 1.23: FreeBSD 7 bug affects GNU tar

2010-03-29 Thread Sergey Poznyakoff
Hello,

Here's a report from one of GNU tar users.

Regards,
Sergey

--- Forwarded message
Date: Mon, 29 Mar 2010 22:12:02 +0200
From: Christian Weisgerber na...@mips.inka.de
To: bug-...@gnu.org
Message-ID: 20100329201202.ga28...@lorvorc.mips.inka.de
Subject: [Bug-tar] 1.23: FreeBSD 7 bug affects GNU tar

There is a stupid, stupid bug in FreeBSD 7 (up to and including the
7.3 release):  The fdopendir() function is present in libc, but the
prototype is missing from dirent.h.

GNU tar's configure picks up fdopendir(), but since there is no
prototype, it ends up typed as

  int fdopendir();

This is bad.  fdopendir() returns a pointer, which is truncated
from 64 to 32 bits on LP64 platforms.  Running GNU tar's make
check leaves a trail of coredumps behind...

The macro complex around m4/dirent*.m4 and m4/fdopendir.m4 needs
some sort of check if fdopendir() is declared, and if not, must
provide a prototype.  These macros are probably used in other GNU
projects as well, and bug-tar may not be the right address, but I'm
throwing it out there in the hope that it will reach somebody who
knows how to deal with this properly.

- -- 
Christian naddy Weisgerber  na...@mips.inka.de



--- End of Forwarded message





Petr Sumbera: [Bug-tar] tar 1.23 + verify() macro vs old compiler

2010-03-15 Thread Sergey Poznyakoff
Hello,

Forwarded is a user report and a proposed patch.  OK to apply?

Regards,
Sergey

--- Forwarded message
Date: Mon, 15 Mar 2010 16:37:00 +0100
From: Petr Sumbera petr.sumb...@sun.com
To: bug-...@gnu.org

This is a multi-part message in MIME format.

- --Boundary_(ID_saQ6xP8Er0Imd0fVVI/0wQ)
Content-type: text/plain; CHARSET=US-ASCII; format=flowed
Content-transfer-encoding: 7BIT

Hi,

Some older compilers basically wouldn't allow variable declaration 
inside function body. And that's exactly what happens with verify() 
macro and latest tar 1.23.

Please see attached patch.

Thanks,

Petr


- --Boundary_(ID_saQ6xP8Er0Imd0fVVI/0wQ)
Content-type: text/plain; name=inttostr.diff
Content-transfer-encoding: 7BIT
Content-disposition: attachment; filename=inttostr.diff

- --- tar-1.23/gnu/inttostr.c.orig  Mon Mar 15 08:03:27 2010
+++ tar-1.23/gnu/inttostr.c Mon Mar 15 08:05:00 2010
@@ -32,9 +32,9 @@
 inttostr (inttype i, char *buf)
 {
   char *p = buf + INT_STRLEN_BOUND (inttype);
+  verify (TYPE_SIGNED (inttype) == inttype_is_signed);
   *p = 0;
 
- -  verify (TYPE_SIGNED (inttype) == inttype_is_signed);
 #if inttype_is_signed
   if (i  0)
 {

- --Boundary_(ID_saQ6xP8Er0Imd0fVVI/0wQ)--



--- End of Forwarded message





Re: Petr Sumbera: [Bug-tar] tar 1.23 + verify() macro vs old compiler

2010-03-15 Thread Sergey Poznyakoff
Jim Meyering j...@meyering.net ha escrit:

 However, it'd be slightly better not to separate the declaration
 of p and that first use, so please move it one line higher,
 so that the verify stmt is the first in the block.

That's what I thought. Pushed.

Regards,
Sergey




Re: Gnulib TP template out of date?

2010-02-21 Thread Sergey Poznyakoff
Karl Berry k...@freefriends.org ha escrit:

 Gnulib folks -- perhaps we should set up a cron job to update it
 monthly, or some such?

Nice idea. In the meantime I will submit the new potfile tomorrow.

 Unfortunately I don't know how the previous pot was generated.  Maybe
 a Makefile could be supplied with a pot target, or something?

I've got a script I used to prepare previous versions. It is somewhat
raw to be included in gnulib right now. Allow me some time to
polish it:)

Regards,
Sergey







Argp fix

2010-02-05 Thread Sergey Poznyakoff
Hello,

Argp failed to properly recognize alias options that have
short option letters. For instance, in this setup:

  { dstaddr, 'd', ADDR, 0,
set destination (peer) address to ADDR },
  { peer, 'p', ADDR, OPTION_ALIAS },

both --peer and -p failed to work.

I have installed the attached fix.

Regards,
Sergey

From 11fbc57405a118e6ec9a3ebc19bbf5ececdae4d6 Mon Sep 17 00:00:00 2001
From: Sergey Poznyakoff g...@gnu.org.ua
Date: Fri, 5 Feb 2010 13:33:15 +0200
Subject: [PATCH] Argp: fix recognition of short alias options.

* lib/argp-parse.c (convert_options): Fix improper use of
`|' between character values.
* tests/test-argp.c (group1_option): New alias option
--read (-r).
(group1_parser): Special handling for 'r'.
(test15): New test case.
(test_fun): Add test15.
* tests/test-argp-2.sh: Update expected --help and --usage
outputs.
---
 ChangeLog|   16 +++-
 lib/argp-parse.c |2 +-
 tests/test-argp-2.sh |   18 ++
 tests/test-argp.c|   15 ++-
 4 files changed, 40 insertions(+), 11 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index 064c086..4f4ffb1 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,19 @@
 2010-02-05  Sergey Poznyakoff  g...@gnu.org.ua
 
+	Argp: fix recognition of short alias options.
+
+	* lib/argp-parse.c (convert_options): Fix improper use of
+	`|' between character values.
+	* tests/test-argp.c (group1_option): New alias option
+	--read (-r).
+	(group1_parser): Special handling for 'r'.
+	(test15): New test case.
+	(test_fun): Add test15.
+	* tests/test-argp-2.sh: Update expected --help and --usage
+	outputs.
+
+2010-02-05  Sergey Poznyakoff  g...@gnu.org.ua
+
 	* tests/test-argp.c: Fix indentation.
 
 2010-02-04  Eric Blake  e...@byu.net

diff --git a/lib/argp-parse.c b/lib/argp-parse.c
index 9a78778..a1cbf88 100644
--- a/lib/argp-parse.c
+++ b/lib/argp-parse.c
@@ -339,7 +339,7 @@ convert_options (const struct argp *argp,
values (the sign of the lower bits is preserved
however)...  */
 cvt-long_end-val =
-  ((opt-key | real-key)  USER_MASK)
+  ((opt-key ? opt-key : real-key)  USER_MASK)
   + (((group - cvt-parser-groups) + 1)  USER_BITS);
 
 /* Keep the LONG_OPTS list terminated.  */
diff --git a/tests/test-argp-2.sh b/tests/test-argp-2.sh
index 344bf37..5c0c64c 100755
--- a/tests/test-argp-2.sh
+++ b/tests/test-argp-2.sh
@@ -33,10 +33,10 @@ func_compare() {
 
 # Test --usage output
 cat  $TMP EOT
-Usage: test-argp [-tvCSOlp?V] [-f FILE] [-o[ARG]] [--test] [--file=FILE]
-[--input=FILE] [--verbose] [--cantiga] [--sonet] [--option]
-[--optional[=ARG]] [--limerick] [--poem] [--help] [--usage]
-[--version] ARGS...
+Usage: test-argp [-tvCSOlp?V] [-f FILE] [-r FILE] [-o[ARG]] [--test]
+[--file=FILE] [--input=FILE] [--read=FILE] [--verbose] [--cantiga]
+[--sonet] [--option] [--optional[=ARG]] [--limerick] [--poem]
+[--help] [--usage] [--version] ARGS...
 EOT
 
 ./test-argp$EXEEXT --usage | func_compare || ERR=1
@@ -45,9 +45,10 @@ EOT
 # Test working usage-indent format
 
 cat  $TMP EOT
-Usage: test-argp [-tvCSOlp?V] [-f FILE] [-o[ARG]] [--test] [--file=FILE]
-[--input=FILE] [--verbose] [--cantiga] [--sonet] [--option] [--optional[=ARG]]
-[--limerick] [--poem] [--help] [--usage] [--version] ARGS...
+Usage: test-argp [-tvCSOlp?V] [-f FILE] [-r FILE] [-o[ARG]] [--test]
+[--file=FILE] [--input=FILE] [--read=FILE] [--verbose] [--cantiga] [--sonet]
+[--option] [--optional[=ARG]] [--limerick] [--poem] [--help] [--usage]
+[--version] ARGS...
 EOT
 
 ARGP_HELP_FMT='usage-indent=0' ./test-argp$EXEEXT --usage | func_compare || ERR=1
@@ -62,7 +63,8 @@ documentation string
   -t, --test
 
  Option Group 1
-  -f, --file=FILE, --input=FILE   Option with a mandatory argument
+  -f, -r, --file=FILE, --input=FILE, --read=FILE
+ Option with a mandatory argument
   -v, --verbose  Simple option without arguments
 
  Option Group 1.1
diff --git a/tests/test-argp.c b/tests/test-argp.c
index 7f58ae0..675951f 100644
--- a/tests/test-argp.c
+++ b/tests/test-argp.c
@@ -34,6 +34,7 @@ struct test_args
   int test;
   int verbose;
   char *file;
+  int read;
   char *hidden;
   int opt;
   char *optional;
@@ -47,6 +48,7 @@ static struct argp_option group1_option[] = {
   { verbose, 'v', NULL, 0, Simple option without arguments, 1 },
   { file, 'f', FILE, 0, Option with a mandatory argument, 1 },
   { input, 0, NULL, OPTION_ALIAS, NULL, 1 },
+  { read, 'r', NULL, OPTION_ALIAS, NULL, 1 },
   { hidden, 'H', FILE, OPTION_HIDDEN, Hidden option, 1 },
   { NULL, 0, NULL, 0, NULL, 0 }
 };
@@ -62,6 +64,9 @@ group1_parser (int key, char *arg, struct argp_state *state)
   args-verbose++;
   break;
 
+case 'r':
+  args-read = 1;
+  /* fall through */
 case 'f':
   args-file = arg

Re: Argp fix

2010-02-05 Thread Sergey Poznyakoff
Simon Josefsson si...@josefsson.org ha escrit:

 Ouch.  Should this be reported to glibc as well?

Yes, I'll do it.

Regards,
Sergey




canonicalize_filename_mode memory usage

2009-12-17 Thread Sergey Poznyakoff
Hello,

A user of tar reported a suboptimal memory usage by the
canonicalize_filename_mode.  Attached is the patch he
proposed.  Any comments?

Regards,
Sergey

This patch corrects highly non-optimal memory allocation by
canonicalize_filename_mode(), which got exposed with:

2009-08-07  Sergey Poznyakoff  g...@gnu.org.ua
[...]
* src/misc.c: Include canonicalize.h
(zap_slashes, normalize_filename): New functions.

On a specific test case (a tree with around 3500 sub-directories with a
total of around 58,000 files), this reduces tar's memory usage from
32 MB to 4.5 MB for the initial full backup run (-g enabled), and from
19 MB to 5.5 MB for a subsequent incremental run.

On a real-world system with around 370,000 directories and 2.3 million
files where the problem was first spotted, an incremental run of a
32-bit build of tar 1.22.90 bumped into the 3 GB process address space
limit and failed, whereas a build with this patch applied uses around
400 MB during incremental runs and around 300 MB during initial full
backup runs.

--- tar-1.22.90/gnu/canonicalize.c.orig 2009-08-07 11:55:47 +
+++ tar-1.22.90/gnu/canonicalize.c  2009-12-08 15:50:40 +
@@ -161,6 +161,7 @@ canonicalize_filename_mode (const char *
   char const *end;
   char const *rname_limit;
   size_t extra_len = 0;
+  size_t actual_size;
   Hash_table *ht = NULL;
 
   if (name == NULL)
@@ -325,6 +326,10 @@ canonicalize_filename_mode (const char *
 --dest;
   *dest = '\0';
 
+  actual_size = strlen(rname) + 1;
+  if (rname_limit - rname  actual_size)
+rname = xrealloc (rname, actual_size);
+
   free (extra_buf);
   if (ht)
 hash_free (ht);


Re: canonicalize_filename_mode memory usage

2009-12-17 Thread Sergey Poznyakoff
Eric Blake e...@byu.net ha escrit:

 Who do we use as --author and/or reporter in the git commit?  The patch 
 first appeared on the tar list in an email by Solar Designer, but it is not 
 clear 
 whether he wrote it, or whether we should attribute yet some other
 person.

It was reported by Solar Designer so...@openwall.com.  I don't know
whether it was him who wrote the patch, but (I guess) that would be
relevant only if we really planned to accept the patch as is.  The variant
you proposed looks much better, in my opinion.

 Quite wasteful.  Rather than calling strlen and redoing an O(n) walk of the 
[...]
 For that matter, the temporary variable actual_size is not even needed.  I'd 
 write the patch as just a 2-line addition:

Agreed.  What I was asking about was not the patch itself, but the idea
behind it.

Regards,
Sergey




Re: chown, cpio: proposed change for userspec handling of USER:

2009-12-02 Thread Sergey Poznyakoff
Jim Meyering j...@meyering.net ha escrit:

 Since the above behavior is not specified by POSIX, and
 is IMHO, counter-intuitive, I propose to change it.  However,
 it is documented both in coreutils and in cpio's manuals.

I'm not particularly bound to this feature, but it was here for such a
long time that removing it now will break a lot of existing scripts and
force many people to change their habits.  I'd rather not do it.

Regards,
Sergey





Re: [PATCH] exclude: avoid an unwarranted warning

2009-10-30 Thread Sergey Poznyakoff
Eric Blake e...@byu.net ha escrit:

 Like this?

Yes, it was one of the ways Jim suggested earlier. See
http://lists.gnu.org/archive/html/bug-gnulib/2009-08/msg00435.html

Regards,
Sergey




getopt.h broken on FreeBSD

2009-10-19 Thread Sergey Poznyakoff
Hi,

We've got one more problem with getopt.h. It manifests
itself when compiling lex-generated parsers on FreeBSD.
What happens is the following: the system getopt.h defines
getopt_long, struct option and the accompanying stuff,
but does not define __need_getopt. Consequently, gnulib's
getopt.h includes it and attempts to redefine struct option
afterwards. This works so far as config.h is included before
getopt.h or unistd.h, but fails if it was not:

In file included from ../../gnu/unistd.h:56,
 from grecs-lex.c:12:
../../gnu/getopt.h:184: error: redefinition of 'struct option'

The error is triggered by the fact that the default flex
skeleton begins with

 #include stdio.h
 #include unistd.h

and gives no way to insert anything before this.

I see the following possible solutions:

1. Define __GETOPT_PREFIX directly in getopt.in.h, instead of config.h.

The comment at line 40 says that 'Standalone applications should
#define __GETOPT_PREFIX', so its seems a natural solution, given
that only standalone applications use gnulib.

2. Use custom skeleton file for flex.

It works OK, but introduces a dependency on the flex version in use.

3. Ask flex authors to conditionally #include config.h in their
default skeleton file.

This will fix the problem in the long run (if they accept it),
but the question persists on how to fix it right now.

4. Override the .l.c rule in the Makefile.am like that:

.l.c:
$(AM_V_LEX)$(am__skiplex) $(SHELL) $(YLWRAP) $ $(LEX_OUTPUT_ROOT).c 
$...@-t -- $(LEXCOMPILE) 
$(AM_V_at)echo #ifdef HAVE_CONFIG_H  $@; \
echo  #include config.h  $@; \
echo #endif  $@; \
cat $...@-t  $@; \
rm $...@-t

This is what I'm using at the moment. The drawback is that it
unnecessarily complicates the Makefile.am.

5. Don't use config.h at all, defining everything in the cc's command
line.

The drawbacks of this approach are obvious.

What do you think?

Regards,
Sergey





Re: getopt.h broken on FreeBSD

2009-10-19 Thread Sergey Poznyakoff
Hi Jim,

 How about just using flex's %top directive?

Hm, I overlooked that. Thanks for the suggestion!

Regards,
Sergey




Re: argp warnings

2009-09-27 Thread Sergey Poznyakoff
Eric Blake e...@byu.net ha escrit:

 OK to commit this patch?

Sure! Please, do.

Regards,
Sergey




Re: the signature of getopt, and getopt_long

2009-09-27 Thread Sergey Poznyakoff
Hi Lorenzo,

 the
 
 char * const *argv
 
 libc declaration of getopt_long (which looks wrong, since argv might
 be changed during the parsing, right?)

Yes, it is wrong because argv might be permuted by getopt_long. And
that's why gnulib's implementation uses __getopt_argv_const in the
declaration (see the comment in lib/getopt.in.h:73).

 now, I'd like to avoid the warning in the generated parser when using
 gnulib, but I'd like to avoid it also when using libc getopt_long
 version...
 
 what would you suggest?

I believe typecasting to `char *__getopt_argv_const *___argv' would be
the best way to handle this. Keep in mind, though, that
__getopt_argv_const is a macro, which is defined only if you include
gnulib's version of getopt.h. Perhaps some additional #ifdef magic
would be required before the cast, e.g.:

#ifndef __getopt_argv_const
# define __getopt_argv_const const
#endif

Regards,
Sergey




getopt broken

2009-09-26 Thread Sergey Poznyakoff
Hello,

The latest changes to getopt (commit 6471b462, getopt: fix inclusion
guards for cygwin) break compilation of getopt1.c on GNU/Linux:

GENconfigmake.h
CC getopt1.o
getopt1.c:42: error: syntax error before '*' token
getopt1.c: In function `getopt_long':
getopt1.c:44: error: number of arguments doesn't match prototype
/usr/include/getopt.h:162: error: prototype declaration

The reason is that the declarations of getopt_long and getopt_long_r
both use __getopt_argv_const, which is normally defined in getopt.h.
However, if the system already has getopt.h, it gets included and
further contents of the gnulib's getopt.h is ignored.

Attempts to define __getopt_argv_const in getopt1.c won't fix the bug,
since it is not known whether to define it to empty string or to const
(see comment at getopt.in.h:39). Actually, it is impossible to include
system's getopt.h and to ensure its declarations of getopt_long (et al.)
match those in gnulib's getopt1.c.

Any ideas how to fix it?

Regards,
Sergey




Re: getopt broken

2009-09-26 Thread Sergey Poznyakoff
Eric Blake e...@byu.net ha escrit:

 Oh, I see.  getopt in isolation passes, but getopt in combination with
 argp causes the failure you are seeing.  I guess it's because the argp
 module wants to use lower-level hooks from getopt1.c than what getopt.h
 normally exposes.

Yes, that's it. Argp uses _getopt_long_only_r, which may well be absent,
even if the system's libc provides a compatible implementation of
getopt_long.

Regards,
Sergey





Re: getopt broken

2009-09-26 Thread Sergey Poznyakoff
Eric Blake e...@byu.net ha escrit:

 Maybe the trick is to check whether _getopt_long_only_r is present to the
 linker, in which case we can provide our own declaration of it

Yes, but we cannot guarantee our declaration matches the actual function
definition.

Regards,
Sergey




Re: getopt broken

2009-09-26 Thread Sergey Poznyakoff
Eric Blake e...@byu.net ha escrit:

 But I doubt that interface has ever changed signature in glibc, and is not
 available anywhere else.

There are too many possibilities here. E.g. the function takes as its
last argument a struct _getopt_data, which is declared in getopt_int.h
This structure in libc may have different size, have additional fields,
etc, etc. In short, I believe it is too risky to suppose we use the
same definitions as libc.

Regards,
Sergey




Re: lib/exclude.c calls towlower() without checking for wideline support

2009-09-06 Thread Sergey Poznyakoff
Bruno Haible br...@clisp.org ha escrit:

 Like Solaris 2.5.1 and IRIX 5.3, you mean? This should do it.

Thanks, Bruno!

Regards,
Sergey




Re: lib/exclude.c calls towlower() without checking for wideline support

2009-09-04 Thread Sergey Poznyakoff
Hi Alan,

 Sorry to ping again, but because coreutils 7.5 has the newer version of
 gnulib it's blocking me from upgrading.

Sorry for the delay: I was busy with other projects. I will provide a
patch during this weekend. Stay in touch.

Regards,
Sergey




Re: lib/exclude.c calls towlower() without checking for wideline support

2009-09-01 Thread Sergey Poznyakoff
Alan Hourihane al...@fairlite.co.uk ha escrit:

 Not sure this is right, but it works

Surely it is not right. And it does not work, either: it does
not correctly lower the case of the input string.

Have you tried the patch I sent?

Regards,
Sergey




Re: lib/exclude.c calls towlower() without checking for wideline support

2009-09-01 Thread Sergey Poznyakoff
Alan Hourihane al...@fairlite.co.uk ha escrit:

 exclude.c: In function 'string_hasher_ci':
 exclude.c:167: warning: implicit declaration of function 'towlower'
 exclude.c:167: warning: incompatible implicit declaration of built-in
 function 'towlower'

These are warnings, not errors. What errors do you get? Please, send
me the config.log and error output from make.

Regards,
Sergey




Re: lib/exclude.c calls towlower() without checking for wideline support

2009-09-01 Thread Sergey Poznyakoff
Alan Hourihane al...@fairlite.co.uk ha escrit:

 Yes, but I get this
 
 nm exclude.o  | grep towlower
  U _towlower
 
 And my libc doesn't define towlower() either.

I see. Perhaps it is defined elsewhere? Could you please check?
The gnulib's wchar.h does not provide a wrapper for it, unfortunately.

Regards,
Sergey




Re: lib/exclude.c calls towlower() without checking for wideline support

2009-08-27 Thread Sergey Poznyakoff
Alan Hourihane al...@fairlite.co.uk ha escrit:

 As the subject line says, and I end up with an unresolved symbol.

Please try this patch:

diff --git a/lib/exclude.c b/lib/exclude.c
index 32f2a0a..00f3891 100644
--- a/lib/exclude.c
+++ b/lib/exclude.c
@@ -31,6 +31,7 @@
 #include stdio.h
 #include stdlib.h
 #include string.h
+#include wctype.h
 
 #include exclude.h
 #include hash.h


Regards,
Sergey





Re: [PATCH] progname: also set global program_invocation_name, when possible

2009-08-25 Thread Sergey Poznyakoff
Hello, 

 +#if HAVE_DECL_PROGRAM_INVOCATION_NAME
 +  program_invocation_name = (char *) argv0;
 +#endif

In my opinion, that's not correct.  Libc (and gnulib's argp, FWIW) uses
two variables: program_invocation_name, which points to the full program
name as obtained from argv[0], and program_invocation_short_name, which
points to the program name with all leading directories removed.  So,
set_program_name should set program_invocation_name to arg0, and
program_invocation_short_name to part of arg0 after the last directory
separator.

Regards,
Sergey




Re: [PATCH] progname: also set global program_invocation_name, when possible

2009-08-25 Thread Sergey Poznyakoff
Hi Jim,

 I have no control over glibc's error, and it uses program_invocation_name,
 not program_invocation_short_name, so in order to make diagnostics appear like
 
 program_name: 
 
 rather than
 
 /abs/dir.../.libs/lt-program_name: 
 
 the set_program_name function must update program_invocation_name.

I see, thanks for clarification.

Regards,
Sergey




Minor fix to gitlog-to-changelog

2009-08-12 Thread Sergey Poznyakoff
Hello,

In the output of gitlog-to-changelog, subject lines
are not separated from the body. This fix adds an extra newline
and fixes this. Any objections to push it?

Regards,
Sergey

diff --git a/build-aux/gitlog-to-changelog b/build-aux/gitlog-to-changelog
index 1cc53eb..a4a0c1d 100755
--- a/build-aux/gitlog-to-changelog
+++ b/build-aux/gitlog-to-changelog
@@ -104,7 +104,7 @@ sub quoted_cmd(@)
 ) or usage 1;
 
   my @cmd = (qw (git log --log-size), --since=$since_date,
- '--pretty=format:%ct  %an  %ae%n%n%s%n%b%n', @ARGV);
+ '--pretty=format:%ct  %an  %ae%n%n%s%n%n%b%n', @ARGV);
   open PIPE, '-|', @cmd
 or die ($ME: failed to run `. quoted_cmd (@cmd) .': $!\n
 . (Is your Git too old?  Version 1.5.1 or later is required.)\n);





Re: Minor fix to gitlog-to-changelog

2009-08-12 Thread Sergey Poznyakoff
Jim Meyering j...@meyering.net ha escrit:

 I prefer the existing style, so how about making that format string an
 option?

That's reasonable. Something like that, then:

diff --git a/build-aux/gitlog-to-changelog b/build-aux/gitlog-to-changelog
index 1cc53eb..677e5f6 100755
--- a/build-aux/gitlog-to-changelog
+++ b/build-aux/gitlog-to-changelog
@@ -1,7 +1,7 @@
 #!/usr/bin/perl
 # Convert git log output to ChangeLog format.
 
-my $VERSION = '2009-06-04 08:53'; # UTC
+my $VERSION = '2009-08-12 16:28'; # UTC
 # The definition above must lie within the first 8 lines in order
 # for the Emacs time-stamp write hook (at end) to update it.
 # If you change this file with Emacs, please let the write hook
@@ -96,15 +96,17 @@ sub quoted_cmd(@)
 
 {
   my $since_date = '1970-01-01 UTC';
+  my $format_string = '%ae%n%n%s%n%b%n';
   GetOptions
 (
  help = sub { usage 0 },
  version = sub { print $ME version $VERSION\n; exit },
  'since=s' = \$since_date,
+ 'format=s' = \$format_string,
 ) or usage 1;
 
   my @cmd = (qw (git log --log-size), --since=$since_date,
- '--pretty=format:%ct  %an  %ae%n%n%s%n%b%n', @ARGV);
+ '--pretty=format:%ct  %an  '.$format_string, @ARGV);
   open PIPE, '-|', @cmd
 or die ($ME: failed to run `. quoted_cmd (@cmd) .': $!\n
 . (Is your Git too old?  Version 1.5.1 or later is required.)\n);


Regards,
Sergey




gl_GETOPT_SUBSTITUTE gone

2009-08-12 Thread Sergey Poznyakoff
Bruno,

The recent removal of gl_GETOPT_SUBSTITUTE broke argp.m4.
Argp depends on GNU getopt internals, so it is safer to
always include gnulib's version of getopt even if libc's
one behaves identically to GNU. Will it suffice to do this:

diff --git a/m4/argp.m4 b/m4/argp.m4
index 7263a56..aeb2aeb 100644
--- a/m4/argp.m4
+++ b/m4/argp.m4
@@ -11,8 +11,13 @@ AC_DEFUN([gl_ARGP],
   AC_REQUIRE([gl_USE_SYSTEM_EXTENSIONS])
   dnl argp-parse.c depends on GNU getopt internals, therefore use GNU getopt
   dnl always.
-  gl_GETOPT_SUBSTITUTE
-  dnl Note: gl_GETOPT_SUBSTITUTE does AC_LIBOBJ([getopt]), 
AC_LIBOBJ([getopt1]).
+  gl_GETOPT_SUBSTITUTE_HEADER
+  dnl Arrange for unistd.h to include getopt.h.
+  GNULIB_UNISTD_H_GETOPT=1
+  dnl Arrange to compile the getopt implementation.
+  AC_LIBOBJ([getopt])
+  AC_LIBOBJ([getopt1])
+  gl_PREREQ_GETOPT
 
   AC_CHECK_DECL([program_invocation_name],
 [AC_DEFINE([HAVE_DECL_PROGRAM_INVOCATION_NAME], [1],

Regards,
Sergey




Re: gl_GETOPT_SUBSTITUTE gone

2009-08-12 Thread Sergey Poznyakoff
Bruno Haible br...@clisp.org ha escrit:

 Oops, I did not see this dependency. I'm restoring it now, as it's better
 if most getopt related stuff stays in the same file getopt.m4.

Thank you!

Regards,
Sergey




Re: [PATCH] Exclude optimization

2009-08-11 Thread Sergey Poznyakoff
Hi Bruno,

 'is_fnmatch_pattern' is probably a misnomer, because its argument is
[...]
 Also, I'm surprised that this function does not take an 'options' argument.
 For example, the string 'ab\[cd\]' is constant if FNM_NOESCAPE is off, but
 non-constant if FNM_NOESCAPE is on.

Fixed both.

 I would like to see some unit tests committed to this module before the
 big optimization.

Here they go:

From a83b74985b2226b74e23e9b2d6c32cd8037f3c80 Mon Sep 17 00:00:00 2001
From: Sergey Poznyakoff g...@gnu.org.ua
Date: Tue, 11 Aug 2009 15:47:45 +0300
Subject: [PATCH] Optimize exclude: use hash tables for non-wildcard patterns.

* lib/exclude.c: Include hash.h and mbuiter.h
(struct exclude_pattern, exclude_segment): New data types.
(struct exclude): Rewrite.
(fnmatch_pattern_has_wildcards): New function.
(new_exclude_segment, free_exclude_segment): New functions.
(excluded_file_pattern_p, excluded_file_name_p): New functions.
(excluded_file_name, add_exclude): Rewrite using new struct exclude.
* lib/exclude.h (is_fnmatch_pattern): New prototype.
* modules/exclude: Depend on hash and mbuiter.

* modules/exclude-tests: New file.
* modules/tests/test-exclude.c: New file.
* modules/tests/test-exclude1.sh: New file.
* modules/tests/test-exclude2.sh: New file.
* modules/tests/test-exclude3.sh: New file.
* modules/tests/test-exclude4.sh: New file.
* modules/tests/test-exclude5.sh: New file.
* modules/tests/test-exclude6.sh: New file.
* modules/tests/test-exclude7.sh: New file.
---
 lib/exclude.c  |  343 +++-
 lib/exclude.h  |7 +-
 modules/exclude|2 +
 modules/exclude-tests  |   28 
 tests/test-exclude.c   |  119 +
 tests/test-exclude1.sh |   42 ++
 tests/test-exclude2.sh |   44 ++
 tests/test-exclude3.sh |   44 ++
 tests/test-exclude4.sh |   39 ++
 tests/test-exclude5.sh |   42 ++
 tests/test-exclude6.sh |   39 ++
 tests/test-exclude7.sh |   42 ++
 12 files changed, 757 insertions(+), 34 deletions(-)
 create mode 100644 modules/exclude-tests
 create mode 100644 tests/test-exclude.c
 create mode 100755 tests/test-exclude1.sh
 create mode 100755 tests/test-exclude2.sh
 create mode 100755 tests/test-exclude3.sh
 create mode 100755 tests/test-exclude4.sh
 create mode 100755 tests/test-exclude5.sh
 create mode 100755 tests/test-exclude6.sh
 create mode 100755 tests/test-exclude7.sh

diff --git a/lib/exclude.c b/lib/exclude.c
index f38abf2..d4baab5 100644
--- a/lib/exclude.c
+++ b/lib/exclude.c
@@ -1,7 +1,7 @@
 /* exclude.c -- exclude file names
 
Copyright (C) 1992, 1993, 1994, 1997, 1999, 2000, 2001, 2002, 2003,
-   2004, 2005, 2006, 2007 Free Software Foundation, Inc.
+   2004, 2005, 2006, 2007, 2009 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
@@ -16,7 +16,10 @@
You should have received a copy of the GNU General Public License
along with this program.  If not, see http://www.gnu.org/licenses/.  */
 
-/* Written by Paul Eggert egg...@twinsun.com  */
+/* Written by Paul Eggert egg...@twinsun.com
+   and Sergey Poznyakoff g...@gnu.org.
+   Thanks to Phil Proudman p...@proudman51.freeserve.co.uk
+   for improvement suggestions. */
 
 #include config.h
 
@@ -30,6 +33,8 @@
 #include string.h
 
 #include exclude.h
+#include hash.h
+#include mbuiter.h
 #include fnmatch.h
 #include xalloc.h
 #include verify.h
@@ -54,6 +59,14 @@ verify (((EXCLUDE_ANCHORED | EXCLUDE_INCLUDE | 
EXCLUDE_WILDCARDS)
| FNM_CASEFOLD | FNM_EXTMATCH))
== 0);
 
+
+/* Exclusion patterns are grouped into a singly-linked list of
+   exclusion segments.  Each segment represents a set of patterns
+   that can be matches using the same algorithm.  Non-wildcard
+   patterns are kept in hash tables, to speed up searches.  Wildcard
+   patterns are stored as arrays of patterns. */
+
+
 /* An exclude pattern-options pair.  The options are fnmatch options
ORed with EXCLUDE_* options.  */
 
@@ -63,15 +76,63 @@ struct patopts
 int options;
   };
 
-/* An exclude list, of pattern-options pairs.  */
+/* An array of pattern-options pairs.  */
 
-struct exclude
+struct exclude_pattern
   {
 struct patopts *exclude;
 size_t exclude_alloc;
 size_t exclude_count;
   };
 
+enum exclude_type
+  {
+exclude_hash,/* a hash table of excluded names */
+exclude_pattern  /* an array of exclude patterns */
+  };
+
+struct exclude_segment
+  {
+struct exclude_segment *next;/* next segment in list */
+enum exclude_type type;  /* type of this segment */
+int options; /* common options for this segment */
+union
+{
+  Hash_table *table; /* for type == exclude_hash */
+  struct exclude_pattern pat;/* for type == exclude_pattern */
+} v;
+  };
+
+/* The exclude

Re: [PATCH] Exclude optimization

2009-08-11 Thread Sergey Poznyakoff
Hi Bruno,

Thanks for your remarks.

 Has the precedence handling changed, or is the test checking undefined
 behaviour?

Yes, it has changed. The first match determines whether the string
should be rejected or not. However, it does not rise any compatibility
concerns because none of the existing projects uses this feature
anyway.

   test_exclude_LDADD = $(LDADD) @LIBINTL@
[...]
  +#if HAVE_STRING_H
  +# include string.h
  +#endif

Fixed.

  +#ifndef FNM_EXTMATCH
  +# define FNM_EXTMATCH 0
  +#endif
 
 Not needed either: The identifier FNM_EXTMATCH is not used by the test
 (should it?).

No, it should not. It's a copy-n-paste bug.

  +++ b/tests/test-exclude1.sh
  @@ -0,0 +1,42 @@
  +TMP=excltmp
  +LIST=flist

I've suffixed these with .$$

 Why do test-exclude[2345].sh set ERR=0 at the beginning, while
 test-exclude[167].sh don't?

I've forgotten to set it there :) Fixed as well.

Here goes the updated patch:

From c531a900bf4e62d0d6675a9133d6ccde972dc29d Mon Sep 17 00:00:00 2001
From: Sergey Poznyakoff g...@gnu.org.ua
Date: Tue, 11 Aug 2009 18:23:23 +0300
Subject: [PATCH] Optimize exclude: use hash tables for non-wildcard patterns.

* lib/exclude.c: Include hash.h and mbuiter.h
(struct exclude_pattern, exclude_segment): New data types.
(struct exclude): Rewrite.
(fnmatch_pattern_has_wildcards): New function.
(new_exclude_segment, free_exclude_segment): New functions.
(excluded_file_pattern_p, excluded_file_name_p): New functions.
(excluded_file_name, add_exclude): Rewrite using new struct exclude.
* lib/exclude.h (is_fnmatch_pattern): New prototype.
* modules/exclude: Depend on hash and mbuiter.

* modules/exclude-tests: New file.
* modules/tests/test-exclude.c: New file.
* modules/tests/test-exclude1.sh: New file.
* modules/tests/test-exclude2.sh: New file.
* modules/tests/test-exclude3.sh: New file.
* modules/tests/test-exclude4.sh: New file.
* modules/tests/test-exclude5.sh: New file.
* modules/tests/test-exclude6.sh: New file.
* modules/tests/test-exclude7.sh: New file.
---
 lib/exclude.c  |  343 +++-
 lib/exclude.h  |7 +-
 modules/exclude|2 +
 tests/test-exclude1.sh |   43 ++
 tests/test-exclude2.sh |   44 ++
 tests/test-exclude3.sh |   44 ++
 tests/test-exclude4.sh |   39 ++
 tests/test-exclude5.sh |   42 ++
 tests/test-exclude6.sh |   40 ++
 tests/test-exclude7.sh |   43 ++
 10 files changed, 613 insertions(+), 34 deletions(-)
 create mode 100755 tests/test-exclude1.sh
 create mode 100755 tests/test-exclude2.sh
 create mode 100755 tests/test-exclude3.sh
 create mode 100755 tests/test-exclude4.sh
 create mode 100755 tests/test-exclude5.sh
 create mode 100755 tests/test-exclude6.sh
 create mode 100755 tests/test-exclude7.sh

diff --git a/lib/exclude.c b/lib/exclude.c
index f38abf2..d4baab5 100644
--- a/lib/exclude.c
+++ b/lib/exclude.c
@@ -1,7 +1,7 @@
 /* exclude.c -- exclude file names
 
Copyright (C) 1992, 1993, 1994, 1997, 1999, 2000, 2001, 2002, 2003,
-   2004, 2005, 2006, 2007 Free Software Foundation, Inc.
+   2004, 2005, 2006, 2007, 2009 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
@@ -16,7 +16,10 @@
You should have received a copy of the GNU General Public License
along with this program.  If not, see http://www.gnu.org/licenses/.  */
 
-/* Written by Paul Eggert egg...@twinsun.com  */
+/* Written by Paul Eggert egg...@twinsun.com
+   and Sergey Poznyakoff g...@gnu.org.
+   Thanks to Phil Proudman p...@proudman51.freeserve.co.uk
+   for improvement suggestions. */
 
 #include config.h
 
@@ -30,6 +33,8 @@
 #include string.h
 
 #include exclude.h
+#include hash.h
+#include mbuiter.h
 #include fnmatch.h
 #include xalloc.h
 #include verify.h
@@ -54,6 +59,14 @@ verify (((EXCLUDE_ANCHORED | EXCLUDE_INCLUDE | 
EXCLUDE_WILDCARDS)
| FNM_CASEFOLD | FNM_EXTMATCH))
== 0);
 
+
+/* Exclusion patterns are grouped into a singly-linked list of
+   exclusion segments.  Each segment represents a set of patterns
+   that can be matches using the same algorithm.  Non-wildcard
+   patterns are kept in hash tables, to speed up searches.  Wildcard
+   patterns are stored as arrays of patterns. */
+
+
 /* An exclude pattern-options pair.  The options are fnmatch options
ORed with EXCLUDE_* options.  */
 
@@ -63,15 +76,63 @@ struct patopts
 int options;
   };
 
-/* An exclude list, of pattern-options pairs.  */
+/* An array of pattern-options pairs.  */
 
-struct exclude
+struct exclude_pattern
   {
 struct patopts *exclude;
 size_t exclude_alloc;
 size_t exclude_count;
   };
 
+enum exclude_type
+  {
+exclude_hash,/* a hash table of excluded names */
+exclude_pattern  /* an array of exclude patterns */
+  };
+
+struct exclude_segment
+  {
+struct exclude_segment *next;/* next

Re: [PATCH] Exclude optimization

2009-08-11 Thread Sergey Poznyakoff
Hi Ralf,

 This would seem to still mis-characterizes patterns such as 'foo]'.

Yes, of course. But this function is by no means thought to correctly
catch all possible variations of wildcard patterns (one would have to
duplicate fnmatch for that). Its purpose is to give a rough estimate
on whether a given pattern is a fixed literal or a wildcard string.
It may, in same cases, incorrectly recognize the former to be the
latter, but never vice-versa.

Regards,
Sergey




Re: [PATCH] Exclude optimization

2009-08-11 Thread Sergey Poznyakoff
Sergey Poznyakoff g...@gnu.org.ua ha escrit:

 It may, in same cases, incorrectly recognize the former to be the

I wanted to say in some cases, of course.

Regards,
Sergey




Re: [PATCH] Exclude optimization

2009-08-10 Thread Sergey Poznyakoff
Hi Bruno,

 'is_fnmatch_pattern' is probably a misnomer, because its argument is
 by definition already an fnmatch pattern. What the function is testing is
 whether it contains wildcard characters

Yes, indeed.

 Btw, this function does not handle multiple adjacent backslashes correctly,
 i.e. patterns such as 'ab\\[cd]'.
 
 Also, I'm surprised that this function does not take an 'options' argument.
 For example, the string 'ab\[cd\]' is constant if FNM_NOESCAPE is off, but
 non-constant if FNM_NOESCAPE is on.

Good catch. I'll fix this.

 I would like to see some unit tests committed to this module before the
 big optimization.

OK, I'll write some.

 Thinking more into the future, there are now multiple optimizations of
 regex / fnmatch from various sides. (Recall that fnmatch patterns can
 be transformed into regular expressions.)

By the way, I am also experimenting with the idea of re-implementing
the exclude module using DFA, i.e. regarding the entire exclude list
as a set of regular language definitions and creating a DFA for each
of them (it is a *set* of definitions, because its parts can have
different EXCLUDE_* flags, so they should be processed differently).
This may constitute a significant speed-up. 

Regards,
Sergey




Re: [PATCH] Exclude optimization

2009-08-10 Thread Sergey Poznyakoff
Bruno Haible br...@clisp.org ha escrit:

 Why does it not fit into two regexes / DFAs?

Yes, it would, provided that we translate fnmatch patterns to regexps.

   EXCLUDE_WILDCARDS on:  'a?b*' - 'a.b.*'
   EXCLUDE_WILDCARDS off: 'a?b*' - 'a[?]b[*]'
   EXCLUDE_ANCHORED on:  'a?b' - '^a.b$'
   EXCLUDE_ANCHORED off: 'a?b' - '^\([^/]*/\)*a.b$'

There is also FNM_LEADING_DIR, which translates to

'a?b' - '^a.b/.*'

 The DFA code from grep and gawk is next to unmaintainable [1].

That is exactly the main obstacle :)

Regards,
Sergey




[PATCH] Exclude optimization

2009-08-09 Thread Sergey Poznyakoff
Hello,

The proposed patch considerably speed-ups the exclude module
for large exclusion lists of non-wildcard patterns. Ok to push?

From 5421774438de3a67d89f988a0cd735e19a4cafd4 Mon Sep 17 00:00:00 2001
From: Sergey Poznyakoff g...@gnu.org.ua
Date: Mon, 10 Aug 2009 00:14:45 +0300
Subject: [PATCH] Optimize exclude: use hash tables for non-wildcard patterns.

* lib/exclude.c: Include hash.h and mbuiter.h
(struct exclude_pattern, exclude_segment): New data types.
(struct exclude): Rewrite.
(is_fnmatch_pattern): New function.
(new_exclude_segment, free_exclude_segment): New functions.
(excluded_file_pattern_p, excluded_file_name_p): New functions.
(excluded_file_name, add_exclude): Rewrite using new struct exclude.
* lib/exclude.h (is_fnmatch_pattern): New prototype.
* modules/exclude: Depend on hash and mbuiter.
---
 lib/exclude.c   |  335 +--
 lib/exclude.h   |7 +-
 modules/exclude |2 +
 3 files changed, 310 insertions(+), 34 deletions(-)

diff --git a/lib/exclude.c b/lib/exclude.c
index f38abf2..d3af524 100644
--- a/lib/exclude.c
+++ b/lib/exclude.c
@@ -1,7 +1,7 @@
 /* exclude.c -- exclude file names
 
Copyright (C) 1992, 1993, 1994, 1997, 1999, 2000, 2001, 2002, 2003,
-   2004, 2005, 2006, 2007 Free Software Foundation, Inc.
+   2004, 2005, 2006, 2007, 2009 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
@@ -16,7 +16,10 @@
You should have received a copy of the GNU General Public License
along with this program.  If not, see http://www.gnu.org/licenses/.  */
 
-/* Written by Paul Eggert egg...@twinsun.com  */
+/* Written by Paul Eggert egg...@twinsun.com
+   and Sergey Poznyakoff g...@gnu.org.
+   Thanks to Phil Proudman p...@proudman51.freeserve.co.uk
+   for improvement suggestions. */
 
 #include config.h
 
@@ -30,6 +33,8 @@
 #include string.h
 
 #include exclude.h
+#include hash.h
+#include mbuiter.h
 #include fnmatch.h
 #include xalloc.h
 #include verify.h
@@ -54,6 +59,14 @@ verify (((EXCLUDE_ANCHORED | EXCLUDE_INCLUDE | 
EXCLUDE_WILDCARDS)
| FNM_CASEFOLD | FNM_EXTMATCH))
== 0);
 
+
+/* Exclusion patterns are grouped into a singly-linked list of
+   exclusion segments.  Each segment represents a set of patterns
+   that can be matches using the same algorithm.  Non-wildcard
+   patterns are kept in hash tables, to speed up searches.  Wildcard
+   patterns are stored as arrays of patterns. */
+
+
 /* An exclude pattern-options pair.  The options are fnmatch options
ORed with EXCLUDE_* options.  */
 
@@ -63,15 +76,56 @@ struct patopts
 int options;
   };
 
-/* An exclude list, of pattern-options pairs.  */
+/* An array of pattern-options pairs.  */
 
-struct exclude
+struct exclude_pattern
   {
 struct patopts *exclude;
 size_t exclude_alloc;
 size_t exclude_count;
   };
 
+enum exclude_type
+  {
+exclude_hash,/* a hash table of excluded names */
+exclude_pattern  /* an array of exclude patterns */
+  };
+
+struct exclude_segment
+  {
+struct exclude_segment *next;/* next segment in list */
+enum exclude_type type;  /* type of this segment */
+int options; /* common options for this segment */
+union
+{
+  Hash_table *table; /* for type == exclude_hash */
+  struct exclude_pattern pat;/* for type == exclude_pattern */
+} v;
+  };
+
+/* The exclude structure keeps a singly-linked list of exclude segments */
+struct exclude
+  {
+struct exclude_segment *head, *tail;
+  };
+
+/* Return true if str is a fnmatch pattern */
+bool
+is_fnmatch_pattern (const char *str)
+{
+  while (*str)
+{
+  size_t n = strcspn (str, ?*[]);
+  if (str[n] == 0)
+   break;
+  else if (n  0  str[n-1] == '\\')
+   str += n + 1;
+  else
+   return true;
+}
+  return false;
+}
+
 /* Return a newly allocated and empty exclude list.  */
 
 struct exclude *
@@ -80,12 +134,122 @@ new_exclude (void)
   return xzalloc (sizeof *new_exclude ());
 }
 
-/* Free the storage associated with an exclude list.  */
+/* Calculate the hash of string.  */
+static size_t
+string_hasher (void const *data, size_t n_buckets)
+{
+  char const *p = data;
+  return hash_string (p, n_buckets);
+}
+
+/* Ditto, for case-insensitive hashes */
+static size_t
+string_hasher_ci (void const *data, size_t n_buckets)
+{
+  char const *p = data;
+  mbui_iterator_t iter;
+  size_t value = 0;
+
+  for (mbui_init (iter, p); mbui_avail (iter); mbui_advance (iter))
+{
+  mbchar_t m = mbui_cur (iter);
+  wchar_t wc;
+
+  if (m.wc_valid)
+   wc = towlower (m.wc);
+  else
+   wc = *m.ptr;
+
+  value = (value * 31 + wc) % n_buckets;
+}
+
+  return value;
+}
+
+/* compare two strings for equality */
+static bool
+string_compare (void const

Re: test-argp-version-etc

2009-08-03 Thread Sergey Poznyakoff
Hi Simon,

 the self test fails like this when used in a project:

Thanks for noticing.

 How about this patch?

Nice, please push it.

Regards,
Sergey




Re: New module argp-version-etc

2009-06-25 Thread Sergey Poznyakoff
Bruno Haible br...@clisp.org ha escrit:

   - Do you really need *two* array-taking functions?

Yes, I believe so. I could remove one of them, but that would make
the interface more awkward. E.g. retaining only version_etc_ar would mean
extra iteration when called from version_etc_va. On the other hand,
retaining only version_etc_arn will mean that argp_version_setup needs
to compute the number of elements in the array.

   +/* Like version_etc, below, but with the NULL-terminated author list
   +   provided via a variable of type va_list.  */
 
   Ouch! Not only you expect the user to look up the documentation of the
   API inside a long source file, but you also play paper chase with the
   user.

Not me :^) It was the original comment in version_etc.c. I did not touch it.

 Please commit the two module changes as distinct commits in git.

Yes, that was intended. 

Thanks for your feedback. I'll fix those issues and commit the stuff.

Regards,
Sergey




Re: New module argp-version-etc

2009-06-25 Thread Sergey Poznyakoff
Hello,

I have fixed the issues Bruno pointed out in his posting, and committed
the following changes.

Regards,
Sergey


From 3457fcf5632d0411821c6ca61b09c945da9b1063 Mon Sep 17 00:00:00 2001
From: Sergey Poznyakoff g...@gnu.org.ua
Date: Thu, 25 Jun 2009 10:31:56 +0300
Subject: [PATCH] Provide additional interfaces and documentation for 
version-etc module.

* lib/version-etc.c (version_etc_arn, version_etc_ar): New
interfaces.
* lib/version-etc.h (version_etc_arn, version_etc_ar): New
prototypes.
---
 ChangeLog |   10 +
 lib/version-etc.c |  117 +---
 lib/version-etc.h |   30 ++
 3 files changed, 123 insertions(+), 34 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index 8aa5ac0..7405482 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,13 @@
+2009-06-25  Sergey Poznyakoff  g...@gnu.org.ua
+
+   Provide additional interfaces and documentation for version-etc
+   module.
+
+   * lib/version-etc.c (version_etc_arn, version_etc_ar): New
+   interfaces.
+   * lib/version-etc.h (version_etc_arn, version_etc_ar): New
+   prototypes.
+
 2009-06-24  Bruno Haible  br...@clisp.org
 
* m4/lib-link.m4 (AC_LIB_HAVE_LINKFLAGS): Fix description of
diff --git a/lib/version-etc.c b/lib/version-etc.c
index c3b0289..ddac305 100644
--- a/lib/version-etc.c
+++ b/lib/version-etc.c
@@ -34,26 +34,30 @@
 
 enum { COPYRIGHT_YEAR = 2009 };
 
-/* Like version_etc, below, but with the NULL-terminated author list
-   provided via a variable of type va_list.  */
-void
-version_etc_va (FILE *stream,
-   const char *command_name, const char *package,
-   const char *version, va_list authors)
-{
-  size_t n_authors;
+/* The three functions below display the --version information the
+   standard way.
+
+   If COMMAND_NAME is NULL, the PACKAGE is asumed to be the name of
+   the program.  The formats are therefore:
 
-  /* Count the number of authors.  */
-  {
-va_list tmp_authors;
+   PACKAGE VERSION
 
-va_copy (tmp_authors, authors);
+   or
 
-n_authors = 0;
-while (va_arg (tmp_authors, const char *) != NULL)
-  ++n_authors;
-  }
+   COMMAND_NAME (PACKAGE) VERSION.
 
+   The functions differ in the way they are passed author names. */
+
+/* Display the --version information the standard way.
+
+   Author names are given in the array AUTHORS. N_AUTHORS is the
+   number of elements in the array. */
+void
+version_etc_arn (FILE *stream,
+const char *command_name, const char *package,
+const char *version,
+const char * const * authors, size_t n_authors)
+{
   if (command_name)
 fprintf (stream, %s (%s) %s\n, command_name, package, version);
   else
@@ -89,57 +93,64 @@ There is NO WARRANTY, to the extent permitted by law.\n\
   abort ();
 case 1:
   /* TRANSLATORS: %s denotes an author name.  */
-  vfprintf (stream, _(Written by %s.\n), authors);
+  fprintf (stream, _(Written by %s.\n), authors[0]);
   break;
 case 2:
   /* TRANSLATORS: Each %s denotes an author name.  */
-  vfprintf (stream, _(Written by %s and %s.\n), authors);
+  fprintf (stream, _(Written by %s and %s.\n), authors[0], authors[1]);
   break;
 case 3:
   /* TRANSLATORS: Each %s denotes an author name.  */
-  vfprintf (stream, _(Written by %s, %s, and %s.\n), authors);
+  fprintf (stream, _(Written by %s, %s, and %s.\n),
+  authors[0], authors[1], authors[2]);
   break;
 case 4:
   /* TRANSLATORS: Each %s denotes an author name.
 You can use line breaks, estimating that each author name occupies
 ca. 16 screen columns and that a screen line has ca. 80 columns.  */
-  vfprintf (stream, _(Written by %s, %s, %s,\nand %s.\n), authors);
+  fprintf (stream, _(Written by %s, %s, %s,\nand %s.\n),
+  authors[0], authors[1], authors[2], authors[3]);
   break;
 case 5:
   /* TRANSLATORS: Each %s denotes an author name.
 You can use line breaks, estimating that each author name occupies
 ca. 16 screen columns and that a screen line has ca. 80 columns.  */
-  vfprintf (stream, _(Written by %s, %s, %s,\n%s, and %s.\n), authors);
+  fprintf (stream, _(Written by %s, %s, %s,\n%s, and %s.\n),
+  authors[0], authors[1], authors[2], authors[3], authors[4]);
   break;
 case 6:
   /* TRANSLATORS: Each %s denotes an author name.
 You can use line breaks, estimating that each author name occupies
 ca. 16 screen columns and that a screen line has ca. 80 columns.  */
-  vfprintf (stream, _(Written by %s, %s, %s,\n%s, %s, and %s.\n),
-   authors);
+  fprintf (stream, _(Written by %s, %s, %s,\n%s, %s, and %s.\n),
+  authors[0], authors[1], authors[2], authors[3], authors[4],
+  authors[5]);
   break;
 case 7:
   /* TRANSLATORS: Each %s denotes an author

Re: New module argp-version-etc

2009-06-25 Thread Sergey Poznyakoff
Hi Jim,

 Another issue: consistency.  With Bruno's approach, a public function must
 have *no* spec just before its definition, while each private one does.
 I think we all agree that duplicating the spec (before definition and in
 the .h file) is not maintainable.

Unfortunately your mail arrived after I pushed the changes, for I have
added some short descriptions to version-etc.h as well... I hope you would
not mind?

Regards,
Sergey




Re: New module argp-version-etc

2009-06-25 Thread Sergey Poznyakoff
Bruno Haible br...@clisp.org ha escrit:

 typo:assumed
[..]
 A dependency to 'version-etc' is missing. It leads to this error:

Thanks, Bruno.  I've fixed it.

 $ ./gnulib-tool --test argp-version-etc

I ran ./gnulib-tool --test --with-tests argp-version-etc, and it pulled
the missing dependency via modules/argp-version-etc-tests.  That's why I
didn't notice it.

Regards,
Sergey




Re: New module argp-version-etc

2009-06-25 Thread Sergey Poznyakoff
Eric Blake e...@byu.net ha escrit:

 And introduced a bug to plain version_etc clients in the process, with the 
 potential to make --version segfault.  Sorry for not spotting it before you 
 committed:

Oops, it's me who should apologize for not spotting it!

 I will be checking in this patch, if no one else beats me to it.

Yes, please do!

Regards,
Sergey




New module argp-version-etc

2009-06-24 Thread Sergey Poznyakoff
Hello,

The new module argp-version-etc (patch 2) is designed to
facilitate the use of argp and version-etc modules together.
This will ensure uniform version output between several
programs within the same project, and will be useful for
such projects as, for example, GNU Inetutils. 

This new functionality requires some minor changes to the
existing version-etc module (patch 1).

Opinions?

Regards,
Sergey

2009-06-24  Sergey Poznyakoff  g...@gnu.org.ua

Provide additional interfaces for version-etc module.

* lib/version-etc.c (version_etc_arn, version_etc_ar): New
interfaces.
* lib/version-etc.h (version_etc_arn, version_etc_ar): New
prototyples.

diff --git a/lib/version-etc.c b/lib/version-etc.c
index c3b0289..6a51656 100644
--- a/lib/version-etc.c
+++ b/lib/version-etc.c
@@ -34,26 +34,11 @@
 
 enum { COPYRIGHT_YEAR = 2009 };
 
-/* Like version_etc, below, but with the NULL-terminated author list
-   provided via a variable of type va_list.  */
 void
-version_etc_va (FILE *stream,
-   const char *command_name, const char *package,
-   const char *version, va_list authors)
+version_etc_arn (FILE *stream,
+const char *command_name, const char *package,
+const char *version, size_t n_authors, const char *authors[])
 {
-  size_t n_authors;
-
-  /* Count the number of authors.  */
-  {
-va_list tmp_authors;
-
-va_copy (tmp_authors, authors);
-
-n_authors = 0;
-while (va_arg (tmp_authors, const char *) != NULL)
-  ++n_authors;
-  }
-
   if (command_name)
 fprintf (stream, %s (%s) %s\n, command_name, package, version);
   else
@@ -89,57 +74,64 @@ There is NO WARRANTY, to the extent permitted by law.\n\
   abort ();
 case 1:
   /* TRANSLATORS: %s denotes an author name.  */
-  vfprintf (stream, _(Written by %s.\n), authors);
+  fprintf (stream, _(Written by %s.\n), authors[0]);
   break;
 case 2:
   /* TRANSLATORS: Each %s denotes an author name.  */
-  vfprintf (stream, _(Written by %s and %s.\n), authors);
+  fprintf (stream, _(Written by %s and %s.\n), authors[0], authors[1]);
   break;
 case 3:
   /* TRANSLATORS: Each %s denotes an author name.  */
-  vfprintf (stream, _(Written by %s, %s, and %s.\n), authors);
+  fprintf (stream, _(Written by %s, %s, and %s.\n),
+  authors[0], authors[1], authors[2]);
   break;
 case 4:
   /* TRANSLATORS: Each %s denotes an author name.
 You can use line breaks, estimating that each author name occupies
 ca. 16 screen columns and that a screen line has ca. 80 columns.  */
-  vfprintf (stream, _(Written by %s, %s, %s,\nand %s.\n), authors);
+  fprintf (stream, _(Written by %s, %s, %s,\nand %s.\n),
+  authors[0], authors[1], authors[2], authors[3]);
   break;
 case 5:
   /* TRANSLATORS: Each %s denotes an author name.
 You can use line breaks, estimating that each author name occupies
 ca. 16 screen columns and that a screen line has ca. 80 columns.  */
-  vfprintf (stream, _(Written by %s, %s, %s,\n%s, and %s.\n), authors);
+  fprintf (stream, _(Written by %s, %s, %s,\n%s, and %s.\n),
+  authors[0], authors[1], authors[2], authors[3], authors[4]);
   break;
 case 6:
   /* TRANSLATORS: Each %s denotes an author name.
 You can use line breaks, estimating that each author name occupies
 ca. 16 screen columns and that a screen line has ca. 80 columns.  */
-  vfprintf (stream, _(Written by %s, %s, %s,\n%s, %s, and %s.\n),
-   authors);
+  fprintf (stream, _(Written by %s, %s, %s,\n%s, %s, and %s.\n),
+  authors[0], authors[1], authors[2], authors[3], authors[4],
+  authors[5]);
   break;
 case 7:
   /* TRANSLATORS: Each %s denotes an author name.
 You can use line breaks, estimating that each author name occupies
 ca. 16 screen columns and that a screen line has ca. 80 columns.  */
-  vfprintf (stream, _(Written by %s, %s, %s,\n%s, %s, %s, and %s.\n),
-   authors);
+  fprintf (stream, _(Written by %s, %s, %s,\n%s, %s, %s, and %s.\n),
+  authors[0], authors[1], authors[2], authors[3], authors[4],
+  authors[5], authors[6]);
   break;
 case 8:
   /* TRANSLATORS: Each %s denotes an author name.
 You can use line breaks, estimating that each author name occupies
 ca. 16 screen columns and that a screen line has ca. 80 columns.  */
-  vfprintf (stream, _(\
+  fprintf (stream, _(\
 Written by %s, %s, %s,\n%s, %s, %s, %s,\nand %s.\n),
-   authors);
+   authors[0], authors[1], authors[2], authors[3], authors[4],
+   authors[5], authors[6], authors[7]);
   break;
 case 9:
   /* TRANSLATORS: Each %s denotes an author name.
 You can use line breaks, estimating

Re: New module argp-version-etc

2009-06-24 Thread Sergey Poznyakoff
Eric Blake e...@byu.net ha escrit:

 Why'd you drop the comments describing what the method does?

I did not. I simply retained the original comment before version_etc_va.
I should have supplied comments before the two new functions, that's
true. I'll fix this.

 I'd like to see the arguments reversed:
 
 const char *authors[], size_t n_authors

No problem.

  +  for (n_authors = 0;
  +   n_authors  10
  + (authtab[n_authors++] = va_arg (authors, const char *)) != NULL;
  +   n_authors++)
  +;
 
 missing va_end

Is it really necessary here? I believe the caller should call
va_end, because that's the caller who called va_start. Am I missing
something?

  +test-ave (dummy) 0
  +Copyright (C) 2009 Free Software Foundation, Inc.
 
 Are we going to have to update this test every year?  It would be nice to 
 compute the year that should be present, rather than hard-coding it

I thought about it too. But there is no warranty the computed year will
coincide with the COPYRIGHT_YEAR constant from version-etc.c.

Regards,
Sergey




Re: New module argp-version-etc

2009-06-24 Thread Sergey Poznyakoff
Here's the updated patch. It swaps the n_authors and authors arguments,
provides additional comments, removes the year-dependency from the
test case and adds a call to va_end in version_etc.

Regards,
Sergey

2009-06-24  Sergey Poznyakoff  g...@gnu.org.ua

	Provide additional interfaces for version-etc module.
	
	* lib/version-etc.c (version_etc_arn, version_etc_ar): New
	interfaces.
	* lib/version-etc.h (version_etc_arn, version_etc_ar): New
	prototypes.

	Implement argp-version-etc module.

	* lib/argp-version-etc.c: New file.
	* lib/argp-version-etc.h: New file.
	* tests/test-ave.c: New test program.
	* tests/test-ave-2.sh: New test program

diff --git a/lib/argp-version-etc.c b/lib/argp-version-etc.c
new file mode 100644
index 000..52cb21b
--- /dev/null
+++ b/lib/argp-version-etc.c
@@ -0,0 +1,22 @@
+#include config.h
+#include version-etc.h
+#include argp.h
+#include argp-version-etc.h
+
+static const char *program_canonical_name;
+static const char **program_authors;
+
+static void
+version_etc_hook (FILE *stream, struct argp_state *state)
+{
+  version_etc_ar (stream, program_canonical_name, PACKAGE_NAME, VERSION,
+		  program_authors);
+}
+
+void
+argp_version_setup (const char *name, const char **authors)
+{
+  argp_program_version_hook = version_etc_hook;
+  program_canonical_name = name;
+  program_authors = authors;
+}
diff --git a/lib/argp-version-etc.h b/lib/argp-version-etc.h
new file mode 100644
index 000..fdad84a
--- /dev/null
+++ b/lib/argp-version-etc.h
@@ -0,0 +1,30 @@
+/* Version hook for Argp.
+   Copyright (C) 2009 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
+   the Free Software Foundation; either version 3 of the License, 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 General Public License for more details.
+
+   You should have received a copy of the GNU General Public License
+   along with this program.  If not, see http://www.gnu.org/licenses/.  */
+
+#ifndef _ARGP_VERSION_ETC_H
+#define _ARGP_VERSION_ETC_H
+
+#ifdef __cplusplus
+extern C {
+#endif
+
+extern void argp_version_setup (const char *name, const char **authors);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* _ARGP_VERSION_ETC_H */
diff --git a/lib/version-etc.c b/lib/version-etc.c
index c3b0289..0454ac5 100644
--- a/lib/version-etc.c
+++ b/lib/version-etc.c
@@ -34,26 +34,18 @@
 
 enum { COPYRIGHT_YEAR = 2009 };
 
-/* Like version_etc, below, but with the NULL-terminated author list
-   provided via a variable of type va_list.  */
+/* Display command and package names, package version,
+   short GPLv3+ notice, and N_AUTHORS names from the 
+   AUTHORS array.
+
+   For more info, see the comment before version_etc
+   function, below.
+*/
 void
-version_etc_va (FILE *stream,
-		const char *command_name, const char *package,
-		const char *version, va_list authors)
+version_etc_arn (FILE *stream,
+		 const char *command_name, const char *package,
+		 const char *version, const char *authors[], size_t n_authors)
 {
-  size_t n_authors;
-
-  /* Count the number of authors.  */
-  {
-va_list tmp_authors;
-
-va_copy (tmp_authors, authors);
-
-n_authors = 0;
-while (va_arg (tmp_authors, const char *) != NULL)
-  ++n_authors;
-  }
-
   if (command_name)
 fprintf (stream, %s (%s) %s\n, command_name, package, version);
   else
@@ -89,57 +81,64 @@ There is NO WARRANTY, to the extent permitted by law.\n\
   abort ();
 case 1:
   /* TRANSLATORS: %s denotes an author name.  */
-  vfprintf (stream, _(Written by %s.\n), authors);
+  fprintf (stream, _(Written by %s.\n), authors[0]);
   break;
 case 2:
   /* TRANSLATORS: Each %s denotes an author name.  */
-  vfprintf (stream, _(Written by %s and %s.\n), authors);
+  fprintf (stream, _(Written by %s and %s.\n), authors[0], authors[1]);
   break;
 case 3:
   /* TRANSLATORS: Each %s denotes an author name.  */
-  vfprintf (stream, _(Written by %s, %s, and %s.\n), authors);
+  fprintf (stream, _(Written by %s, %s, and %s.\n),
+	   authors[0], authors[1], authors[2]);
   break;
 case 4:
   /* TRANSLATORS: Each %s denotes an author name.
 	 You can use line breaks, estimating that each author name occupies
 	 ca. 16 screen columns and that a screen line has ca. 80 columns.  */
-  vfprintf (stream, _(Written by %s, %s, %s,\nand %s.\n), authors);
+  fprintf (stream, _(Written by %s, %s, %s,\nand %s.\n),
+	   authors[0], authors[1], authors[2], authors[3]);
   break;
 case 5:
   /* TRANSLATORS: Each %s denotes an author name.
 	 You can use line breaks, estimating that each author name occupies
 	 ca. 16 screen columns

Re: New module argp-version-etc

2009-06-24 Thread Sergey Poznyakoff
Eric Blake e...@byu.net ha escrit:

 One alternative is to massage the actual output through sed to match the 
 expected output, regardless of the year from version-etc.c.  Such as:
 
 ./test-ave --version | sed 's/(C) [0-9][0-9][0-9][0-9]/(C) 2009/' \
   | diff -c $TMP - || ERR=1 

That's exactly what I did in my updated patch :^)

Regards,
Sergey




Re: dropping setuid/setgid privileges

2009-06-11 Thread Sergey Poznyakoff
Bruno Haible br...@clisp.org ha escrit:

 What is the use-case that you are considering? A setuid/setgid executable,
 or an executable run by root?

I was considering an executable run by root.

 And what task does it do, related to the user's data and devices?

Retaining supplementary is often necessary for the program to be
able to access various files. I use this approach in Mailfromd
(http://www.gnu.org.ua/software/mailfromd).

idpriv_drop_grp (size_t ngrp, gid_t *groups)
 
 Should that drop the specified supplementary groups (and keep the rest),
 or keep the specified supplementary groups?

It should keep only the specified supplementary groups and
drop the rest. If ngrp==0 it should drop all supplementary
groups.

Regards,
Sergey




Re: dropping setuid/setgid privileges

2009-06-10 Thread Sergey Poznyakoff
James Youngman j...@gnu.org ha escrit:

 It's possible that one of the process's supplementary groups is
 privileged.   So we may also need to do something like this:
 
 #if HAVE_SETGROUPS
   /* Use of setgroups() is restricted to root only. */
   if (0 =3D=3D geteuid())
 {
   /* We're either root or running setuid-root. */
   gid_t groups[1];
   groups[0] =3D gid;
   if (0 !=3D setgroups(1u, groups))

Yes, but on the other hand the caller might need to retain some
supplementary groups when dropping privileges. Perhaps it is worth
to provide a mechanism for that too? Something like

  idpriv_drop_grp (size_t ngrp, gid_t *groups)

Regards,
Sergey




Re: open_safer on amd64

2009-05-21 Thread Sergey Poznyakoff
Bruno Haible br...@clisp.org ha escrit:

 You can ignore this warning. The code is fine.

Ah, OK.  Thank you.  Perhaps it merits mentioning in the docs,
to avoid further reports of this kind?

Regards,
Sergey




Re: open_safer on amd64

2009-05-21 Thread Sergey Poznyakoff
Eric Blake e...@byu.net ha escrit:

 In earlier versions of POSIX, the intent was that mode_t could
 be narrower than int, and that all programmers had to use only symbolic
 constants in that argument.

As a side note, on that particular architecture, mode_t is indeed
narrower than int.

Regards,
Sergey




[PATCH] Add optional silent-rules support

2009-05-21 Thread Sergey Poznyakoff
Hello,

How about the following patch, which adds support for `silent-rules'
mode introduced in Automake 1.11:

* build-aux/bootstrap (slurp): Add silent rule support to $gnulib_mk,
if required by the configure.ac.
---
 build-aux/bootstrap |   49 +
 1 files changed, 49 insertions(+), 0 deletions(-)

diff --git a/build-aux/bootstrap b/build-aux/bootstrap
index 2087bab..054ad38 100755
--- a/build-aux/bootstrap
+++ b/build-aux/bootstrap
@@ -471,6 +471,51 @@ version_controlled_file() {
   test $found = yes
 }
 
+# AWK program to convert a Makefile(.am) file rules to Automake 1.11
+# silent mode.
+silent_rules_prog='
+# state = 0 - outside rules
+# state = 1 - first line inside a rule
+# state = 2 - subsequent lines inside a rule
+# cont  = 1 - this line is a continuation of the previous one
+
+# Print comment lines
+/^[ \t]*#/ { print; next }
+# Start of a rule
+/^[^ \t].*:/ { print; state = 1; cont = 0; next }
+# First action within the rule
+state == 1  /^\t/ {
+   # Print silent rules without changes.  The second match
+   # is necessary to handle @VAR@ substitutions.
+   if (match($1, /^@/)  !match($1, /@$/))
+   print
+   else {
+   sub(/^\t[\t ]*/,)
+   print \t$(AM_V_GEN) $0
+   }
+   cont = match($0, /\\$/)
+   state = 2
+   next
+}
+# All non-continuation lines within the rule are prefixed
+# with $(AM_V_at).
+state == 2  /^\t/  NF  0 {
+   if (!cont) {
+   sub(/^\t[\t ]*/,)
+   print \t$(AM_V_at) $0
+   } else
+   print
+   cont = match($0, /\\$/)
+   next
+}
+# Everything else is output verbatim
+{ print }'
+
+silent_rules=yes
+grep 'AM_SILENT_RULES' configure.ac  /dev/null ||
+  grep '^[ ]*AM_INIT_AUTOMAKE([^)][^)]*silent-rules' configure.ac  
/dev/null ||
+  silent_rules=no
+
 slurp() {
   for dir in . `(cd $1  find * -type d -print)`; do
 copied=
@@ -492,6 +537,10 @@ slurp() {
  rm -f $dir/$gnulib_mk 
  sed $remove_intl $1/$dir/$file $dir/$gnulib_mk
}
+   if test $silent_rules = yes; then
+ awk $silent_rules_prog $dir/$gnulib_mk  $dir/${gnulib_mk}-t 
+ mv $dir/${gnulib_mk}-t $dir/${gnulib_mk}
+   fi
   elif { test ${2+set} = set  test -r $2/$dir/$file; } ||
   version_controlled_file $dir $file; then
echo $0: $dir/$file overrides $1/$dir/$file
-- 
1.6.0





Re: [PATCH] Add optional silent-rules support

2009-05-21 Thread Sergey Poznyakoff
Hi Ralf,

 Can gnulib-tool create
   target1 target2 ... \
 targetN : prereq1 ... \
   prereqN ; rule-command
 
 rules?

Well, quick grep through modules/* shows that so far no module
generates such rules.  But in theory it is possible.  I'll take
it into account, then.

 Shouldn't that be
   if (match($1, /^@/)  !match($1, /@$/))
 
 so that it won't treat
   @ command
 
 wrongly?

Yes, indeed.  Nice catch.

 Also, this ignores the other possible command prefixes,
 '-' and '+', which can be mixed and matched together with '@' in any
 order.  But that probably doesn't happen in the files this targets.

Yes, so far it does not.  But probably it should be addressed, too.

 IIUC then you remove any extra indentation; why not something like
   sub(/^\t[\t ]*/, $(AM_V_GEN))
   print

Yes, that's a better approach.  Thanks.

 FWIW the awk script is not portable to ancient awk, such as found on
 Solaris.

Hmm, but why?  I didn't use any GNU awk extensions, did I?

Regards,
Sergey






Re: [PATCH] Add optional silent-rules support

2009-05-21 Thread Sergey Poznyakoff
Ralf Wildenhues ralf.wildenh...@gmx.de ha escrit:

 - the awk script won't detect if there are already $(AM_V_...) variables
   present in the rules,

Yes, that's intended.  It was supposed that silent-rules variables can
not appear in the input.

Regards,
Sergey




Re: [PATCH] Add optional silent-rules support

2009-05-21 Thread Sergey Poznyakoff
Ralf Wildenhues ralf.wildenh...@gmx.de ha escrit:

 Not as far as I can see.  Solaris /bin/awk doesn't have the match and
 sub functions, and has several other limitations over POSIX awk.

Ah, I see.

 On Solaris, you should be able to use nawk or /usr/xpg4/bin/awk.

OK, then using ${AWK-awk} should do to help in this case.

Regards,
Sergey




open_safer on amd64

2009-05-20 Thread Sergey Poznyakoff
Hello,

When trying to compile open-safer.c on amd64 I get:

open-safer.c: In function 'open_safer':
open-safer.c:46: warning: 'mode_t' is promoted to 'int' when passed
through '...'
open-safer.c:46: warning: (so you should pass 'int' not 'mode_t' to
'va_arg')
open-safer.c:46: note: if this code is reached, the program will abort

This is gnulib v0.0.2009-5a128.  The compiler used was gcc v. 4.2.1.

Regards,
Sergey




Re: gnulib.pot versioning scheme

2009-03-27 Thread Sergey Poznyakoff
Bruno Haible br...@clisp.org ha escrit:

 gnulib-1836.86a37.1.1
 
 If you do this, you can never again switch to a different versioning
 scheme.

Not quite so. What I meant is that the part between `-' and `1.1' is
to be ignored (it cannot be used for ordering anyway). In this case
I see no difficulty in eventual switching to another versioning scheme.

Regards,
Sergey




Re: gnulib.pot versioning scheme

2009-03-26 Thread Sergey Poznyakoff
Sergey Poznyakoff wrote:

 I am going to submit the updated gnulib.pot to TP.  Before this,
 I'd like to change its versioning scheme so that it coincides with the
 version reported by `gnilib-tool --version'.  E.g. this potfile will be
 named gnulib-0.0.1991-dbebf.pot.

After discussing this with Erwin (the TP coordinator), I had to abandon
the idea, because the TP robot assumes that version numbers are growing
from version to version and relies on this for sorting. Given
this, I'll continue using the old numbering scheme for potfiles
(gnulib-major.minor.pot), but before submitting the potfile, I'll create
a tag TP-major.minor, so we can keep track of which Git commit it
corresponds to.

Opinions?

Regards,
Sergey




Re: gnulib.pot versioning scheme

2009-03-26 Thread Sergey Poznyakoff
Bruno Haible br...@clisp.org ha escrit:

 How about changing the versioning scheme to
   gnulib-1.1.2009.03.26
 or
   gnulib-1.1.1836.86a37

It would be better to place TP version at the end, as in:

   gnulib-1836.86a37.1.1

This should work with the TP software.   

 Could you also generate and publish a source snapshot when you create
 a gnulib POT file?

OK.

Regards,
Sergey




gnulib.pot versioning scheme

2009-03-20 Thread Sergey Poznyakoff
Hello,

I am going to submit the updated gnulib.pot to TP.  Before this,
I'd like to change its versioning scheme so that it coincides with the
version reported by `gnilib-tool --version'.  E.g. this potfile will be
named gnulib-0.0.1991-dbebf.pot.  Does it seem a good idea?

Regards,
Sergey




Re: [Translation-team-de] German translations for man-db and gnulib

2009-03-19 Thread Sergey Poznyakoff
Colin Watson cjwat...@debian.org ha escrit:

 Indeed, http://translationproject.org/POT-files/gnulib-1.1.pot is
 looking a bit stale. Could somebody on bug-gnulib update the POT file
 held by the TP, please?

That's my fault. I'll update it today.

Regards,
Sergey




[PATCH] Specify archive suffixes to announce-gen

2009-03-05 Thread Sergey Poznyakoff
Hello,

The enclosed patch add to announce-gen a new option, --archive-suffix,
which allows to specify new archive suffixes. For example:

  announce-gen --archive-suffix cpio.gz --archive-suffix shar.gz

It is useful for such projects as GNU tar, which is distributed in a
wider set of archive formats.

OK to push?

Regards,
Sergey

---
 build-aux/announce-gen |   21 +++--
 1 files changed, 11 insertions(+), 10 deletions(-)

diff --git a/build-aux/announce-gen b/build-aux/announce-gen
index f6affab..d18b2f4 100755
--- a/build-aux/announce-gen
+++ b/build-aux/announce-gen
@@ -1,7 +1,7 @@
 #!/usr/bin/perl -w
 # Generate a release announcement message.
 
-my $VERSION = '2009-03-02 07:45'; # UTC
+my $VERSION = '2009-03-05 09:52'; # UTC
 # The definition above must lie within the first 8 lines in order
 # for the Emacs time-stamp write hook (at end) to update it.
 # If you change this file with Emacs, please let the write hook
@@ -34,7 +34,8 @@ use POSIX qw(strftime);
 (my $ME = $0) =~ s|.*/||;
 
 my %valid_release_types = map {$_ = 1} qw (alpha beta major);
-
+my @archive_suffixes = ('tar.gz', 'tar.bz2', 'tar.lzma', 'tar.xz');
+  
 END
 {
   # Nobody ever checks the status of print()s.  That's okay, because
@@ -97,7 +98,8 @@ The following are optional:
 in the gnulib source directory.
 required if gnulib is in TOOL_LIST.
--no-print-checksums do not emit MD5 or SHA1 checksums
-
+   --archive-suffix=SUF add SUF to the list of archive suffixes
+   
--help display this help and exit
--version  output version information and exit
 
@@ -391,6 +393,7 @@ sub get_tool_versions ($$)
  'bootstrap-tools=s'  = \$bootstrap_tools,
  'gnulib-version=s'   = \$gnulib_version,
  'print-checksums!'   = \$print_checksums_p,
+ 'archive-suffix=s'   = \...@archive_suffixes,
 
  help = sub { usage 0 },
  version = sub { print $ME version $VERSION\n; exit },
@@ -428,16 +431,14 @@ sub get_tool_versions ($$)
 and usage 1;
 
   my $my_distdir = $package_name-$curr_version;
-  my $tgz = $my_distdir.tar.gz;
-  my $tbz = $my_distdir.tar.bz2;
-  my $lzma = $my_distdir.tar.lzma;
-  my $xz = $my_distdir.tar.xz;
 
   my $xd = $package_name-$prev_version-$curr_version.xdelta;
 
-  my @tarballs = grep {-f $_} ($tgz, $tbz, $lzma, $xz);
+  my @candidates = map { $my_distdir.$_ } @archive_suffixes;
+  my @tarballs = grep {-f $_} @candidates;
+  
   @tarballs
-or die $ME: none of $tgz, $tbz, $lzma or $xz were found\n;
+or die $ME: none of  . join(', ', @candidates) .  were found\n;
   my @sizable = @tarballs;
   -f $xd
 and push @sizable, $xd;
@@ -475,7 +476,7 @@ the corresponding file (without the .sig suffix) is intact. 
 First,
 be sure to download both the .sig file and the corresponding tarball.
 Then, run a command like this:
 
-  gpg --verify $tgz.sig
+  gpg --verify $tarballs[0].sig
 
 If that command fails because you don't have the required public key,
 then run this command to import it:
-- 
1.6.0





Re: [PATCH] Specify archive suffixes to announce-gen

2009-03-05 Thread Sergey Poznyakoff
Jim Meyering j...@meyering.net ha escrit:

 Sure, that looks fine.
 But please remove the trailing blanks first.

Done.

Regards,
Sergey




Re: url's in --help output

2009-02-01 Thread Sergey Poznyakoff
Ben Asselstine benasselst...@gmail.com ha escrit:

 On Sat, Jan 31, 2009 at 5:22 PM, Karl Berry k...@freefriends.org wrote:
 The ... markup is helpful when the URL is broken into two lines,
 
 
 Let's not forget about argp.  Here's a patch to sync it to the new
 format.

That would break too many existing programs. I'd rather use the attached
patch, which would not require any changes in the user code.
Although, frankly speaking, I'm not sure it is necessary, especially
given Karl's and Bruno's feedback on that subject.

Regards,
Sergey

diff --git a/lib/argp-help.c b/lib/argp-help.c
index a9843c0..7d5030e 100644
--- a/lib/argp-help.c
+++ b/lib/argp-help.c
@@ -1704,11 +1704,20 @@ Try `%s --help' or `%s --usage' for more information.\n),
 
   if ((flags  ARGP_HELP_BUG_ADDR)  argp_program_bug_address)
 {
+  const char *addr = argp_program_bug_address;
+  size_t len = strlen (addr);
+  
   if (anything)
 	__argp_fmtstream_putc (fs, '\n');
+
+  if (addr[0] == ''  addr[len-1] == '')
+	{
+	  addr ++;
+	  len -= 2;
+	}
   __argp_fmtstream_printf (fs, dgettext (argp-argp_domain,
-	 Report bugs to %s.\n),
- 			   argp_program_bug_address);
+	 Report bugs to %.*s.\n),
+ 			   len, addr);
   anything = 1;
 }
 


Re: [gnu-prog-discuss] url's in --help output

2009-01-27 Thread Sergey Poznyakoff
Simon Josefsson si...@josefsson.org ha escrit:

 Ah, interesting, I wasn't aware of this feature.  Do I as maintainer of
 projects using gnulib have to do anything special to make this usable
 for translators?

Nothing special, only make sure the files imported from gnulib are
listed in your po/POTFILES.in.

Regards,
Sergey





Re: [gnu-prog-discuss] url's in --help output

2009-01-23 Thread Sergey Poznyakoff
Karl Berry k...@freefriends.org ha escrit:

 However, as far as I know there isn't a gnulib translation domain that
 
 There actually is, although I admit I don't know how the messages get
 integrated into the gnulib-using packages:
 http://translationproject.org/domain/gnulib.html

It is a compendium domain, and is used by translators when preparing
their .po files. The translator gets the gnulib.po file from the
corresponding language team and incorporates it into his $project.po by
using msgcat+msgmerge. 

Regards,
Sergey




set_program_name behavior

2009-01-14 Thread Sergey Poznyakoff
Hello,

The behavior of set_program_name differs depending on whether argv[0]
refers to a libtool script (*/.libs/lt-*) or to a usual binary. In the first
case, the function strips off all directory components and the `lt-'
prefix, and assigns the result to program_name. In the second case,
however, it does nothing and assings unchanged argv[0] to
program_name. Is this intentional? It would be logical if it removed
directory components in both cases.

Regards,
Sergey




Re: Alan Hourihane: [bug #24687] implicit usage of mbsinit mbrtowc

2008-12-22 Thread Sergey Poznyakoff
Bruno Haible br...@clisp.org ha escrit:

 This is done.

Thanks, Bruno!

Regards,
Sergey




Re: Alan Hourihane: [bug #24687] implicit usage of mbsinit mbrtowc

2008-10-31 Thread Sergey Poznyakoff
Hi Bruno,

 The problem is that texinfo's info.h includes mbiter.h unconditionally,
 whereas the module description in gnulib specifies this:

Ah, that's my fault. 

 Now I see that you have 9 functions in
 texinfo/info/{display.c,session.c,window.c} which use the mbiter
 facility unconditionally, and you probably have no  
 interest in adding fallback code for older systems for each of these
 functions. 

Sure, I'd like to avoid this.

 I'll therefore extend the modules in a way that they work also on older
 systems without HAVE_MBRTOWC.
 
 Something like this. Probably also adding replacements for btowc and mbrtowc.

Thanks, that will greatly help. Could you please push these changes?

Regards,
Sergey




bootstrap for SVN

2008-03-11 Thread Sergey Poznyakoff
Hello,

I have installed the following change to make bootstrap work better with
SVN repositories:

diff --git a/build-aux/bootstrap b/build-aux/bootstrap
index cf6b73b..1a24e82 100755
--- a/build-aux/bootstrap
+++ b/build-aux/bootstrap
@@ -415,6 +415,8 @@ version_controlled_file() {
 grep '^/[^/]*/[0-9]'  /dev/null  found=yes
   elif test -d .git; then
 git rm -n $dir/$file  /dev/null 21  found=yes
+  elif test -d .svn; then
+svn log -r HEAD $dir/$file  /dev/null 21  found=yes  
   else
 echo $0: no version control for $dir/$file? 2
   fi

Regards,
Sergey   




Minor change to m4/argp.m4

2008-02-29 Thread Sergey Poznyakoff
Hello,

I have installed the following patch:

2008-02-29  Sergey Poznyakoff  [EMAIL PROTECTED]

* m4/argp.m4 (gl_ARGP): Use AC_TRY_LINK to test
if program_invocation_name and program_invocation_short_name are
present.

diff --git a/m4/argp.m4 b/m4/argp.m4
index 77f1510..80cb72f 100644
--- a/m4/argp.m4
+++ b/m4/argp.m4
@@ -32,20 +32,20 @@ AC_DEFUN([gl_ARGP],
   # be defined and other not, I prefer to stay on the safe side and to
   # test each one separately.
   AC_MSG_CHECKING(whether program_invocation_name is defined)
-  AC_TRY_COMPILE([#include argp.h],
- [ program_invocation_name = test; ],
- [ AC_DEFINE(HAVE_PROGRAM_INVOCATION_NAME,1,
-   [Define if program_invocation_name is defined])
-   AC_MSG_RESULT(yes)],
- [ AC_MSG_RESULT(no)] )
+  AC_TRY_LINK([#include argp.h],
+  [ program_invocation_name = test; ],
+  [ AC_DEFINE(HAVE_PROGRAM_INVOCATION_NAME,1,
+ [Define if program_invocation_name is defined])
+ AC_MSG_RESULT(yes)],
+  [ AC_MSG_RESULT(no)] )
 
   AC_MSG_CHECKING(whether program_invocation_short_name is defined)
-  AC_TRY_COMPILE([#include argp.h],
- [ program_invocation_short_name = test; ],
- [ AC_DEFINE(HAVE_PROGRAM_INVOCATION_SHORT_NAME,1,
-   [Define if program_invocation_short_name is defined])
-   AC_MSG_RESULT(yes)],
- [ AC_MSG_RESULT(no)] )
+  AC_TRY_LINK([#include argp.h],
+  [ program_invocation_short_name = test; ],
+  [ AC_DEFINE(HAVE_PROGRAM_INVOCATION_SHORT_NAME,1,
+ [Define if program_invocation_short_name is defined])
+ AC_MSG_RESULT(yes)],
+  [ AC_MSG_RESULT(no)] )
 
   AC_CHECK_DECLS_ONCE([clearerr_unlocked])
   AC_CHECK_DECLS_ONCE([feof_unlocked])




Re: Configurable source_base et al. in bootstrap

2008-02-28 Thread Sergey Poznyakoff
Hello,

In the absense of any objections, I have installed the following
changes:

2008-02-28  Sergey Poznyakoff  [EMAIL PROTECTED]

* build-aux/bootstrap (source_base, m4_base)
(doc_base, tests_base): New variables.
(gnulib_tool_options): Do not hardcode base
directories, use the above variables instead.

diff --git a/build-aux/bootstrap b/build-aux/bootstrap
index 6fa1553..87a2798 100755
--- a/build-aux/bootstrap
+++ b/build-aux/bootstrap
@@ -96,6 +96,11 @@ package=`sed -n $extract_package_name configure.ac` || exit
 gnulib_name=lib$package
 
 build_aux=build-aux
+source_base=lib
+m4_base=m4
+doc_base=doc
+tests_base=tests
+
 # Extra files from gnulib, which override files from other sources.
 gnulib_extra_files=
$build_aux/install-sh
@@ -490,11 +495,11 @@ gnulib_tool_options=\
  --import\
  --no-changelog\
  --aux-dir $bt/$build_aux\
- --doc-base $bt/doc\
+ --doc-base $bt/$doc_base\
  --lib $gnulib_name\
- --m4-base $bt/m4/\
- --source-base $bt/lib/\
- --tests-base $bt/tests\
+ --m4-base $bt/$m4_base/\
+ --source-base $bt/$source_base/\
+ --tests-base $bt/$tests_base\
  --local-dir $local_gl_dir\
  $gnulib_tool_option_extras\
 

Regards,
Sergey
   





Configurable source_base et al. in bootstrap

2008-02-08 Thread Sergey Poznyakoff
Hello,

Some projects place gnulib sources into a directory named other than
`lib'. Therefore, I propose the following changes (m4_base and others
are added for the sake of completeness):

diff --git a/build-aux/bootstrap b/build-aux/bootstrap
index 6fa1553..87a2798 100755
--- a/build-aux/bootstrap
+++ b/build-aux/bootstrap
@@ -96,6 +96,11 @@ package=`sed -n $extract_package_name configure.ac` || exit
 gnulib_name=lib$package
 
 build_aux=build-aux
+source_base=lib
+m4_base=m4
+doc_base=doc
+tests_base=tests
+
 # Extra files from gnulib, which override files from other sources.
 gnulib_extra_files=
$build_aux/install-sh
@@ -490,11 +495,11 @@ gnulib_tool_options=\
  --import\
  --no-changelog\
  --aux-dir $bt/$build_aux\
- --doc-base $bt/doc\
+ --doc-base $bt/$doc_base\
  --lib $gnulib_name\
- --m4-base $bt/m4/\
- --source-base $bt/lib/\
- --tests-base $bt/tests\
+ --m4-base $bt/$m4_base/\
+ --source-base $bt/$source_base/\
+ --tests-base $bt/$tests_base\
  --local-dir $local_gl_dir\
  $gnulib_tool_option_extras\
 

Regards,
Sergey
 




Re: [Bug-tar] Wildcards do not match invalid characters

2008-02-07 Thread Sergey Poznyakoff
jlh [EMAIL PROTECTED] ha escrit:

 Ok, here's an update.  I could track down the cause of this
 problem.  In order to match file names to patterns, tar uses the
 fnmatch(3), which is provided by glibc.  This happens in
 lib/exclude.c:149:exclude_fnmatch().  fnmatch() is documented to
 return 0 on a successful match, FNM_NOMATCH (defined to be 1) on a
 not-match, and anything else on error.  exclude_fnmatch() only
 compares the return value to 0 and thus treats a non-match and an
 error the same way.  The particular problem I'm experiencing
 triggered an error and fnmatch() indeed returns -1, which means an
 error happened and perror() says Invalid or incomplete multibyte
 or wide character.  The message is correct, since the byte is
 invalid in utf8, but I was under the impression that a path
 component may consist of any sequence of non-nul, non-slash bytes.
 Since fnmatch() is specially aimed at matching paths I would think
 it should also handle the cases where a path component contains
 arbitrary bytes.  I've been able to reproduce this error as a
 stand-alone small test-case that calls fnmatch(), so this is not a
 tar problem anymore (excepted that tar doesn't check for errors).
 I will take it to the glibc list.

Thanks for reporting. I am not sure what exclude_fnmatch is supposed
to return on error, since it returns bool, so I'm CC-ing this to
[EMAIL PROTECTED] 
 
 One other comment: I also noticed that tar makes the call to
 fnmatch with the flag value 0x5008 in this particular case.
 The low bit corresponds to the flag FNM_LEADING_DIR, but the two
 high bits have no meaning to fnmatch() as far as I can see,
 they're only used by tar itself for internal use.  Does it say
 somewhere that one may set undefined bits in flags and expect
 things to still work?

It works with fnmatch from gnulib, but I agree that it is a
risky thing to do with an arbitrary third-party fnmatch implementation. 

Regards,
Sergey 




bootstrap: copy failure

2007-11-18 Thread Sergey Poznyakoff
Bootstrap reports

cp: cannot create regular file `lib/uniwidth/cjk.h-t': No such file or
directory

The following patch fixes it:

diff --git a/build-aux/bootstrap b/build-aux/bootstrap
index 0e2bd34..278c10b 100755
--- a/build-aux/bootstrap
+++ b/build-aux/bootstrap
@@ -366,6 +367,11 @@ cp_mark_as_generated()
   *)  c1= ; c2= ;;
 esac
 
+dst_dir=`dirname $cp_dst`
+if ! test -d $dst_dir; then
+  mkdir -p $dst_dir
+fi
+
 if test -z $c1; then
   cmp -s $cp_src $cp_dst || {
echo $0: cp -f $cp_src $cp_dst 

Regards,
Sergey





Re: new gnulib admin?

2007-09-30 Thread Sergey Poznyakoff
Bruno Haible [EMAIL PROTECTED] ha escrit:

 I propose to make Eric Blake an admin of the gnulib project at
 http://savannah.gnu.org/projects/gnulib.

Agreed.

Regards,
Sergey




Re: POTFILES.in updates?

2007-07-19 Thread Sergey Poznyakoff
Bruno Haible [EMAIL PROTECTED] ha escrit:

   - Install separate .mo files for the part from gnulib.
 
 The first option would minimize system calls at runtime, but is harder to
 put in place, because PO file handling is not supported by automake.
 The second option can be implemented completely in gnulib. This patch
 adds a --po-base option; when specified a po/ directory for the gnulib
 part is created and populated with the PO files from the translation project.

In that case the `_' macro for gnulib has to be changed to

#define _(s) dgettext(gnulib,s)

Regards,
Sergey




Re: POTFILES.in updates?

2007-07-19 Thread Sergey Poznyakoff
Bruno Haible [EMAIL PROTECTED] ha escrit:

 Your updates have apparently not been registered:
http://translationproject.org/POT-files/gnulib-1.0.pot
 is still from 2005-09-30.
 
 Can you write to coordinator at translationproject '.' org to see where's
 the problem?

Done. I expect the things to get updated today.

Regards,
Sergey




Re: POTFILES.in updates?

2007-07-19 Thread Sergey Poznyakoff
Eric Blake [EMAIL PROTECTED] ha escrit:

 Not to mention that not all of gnulib's uses occur with the _ macro - for
 example, xstrtol.h currently calls gettext directly, rather than going
 through a macro, so that it won't pollute the user's namespace with a
 conflicting _ macro.

Yes, indeed.  After all I believe we should give package maintainers the
freedom to decide whether they want gnulib msgids to be merged into
their project's potfile or to be handled separately as Bruno
proposed. I, for one, would certainly prefer the former.

Regards,
Sergey




Re: POTFILES.in updates?

2007-07-18 Thread Sergey Poznyakoff
Bruce Korb [EMAIL PROTECTED] ha escrit:

 Would it make sense to simply provide the .po fragments

Actually, that's what we are doing now. The gnulib textual domain is 
registered at TP and I update gnulib.pot file there from time to
time. Moreover, quite a few translations for it are already available.

The provided localizations serve as a compendium for project
translators, who are supposed to download the corresponding version of
gnulib.po for their language and run msgmerge to incorporate the
translations into their localization.

Nevertheless, that does not change the fact that a project's
POTFILES.in must contain the msgids from gnulib.pot, otherwise msgmerge
won't be able to do its job. So, Eric's proposition seems very important
to me.

Regards,
Sergey





Re: bootstrap: TP urls changed

2007-07-05 Thread Sergey Poznyakoff
I have installed the following patch:

2007-07-05  Sergey Poznyakoff  [EMAIL PROTECTED]

* build-aux/bootstrap (TP_URL,get_translations): Update to use
the new TP address.
(usage): Fix typo
(gnulib_mk): New variable.


Index: build-aux/bootstrap
===
RCS file: /cvsroot/gnulib/gnulib/build-aux/bootstrap,v
retrieving revision 1.8
diff -p -u -r1.8 bootstrap
--- build-aux/bootstrap 20 Jun 2007 11:56:14 -  1.8
+++ build-aux/bootstrap 5 Jul 2007 08:20:01 -
@@ -52,7 +52,7 @@ Options:
  --cvs-user=USERNAME  Set the username to use when checking out
   sources from the gnulib repository.
 
-If the file .bootstrap.conf exists in the current working directory, its
+If the file bootstrap.conf exists in the current working directory, its
 contents are read as shell variables to configure the bootstrap.
 
 Running without arguments will suffice in most cases.
@@ -61,6 +61,9 @@ Running without arguments will suffice i
 
 # Configuration.
 
+# Name of the Makefile.am
+gnulib_mk=gnulib.mk
+
 # List of gnulib modules needed.
 gnulib_modules=
 
@@ -69,8 +72,7 @@ gnulib_files=
 
 # Translation Project URL, for the registry of all projects
 # and for the translation-team master directory.
-TP_URL='http://www.iro.umontreal.ca/translation/registry.cgi?domain='
-TP_PO_URL='http://www.iro.umontreal.ca/translation/teams/PO/'
+TP_URL=http://translationproject.org/latest/;
 
 extract_package_name='
   /^AC_INIT(/{
@@ -246,31 +248,12 @@ get_translations() {
   ?*)
 echo $0: getting translations into $subdir for $domain... 
 
-(cd $subdir  rm -f dummy `ls | sed -n '/\.gmo$/p; /\.po/p'`) 
-$WGET_COMMAND -O $subdir/$domain.html $TP_URL$domain 
-
-sed -n 
's|.*http://[^]*/translation/teams/PO/\([^/]*\)/'$domain'-\([^/]*\)\.[^.]*\.po.*|\1.\2|p'
 $subdir/$domain.html |
-sort -k 1,1 -k 2,2n -k2,2 -k3,3n -k3,3 -k4,4n -k4,4 -k5,5n -k5.5 |
-awk -F. '
-  { if (lang  $1 != lang) print lang, ver }
-  { lang = $1; ver = substr($0, index($0, .) + 1) }
-  END { if (lang) print lang, ver }
-' | awk -v domain=$domain -v subdir=$subdir '
-  {
-   lang = $1
-   ver = $2
-   urlfmt = 
-   printf { $WGET_COMMAND -O %s/%s.po '\'$TP_PO_URL'/%s/%s-%s.%s.po'\'' 
\n, subdir, lang, lang, domain, ver, lang
-   printf   msgfmt -c -o /dev/null %s/%s.po || {\n, subdir, lang
-   printf echo 2 '\'$0': omitting translation for %s'\''\n, lang
-   printf rm -f %s/%s.po; }; } \n, subdir, lang
-  }
-  END { print : }
-' | WGET_COMMAND=$WGET_COMMAND sh;;
+(cd $subdir  rm -f dummy `ls | sed -n '/\.gmo$/p; /\.po/p'` 
+ $WGET_COMMAND -r -l1 -nd -np -A.po $TP_URL/$domain)
+;;
   esac 
   ls $subdir/*.po 2/dev/null |
-sed 's|.*/||; s|\.po$||' $subdir/LINGUAS 
-  rm -f $subdir/$domain.html
+sed 's|.*/||; s|\.po$||' $subdir/LINGUAS
 }
 
 case $SKIP_PO in
@@ -404,12 +387,12 @@ slurp() {
test $dir/$file = $excluded_file  continue 2
   done
   if test $file = Makefile.am; then
-copied=$copied${sep}gnulib.mk; sep=$nl
+copied=$copied${sep}$gnulib_mk; sep=$nl
remove_intl='/^[^#].*\/intl/s/^/#/;'s!$bt_regex/!!g
-sed $remove_intl $1/$dir/$file | cmp -s - $dir/gnulib.mk || {
- echo $0: Copying $1/$dir/$file to $dir/gnulib.mk ... 
- rm -f $dir/gnulib.mk 
- sed $remove_intl $1/$dir/$file $dir/gnulib.mk
+sed $remove_intl $1/$dir/$file | cmp -s - $dir/$gnulib_mk || {
+ echo $0: Copying $1/$dir/$file to $dir/$gnulib_mk ... 
+ rm -f $dir/$gnulib_mk 
+ sed $remove_intl $1/$dir/$file $dir/$gnulib_mk
}
   elif { test ${2+set} = set  test -r $2/$dir/$file; } ||
   version_controlled_file $dir $file; then




gnulib-tool incorrectly handles library names with dashes

2007-07-05 Thread Sergey Poznyakoff
Hello,

When converting library names to Makefile variables, gnulib-tool
forgets to convert dashes. The following patch fixes it. It also fixes
unneeded duplication of --avoid options, notable in `# Reproduce by:'
headers in generated Makefile.ams.

No objections?

Regards,
Sergey

2007-07-05  Sergey Poznyakoff  [EMAIL PROTECTED]

* gnulib-tool (func_dest_tmpfilename)
(func_create_testdir): Translate `-' in file names to `_' in
variable names.
(func_import): Avoid duplication of --avoid statements


Index: gnulib-tool
===
RCS file: /cvsroot/gnulib/gnulib/gnulib-tool,v
retrieving revision 1.245
diff -p -u -r1.245 gnulib-tool
--- gnulib-tool 1 Jul 2007 13:01:40 -   1.245
+++ gnulib-tool 5 Jul 2007 08:43:15 -
@@ -1864,7 +1864,7 @@ func_import ()
   specified_modules=$cached_specified_modules $1
   # Append the cached and the specified avoidlist. This is probably better
   # than dropping the cached one when --avoid is specified at least once.
-  avoidlist=`echo $cached_avoidlist $avoidlist`
+  avoidlist=`echo $cached_avoidlist $avoidlist | tr ' ' '\n' | sort | uniq | 
tr '\n' ' '`
   # The sourcebase defaults to the cached one.
   if test -z $sourcebase; then
 sourcebase=$cached_sourcebase
@@ -2390,7 +2390,7 @@ func_import ()
 # _LIBDEPS and _LTLIBDEPS variables are not needed if this library is
 # created using libtool, because libtool already handles the dependencies.
 if test $libtool != true; then
-  libname_upper=`echo $libname | LC_ALL=C tr 'a-z' 'A-Z'`
+  libname_upper=`echo $libname | LC_ALL=C tr 'a-z-' 'A-Z_'`
   echo   ${libname_upper}_LIBDEPS=\\$gl_libdeps\
   echo   AC_SUBST([${libname_upper}_LIBDEPS])
   echo   ${libname_upper}_LTLIBDEPS=\\$gl_ltlibdeps\
@@ -2839,7 +2839,7 @@ func_create_testdir ()
  # _LIBDEPS and _LTLIBDEPS variables are not needed if this library is
  # created using libtool, because libtool already handles the dependencies.
  if test $libtool != true; then
-   libname_upper=`echo $libname | LC_ALL=C tr 'a-z' 'A-Z'`
+   libname_upper=`echo $libname | LC_ALL=C tr 'a-z-' 'A-Z_'`
echo   ${libname_upper}_LIBDEPS=\\$gl_libdeps\
echo   AC_SUBST([${libname_upper}_LIBDEPS])
echo   ${libname_upper}_LTLIBDEPS=\\$gl_ltlibdeps\
@@ -2950,7 +2950,7 @@ func_create_testdir ()
# _LIBDEPS and _LTLIBDEPS variables are not needed if this library is
# created using libtool, because libtool already handles the dependencies.
if test $libtool != true; then
- libname_upper=`echo $libname | LC_ALL=C tr 'a-z' 'A-Z'`
+ libname_upper=`echo $libname | LC_ALL=C tr 'a-z-' 'A-Z_'`
  echo   ${libname_upper}_LIBDEPS=\\$gl_libdeps\
  echo   AC_SUBST([${libname_upper}_LIBDEPS])
  echo   ${libname_upper}_LTLIBDEPS=\\$gl_ltlibdeps\






  1   2   >