]> git.draconx.ca Git - dxcommon.git/log
dxcommon.git
8 days agoDX_C_ALIGNAS: Work around bash-5 parsing bug. master
Nick Bowler [Thu, 11 Apr 2024 00:57:36 +0000 (20:57 -0400)]
DX_C_ALIGNAS: Work around bash-5 parsing bug.

Apparently bash-5 and later versions fail to parse for loops with
a newline before the 'in' keyword, if that loop itself is in a case.
statement.

Previous versions of bash have no such problem, nor does any other
shell I've tried, but the workaround is simple enough.

2 weeks agoAvoid _Alignas/_Alignof redefinition on FreeBSD.
Nick Bowler [Thu, 4 Apr 2024 03:57:32 +0000 (23:57 -0400)]
Avoid _Alignas/_Alignof redefinition on FreeBSD.

It seems that FreeBSD provides _Alignof and _Alignas macros in
various standard header files, including <stddef.h>.  Since the
configure probes don't include any headers, these are missed,
resulting in conflicting macro definitions.

To fix this, all we really need to do is include some header
file in the test program, so these system versions are visible
when testing for _Alignas and _Alignof support.

7 weeks agoAdd helper macro for libtool patches.
Nick Bowler [Thu, 29 Feb 2024 04:08:12 +0000 (23:08 -0500)]
Add helper macro for libtool patches.

Monkey patch libtool to workaround a problem discovered when using the
VAX C compiler.  It seems that read-only static data initialized with
function pointers can lead to trouble with this compiler.

It is obviously not the only compiler with a problem like this, since
libtool already similar exceptions to avoid "const" on other systems,
we just need to add another case.

8 weeks agoDX_RUN_LOG: Work around DJGPP subshell bug.
Nick Bowler [Fri, 23 Feb 2024 01:26:02 +0000 (20:26 -0500)]
DX_RUN_LOG: Work around DJGPP subshell bug.

On DJGPP bash, running set -x in a subshell also affects the parent
shell environment.  Inadvertently turning on traces for the whole
rest of the configure run is not desirable, so work around the
problem by manually turning the traces back off when this happens.

8 weeks agocopysym: Merge tables into a single static allocation.
Nick Bowler [Wed, 21 Feb 2024 02:20:37 +0000 (21:20 -0500)]
copysym: Merge tables into a single static allocation.

On x86_64, gcc overaligns static arrays at least 16 bytes long onto
a 16-byte boundary, and arrays at least 32 bytes long on a 32-byte
boundary, which for these tables seems to be totally unnecessary.

Putting both arrays into one structure means that at least within
this one translation unit, we don't pointlessly waste space padding
between the two arrays to maintain unneeded alignment.

8 weeks agocopysym: Integrate code offset into lookup table.
Nick Bowler [Wed, 21 Feb 2024 01:52:04 +0000 (20:52 -0500)]
copysym: Integrate code offset into lookup table.

Instead of shifting out a nibble from a 64-bit constant based on the
lookup result, we can just add a byte to each entry in the table with
the same value.  Since we no longer need to worry about fitting the
offsets into 4 bits we can also rearrange the code array a bit, for
an overall code size reduction.

8 weeks agoAdd configure tests for C11-ish _Alignof and _Alignas.
Nick Bowler [Mon, 19 Feb 2024 04:25:15 +0000 (23:25 -0500)]
Add configure tests for C11-ish _Alignof and _Alignas.

These features are pretty feasible to implement usable macro-based
fallbacks on pre-C11 compilers.  Add some basic configure probes
to check these C11 features and AC_DEFINE reasonable fallbacks
where unsupported.

If Autoconf already detected C11 support, do nothing (as it tests
these features already).  Compilers which support these in C11 mode
usually also support them in other conformance modes, so it is still
useful to probe these specifically.

2 months agotests: Ignore output from the C compiler.
Nick Bowler [Fri, 26 Jan 2024 06:06:45 +0000 (01:06 -0500)]
tests: Ignore output from the C compiler.

Some C compilers are quite noisy and a lot of the tests aren't
actually ignoring the output, leading to spurious failures.

2 months agoat-compat: Add diff workaround for DOS/Windows hosts.
Nick Bowler [Fri, 26 Jan 2024 06:01:01 +0000 (01:01 -0500)]
at-compat: Add diff workaround for DOS/Windows hosts.

Kind of ugly, but we need to hook at_diff in order to deal with the
fact that programs under test might generate DOS line endings but the
shell and utilities do not.

2 months agoAdd AM_PROG_AR to configure.ac.
Nick Bowler [Fri, 26 Jan 2024 01:32:12 +0000 (20:32 -0500)]
Add AM_PROG_AR to configure.ac.

Without this, Automake fails to build static libraries with the
Microsoft compiler tools.

Update DX_AUTOMAKE_COMPAT to wrap ar-lib just like is currently
done with compile, so that it is run with the configured shell
instead of hardcoded /bin/sh.

3 months agogl-patches: Don't force HAVE_LONG_LONG_INT.
Nick Bowler [Thu, 18 Jan 2024 02:30:04 +0000 (21:30 -0500)]
gl-patches: Don't force HAVE_LONG_LONG_INT.

Gnulib nowadays just assumes long long works but forces these
definitions, it doesn't actually need them set so it is just
pointless at best.

3 months agocurses-compat: Improve probe for request_mouse_pos.
Nick Bowler [Sun, 7 Jan 2024 03:55:22 +0000 (22:55 -0500)]
curses-compat: Improve probe for request_mouse_pos.

On AIX 7.2, the request_mouse_pos function is defined but it seems
the related macros (e.g., MOUSE_X_POS) don't actually work, leading to
undefined variable references at link time.  The configure test should
have caught this, but it turns out GCC optimizes out the check.

So configure concludes request_mouse_pos is supported and then later
compilation of programs which use this feature fail to link.  Ensure
the macro usage influences the program return value so GCC doesn't
delete it.

3 months agocopysym: Improve compatibility with old compilers.
Nick Bowler [Sat, 6 Jan 2024 21:51:25 +0000 (16:51 -0500)]
copysym: Improve compatibility with old compilers.

Some C89 compilers with 32-bit longs won't automatically widen integer
constants to (unsigned) long long in order to represent values that
don't fit in an (unsigned) long, even if those compilers otherwise
support 64-bit long long.

The "ll" and "ull" suffixes seem to get things working.

3 months agocopysym: Fix testcase on pre-C99 compilers.
Nick Bowler [Sat, 6 Jan 2024 21:34:29 +0000 (16:34 -0500)]
copysym: Fix testcase on pre-C99 compilers.

Apparently some C++-style // comments slipped in to this test
program, which is not supported by C89 compilers.

3 months agohelp: Improve compatibility with old compilers.
Nick Bowler [Sat, 6 Jan 2024 21:28:01 +0000 (16:28 -0500)]
help: Improve compatibility with old compilers.

Before C99 it is not allowed to have a comma after the last item in an
enum declaration, even though a lot of C89 compilers do support it.

3 months agotest-tap.at: Tweak filename generation.
Nick Bowler [Sat, 6 Jan 2024 20:49:53 +0000 (15:49 -0500)]
test-tap.at: Tweak filename generation.

When generating the output filenames, use only the last component of the
test program's filename, up to but not including the first period.

This should enable things to work if an absolute or relative path to an
executable is specified, and avoids extending filenames unnecessarily.

3 months agotest-tap.at: Use PATH instead of hardcoding "$builddir/t"
Nick Bowler [Sat, 6 Jan 2024 20:36:59 +0000 (15:36 -0500)]
test-tap.at: Use PATH instead of hardcoding "$builddir/t"

Hardcoding "$builddir/t" doesn't work at all if VPATH builds need to
run programs in "$srcdir", which we do now need.  Generally PATH
lookups are more flexible in Autotest and work out much better.

Technically this is a change in behaviour so some downstream projects
may need to be updated.

3 months agotest-tap.at: Fix regression passing program arguments.
Nick Bowler [Sat, 6 Jan 2024 07:34:10 +0000 (02:34 -0500)]
test-tap.at: Fix regression passing program arguments.

Moving the test_run_tap() function definition into a macro failed to
properly quote $@ so it isn't eaten by m4.  So instead of calling
the test program with "$@" as the argument, it is changed to "".

Fix that up, and add a very simple test case to check this behaviour.

3 months agoDX_PROG_FLEX: redirect lex output to the log file.
Nick Bowler [Wed, 3 Jan 2024 03:07:52 +0000 (22:07 -0500)]
DX_PROG_FLEX: redirect lex output to the log file.

AIX 7.2 includes a "lex" program which prints error messages to standard
output.  So ensure that is also redirected to the log file, otherwise
we get a bunch of garbage printed to the terminal when configuring.

3 months agohelp_print_optstring: Fix NLS test on AIX.
Nick Bowler [Tue, 2 Jan 2024 04:24:22 +0000 (23:24 -0500)]
help_print_optstring: Fix NLS test on AIX.

AIX 7.2 awk does not support "-" as an argument to the -f option
to mean "read from standard input", contrary to POSIX.

Easy enough to work around.

3 months agogen-strtab.awk: Work around AIX substitution bug.
Nick Bowler [Mon, 1 Jan 2024 21:37:55 +0000 (16:37 -0500)]
gen-strtab.awk: Work around AIX substitution bug.

On AIX 7.2 awk, the sub and gsub functions have a bug when the
replacement string contains a "\1" character.  The substituted
strings have \1 characters replaced with amperands, for example:

  aix72% awk 'BEGIN { s="x"; sub("x","\1",s); sub("\1","x",s); print s; }'
  &

Very strange.  The problem is internal to (g)sub, there is no
problem using "\1" characters in other contexts -- including
with the other arguments to (g)sub.  It should be fine to use
"\2" instead which avoids this particular bug.

3 months agoDX_GNULIB_SYMFILES: Don't use "awk -f -".
Nick Bowler [Mon, 1 Jan 2024 20:21:12 +0000 (15:21 -0500)]
DX_GNULIB_SYMFILES: Don't use "awk -f -".

Even though a filename of "-" is specified by POSIX to read the program
from standard input and works with almost every awk implementation out
there, it seems it does not work on AIX 7.2 awk (which tries to read the
program from a file named "-" instead).  How wonderful.

In this case, it is easy enough to use a quoted string for the program
instead of a here-document.

3 months agoDX_PROG_AUTOTEST: Modernize.
Nick Bowler [Sat, 23 Dec 2023 21:41:03 +0000 (16:41 -0500)]
DX_PROG_AUTOTEST: Modernize.

This macro can use some rework to behave a bit more like other program
probing macros in this package.

In particular, if Autotest is not found, configure now prints

  checking for autotest... no

rather than "... false", and configure no longer prints the next line
"checking if autotest works..." in this case.

Additionally, extra code to support snippet/autotest.mk is moved to
a new macro, DX_PROG_AUTOTEST_AM which also defines the necessary
conditional.

Finally, this macro now has coverage in the test suite.

3 months agoat-compat.at: Add patch to fix option parsing bug.
Nick Bowler [Sat, 23 Dec 2023 16:22:03 +0000 (11:22 -0500)]
at-compat.at: Add patch to fix option parsing bug.

This fixes a bug in AT_ARG_OPTION_ARG where the two-argument form
does not work if the option name contains a hyphen:

  % ./testsuite --my-option val
  testsuite: error: invalid variable name: `--my_option'

3 months agoat-compat.at: Add patch to avoid DJGPP date issue.
Nick Bowler [Fri, 22 Dec 2023 05:28:08 +0000 (00:28 -0500)]
at-compat.at: Add patch to avoid DJGPP date issue.

DJGPP's "date +%s" does not actually work like GNU, although it probably
was supposed to.  It can return a string which begins with zero.  The
testsuite only checks that the output is all digits, so accepts this as
being a working GNU-like date output.

This is then used in an arithmetic expansion, and the shell interprets
this string as octal digits, crapping out if any of those digits are 8
or 9.  If this happens (perhaps depending on the phase of the moon)
then the testsuite crashes before printing the final summary.

4 months agoDX_AUTOMAKE_COMPAT: Fix compile with newer Automake.
Nick Bowler [Thu, 7 Dec 2023 01:56:24 +0000 (20:56 -0500)]
DX_AUTOMAKE_COMPAT: Fix compile with newer Automake.

Current versions of Automake's compile script depend on shell functions
which are not supported by ULTRIX 4.5 /bin/sh.

Now ksh does support these and configure does find and use this shell
on ULTRIX, but compile starts with #!/bin/sh so when it is executed
directly, it is run with /bin/sh instead of the shell we want.

This is a bit tricky to work around since Automake updates $CC (if
needed) to refer to the compile script, which is used throughout
the configure run.  So we can't just patch it up whenever, it has
to be done early on.  AC_BEFORE can be used to at least warn if the
patches are ineffective.

4 months agofix-gnulib.pl: Convert rules to dirstamp prerequisites.
Nick Bowler [Wed, 6 Dec 2023 04:00:42 +0000 (23:00 -0500)]
fix-gnulib.pl: Convert rules to dirstamp prerequisites.

ULTRIX 4.5 make fails during rule lookup when it tries to build a
target in a nonexistent directory that might have inference rules
associated with it (i.e., ends with a defined suffix), for example:

  % echo 'nonexistent/baz.o: ;' | make -f -
  Directory nonexistent/: Make: Cannot open.  Stop.

We can work around this problem by using a prerequisite to create
the output directory instead of creating it directly in the rule.
Automake itself actually does this already using dirstamps, so
let's try to patch things to use the same mechanism.  As a bonus,
this should reduce the number of mkdir invocations.

This breaks some of the relevant tests which are looking for specific
output.  Drop the %reldir% test completely as it appears every usage
in gnulib is for this exact scenario, and patch the subdirectory test
to expect the new output.

4 months agoglconfig.mk: Remove some redundant prerequisites.
Nick Bowler [Wed, 6 Dec 2023 02:11:35 +0000 (21:11 -0500)]
glconfig.mk: Remove some redundant prerequisites.

Since the glsym rules are only invoked recursively by a rule that
already has all required dependencies, it is not necessary to have
prerequisites on the individual glsym files to the gnulib headers.

As it turns out these redundant prerequisites trip up "make" on
ULTRIX 4.5 due to a bug expanding $(gnulib_symfiles) (which I do
not fully understand), dropping it basically makes things work
just fine, so no real reason to hang onto it.

4 months agoDX_AUTOMAKE_COMPAT: Fix install-sh with newer Automake.
Nick Bowler [Wed, 6 Dec 2023 01:46:26 +0000 (20:46 -0500)]
DX_AUTOMAKE_COMPAT: Fix install-sh with newer Automake.

Current versions of Automake's install-sh depends on substitutions like
${var:-foo}, which are not supported by ULTRIX 4.5 /bin/sh.

Now, ksh does support these and configure does find and use this shell
on ULTRIX, but install-sh starts with #!/bin/sh so when it is executed
directly, it is run with /bin/sh instead of the shell we want.

We can work around the problem by patching up the MKDIR_P and INSTALL
assignments at configure time to include the known-good shell, which
seems to work well.

4 months agohelp_print_optstring: Better output on some old systems.
Nick Bowler [Wed, 6 Dec 2023 01:10:08 +0000 (20:10 -0500)]
help_print_optstring: Better output on some old systems.

Some very old printf implementations return 0 on success instead of the
number of bytes written.  We should never see a return of 0 normally,
so we can improve the output to be less of a garbled mess by printing a
newline if that happens (same as the error case).  This is a simple
tweak that should have virtually no impact on modern systems.

The tests are adapted to verify the new behaviour, although we'll mark
the result as "skipped" (assuming it is correct) instead of "passed"
since it's only sortof working.

4 months agohelp: Perform some suffix merging.
Nick Bowler [Tue, 5 Dec 2023 02:37:43 +0000 (21:37 -0500)]
help: Perform some suffix merging.

Change the format strings to change the two-space indent to just one
space.  This looks perfectly fine, and for the normal case enables half
the strings to be dropped as they are now suffixes of other strings.

We also move the strings in help_print_desc into the table, as one of
these is a suffix of the other, but out of the box GCC does not fully
perform this optimization.

4 months agohelp_print_optstring: New table-based implementation.
Nick Bowler [Tue, 5 Dec 2023 02:16:36 +0000 (21:16 -0500)]
help_print_optstring: New table-based implementation.

By moving the format strings into a single table and a table-based
lookup to select the matching string, we can drastically simplify
the control flow in this function.

This results in about a ~35% code size reduction compiled with gcc.

The tables are generated using gen-strtab.awk but we manually copy
it into the source file, as downstream users just pick out help.c
and help.h by themselves.

4 months agohelp_print_desc: Simplify implementation.
Nick Bowler [Tue, 5 Dec 2023 01:55:43 +0000 (20:55 -0500)]
help_print_desc: Simplify implementation.

Simplify the way this function works by basing the loop around strcspn.

There is a slight change of behaviour when called with i==0 and an empty
description.   Previously, no newline was printed.  Now, a newline is
printed.  I think the original behaviour was a mistake as it does not
make much sense (and this function serves no real purpose unless i is
nonzero).  The tests are updated to expect this behaviour change.

As a bonus, we no longer tickle a problem with some ancient systems
(e.g., ULTRIX 4.5) which have a printf that doesn't support a negative
precision argument to mean "default precision".  This problem actually
has no coverage in the test suite, so fix that up too.

4 months agogen-strtab.awk: Allow repeated whitespace in one-line strings.
Nick Bowler [Tue, 5 Dec 2023 01:36:17 +0000 (20:36 -0500)]
gen-strtab.awk: Allow repeated whitespace in one-line strings.

The documentation says that, for a one-line string, all whitespace
immediately following the identifier is deleted.

It does not say that anything happens to other withespace on the line,
but it turns out that consecutive sequences of whitespace are replaced
by a single space.  This is unexpected.

Fix up the script so that doesn't happen, and add a test for this.

4 months agogen-strtab.awk: Work around weird ULTRIX nawk bug.
Nick Bowler [Sun, 3 Dec 2023 06:04:21 +0000 (01:04 -0500)]
gen-strtab.awk: Work around weird ULTRIX nawk bug.

ULTRIX 4.5 nawk has a weird bug where it seems to sometimes "forget" the
length of $0 after it has been modified, when assigning the modified
value directly to a named variable.  For example:

  % echo x | nawk '{ $0 = "hello"; x = $0; print x "rld"; }'
  hrld
  % echo xx | nawk '{ $0 = "hello"; x = $0; print x "rld"; }'
  herld

The bug does not occur if there is an intervening assignment to any of
the field variables, or if the assignment is made slightly more complex,
or if any other variable is used:

  % echo x | nawk '{ $0 = "hello"; $1 = $1; x = $0; print x "rld"; }'
  hellorld
  % echo x | nawk '{ $0 = "hello"; x = "" $0; print x "rld"; }'
  hellorld
  % nawk 'BEGIN { z = "hello"; x = z; print x "rld"; }' z=x
  hellorld

So there are many easy workarounds.

4 months agogen-options.awk: Don't pass ERE to split().
Nick Bowler [Sun, 3 Dec 2023 05:52:53 +0000 (00:52 -0500)]
gen-options.awk: Don't pass ERE to split().

Strange behaviour is observed on ULTRIX 4.5 nawk when passing a
literal ERE as the fs argument to the split function.  There is
no problem passing an equivalent string instead.

4 months agoExplicitly test for empty strings in awk scripts.
Nick Bowler [Sun, 3 Dec 2023 05:36:52 +0000 (00:36 -0500)]
Explicitly test for empty strings in awk scripts.

ULTRIX 4.5 nawk does not treat arbitrary nonempty strings as "true"
in boolean contexts; they appear to be converted to integers and
compared against zero, which means most nonempty strings are false.
Easy enough to work around.

4 months agoAvoid local array parameters in awk scripts.
Nick Bowler [Sun, 3 Dec 2023 05:21:49 +0000 (00:21 -0500)]
Avoid local array parameters in awk scripts.

ULTRIX 4.5 nawk appears to not support local array parameters on user-
defined functions (it is OK for array arguments passed by the caller).
Things seems to work on the first call but on the second call the array
is not empty and other weird behaviours occur.

Using a global array instead seems OK and avoids the problem.

4 months agoRework backslash substitutions in awk scripts.
Nick Bowler [Sun, 3 Dec 2023 04:13:24 +0000 (23:13 -0500)]
Rework backslash substitutions in awk scripts.

It appears that even using plain "\\" in a replacement string for sub
and gsub is still problematic.  Most awks handle this OK (returning a
literal backslash) provided the next character is not a backslash, but
on ULTRIX 4.5 nawk eats the next character regardless and interprets
it as a backslash-escape sequence, oops.

So let's try something a bit different.  We can ask awk what it does
with "\\\\", and use either "\\\\" or "\\" depending on the answer.

Hopefully this actually works everywhere.

4 months agoInclude AT_INIT bugfix monkey patch in the testsuite.
Nick Bowler [Sun, 3 Dec 2023 03:47:29 +0000 (22:47 -0500)]
Include AT_INIT bugfix monkey patch in the testsuite.

I keep running into this stupid bug where AT_CHECK uses redirections on
: and this fails on certain shells[1].  Maybe one day it will be fixed
upstream.  We already have a workaround but the dxcommon test suite is
not using it... easily solved.

[1] https://lists.gnu.org/archive/html/autoconf-patches/2021-03/msg00000.html

4 months agoDX_GNULIB_SYMFILES: Don't use -v option with awk.
Nick Bowler [Sun, 3 Dec 2023 03:37:12 +0000 (22:37 -0500)]
DX_GNULIB_SYMFILES: Don't use -v option with awk.

Some older awks (e.g., ULTRIX 4.5 nawk) don't accept the "-v" option.
It is not actually needed here so easy enough to just change it.

4 months agoAdd a script to embed config.h into installed headers.
Nick Bowler [Sun, 3 Dec 2023 03:33:49 +0000 (22:33 -0500)]
Add a script to embed config.h into installed headers.

When installing a library, sometimes it is difficult to avoid that
certain aspects of the interface depend on the build configuration.

While it is possible use configuration header templates to create
reasonably installable header files, this script enables a different
approach: just write code (mostly) normally and then patch up any
configuration macro references at install time.

4 months agogl-patches: Stub out gl_CC_GNULIB_WARNINGS.
Nick Bowler [Fri, 1 Dec 2023 05:46:35 +0000 (00:46 -0500)]
gl-patches: Stub out gl_CC_GNULIB_WARNINGS.

We don't need these pointless additional configure tests when using
newer gnulib (this trick imported from rrace).

4 months agoAdd a helper macro for gnulib monkey patches.
Nick Bowler [Fri, 1 Dec 2023 02:31:06 +0000 (21:31 -0500)]
Add a helper macro for gnulib monkey patches.

Certain gnulib patches can be applied directly at m4 time, which
makes it pretty simple to share between projects, and should be a
bit more robust than e.g., patching conditional dependencies in
bootstrap scripts.

4 months agoAdd a configure test for C99-ish "for" declarations.
Nick Bowler [Thu, 30 Nov 2023 01:33:29 +0000 (20:33 -0500)]
Add a configure test for C99-ish "for" declarations.

Several C89-era compilers support for loop declarations (although
I'm not sure if they implement C99 block scoping rules exactly and
this new macro doesn't check for that).

It is generally easy to simply not use this feature, so conditional
compilation based on its presence is of limited utility.  But it can
sometimes be handy to know when (optionally) including third-party
code that depends on this syntax.

The test is short-circuited based on Autoconf's C version probes, which
requires an annoying amount of complexity because Autoconf 2.70 has
totally broken C99 detection and Autoconf 2.71 includes incompatible
changes to previously-documented behaviour.

4 months agogettext.mk: Rewrite rules with less forking.
Nick Bowler [Tue, 21 Nov 2023 05:20:26 +0000 (00:20 -0500)]
gettext.mk: Rewrite rules with less forking.

Use a pure shell solution to parse the .mo filenames instead
of forking out to expr, and don't use subshells with "set -x"
to print commands when we can almost as easily use plain echo.

4 months agogettext.mk: Fix installation rules with some shells.
Nick Bowler [Tue, 21 Nov 2023 03:57:23 +0000 (22:57 -0500)]
gettext.mk: Fix installation rules with some shells.

The following syntax is not portable to certain shells:

  for f in ; do stuff; done

When no translations are installed, a command just like this is
generated in the installation rules.  Instead of doing nothing
as desired, HP-UX 11 /bin/sh, heirloom-sh, and presumably also
old Solaris /bin/sh will exit with an error.

To work around this problem, we can stuff the list into a shell
variable and then use that in the for loop.

4 months agotests: Add some coverage of the gettext.mk snippet.
Nick Bowler [Tue, 21 Nov 2023 03:42:33 +0000 (22:42 -0500)]
tests: Add some coverage of the gettext.mk snippet.

There is zero test coverage of this snippet, add a new test case to
executes these rules in various ways.  As with other test cases, one
can set TEST_SHELL in the environment to test the behaviour with a
particular shell.  The astute reader may notice that the rules do
not work with some shells...

5 months agofix-gnulib: Restore compatibility with perl 5.8.
Nick Bowler [Sat, 18 Nov 2023 20:54:56 +0000 (15:54 -0500)]
fix-gnulib: Restore compatibility with perl 5.8.

The //= operator was added in perl 5.10.  The benefit of using it in
this script is way too slight to be worth losing compatibility.

5 months agopack: Fix 64-bit tests on old HP cc.
Nick Bowler [Sat, 18 Nov 2023 20:45:20 +0000 (15:45 -0500)]
pack: Fix 64-bit tests on old HP cc.

At least some versions of the HP compiler appear to require "ll" suffix,
otherwise the decimal constants end up as a 32-bit type.

5 months agopack: Improve 64-bit detection.
Nick Bowler [Sat, 18 Nov 2023 20:28:10 +0000 (15:28 -0500)]
pack: Improve 64-bit detection.

HP-UX 11.11 does not provide (U)LLONG_MAX in <limits.h>, but does provide
(U)LONG_LONG_MAX.  Tweak the check to find this, and also accept the
Autoconf-provided HAVE_LONG_LONG_INT so things just work if that is
used.

5 months agotests: Improve portability for perl script tests.
Nick Bowler [Sat, 18 Nov 2023 07:40:51 +0000 (02:40 -0500)]
tests: Improve portability for perl script tests.

Older versions of perl do not recognize the "-f" option, which I think
was just used by mistake anyway, so we can just remove it.

Sed commands like /foo/{g;p} are not portable; POSIX requires it to be
written like:

  /foo/{
  g
  p
  }

HP-UX 11 sed does not interpret "-f -" to mean "read the script from
standard input", as intended; it looks for a file called - instead.
There is little reason to do this, we can just quote the script
normally.

Fixing all this allows the tests to run on HP-UX 11.

5 months agogen-strtab.awk: Work around HP-UX shell bug in test case.
Nick Bowler [Fri, 17 Nov 2023 08:03:42 +0000 (03:03 -0500)]
gen-strtab.awk: Work around HP-UX shell bug in test case.

On HP-UX /bin/sh, redirections on "read" in a subshell can drop some
input on the floor.  Since Autotest runs many things in subshells, we
hit this when trying to construct the program to dump the string table.

Rearranging the code to use only a single redirection works around
the problem.

5 months agohelp: Fix NLS test on HP-UX 11.
Nick Bowler [Fri, 17 Nov 2023 05:28:11 +0000 (00:28 -0500)]
help: Fix NLS test on HP-UX 11.

This system has a "C.utf8" locale which appears disfunctional, all
other utf8 locales are OK.  So change the locale probe to avoid this
one if possible.

The HP-UX shell also seems to have some trouble with UTF-8 (especially
if the user set this C.utf8 locale where it just barfs on everything),
so rework the test to not involve the shell trying to decode strings.

5 months agogen-options.awk: Fix test with older gettext.
Nick Bowler [Fri, 17 Nov 2023 04:17:22 +0000 (23:17 -0500)]
gen-options.awk: Fix test with older gettext.

Really old versions of xgettext do not support msgctx, but they do
produce _some_ output so the test is not skipped, just fails.

Enhance the xgettext probe to skip the test with these old versions, and
split it into two so we can still get a proper pass result for the rest.

5 months agocopysym: Avoid dependency on <stdint.h>
Nick Bowler [Fri, 17 Nov 2023 04:07:34 +0000 (23:07 -0500)]
copysym: Avoid dependency on <stdint.h>

The <inttypes.h> header is older and a bit more portable.  But even
then, it is not really essential for this code.  So adjust things to
use <inttypes.h> only if the Autoconf-provided HAVE_INTTYPES_H is
defined; otherwise a C89 <limits.h>-based fallback is used.

5 months agoPartially fix "make distcheck".
Nick Bowler [Fri, 17 Nov 2023 03:12:41 +0000 (22:12 -0500)]
Partially fix "make distcheck".

It is helpful to build a distribution package to run tests on other
machines, which may not have full development toolsets available.

This packages things up so at least the compilation part of distcheck
succeeds.

5 months agohelp: Allow tests to build/run without <getopt.h>
Nick Bowler [Fri, 17 Nov 2023 02:29:27 +0000 (21:29 -0500)]
help: Allow tests to build/run without <getopt.h>

We only need a suitable definition of struct option in order to build
the tests; this can be provided by a stub header if the system does not
provide it.

5 months agohelp_print_optstring: Don't depend on snprintf.
Nick Bowler [Thu, 16 Nov 2023 01:33:31 +0000 (20:33 -0500)]
help_print_optstring: Don't depend on snprintf.

The current code calls snprintf unconditionally, even if NLS is disabled
(although the function is not called, the code is still compiled), so it
won't build in environments which lack this function.

For the NLS-enabled case we can rely on the GNU libintl fallback being
available as required.

Otherwise we can just provide a stub to ensure the dead code compiles,
and for the NLS test programs hack in sprintf as a replacement which
should work just fine.

5 months agohelp_print_optstring: Test fullwidth/halfwidth character output.
Nick Bowler [Thu, 16 Nov 2023 01:04:16 +0000 (20:04 -0500)]
help_print_optstring: Test fullwidth/halfwidth character output.

This function is supposed to support proper alignment with translated
strings possibly containing fullwidth characters, but we have no
test coverage of that aspect whatsoever.

Let's try to have at least some basic tests, which is made a bit
tricky since Autotest/m4sh busts the locale (but we can work around
this problem).

8 months agoAdd a configure test for syslog support.
Nick Bowler [Sat, 29 Jul 2023 00:07:28 +0000 (20:07 -0400)]
Add a configure test for syslog support.

9 months agotest-tap: Fix Solaris /bin/sh "prove: not found" on stderr.
Nick Bowler [Sat, 1 Jul 2023 21:32:57 +0000 (17:32 -0400)]
test-tap: Fix Solaris /bin/sh "prove: not found" on stderr.

The prove command is intended to be optional, just to display a summary
of the test result if it is available.  However, on old Solaris /bin/sh,
our command

  prove ... 2>&1

doesn't redirect the error message from the shell when prove is not
found.  We can use a command like like

  { prove ...; } 2>&1

instead, which does redirect the error.

9 months agotest-tap: Use m4_require to pull in global definitions.
Nick Bowler [Sat, 1 Jul 2023 20:53:08 +0000 (16:53 -0400)]
test-tap: Use m4_require to pull in global definitions.

We can use the m4_require machinery to pull in the PREPARE_TESTS bits,
so they only get included if/when the TEST_TAP macro is actually used.

9 months agoAdd helper to work around Solaris /bin/sh bug in Autotest.
Nick Bowler [Sat, 1 Jul 2023 20:38:06 +0000 (16:38 -0400)]
Add helper to work around Solaris /bin/sh bug in Autotest.

This hackjob edits the definition of AT_INIT to fix the problem
described in this patch[1], even for versions of Autoconf which
do not include this fix (which, as of this writing, is all of
them).

Specifically, older Solaris /bin/sh does not correctly handle
redirections on : within a shell function, but Autotest test
suites expect this to work when preparing the environment
for AT_CHECK.

[1] https://lists.gnu.org/archive/html/autoconf-patches/2021-03/msg00000.html

10 months agocopysym: Fix pointer qualifier mismatch.
Nick Bowler [Fri, 16 Jun 2023 04:01:35 +0000 (00:01 -0400)]
copysym: Fix pointer qualifier mismatch.

The "const void *" in the search function can't be directly assigned to
the "const char (*)[5]" variable, due to the differently-qualified
pointer target types.  Let's just cast off that qualifier, shall we?

10 months agoMove TAP testsuite macros into snippets.
Nick Bowler [Tue, 13 Jun 2023 01:14:19 +0000 (21:14 -0400)]
Move TAP testsuite macros into snippets.

That way we can share these macros more easily.  Furthermore, merge in
some compatibility improvements w/ old perl that were implemented in
rrace.

10 months agotap: Include <config.h> as needed.
Nick Bowler [Tue, 13 Jun 2023 01:01:27 +0000 (21:01 -0400)]
tap: Include <config.h> as needed.

When using a config header in Autoconf, it is necessary to #include
that header before including anything else that might be influenced
by configure tests, which includes standard C headers.

In particular, things can go completely off the rails if Gnulib is
involved and generates replacements for the standard headers used
by this file.

10 months agocopysym: Avoid including xtra.h.
Nick Bowler [Tue, 30 May 2023 00:35:15 +0000 (20:35 -0400)]
copysym: Avoid including xtra.h.

Using the xtra.h header just for the arraysize macro is just added
complexity for downstream projects (who then need to ensure the xtra.h
header is distributed even if they don't otherwise need it).

10 months agoAdd a dedicated function to emit the copyright symbol.
Nick Bowler [Sat, 27 May 2023 00:56:45 +0000 (20:56 -0400)]
Add a dedicated function to emit the copyright symbol.

This is intended to replace gnulib's str_iconv function in programs
when the only use of that function is to generate a copyright symbol
for output.  This implementation should be much more compact.

12 months agohelp_print_desc: Ensure newline is printed for empty description.
Nick Bowler [Thu, 13 Apr 2023 01:11:38 +0000 (21:11 -0400)]
help_print_desc: Ensure newline is printed for empty description.

Callers expect help_print_desc to always end on a new line, so that the
next option can be printed at the start of a new line.  Currently,
however, this function does nothing for an empty description string,
leading to incorrect output unless the option name was long enough
that help_print_optstring took care of it.

Add a special case to fix that up, and a new test case.

14 months agogen-strtab.awk: Add an option to suppress object definitions.
Nick Bowler [Thu, 26 Jan 2023 02:06:21 +0000 (21:06 -0500)]
gen-strtab.awk: Add an option to suppress object definitions.

Defining objects in the generated header can make some usage more
difficult.  Add an option which defines a macro instead, allowing
the user to control definitions.

14 months agoUse AC_PROG_AWK and $AWK in DX_LINGUAS.
Nick Bowler [Tue, 24 Jan 2023 04:21:42 +0000 (23:21 -0500)]
Use AC_PROG_AWK and $AWK in DX_LINGUAS.

The awk script used internally by this macro does not work on traditional
awk, such as old Solaris /bin/awk.  Use $AWK to get a better awk.

To avoid similar problems in the future, arrange for tests to be run
with a busted "awk" command in PATH, so only $AWK will work at all.

14 months agoxtra: Avoid undefined ## usage.
Nick Bowler [Mon, 23 Jan 2023 04:34:16 +0000 (23:34 -0500)]
xtra: Avoid undefined ## usage.

According to the C spec, every use of the ## operator has to produce a
valid preprocessing token, otherwise the behaviour is undefined.  It is
not enough to merely ensure that a sequence of ## operators results in
a valid token at the end.

This matters in practice, as at least some versions of the Sun Studio
compiler will turn:

  #define PASTE(a, b) a ## b
  #define PASTE2(a, b) PASTE(a, b)

  PASTE2(uint_least, PASTE(8, _t))

into two tokens:

  uint_least8 _t

instead of uint_least8_t as desired.  The results are not good for
the XTRA_PACKED_LOPTS macro.  Fortunately, it is straightforward to
rearrange the expansions to avoid this problem.

14 months agotests: Don't use AT_TESTED for optional build tools.
Nick Bowler [Mon, 23 Jan 2023 04:31:24 +0000 (23:31 -0500)]
tests: Don't use AT_TESTED for optional build tools.

Turns out that AT_TESTED causes a hard failure if a listed tool is not
installed.  This makes it useless to get version numbers recorded for
build tools that may or may not be available, so I guess we just have
to code that up explicitly.

14 months agotests: Generate gen-options.awk expected output better.
Nick Bowler [Mon, 23 Jan 2023 04:23:52 +0000 (23:23 -0500)]
tests: Generate gen-options.awk expected output better.

In the main test group for gen-options.awk, various combinations of
sed and shell line noise are used to create the expected output.

It turns out that at least some versions of Solaris /bin/sed don't
accept patterns like [^\n] as meaning "any character other than
newline", which causes this line noise to fail.  We could perhaps
use /usr/xpg4/bin/sed instead which seems to not have this specific
problem, but let's just do everything in awk which is much simpler.

14 months agotests: Add missing returns test programs.
Nick Bowler [Mon, 23 Jan 2023 04:14:16 +0000 (23:14 -0500)]
tests: Add missing returns test programs.

Failing to "return" from main is well-defined in C99, but older
implementations will have undefined results.  Easily solved.

15 months agoAdd a helper macro to use the new gen-options packed format.
Nick Bowler [Sun, 8 Jan 2023 05:32:22 +0000 (00:32 -0500)]
Add a helper macro to use the new gen-options packed format.

Abstract some of the boilerplate into a new macro.  The gen-options.awk
is augmented to also give the packed format width as a power of two
(8/16/32/64).  Other than that we can use all the existing definitions
to make this common code in a new "xtra.h" header file.

15 months agogen-options.awk: Work around busybox regex bug.
Nick Bowler [Sun, 8 Jan 2023 04:19:18 +0000 (23:19 -0500)]
gen-options.awk: Work around busybox regex bug.

It appears that busybox awk does not recognize \] in a character class,
interpreting the backslash literally and taking the ] as the end of the
character class:

  % printf '%s\n' ']' '\]' | busybox awk '/^[\]]$/ { print; }'
  \]

  % printf '%s\n' ']' '\]' | gawk '/^[\]]$/ { print; }'
  ]

Busybox does accept []] as meaning "] is part of the character class",
but this syntax is not portable to heirloom (and presumably also Solaris
10) awk, which only works with [\]].  GNU awk accepts either form.

So instead, let's avoid this problematic construct entirely by writing
the test in a different way.

15 months agogen-options.awk: Fix generated help text under mawk.
Nick Bowler [Sun, 8 Jan 2023 04:14:56 +0000 (23:14 -0500)]
gen-options.awk: Fix generated help text under mawk.

It appears that the following construction is not portable:

  % gawk 'BEGIN { a[0] = 0 in a ? 54 : 42; print a[0]; }'
  42

  % mawk 'BEGIN { a[0] = 0 in a ? 54 : 42; print a[0]; }'
  54

In gen-options.awk, this results in results in bogus leading newlines
added to the help text.  It is easy enough to restructure the code
to not do that, separating the test from the assignment.

15 months agogen-options.awk: Add a more compact data representation.
Nick Bowler [Sun, 8 Jan 2023 02:14:10 +0000 (21:14 -0500)]
gen-options.awk: Add a more compact data representation.

Add a new set of macros that can be used to encode the long options
array as integers, which is possible provided that the "action"
feature is not used.  In addition to reducing the size of the
static array, it should be helpful to avoid relocations in
position-independent executables and improve data sharing.

15 months agogen-strtab.awk: Work around portability problems with \\\\.
Nick Bowler [Wed, 4 Jan 2023 03:41:58 +0000 (22:41 -0500)]
gen-strtab.awk: Work around portability problems with \\\\.

It seems that mawk, and also gawk in POSIX mode, handle backslashes
in the (g)sub replacement strings strangely.  For example:

  % echo 'hello' | mawk '{ sub(/e/, "\\\\"); print }'
  h\llo

  % echo 'hello' | gawk '{ sub(/e/, "\\\\"); print }'
  h\\llo

  % echo 'hello' | POSIXLY_CORRECT=1 gawk '{ sub(/e/, "\\\\"); print }'
  h\llo

This causes errors when the script tries to use gsub to restore
the double backslashes on these implementations.  There seems to
be no trouble substiting "\\" to get a single backslash, so we
can work around the problem by doubling up the characters being
replaced instead (which additionally requires an adjustment to
the length calculations to reverse this).

15 months agogen-strtab.awk: Work around parse issue on HP-UX 11.
Nick Bowler [Wed, 4 Jan 2023 02:19:09 +0000 (21:19 -0500)]
gen-strtab.awk: Work around parse issue on HP-UX 11.

HP-UX 11 awk seems to have some issues parsing ! in expressions.
For example:

  % awk 'BEGIN { print 1 + !0 }'
  syntax error The source line is 1.
  The error context is
BEGIN { print 1 + >>>  ! <<< 0 }
  awk: The statement cannot be correctly parsed.
  The source line is 1.

Adding parentheses appers sufficient to avoid the problem:

  % awk 'BEGIN { print 1 + (!0) }'
  2

15 months agogen-strtab.awk: Add a feature to disable l10n markings.
Nick Bowler [Tue, 3 Jan 2023 04:08:00 +0000 (23:08 -0500)]
gen-strtab.awk: Add a feature to disable l10n markings.

Preceding an identifier with two ampersands now causes the output to
not include the N_ macro for that string, so xgettext won't pick it up.
This enables creating a mixed string table with some strings marked as
translatable and others not.

15 months agogen-strtab.awk: Add options to tweak the output.
Nick Bowler [Tue, 3 Jan 2023 02:31:45 +0000 (21:31 -0500)]
gen-strtab.awk: Add options to tweak the output.

Add a @nozero option to ensure all strings have non-zero offsets
into the strtab.

17 months agoDX_PROG_MD5: direct probing error messages to the log file.
Nick Bowler [Fri, 18 Nov 2022 03:00:27 +0000 (22:00 -0500)]
DX_PROG_MD5: direct probing error messages to the log file.

Otherwise we can get a bunch of garbage printed to the terminal when
configuring on some systems.

17 months agoAdd a macro to probe -mwindows on MinGW.
Nick Bowler [Fri, 18 Nov 2022 02:55:34 +0000 (21:55 -0500)]
Add a macro to probe -mwindows on MinGW.

MinGW is typically configured to build console applications by default.
So in order to build a normal Windows GUI application, this flag is
needed when linking.  Otherwise, a console window will be opened when
the program is run.

Other Windows compilers probably have similar options which can added to
the probe in the future.

22 months agogen-tree.awk: Allow simple '#' comments.
Nick Bowler [Sat, 18 Jun 2022 01:33:07 +0000 (21:33 -0400)]
gen-tree.awk: Allow simple '#' comments.

22 months agogen-tree.awk: Add options to tweak the strtab output.
Nick Bowler [Sat, 18 Jun 2022 01:29:28 +0000 (21:29 -0400)]
gen-tree.awk: Add options to tweak the strtab output.

Add a @nostrtab option to disable the string table output in tree
generation, and make it possible to omit the node identifiers from
the initializers.

22 months agoAdd some curses-related feature tests.
Nick Bowler [Tue, 7 Jun 2022 03:56:03 +0000 (23:56 -0400)]
Add some curses-related feature tests.

Add helper macros to check the existence of specific functions in the
curses library, and also a helper to check for mouse support functions.

22 months agoAdd library test for curses.
Nick Bowler [Sun, 5 Jun 2022 15:59:13 +0000 (11:59 -0400)]
Add library test for curses.

22 months agoAdd missing file for autotest snippet test.
Nick Bowler [Wed, 8 Jun 2022 01:50:06 +0000 (21:50 -0400)]
Add missing file for autotest snippet test.

The test for --disable-dependency-tracking depends on a mock autotest
command but I apparently failed to commit that script.

23 months agoexported.sh: Work around DJGPP shell redirection bug.
Nick Bowler [Thu, 21 Apr 2022 05:29:22 +0000 (01:29 -0400)]
exported.sh: Work around DJGPP shell redirection bug.

In DJGPP's bash port, it seems that redirections of the form

  /absolute/path/to/program 3>&-

result in the file descriptor being closed for the whole shell,
rather than just for the one command as expected.  Since some of
the configure substitutions into exported.sh can be absolute paths,
this causes failures.

Using a different command syntax avoids this problem.  For example,

  { /absolute/path/to/program; } 3>&-

appears to work as expected.  Adjust the exported.sh.in snippet to
do just that.  There is still one redirection error message printed
to stderr by DJGPP bash but it appears spurious at first glance.
All the redirections now appear to be working properly and the
script output looks good.

23 months agoexported.sh: Restructure argument processing a bit.
Nick Bowler [Thu, 21 Apr 2022 05:23:05 +0000 (01:23 -0400)]
exported.sh: Restructure argument processing a bit.

Adjust the script to iterate over arguments using a for loop instead of
repeatedly checkind $# and shifting.  More significantly, avoid calling
expr on each filename where a case pattern can do the job.

Additionally, add a new test case to verify the basic sanity of this
script and its corresponding Autoconf macro.

2 years agoFix autotest snippet with --disable-dependency-tracking.
Nick Bowler [Sat, 26 Mar 2022 03:58:29 +0000 (23:58 -0400)]
Fix autotest snippet with --disable-dependency-tracking.

When configuring with --disable-dependency-tracking, the .deps
directories are not created by config.status so unconditionally
creating files in there will not work.

We can avoid this problem by adjusting the rule to skip updating
testsuite.P in this configuration.  Add a new test case to expose
the issue.

2 years agoFix glconfig with --disable-dependency-tracking.
Nick Bowler [Thu, 24 Mar 2022 02:22:50 +0000 (22:22 -0400)]
Fix glconfig with --disable-dependency-tracking.

When configuring with --disable-dependency-tracking, the .deps
directories are not created by config.status so unconditionally
creating files in there will not work.

Making the dependency file generation conditional will avoid this
problem.  Add a new test case to cover this issue.

2 years agofix-gnulib: Ensure header rules create output directory.
Nick Bowler [Thu, 24 Mar 2022 01:31:06 +0000 (21:31 -0400)]
fix-gnulib: Ensure header rules create output directory.

Normally there is no problem, but when performing a VPATH builds
with --disable-dependency-tracking the "lib" directory does not get
created by configure and some of the rules that create header files
will fail.

It seems recent versions of Gnulib have a potential solution for this
particular problem but is easy enough to patch it up here too.

2 years agofix-gnulib: Drop silly libgnu warning options.
Nick Bowler [Sun, 27 Feb 2022 01:21:42 +0000 (20:21 -0500)]
fix-gnulib: Drop silly libgnu warning options.

We really don't care about upstream's choice of build warning flags.
All pushing this on downstream users does is massively inflate generated
makefiles for no actual benefit.

2 years agofix-ltdl: Fix LIBOBJ mangling to work with automake-1.16.
Nick Bowler [Sat, 26 Feb 2022 22:55:30 +0000 (17:55 -0500)]
fix-ltdl: Fix LIBOBJ mangling to work with automake-1.16.

Apparently automake 1.16 changed how object files in a subdirectory are
named when using subdir-objects.  As the generated rules to copy compiled
objects to the ltdl_LTLIBOBJ substituted names, these rules are now failing
on current automake.

Fix this by explicitly setting a _SHORTNAME for the dummy libobj library,
which explicitly sets the name to use and thus it will be consistent
between different Automake versions.

Add new test cases to verify this behaviour.

2 years agofix-ltdl: Fix order-only hack with HP-UX make.
Nick Bowler [Sat, 26 Feb 2022 20:26:58 +0000 (15:26 -0500)]
fix-ltdl: Fix order-only hack with HP-UX make.

HP-UX make gets confused by the space in $(findstring ...,$(...))
syntax: instead of expanding to the empty string as desired, it
mismatches the parentheses and we are left with a single ).  E.g.:

  % cat >Makefile <<'EOF'
  all:
@echo '$(a $(b))'
EOF
  % make
  )

Since $(x) and ${x} are equivalent in Make, a neat solution is to
just replace one set of parentheses with braces; now there are no
nested parentheses to mismatch in the first place.

2 years agohelp_print_optstring: Fix handling of 'flag' options.
Nick Bowler [Thu, 24 Feb 2022 01:47:55 +0000 (20:47 -0500)]
help_print_optstring: Fix handling of 'flag' options.

When getopt_long options use the 'flag' feature, the 'val' member is
not meaningful as a short option.  So we shouldn't try to format it
as if there is a short option, as this leads to printing garbage.