* gettext-tools/src/x-c.c (phase5_get): Recognize the u8"..." syntax.
* gettext-tools/tests/xgettext-c-25: New file.
* gettext-tools/tests/Makefile.am (TESTS): Add it.
* NEWS: Mention the change.
- The .pot file in a 'po' directory is now erased by "make maintainer-clean".
* Programming languages support:
+ - C, C++:
+ xgettext now supports strings in u8"..." syntax, as specified in C11
+ and C++11.
- C, C++:
xgettext now supports 'p'/'P' exponent markers in number tokens, as
specified in C99 and C++17.
case '5': case '6': case '7': case '8': case '9':
continue;
+ case '"':
+ /* Recognize C11 / C++11 string literals.
+ See (for C) ISO 9899:2011 section 6.4.5
+ and (for C++) ISO C++ 11 section 2.14.5 [lex.string].
+ Note: The programmer who passes an UTF-8 encoded string to
+ gettext() or similar API functions will have to have called
+ bind_textdomain_codeset (DOMAIN, "UTF-8") first. */
+ if (bufpos == 2 && buffer[0] == 'u' && buffer[1] == '8')
+ goto string_literal;
+ /* FALLTHROUGH */
+
default:
phase4_ungetc (c);
break;
return;
case '"':
+ string_literal:
+ /* We could worry about the 'L' or 'u' or 'U' before wide string
+ constants, but since gettext's argument is a 'const char *', not
+ a 'const wchar_t *' (for 'L') nor a 'const char16_t *' (for 'u')
+ nor a 'const char32_t *' (for 'U'), the compiler would complain
+ about the argument not matching the prototype. Just pretend it
+ won't happen. */
{
struct mixed_string_buffer *bp;
logical_file_name,
line_number);
- /* We could worry about the 'L' before wide string constants,
- but since gettext's argument is not a wide character string,
- let the compiler complain about the argument not matching the
- prototype. Just pretend it won't happen. */
for (;;)
{
c = phase7_getc ();
xgettext-c-6 xgettext-c-7 xgettext-c-8 xgettext-c-9 xgettext-c-10 \
xgettext-c-11 xgettext-c-12 xgettext-c-13 xgettext-c-14 xgettext-c-15 \
xgettext-c-16 xgettext-c-17 xgettext-c-18 xgettext-c-19 xgettext-c-20 \
- xgettext-c-21 xgettext-c-22 xgettext-c-23 xgettext-c-24 \
+ xgettext-c-21 xgettext-c-22 xgettext-c-23 xgettext-c-24 xgettext-c-25 \
xgettext-csharp-1 xgettext-csharp-2 xgettext-csharp-3 \
xgettext-csharp-4 xgettext-csharp-5 xgettext-csharp-6 \
xgettext-csharp-7 xgettext-csharp-8 \
--- /dev/null
+#! /bin/sh
+. "${srcdir=.}/init.sh"; path_prepend_ . ../src
+
+# Test C support: C11 string literals.
+
+: ${XGETTEXT=xgettext}
+
+cat <<\EOF > xg-c-25.c
+gettext("Choose a " u8"rosé wine à la carte");
+EOF
+
+${XGETTEXT} --from-code=ISO-8859-1 --no-location \
+ -o xg-c-25.tmp xg-c-25.c || Exit 1
+grep -v 'POT-Creation-Date' < xg-c-25.tmp > xg-c-25.tmq || Exit 1
+LC_ALL=C tr -d '\r' < xg-c-25.tmq > xg-c-25.po || Exit 1
+
+cat <<\EOF > xg-c-25.ok
+# SOME DESCRIPTIVE TITLE.
+# Copyright (C) YEAR THE PACKAGE'S COPYRIGHT HOLDER
+# This file is distributed under the same license as the PACKAGE package.
+# FIRST AUTHOR <EMAIL@ADDRESS>, YEAR.
+#
+#, fuzzy
+msgid ""
+msgstr ""
+"Project-Id-Version: PACKAGE VERSION\n"
+"Report-Msgid-Bugs-To: \n"
+"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
+"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
+"Language-Team: LANGUAGE <LL@li.org>\n"
+"Language: \n"
+"MIME-Version: 1.0\n"
+"Content-Type: text/plain; charset=UTF-8\n"
+"Content-Transfer-Encoding: 8bit\n"
+
+msgid "Choose a rosé wine à la carte"
+msgstr ""
+EOF
+
+: ${DIFF=diff}
+${DIFF} xg-c-25.ok xg-c-25.po
+result=$?
+
+exit $result