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.
AT_BANNER([Script tests])
AT_BANNER([Script tests])
-AT_SETUP([gen-options.awk])
-AT_KEYWORDS([gen-options awk script scripts])
+m4_define([TEST_GEN_OPTIONS],
+[AT_KEYWORDS([gen-options awk script scripts])dnl
+AT_DATA([m4_default([$2], [options.def])], [$1])
+AT_CHECK([$AWK -f "$srcdir/scripts/gen-options.awk" dnl
+<m4_default([$2], [options.def]) >options.h])])
+m4_define([TEST_GEN_OPTIONS_SAMPLE],
[[--option-only
--option-with-val (5)
--option-with-flagval (&x, 5)
[[--option-only
--option-with-val (5)
--option-with-flagval (&x, 5)
-AT_CHECK([$AWK -f "$srcdir/scripts/gen-options.awk" <options.def >options.h])
+AT_SETUP([gen-options.awk])
+TEST_GEN_OPTIONS([TEST_GEN_OPTIONS_SAMPLE])
AT_DATA([context.h],
[[struct option { const char *name; int has_arg; int *flag; int val; };
AT_DATA([context.h],
[[struct option { const char *name; int has_arg; int *flag; int val; };
AT_CHECK([$CC -o test2$EXEEXT test2.c && ./test2$EXEEXT],
[0], [expout], [ignore])
AT_CHECK([$CC -o test2$EXEEXT test2.c && ./test2$EXEEXT],
[0], [expout], [ignore])
+AT_CLEANUP
+
+AT_SETUP([gen-options.awk xgettext annotation])
+TEST_GEN_OPTIONS([TEST_GEN_OPTIONS_SAMPLE])
+
# Check that all help strings are translatable
AT_DATA([messages.awk],
[[BEGIN { lines = -1; }
# Check that all help strings are translatable
AT_DATA([messages.awk],
[[BEGIN { lines = -1; }
+dnl Antique versions of xgettext which predate the pgettext/msgctx feature
+dnl will produce an output po file with no msgctx lines. So try to spot
+dnl that and skip the test with such versions.
AT_CHECK([xgettext --keyword=PN_:1c,2 options.h
AT_CHECK([xgettext --keyword=PN_:1c,2 options.h
- test -f messages.po || exit 77])
+ test -f messages.po || exit 77
+ grep msgid messages.po >/dev/null &&
+ { grep msgctx messages.po >/dev/null || exit 77; }])
$AWK -f messages.awk options.def | LC_ALL=C sort >expout
AT_CHECK([sed -n '/^msgctxt/{
$AWK -f messages.awk options.def | LC_ALL=C sort >expout
AT_CHECK([sed -n '/^msgctxt/{
AT_CLEANUP
AT_SETUP([gen-options.awk packed format])
AT_CLEANUP
AT_SETUP([gen-options.awk packed format])
-AT_KEYWORDS([gen-options awk script scripts])
AT_DATA([test.c], [[#include <stdio.h>
struct option { const char *name; int has_arg; int *flag; int val; };
AT_DATA([test.c], [[#include <stdio.h>
struct option { const char *name; int has_arg; int *flag; int val; };
-AT_DATA([single.dat],
-[[--single-option
-]])
-AT_CHECK([$AWK -f "$srcdir/scripts/gen-options.awk" <single.dat >options.h])
+TEST_GEN_OPTIONS([[--single-option
+]], [single.dat])
AT_CHECK([$CC -o single$EXEEXT test.c && ./single$EXEEXT], [0],
[[0
--single-option, 0, 0
]])
AT_CHECK([$CC -o single$EXEEXT test.c && ./single$EXEEXT], [0],
[[0
--single-option, 0, 0
]])
-AT_DATA([16bit.dat],
-[[-a, --the-first-option
+TEST_GEN_OPTIONS([[-a, --the-first-option
-b, --the-second-option=ARG
-c, --the-third-option[=ARG]
-d, --the-fourth-option
-b, --the-second-option=ARG
-c, --the-third-option[=ARG]
-d, --the-fourth-option
-]])
-AT_CHECK([$AWK -f "$srcdir/scripts/gen-options.awk" <16bit.dat >options.h])
AT_CHECK([$CC -o 16bit$EXEEXT test.c && ./16bit$EXEEXT], [0],
[[2
--the-first-option, 0, 'a'
AT_CHECK([$CC -o 16bit$EXEEXT test.c && ./16bit$EXEEXT], [0],
[[2
--the-first-option, 0, 'a'