gnulib-tool.py: Follow gnulib-tool changes, part 43, 44.

2024-03-06 Thread Collin Funk
These two patches add the notice banners when running 'make all' and
'make check'. I'm hoping to get around to implementing the
substitutions needed for header files soon. Until then this can be
used to build a package that will configure for testing:

gnulib-tool.py --create-testdir --dir test-python readme-release
gnulib-tool --create-testdir --dir test-shell readme-release
git diff --no-index test-python/gltests/Makefile.am 
test-shell/gltests/Makefile.am

Then you can do:

cd test-python
./configure
make all
make check

To see if all the banners print correctly. The library is just the
dummy module and the tests are vc-list-files.

CollinFrom 1ec490bdc80f64d63ce7177114fcecfc50d460db Mon Sep 17 00:00:00 2001
From: Collin Funk 
Date: Tue, 5 Mar 2024 23:47:08 -0800
Subject: [PATCH 3/4] gnulib-tool.py: Follow gnulib-tool changes, part 43.

Follow gnulib-tool change
2021-06-10  Bruno Haible  
Clarify that compiler warnings in the Gnulib tests can be ignored.

* pygnulib/GLEmiter.py (GLEmiter.initmacro_start): Add boolean argument
to control whether gl_CC_ALLOW_WARNINGS and gl_CXX_ALLOW_WARNINGS should
be required.
(GLEmiter.tests_Makefile_am): Emit overrides for CFLAGS and CXXFLAGS.
Emit a dependency of 'all' on 'all-notice' that prints a warning that
compiler warnings can be ignored for tests.
* pygnulib/GLImport.py (GLImport.gnulib_comp): Add boolean argument to
tell whether a tests Makefile.am is being emitted. Update calls to
GLEmiter.initmacro_start.
(GLImport.execute): Update calls to GLEmiter.initmacro_start.
* pygnulib/GLTestDir.py (GLTestDir.execute): Likewise.
---
 ChangeLog | 18 +
 gnulib-tool.py.TODO   | 17 
 pygnulib/GLEmiter.py  | 46 +++
 pygnulib/GLImport.py  | 14 -
 pygnulib/GLTestDir.py |  6 +++---
 5 files changed, 72 insertions(+), 29 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index cfba30ce3e..53234e7de6 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,21 @@
+2024-03-05  Collin Funk  
+
+	gnulib-tool.py: Follow gnulib-tool changes, part 43.
+	Follow gnulib-tool change
+	2021-06-10  Bruno Haible  
+	Clarify that compiler warnings in the Gnulib tests can be ignored.
+	* pygnulib/GLEmiter.py (GLEmiter.initmacro_start): Add boolean argument
+	to control whether gl_CC_ALLOW_WARNINGS and gl_CXX_ALLOW_WARNINGS should
+	be required.
+	(GLEmiter.tests_Makefile_am): Emit overrides for CFLAGS and CXXFLAGS.
+	Emit a dependency of 'all' on 'all-notice' that prints a warning that
+	compiler warnings can be ignored for tests.
+	* pygnulib/GLImport.py (GLImport.gnulib_comp): Add boolean argument to
+	tell whether a tests Makefile.am is being emitted. Update calls to
+	GLEmiter.initmacro_start.
+	(GLImport.execute): Update calls to GLEmiter.initmacro_start.
+	* pygnulib/GLTestDir.py (GLTestDir.execute): Likewise.
+
 2024-03-05  Collin Funk  
 
 	gnulib-tool.py: Fix gnulib-cache.m4 output.
diff --git a/gnulib-tool.py.TODO b/gnulib-tool.py.TODO
index 42728ed60d..a15bfc948a 100644
--- a/gnulib-tool.py.TODO
+++ b/gnulib-tool.py.TODO
@@ -551,23 +551,6 @@ Date:   Thu Jun 10 21:43:59 2021 +0200
 
 
 
-commit 16c3e1868a15a5946c0f0f7df6e107e9b3c6389d
-Author: Bruno Haible 
-Date:   Thu Jun 10 21:26:53 2021 +0200
-
-Clarify that compiler warnings in the Gnulib tests can be ignored.
-
-* gnulib-tool (func_emit_tests_Makefile_am): Emit overrides for CFLAGS
-and CXXFLAGS. Emit a dependency of 'all' on 'all-notice' that prints a
-notice.
-(func_emit_initmacro_start): Add a second argument. If it is true, emit
-code to require gl_CC_ALLOW_WARNINGS and gl_CXX_ALLOW_WARNINGS.
-(func_import, func_create_testdir): All callers updated.
-* m4/gnulib-common.m4 (gl_CC_ALLOW_WARNINGS, gl_CXX_ALLOW_WARNINGS): New
-macros.
-
-
-
 commit 4b071c115309079528db7b60e8d2ffb22b129088
 Author: Paul Eggert 
 Date:   Mon Apr 26 23:31:29 2021 -0700
diff --git a/pygnulib/GLEmiter.py b/pygnulib/GLEmiter.py
index ee963e69d7..1d1463851b 100644
--- a/pygnulib/GLEmiter.py
+++ b/pygnulib/GLEmiter.py
@@ -457,13 +457,20 @@ USE_MSGCTXT = no\n"""
 emit += '%s\n' % constants.substart('lib/', sourcebase, file)
 return emit
 
-def initmacro_start(self, macro_prefix_arg):
-'''GLEmiter.initmacro_start(macro_prefix_arg) -> str
+def initmacro_start(self, macro_prefix_arg, gentests):
+'''GLEmiter.initmacro_start(macro_prefix_arg, gentests) -> str
 
-Emit the first few statements of the gl_INIT macro.'''
+Emit the first few statements of the gl_INIT macro.
+
+macro_prefix_arg is the prefix of gl_EARLY and gl_INIT macros to use.
+gentests is True if a tests Makefile.am is being generated, False
+  otherwise.'''
 if type(macro_prefix_arg) is not str:
 raise TypeE

Re: gnulib-tool.py: Follow gnulib-tool changes, part 42.

2024-03-06 Thread Bruno Haible
Collin Funk wrote:
> Here is two patches. The first fixes on item in gnulib-tool.py.TODO.

Thanks. Applied. Since I misunderstood the 'gentests' description when I read
it, I'm clarifying it.

> I thought I remembered seeing a good test case for this on the mailing
> list but the archives seem to be down at the moment.

Yep, lists.gnu.org still does not answer.
https://hostux.social/@fsfstatus has no info. 
https://www.gnu.org/server/irc-rules.en.html mentions the IRC channel #savannah.

> The second fixes this diff in gnulib-cache.m4 I found when testing:
> 
> diff --git a/test-python/m4/gnulib-cache.m4 b/test-shell/m4/gnulib-cache.m4
> index 6afe7d8d1c..91f3e48123 100644
> --- a/test-python/m4/gnulib-cache.m4
> +++ b/test-shell/m4/gnulib-cache.m4
> @@ -27,7 +27,7 @@
>  
>  
>  # Specification in the form of a command-line invocation:
> -#   # gnulib-tool --import \
> +# gnulib-tool --import \
>  #  --lib=libgnu \
>  #  --source-base=lib \
>  #  --m4-base=m4 \
> 
> The actioncmd already handles the comment '#' so we don't need another
> when outputting in gnulib_cache.

Applied as well; thanks.


2024-03-06  Bruno Haible  

gnulib-tool.py: Tweak comment.
* pygnulib/GLMakefileTable.py (GLMakefileTable.parent): Tweak 'gentests'
description.

diff --git a/pygnulib/GLMakefileTable.py b/pygnulib/GLMakefileTable.py
index d1e6178880..35f32685b5 100644
--- a/pygnulib/GLMakefileTable.py
+++ b/pygnulib/GLMakefileTable.py
@@ -87,7 +87,7 @@ class GLMakefileTable(object):
 which contains or will contain Makefile.am file.
 GLConfig: sourcebase, m4base, testsbase, incl_test_categories,
 excl_test_categories, makefile_name.
-gentests is a bool that is True if files are placed in $testsbase.'''
+gentests is a bool that is True if any files are to be placed in 
$testsbase.'''
 if type(gentests) is not bool:
 raise TypeError('gentests must be a bool, not %s' % 
(type(gentests).__name__))
 m4base = self.config['m4base']






Re: gnulib-tool.py: Follow gnulib-tool changes, part 43, 44.

2024-03-06 Thread Collin Funk
On 3/6/24 12:26 AM, Collin Funk wrote:
> gnulib-tool.py --create-testdir --dir test-python readme-release
> gnulib-tool --create-testdir --dir test-shell readme-release
> git diff --no-index test-python/gltests/Makefile.am 
> test-shell/gltests/Makefile.am

While running that I noticed this in gltests/Makefile.am:

-LDADD = ../gllib/libgnu.a libtests.a ../gllib/libgnu.a
+LDADD = ../gllib/libgnu.a

I've copied the logic for this from gnulib-tool and the attached patch
fixes this.

Also I've just noticed that GLImport has an exit() call that prevents
the advice for headers and such from being printed [1]. It is also
documented in gnulib-tool.py.TODO [2]. Is there a reason for this? The
git history doesn't seem to say much and it worked fine when I tried
it _once_. Just seems sort of strange LOL

[1] https://git.savannah.gnu.org/cgit/gnulib.git/tree/pygnulib/GLImport.py#n1337
[2] https://git.savannah.gnu.org/cgit/gnulib.git/tree/gnulib-tool.py.TODO#n29

CollinFrom 6d2962ced49af6695e33365e78601988a5264979 Mon Sep 17 00:00:00 2001
From: Collin Funk 
Date: Wed, 6 Mar 2024 02:44:39 -0800
Subject: [PATCH 5/5] gnulib-tool.py: Fix value of LDADD for libtests.

* pygnulib/GLEmiter.py (GLEmiter.tests_Makefile_am): Fix value of LDADD
to match gnulib-tool.
---
 ChangeLog|  6 ++
 pygnulib/GLEmiter.py | 15 ++-
 2 files changed, 12 insertions(+), 9 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index 44e86f7f52..076ad9c3ce 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,9 @@
+2024-03-06  Collin Funk  
+
+	gnulib-tool.py: Fix value of LDADD for libtests.
+	* pygnulib/GLEmiter.py (GLEmiter.tests_Makefile_am): Fix value of LDADD
+	to match gnulib-tool.
+
 2024-03-06  Collin Funk  
 
 	gnulib-tool.py: Follow gnulib-tool changes, part 44.
diff --git a/pygnulib/GLEmiter.py b/pygnulib/GLEmiter.py
index 8316d0af5c..e0df1373c6 100644
--- a/pygnulib/GLEmiter.py
+++ b/pygnulib/GLEmiter.py
@@ -1154,8 +1154,6 @@ AC_DEFUN([%V1%_LIBSOURCES], [
 emit += '  -I%s/%s -I$(srcdir)/%s/%s\n' % (testsbase_inverse, sourcebase, testsbase_inverse, sourcebase)
 emit += '\n'
 
-ldadd_before = ''
-ldadd_after = ''
 if libtests:
 # All test programs need to be linked with libtests.a.
 # It needs to be passed to the linker before ${libname}.${libext},
@@ -1166,13 +1164,12 @@ AC_DEFUN([%V1%_LIBSOURCES], [
 # voluntarily omitted).
 # The LIBTESTS_LIBDEPS can be passed to the linker once or twice, it
 # does not matter.
-ldadd_before = ' libtests.a'
-ldadd_after = ' libtests.a $(LIBTESTS_LIBDEPS)'
-emit += 'LDADD =%s %s/%s/%s.%s libtests.a %s/%s/%s.%s%s\n\n' \
-% (ldadd_before,
-   testsbase_inverse, sourcebase, libname, libext,
-   testsbase_inverse, sourcebase, libname, libext,
-   ldadd_after)
+emit += ("LDADD = libtests.a %s/%s/%s.%s libtests.a %s/%s/%s.%s libtests.a $(LIBTESTS_LIBDEPS)\n"
+ % (testsbase_inverse, sourcebase, libname, libext, testsbase_inverse, sourcebase, libname, libext))
+else:
+emit += ("LDADD = %s/%s/%s.%s\n"
+ % (testsbase_inverse, sourcebase, libname, libext))
+emit += '\n'
 if libtests:
 emit += 'libtests_a_SOURCES =\n'
 # Here we use $(LIBOBJS), not @LIBOBJS@. The value is the same. However,
-- 
2.44.0



Re: gnulib-tool.py: Follow gnulib-tool changes, part 43, 44.

2024-03-06 Thread Bruno Haible
Collin Funk wrote:
> These two patches add the notice banners when running 'make all' and
> 'make check'.

Thanks! Applied.

Bruno






Re: gnulib-tool.py: Follow gnulib-tool changes, part 43, 44.

2024-03-06 Thread Bruno Haible
Hi Collin,

> While running that I noticed this in gltests/Makefile.am:
> 
> -LDADD = ../gllib/libgnu.a libtests.a ../gllib/libgnu.a
> +LDADD = ../gllib/libgnu.a
> 
> I've copied the logic for this from gnulib-tool and the attached patch
> fixes this.

Thanks, applied. (With an extra newline, just to make it clear that the
%s/%s/%s.%s arguments are the same in all three cases. Could be simplified
in the future, but that's not a priority now.)

> Also I've just noticed that GLImport has an exit() call that prevents
> the advice for headers and such from being printed [1]. It is also
> documented in gnulib-tool.py.TODO [2]. Is there a reason for this? The
> git history doesn't seem to say much and it worked fine when I tried
> it _once_. Just seems sort of strange LOL

It's a strange way to disable Python code that is not ready yet :-)

It is a goal to have gnulib-tool.py not only produce the same files, but also
the same stdout output as gnulib-tool. (Whereas the stderr output can be
reasonably different, depending on error situations.) The 'exit()' invocation
only means that neither Dmitry nor I have tested this code in a long long time.

Bruno






Re: gnulib-tool.py: Follow gnulib-tool changes, part 43, 44.

2024-03-06 Thread Collin Funk
Hi Bruno,

On 3/6/24 3:22 AM, Bruno Haible wrote:
> Thanks, applied. (With an extra newline, just to make it clear that the
> %s/%s/%s.%s arguments are the same in all three cases. Could be simplified
> in the future, but that's not a priority now.)

I assumed the intent of the original code was to simplify it. I'll
admit that my fix was a little lazy. :)

> It's a strange way to disable Python code that is not ready yet :-)
> 
> It is a goal to have gnulib-tool.py not only produce the same files, but also
> the same stdout output as gnulib-tool. (Whereas the stderr output can be
> reasonably different, depending on error situations.) The 'exit()' invocation
> only means that neither Dmitry nor I have tested this code in a long long 
> time.

Makes sense. It looked pretty close to what I remember seeing with the
regular gnulib-tool.

Collin



Re: Could `gnulib-tool` check for gjoin?

2024-03-06 Thread Bruno Haible
Reuben Thomas wrote:
> > Such info could be added to the Gnulib manual.
> 
> I doubt that would help many users (why should they read the gnulib manual
> just to build software?)

OK. In the name of having gnulib-tool run out-of-the-box for such users,
I'm applying this change:


2024-03-06  Bruno Haible  

gnulib-tool: Search for a working 'join' program.
Reported by Reuben Thomas  in
.
* gnulib-tool (JOIN): New variable. Use it everywhere instead of 'join'.

diff --git a/gnulib-tool b/gnulib-tool
index a7ba7a98f1..9eb8c4ab87 100755
--- a/gnulib-tool
+++ b/gnulib-tool
@@ -1072,23 +1072,38 @@ for signal in HUP INT QUIT PIPE TERM; do
 done
 signal=EXIT
 
-# The 'join' program does not exist on all platforms, and
+# The 'join' program does not exist on all platforms (e.g. Alpine Linux), and
 # on macOS 12.6, FreeBSD 14.0, NetBSD 9.3 it is buggy, see
 # .
-# In these cases, bail out. Otherwise, we can use it.
-if (type join) >/dev/null 2>&1; then
-  echo a > "$tmp"/join-input-1
-  { echo; echo a; } > "$tmp"/join-input-2
-  if LC_ALL=C join "$tmp"/join-input-1 "$tmp"/join-input-2 | grep a >/dev/null 
\
+# Search for a working 'join' program, by trying $JOIN, join, gjoin,
+# in this order.
+echo a > "$tmp"/join-input-1
+{ echo; echo a; } > "$tmp"/join-input-2
+if test -n "$JOIN" \
+   && LC_ALL=C $JOIN "$tmp"/join-input-1 "$tmp"/join-input-2 >/dev/null \
+   && LC_ALL=C $JOIN "$tmp"/join-input-1 "$tmp"/join-input-2 | grep a 
>/dev/null \
+   && LC_ALL=C $JOIN "$tmp"/join-input-2 "$tmp"/join-input-1 | grep a 
>/dev/null; then
+  :
+else
+  if (type join) >/dev/null 2>&1 \
+ && LC_ALL=C join "$tmp"/join-input-1 "$tmp"/join-input-2 | grep a 
>/dev/null \
  && LC_ALL=C join "$tmp"/join-input-2 "$tmp"/join-input-1 | grep a 
>/dev/null; then
-:
+JOIN=join
   else
-echo "$progname: 'join' program is buggy. Consider installing GNU 
coreutils." >&2
-func_exit 1
+if (type gjoin) >/dev/null 2>&1 \
+   && LC_ALL=C gjoin "$tmp"/join-input-1 "$tmp"/join-input-2 | grep a 
>/dev/null \
+   && LC_ALL=C gjoin "$tmp"/join-input-2 "$tmp"/join-input-1 | grep a 
>/dev/null; then
+  JOIN=gjoin
+else
+  if (type join) >/dev/null 2>&1; then
+echo "$progname: 'join' program is buggy. Consider installing GNU 
coreutils." >&2
+func_exit 1
+  else
+echo "$progname: 'join' program not found. Consider installing GNU 
coreutils." >&2
+func_exit 1
+  fi
+fi
   fi
-else
-  echo "$progname: 'join' program not found. Consider installing GNU 
coreutils." >&2
-  func_exit 1
 fi
 
 # Unset CDPATH.  Otherwise, output from 'cd dir' can surprise callers.
@@ -2596,7 +2611,7 @@ func_get_automake_snippet_unconditional ()
   # Remove $already_mentioned_files from $lib_files.
   echo "$lib_files" | LC_ALL=C sort -u > "$tmp"/lib-files
   extra_files=`for f in $already_mentioned_files; do echo $f; done \
-   | LC_ALL=C sort -u | LC_ALL=C join -v 2 - "$tmp"/lib-files`
+   | LC_ALL=C sort -u | LC_ALL=C $JOIN -v 2 - "$tmp"/lib-files`
   if test -n "$extra_files"; then
 echo "EXTRA_DIST +=" $extra_files
 echo
@@ -2863,7 +2878,7 @@ func_get_dependencies_recursively ()
 handledmodules=`for m in $handledmodules $inmodules_this_round; do echo 
$m; done | LC_ALL=C sort -u`
 # Remove $handledmodules from $inmodules.
 for m in $inmodules; do echo $m; done | LC_ALL=C sort -u > 
"$tmp"/queued-modules
-inmodules=`echo "$handledmodules" | LC_ALL=C join -v 2 - 
"$tmp"/queued-modules`
+inmodules=`echo "$handledmodules" | LC_ALL=C $JOIN -v 2 - 
"$tmp"/queued-modules`
   done
   rm -f "$tmp"/queued-modules
   for m in $outmodules; do echo $m; done | LC_ALL=C sort -u
@@ -2904,7 +2919,7 @@ func_get_link_directive_recursively ()
 handledmodules=`for m in $handledmodules $inmodules_this_round; do echo 
$m; done | LC_ALL=C sort -u`
 # Remove $handledmodules from $inmodules.
 for m in $inmodules; do echo $m; done | LC_ALL=C sort -u > 
"$tmp"/queued-modules
-inmodules=`echo "$handledmodules" | LC_ALL=C join -v 2 - 
"$tmp"/queued-modules`
+inmodules=`echo "$handledmodules" | LC_ALL=C $JOIN -v 2 - 
"$tmp"/queued-modules`
   done
   rm -f "$tmp"/queued-modules
   for m in $outmodules; do func_get_link_directive "$m"; done | LC_ALL=C sort 
-u | sed -e '/^$/d'
@@ -3218,7 +3233,7 @@ func_modules_transitive_closure ()
 handledmodules=`for m in $handledmodules $inmodules_this_round; do echo 
$m; done | LC_ALL=C sort -u`
 # Remove $handledmodules from $inmodules.
 for m in $inmodules; do echo $m; done | LC_ALL=C sort -u > 
"$tmp"/queued-modules
-inmodules=`echo "$handledmodules" | LC_ALL=C join -v 2 - 
"$tmp"/queued-modules`
+inmodules=`echo "$handledmodules" | LC_ALL=C $JOIN -v 2 - 
"$tmp"/queued-modules`
 fmtc_inc_all_t

Re: Could `gnulib-tool` check for gjoin?

2024-03-06 Thread Reuben Thomas
On Wed, 6 Mar 2024 at 17:07, Bruno Haible  wrote:

> Reuben Thomas wrote:
> > > Such info could be added to the Gnulib manual.
> >
> > I doubt that would help many users (why should they read the gnulib
> manual
> > just to build software?)
>
> OK. In the name of having gnulib-tool run out-of-the-box for such users,
> I'm applying this change:
>

Many thanks for this!

 --
https://rrt.sc3d.org


Does gnulib getcwd always allocate if buf is NULL?

2024-03-06 Thread Reuben Thomas
In getcwd.c I find the following comment:

In GNU, if BUF is NULL, an array is allocated with 'malloc'; the array is
> SIZE bytes long, unless SIZE == 0, in which case it is as big as necessary.
>

However, as far as I can see from the code, it always allocates if BUF is
NULL.

I assume this is the behaviour, as even getcwd-lgpl guarantees this GNU
behaviour!

I'm asking because I'd like to use gnulib getcwd to get the GNU behaviour
on non-GNU systems, and since my code is GPL'ed I'd like the "full fat"
gnulib getcwd.

-- 
https://rrt.sc3d.org


Re: Does gnulib getcwd always allocate if buf is NULL?

2024-03-06 Thread Paul Smith
On Wed, 2024-03-06 at 19:55 +0100, Reuben Thomas wrote:
> In getcwd.c I find the following comment:
> 
> > In GNU, if BUF is NULL, an array is allocated with 'malloc'; the
> > array is SIZE bytes long, unless SIZE == 0, in which case it is as
> > big as necessary.
> 
> However, as far as I can see from the code, it always allocates if
> BUF is NULL.

I don't think your observation contradicts the comment...is there more
to it?

Note the use of a semicolon here which means that the second clause is
"separate from" the first clause; this could be rewritten as something
like:

   In GNU, if BUF is NULL, an array is allocated with 'malloc'.

   If allocated, the allocated array is SIZE bytes long, unless SIZE ==
   0, in which case it is as big as necessary.



Re: Does gnulib getcwd always allocate if buf is NULL?

2024-03-06 Thread Bruno Haible
Reuben Thomas wrote:
> In getcwd.c I find the following comment:

The Gnulib documentation
https://www.gnu.org/software/gnulib/manual/html_node/getcwd.html
points to the specification. That's usually a more solid reference than
a comment in the code.

> In GNU, if BUF is NULL, an array is allocated with 'malloc'; the array is
> > SIZE bytes long, unless SIZE == 0, in which case it is as big as necessary.
> >
> 
> However, as far as I can see from the code, it always allocates if BUF is
> NULL.

What is your question?

Bruno






Re: Does gnulib getcwd always allocate if buf is NULL?

2024-03-06 Thread Reuben Thomas
On Wed, 6 Mar 2024 at 20:09, Paul Smith  wrote:

> On Wed, 2024-03-06 at 19:55 +0100, Reuben Thomas wrote:
> > In getcwd.c I find the following comment:
> >
> > > In GNU, if BUF is NULL, an array is allocated with 'malloc'; the
> > > array is SIZE bytes long, unless SIZE == 0, in which case it is as
> > > big as necessary.
> >
> > However, as far as I can see from the code, it always allocates if
> > BUF is NULL.
>
> I don't think your observation contradicts the comment...is there more
> to it?
>

My point is that if BUF is NULL, an array is allocated with 'malloc'. It
has nothing to do with being on a GNU or non-GNU system.


Re: Does gnulib getcwd always allocate if buf is NULL?

2024-03-06 Thread Reuben Thomas
On Wed, 6 Mar 2024 at 20:12, Bruno Haible  wrote:

> Reuben Thomas wrote:
> > In getcwd.c I find the following comment:
>
> The Gnulib documentation
> https://www.gnu.org/software/gnulib/manual/html_node/getcwd.html
> points to the specification. That's usually a more solid reference than
> a comment in the code.
>

Thanks, it seems that the documentation supports my guess.

> In GNU, if BUF is NULL, an array is allocated with 'malloc'; the array is
> > > SIZE bytes long, unless SIZE == 0, in which case it is as big as
> necessary.
> > >
> >
> > However, as far as I can see from the code, it always allocates if BUF is
> > NULL.
>
> What is your question?


Would this comment be better if "In GNU," was deleted? The comment implies
that the implementation only behaves as specified after the comma on GNU
systems, when in fact a particular feature of the gnulib implementation is
to bring the GNU behaviour to non-GNU systems.

-- 
https://rrt.sc3d.org


Re: Does gnulib getcwd always allocate if buf is NULL?

2024-03-06 Thread Bruno Haible
Reuben Thomas wrote:
> > > > In GNU, if BUF is NULL, an array is allocated with 'malloc'; the array 
> > > > is
> > > > SIZE bytes long, unless SIZE == 0, in which case it is as big as
> > > > necessary.
> ...
> Would this comment be better if "In GNU," was deleted? The comment implies
> that the implementation only behaves as specified after the comma on GNU
> systems, when in fact a particular feature of the gnulib implementation is
> to bring the GNU behaviour to non-GNU systems.

You have understood it: "In GNU", here, means "when following the glibc
conventions". And Gnulib brings the glibc conventions to other platforms.

There's no need to change this comment, because the primary places to look
for a function's behaviour are:
  1. the documentation and standard documents,
  2. the .h file (in this case: unistd.in.h line 1121).

Bruno






Re: Does gnulib getcwd always allocate if buf is NULL?

2024-03-06 Thread Reuben Thomas
On Wed, 6 Mar 2024 at 21:45, Bruno Haible  wrote:

>
> There's no need to change this comment, because the primary places to look
> for a function's behaviour are:
>   1. the documentation and standard documents,
>   2. the .h file (in this case: unistd.in.h line 1121).
>

Fair enough that there are better places to look, but the comment misled
me, and I still think it is at least ambiguous.

-- 
https://rrt.sc3d.org


gnulib-tool.py: Follow gnulib-tool changes, part 45, 46.

2024-03-06 Thread Collin Funk
Hi, here is two patches. The first implements the
'--tests-makefile-name' options. Are there any packages that use this
option? I couldn't seem to find anything from Debian and GitHub code
search outside of Gnulib itself or mirrors. I ended up figuring it out
from the manual description --makefile-name pretty easily though. I
used a script with this for testing:

gnulib-tool.py --create-testdir --dir test-python readme-release
gnulib-tool --create-testdir --dir test-shell readme-release
(cd test-python && gnulib-tool.py --import --with-tests 
--tests-makefile-name=Makefile.gnulib fts)
(cd test-shell && gnulib-tool --import --with-tests 
--tests-makefile-name=Makefile.gnulib fts)
git diff --no-index test-python test-shell

I also temporarily removed the exit() in GLImport to check the changes
made there and it looked correct for the most part. I added the exit()
back before committing though since I didn't actually look at that
code too much outside of running it. I'll have another look at it and
make sure it doesn't do anything too weird before removing it.

The second one just bumps the Automake version requirement to 1.14.
That is needed for the %reldir% replacements. Since the header stuff
depends on a few more changes, currently it just removes a few lines
of the diff for me while testing.

CollinFrom e6b9a208c5f911a138adbc350caca46b38c30a0b Mon Sep 17 00:00:00 2001
From: Collin Funk 
Date: Wed, 6 Mar 2024 21:49:21 -0800
Subject: [PATCH 1/2] gnulib-tool.py: Follow gnulib-tool changes, part 45.

Follow gnulib-tool changes
2021-12-12  Bruno Haible  
gnulib-tool: Support different basenames for the lib/,tests/ Makefiles.
2022-01-08  Bruno Haible  
gnulib-tool: Fix "Don't forget" messages (regression 2021-12-12).

* pygnulib/GLConfig.py (GLConfig.__init__): Add 'tests_makefile_name'
argument.
(GLConfig.getMakefileName, GLConfig.setMakefileName)
(GLConfig.resetMakefileName): Remove references to tests Makefile.am in
doc strings.
(GLConfig.getTestsMakefileNamem, GLConfig.setTestsMakefileName)
(GLConfig.resetTestsMakefileName): New methods used to access value
passed with the '--tests-makefile-name' option.
* pygnulib/GLImport.py (GLImport.__init__): Check for
'gl_TESTS_MAKEFILE_NAME' in cache.
(GLImport.actioncmd): Output --tests-makefile-name when describing
gnulib-tool invocation.
(GLImport.gnulib_cache): Output 'gl_TESTS_MAKEFILE_NAME' to cache.
(GLImport.execute): Use two local variables, source_makefile_am and
tests_makefile_am, which are passed to gnulib-tool.py or given default
values.
* pygnulib/GLInfo.py (GLInfo.usage): Add '--tests-makefile-name' to
usage message.
* pygnulib/GLMakefileTable.py (GLMakefileTable.parent): Reduce code
duplication by expecting Makefile names passed as arguments.
* pygnulib/main.py (main): Add support for '--tests-makefile-name'.
---
 ChangeLog   | 30 +++
 gnulib-tool.py.TODO | 24 ---
 pygnulib/GLConfig.py| 41 +---
 pygnulib/GLImport.py| 47 +++--
 pygnulib/GLInfo.py  |  3 +++
 pygnulib/GLMakefileTable.py | 23 +-
 pygnulib/main.py| 10 
 7 files changed, 117 insertions(+), 61 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index 9666d65ba2..7be384b646 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,33 @@
+2024-03-06  Collin Funk  
+
+	gnulib-tool.py: Follow gnulib-tool changes, part 45.
+	Follow gnulib-tool changes
+	2021-12-12  Bruno Haible  
+	gnulib-tool: Support different basenames for the lib/,tests/ Makefiles.
+	2022-01-08  Bruno Haible  
+	gnulib-tool: Fix "Don't forget" messages (regression 2021-12-12).
+	* pygnulib/GLConfig.py (GLConfig.__init__): Add 'tests_makefile_name'
+	argument.
+	(GLConfig.getMakefileName, GLConfig.setMakefileName)
+	(GLConfig.resetMakefileName): Remove references to tests Makefile.am in
+	doc strings.
+	(GLConfig.getTestsMakefileNamem, GLConfig.setTestsMakefileName)
+	(GLConfig.resetTestsMakefileName): New methods used to access value
+	passed with the '--tests-makefile-name' option.
+	* pygnulib/GLImport.py (GLImport.__init__): Check for
+	'gl_TESTS_MAKEFILE_NAME' in cache.
+	(GLImport.actioncmd): Output --tests-makefile-name when describing
+	gnulib-tool invocation.
+	(GLImport.gnulib_cache): Output 'gl_TESTS_MAKEFILE_NAME' to cache.
+	(GLImport.execute): Use two local variables, source_makefile_am and
+	tests_makefile_am, which are passed to gnulib-tool.py or given default
+	values.
+	* pygnulib/GLInfo.py (GLInfo.usage): Add '--tests-makefile-name' to
+	usage message.
+	* pygnulib/GLMakefileTable.py (GLMakefileTable.parent): Reduce code
+	duplication by expecting Makefile names passed as arguments.
+	* pygnulib/main.py (main): Add support for '--tests-makefile-name'.
+
 2024-03-06  Bruno Haible  
 
 	gnulib-tool: Search for a working 'join' program.
diff --git a/gnulib-tool.py.TODO b/gnulib-tool.py.TODO
index 8548013005..a78335e6fd 100644
--- a/gnulib-tool.