Bruno Haible [Mon, 13 Apr 2020 20:41:54 +0000 (22:41 +0200)]
Merge from 0.20.x branch: examples: Use infrastructure from gettext version 0.20.2.
* gettext-tools/examples/hello-*/configure.ac: Use AM_GNU_GETTEXT_VERSION with
version 0.20.2.
* gettext-tools/examples/hello-c++-kde/configure.in.in: Likewise.
Bruno Haible [Sat, 11 Apr 2020 21:00:21 +0000 (23:00 +0200)]
po: Emit a warning when creating a tarball without POT file.
* gettext-runtime/po/Makefile.in.in (dist2): Emit a warning when the POT file
does not exist.
* gettext-tools/examples/hello-*/po/Makefile.am (distdir1): Likewise.
Bruno Haible [Mon, 6 Apr 2020 21:29:56 +0000 (23:29 +0200)]
xgettext: Improve JSX support in JavaScript.
Reported by Vaclav Slavik <vaclav@slavik.io> in
<https://savannah.gnu.org/bugs/?57927>.
* gettext-tools/src/x-javascript.c (enum token_type_ty): Add some more types.
(is_after_expression): New function.
(phase5_get): Distinguish the "other" tokens in more detail. Use
'is_after_expression ()' when interpreting a '<' or '/' character.
(extract_balanced): Don't let commas in braced expressions and in XML elements
disturb the argument processing outside.
(extract_javascript): Update.
* gettext-tools/tests/xgettext-javascript-6: Enhance the test.
* NEWS: Mention the change.
Bruno Haible [Sun, 5 Apr 2020 13:08:34 +0000 (15:08 +0200)]
po, examples: In the .po -> .gmo rules, really consider the newest changes to the POT file.
Reported by Petr Ovtchenkov <ptr@void-ptr.info> in
<https://lists.gnu.org/archive/html/bug-gnulib/2020-04/msg00000.html>.
Helped by Paul Smith.
* gettext-runtime/po/Makefile.in.in (.po.gmo): Write dependency on the POT file
as a target rule, since inference rules don't support prerequisites.
* gettext-tools/examples/hello-*/po/Makefile.am: Likewise, also for the .po.qm
rule.
* NEWS: Mention the fix.
Bruno Haible [Mon, 24 Feb 2020 11:31:21 +0000 (12:31 +0100)]
urlget: Follow the "privacy by design" principle.
* gettext-tools/src/urlget.c (fetch): Override the User-Agent string, so as not
to reveal the program version to the server. For wget, use long options.
Dmitry V. Levin [Fri, 3 Jan 2020 12:08:20 +0000 (13:08 +0100)]
libtextstyle: Enable large files and, on Linux, 64-bit inodes support.
* libtextstyle/autogen.sh (GNULIB_MODULES): Add 'largefile' to enable
large files support on systems where this is not the default and 64-bit
inodes in 32-bit applications on Linux.
Bruno Haible [Tue, 24 Dec 2019 16:37:04 +0000 (17:37 +0100)]
build: Fix build failures on HP-UX 11.31/hppa with cc.
* gnulib-local/lib/libxml/parser.c (struct _xmlDefAttrs): Don't use ISO C 99
syntax with this compiler.
* gettext-runtime/intl/plural-exp.h (HAVE_STRUCT_INITIALIZER): Set to 0 with
this compiler.
Bruno Haible [Tue, 24 Dec 2019 16:37:00 +0000 (17:37 +0100)]
libtextstyle: Don't erase the .sym.in file if 'sed' is not GNU sed.
* libtextstyle/lib/Makefile.am (libtextstyle.sym.in): Test the exit status of
the declared.sh command. Preserve the existing libunistring.sym if it failed.
Bruno Haible [Sun, 24 Nov 2019 23:40:08 +0000 (00:40 +0100)]
libcroco: Improve copyright headers.
The copyright headers should be unambiguous even if a single file is copied from
the GNU gettext package and used elsewhere. Reported by John Darrington.
* libtextstyle/gnulib-local/lib/libcroco/*: Inline the COPYRIGHT file where
applicable. Add copyright header.
* libtextstyle/gnulib-local/lib/libcroco/libcroco-config.h: Add copyright header.
Bruno Haible [Sun, 24 Nov 2019 18:57:37 +0000 (19:57 +0100)]
libxml: Improve copyright headers.
The copyright headers should be unambiguous even if a single file is copied from
the GNU gettext package and used elsewhere. Reported by John Darrington.
* gnulib-local/lib/libxml/*: Inline this directory's COPYING file where
applicable. Add FSF copyright header.
* gnulib-local/lib/libxml/trionan.c: Add copyright header.
Bruno Haible [Sun, 24 Nov 2019 18:53:45 +0000 (19:53 +0100)]
glib: Improve copyright headers.
The copyright headers should be unambiguous even if a single file is copied from
the GNU gettext package and used elsewhere. Reported by John Darrington.
Bruno Haible [Fri, 4 Oct 2019 15:59:22 +0000 (17:59 +0200)]
build: Fix the build error in gettext-tools/examples/po.
Reported by Nick Alcock <nix@esperi.org.uk>
at <https://savannah.gnu.org/bugs/?56529>.
* gettext-tools/examples/po/Makefile.am (USE_BUILT_PROGS): New variable.
(hello-*.pot): Use it.
($(srcdir)/../hello-*/po/$(LL).po): Likewise.
* HACKING: Remove the workaround.
Bruno Haible [Fri, 4 Oct 2019 11:20:12 +0000 (13:20 +0200)]
libxml: Simplify autoconf macro.
* gnulib-local/m4/libxml.m4 (gl_LIBXML): Don't test for dlopen and shlload.
The test for dlopen failed, because it would require linking with '-ldl'.
The test for shlload failed, because the function on HP-UX is called 'shl_load'
and it would require linking with '-ldld'.
Bruno Haible [Fri, 4 Oct 2019 09:47:18 +0000 (11:47 +0200)]
build: Don't fetch gnulib a second time in libtextstyle.
* autogen.sh: Set GNULIB_SRCDIR when invoking libtextstyle/autogen.sh.
* libtextstyle/autogen.sh: Remove all git operations. Look at the GNULIB_SRCDIR
environment variable. Ignore the GNULIB_TOOL environment variable.
Bruno Haible [Sun, 29 Sep 2019 18:20:36 +0000 (20:20 +0200)]
msgcat: Signal error when the same msgid is used with and without msgid_plural.
Suggested by Mikko Rantalainen <mikko.rantalainen@peda.net>
in <https://lists.gnu.org/archive/html/bug-gettext/2019-09/msg00020.html>.
* gettext-tools/src/msgl-cat.c (catenate_msgdomain_list): Signal an error when
the same msgid is used with and without msgid_plural.
* gettext-tools/src/msgcat.c (main): Exit with failure code if there was an
error.
* gettext-tools/src/msgcomm.c (main): Likewise.
* gettext-tools/src/msguniq.c (main): Likewise.
* gettext-tools/tests/msgcat-21: New file.
* gettext-tools/tests/Makefile.am (TESTS): Add it.
Bruno Haible [Sun, 29 Sep 2019 12:29:41 +0000 (14:29 +0200)]
xgettext: Fix parsing of XML tags that end in /> and have attributes.
Reported by Matej Marusak <marusak.matej@gmail.com>
in <https://savannah.gnu.org/bugs/?56848>.
* gettext-tools/src/x-javascript.c (phase5_get): After reading a string, reset
the lexical_context to the previous one, not to lc_outside. When reading /> at
the end of an XML element, decrement xml_element_depth.
* gettext-tools/tests/xgettext-javascript-6: Add a test.
Bruno Haible [Sun, 29 Sep 2019 10:58:09 +0000 (12:58 +0200)]
xgettext: Recognize text blocks in Java parser.
* autogen.sh (GNULIB_MODULES_TOOLS_FOR_SRC): Add
unictype/syntax-java-whitespace.
* gettext-tools/src/x-java.c: Include unictype.h.
(strip_indent): New function.
(phase5_get): Parse text blocks (Java 13 syntax).
* gettext-tools/tests/xgettext-java-2: Add tests of text blocks.
* gettext-tools/doc/gettext.texi (Java): Mention the text block syntax.
* NEWS: Mention the change.
Bruno Haible [Mon, 16 Sep 2019 00:47:44 +0000 (02:47 +0200)]
xgettext: Recognize 'env' and assignments in Shell scripts.
Reported by Jason Vas Dias <jason.vas.dias@gmail.com>
in <https://lists.gnu.org/archive/html/bug-gettext/2019-08/msg00032.html>.
* gettext-tools/src/x-sh.c (enum word_type): Add t_assignment.
(read_word): Recognize assignments.
(read_command): In a function position, ignore assignments and 'env' tokens.
* gettext-tools/tests/xgettext-sh-7: New file.
* gettext-tools/tests/Makefile.am (TESTS): Add it.
* NEWS: Mention the change.
Bruno Haible [Sun, 1 Sep 2019 15:51:31 +0000 (17:51 +0200)]
build: Add support for shallow-cloning of subdirectories.
* gitsub.sh (func_usage): Document allowed git options with 'git pull'.
(func_pull): Accept GIT_OPTIONS argument.
(pull): Parse git options before complaining about too many arguments.
Pass the git options to func_pull.
Bruno Haible [Sun, 25 Aug 2019 21:37:44 +0000 (23:37 +0200)]
xgettext: Assume that Python source files are in UTF-8 by default.
Reported by ilias iliadis <apiuano-bugs@yahoo.gr>
at <https://savannah.gnu.org/bugs/?55231>.
* gettext-tools/src/xg-encoding.h (xgettext_global_source_encoding): Allow a
NULL value.
* gettext-tools/src/xg-encoding.c (xgettext_global_source_encoding): Likewise.
* gettext-tools/src/xgettext.c (main): Initialize
xgettext_global_source_encoding with NULL, not "ASCII". Handle a NULL
xgettext_global_source_encoding.
(extract_from_file): Use ASCII as default for xgettext_global_source_encoding.
* gettext-tools/src/x-javascript.c (extract_javascript): Likewise.
* gettext-tools/src/x-python.c (phase2_getc): Signal an error when encountering
an invalid or incomplete UTF-8 character.
(set_current_file_source_encoding): In the error message, use
xgettext_current_file_source_encoding instead of
xgettext_global_source_encoding.
(extract_python): Use UTF-8 as default for xgettext_global_source_encoding.
* gettext-tools/tests/xgettext-python-3: Verify that if the source file has no
magic coding comment but is UTF-8 encoded, xgettext succeeds.
* NEWS: Mention the change.
Bruno Haible [Sun, 25 Aug 2019 17:17:21 +0000 (19:17 +0200)]
Add support for Java format strings in the Formatter syntax.
* gettext-tools/src/message.h (format_type): Add format_java_printf.
(NFORMATS): Increment.
* gettext-tools/src/message.c (format_language, format_language_pretty): Add
entry for format_java_printf.
* gettext-tools/src/format.h (formatstring_java_printf): New declaration.
* gettext-tools/src/format-java.c: Update comments.
* gettext-tools/src/format-java-printf.c: New file.
* gettext-tools/src/format.c (formatstring_parsers): Add entry for
format_java_printf.
* gettext-tools/src/x-java.h (SCANNERS_JAVA): Use formatstring_java_printf.
* gettext-tools/src/x-java.c (init_flag_table_java): Add entries relevant to
format strings in Formatter syntax.
* gettext-tools/src/xgettext.c (xgettext_record_flag): Add support for
format_java_printf.
* gettext-tools/src/FILES: Add format-java-printf.c.
* gettext-tools/src/Makefile.am (FORMAT_SOURCE): Add format-java-printf.c.
* gettext-tools/woe32dll/gettextsrc-exports.c: Export formatstring_java_printf.
* gettext-tools/libgettextpo/Makefile.am (libgettextpo_la_AUXSOURCES): Likewise.
* gettext-tools/tests/xgettext-6 (xg-test6.java): Add test for recognition of
format strings in Formatter syntax.
* gettext-tools/tests/format-java-printf-1: New file.
* gettext-tools/tests/format-java-printf-2: New file.
* gettext-tools/tests/Makefile.am (TESTS): Add them.
* gettext-tools/tests/lang-java: Add two uses of String.format to the program.
* gettext-tools/doc/gettext.texi (PO Files): Document java-printf-format and
no-java-printf-format.
(java-format): Describe both kinds of format strings. Update URLs.
(Java): Mention the second kind of format string as well.
* NEWS: Mention the improvement.
Bruno Haible [Thu, 22 Aug 2019 14:36:59 +0000 (16:36 +0200)]
xgettext: Handle newlines in Lua long bracket literal strings correctly.
Reported by Frans de Jonge <fransdejonge@gmail.com>
at <https://savannah.gnu.org/bugs/?56794>.
* gettext-tools/src/x-lua.c (phase3_get): Test for EOF first. After an opening
long bracket, swallow one newline.
* gettext-tools/tests/xgettext-lua-1: Add tests for newlines in long brackets.
* gettext-tools/tests/xgettext-lua-2: Update comment.
Bruno Haible [Mon, 19 Aug 2019 08:24:30 +0000 (10:24 +0200)]
doc: Fix documentation of gettext, ngettext programs.
* gettext-runtime/doc/rt-gettext.texi: Clarify when the additional newline is
emitted.
* gettext-runtime/doc/rt-ngettext.texi: Remove '\c' from the list of recognized
escape sequences.
Bruno Haible [Sun, 18 Aug 2019 23:34:34 +0000 (01:34 +0200)]
xgettext: Fix parsing of escaped single-quote characters in shell parser.
Reported by Markus Gothe <nietzsche@lysator.liu.se>
at <https://savannah.gnu.org/bugs/?49809>.
* gettext-tools/src/x-sh.c (phase2_getc): Handle the case c == '\''
&& !open_singlequote && !open_doublequote differently.
* gettext-tools/tests/xgettext-sh-1: Add test with an escape single-quote.
Bruno Haible [Sun, 18 Aug 2019 11:27:30 +0000 (13:27 +0200)]
Don't extract Icon values from .desktop files into POT files.
Reported by Piotr Drąg <piotrdrag@gmail.com>
at <https://savannah.gnu.org/support/?108887>
and by Will Thompson <wjt@endlessm.com>
at <https://savannah.gnu.org/bugs/?56543>.
There was a discussion starting at
<https://lists.freedesktop.org/archives/xdg/2019-June/014158.html>.
The most interesting posts in this thread were
<https://lists.freedesktop.org/archives/xdg/2019-June/014164.html>
<https://lists.freedesktop.org/archives/xdg/2019-June/014167.html>.
* gettext-tools/doc/gettext.texi (Icons): New subsubsection.
* gettext-tools/src/read-desktop.c (desktop_add_default_keywords): Don't add
"Icon".
* gettext-tools/src/x-desktop.c: Update comments.
* gettext-tools/doc/xgettext.texi (Desktop): Remove 'Icon' from the list of
extracted keys.
* gettext-tools/tests/xgettext-desktop-2: New file.
* gettext-tools/tests/msgfmt-desktop-3: New file.
* gettext-tools/tests/Makefile.am (TESTS): Add them.
* NEWS: Mention the change.
Bruno Haible [Wed, 14 Aug 2019 18:52:35 +0000 (20:52 +0200)]
libtextstyle: Document the hyperlink support.
* libtextstyle/doc/libtextstyle.texi (The NO_TERM_HYPERLINKS variable): New
section.
(Hyperlinks): New subsection.
(The abstract styled_ostream class): Document styled_ostream_get_hyperlink_ref,
styled_ostream_get_hyperlink_id, styled_ostream_set_hyperlink.
(The term_ostream class): Document term_ostream_get_hyperlink_ref,
term_ostream_get_hyperlink_id, term_ostream_set_hyperlink.
(The html_ostream class): Document html_ostream_get_hyperlink_ref,
html_ostream_set_hyperlink_ref.
* libtextstyle/NEWS: Mention it.
* libtextstyle/gnulib-local/lib/html-ostream.oo.h (struct html_ostream): Add
methods get_hyperlink_ref, set_hyperlink_ref.
* libtextstyle/gnulib-local/lib/html-ostream.oo.c (struct html_ostream): Add
field hyperlink_ref;
(write_attribute_value): New function.
(html_ostream::free): Emit an anchor end if needed.
(html_ostream::get_hyperlink_ref, html_ostream::set_hyperlink_ref): New
functions.
(html_ostream_create): Initialize the hyperlink_ref field.
* libtextstyle/lib/textstyle.h (html_ostream_get_hyperlink_ref,
html_ostream_set_hyperlink_ref): New declarations.
Bruno Haible [Wed, 14 Aug 2019 00:46:36 +0000 (02:46 +0200)]
libtextstyle: Support the NO_COLOR environment variable.
It follows the specification at https://no-color.org/.
The support is in the example programs, not in the function
styled_ostream_create, so that it can be overridden through the command-line
option --color=always.
We only test whether the environment variable is set, not whether its value
is non-empty. POSIX-specified environment variables are treated like unset
when their value is empty; this is because in the old days it was not possible
to unset an environment variable. But nowadays:
- all shells support the 'unset' built-in,
- all platforms that have the setenv() function also have the unsetenv()
function, and
- the 'env' program from GNU coreutils supports --unset=VARIABLE to unset a
variable.
This makes it possible to unset an environment variable that is set by the
parent process.
* libtextstyle/adhoc-tests/hello.c (main): Do not emit styling when the
environment variable NO_COLOR is set.
* libtextstyle/examples/color-filter/filter.c (main): Likewise.
* libtextstyle/examples/color-hello/hello.c (main): Likewise.
* gettext-tools/src/write-catalog.c (msgdomain_list_print): Likewise.
* libtextstyle/doc/libtextstyle.texi (The NO_COLOR variable): New section.
* libtextstyle/NEWS: Mention it.
Bruno Haible [Mon, 12 Aug 2019 01:31:49 +0000 (03:31 +0200)]
xalloc: Add x2realloc function, from gnulib.
* gnulib-local/lib/xalloc.h (x2realloc): New declaration, from
gnulib/lib/xalloc.h.
* gnulib-local/lib/xmalloc.c (x2nrealloc): New function, from
gnulib/lib/xalloc.h.
(x2realloc): New function, from gnulib/lib/xmalloc.c.
* gnulib-local/modules/xalloc (configure.ac): Require AC_C_INLINE.