* gettext-tools/src/x-c.c (phase5_get): Recognize digit separators.
* gettext-tools/tests/xgettext-c-2: Add more test cases of integer and
floating-point literals.
* NEWS: Mention it.
-Version 0.21.2 - February 2023
+Version 0.21.2 - May 2023
* PO file format:
- When a #: line contains references to file names that contain spaces,
option.
* Programming languages support:
- - C, C++: xgettext now supports gettext-like functions that take wide strings
- (of type 'const wchar_t *', 'const char16_t *', or 'const char32_t *') as
- arguments.
+ - C, C++:
+ o xgettext now supports gettext-like functions that take wide strings
+ (of type 'const wchar_t *', 'const char16_t *', or 'const char32_t *')
+ as arguments.
+ o xgettext now recognizes numbers with digit separators, as defined by
+ ISO C 23, as tokens.
- Tcl: xgettext now supports the \x, \u, and \U escapes as defined in
Tcl 8.6.
case 'b':
return '\b';
- /* The \e escape is preculiar to gcc, and assumes an ASCII
+ /* The \e escape is peculiar to gcc, and assumes an ASCII
character set (or superset). We don't provide support for it
here. */
break;
}
}
+ else
+ {
+ /* In C23, a single-quote between two hexadecimal digits
+ can be part of a number token. It's called a "digit
+ separator". See ISO C 23 § 6.4.4.1 and § 6.4.4.2. */
+ if (bufpos > 0)
+ {
+ char prev = buffer[bufpos - 1];
+ if ((prev >= '0' && prev <= '9')
+ || (prev >= 'A' && prev <= 'F')
+ || (prev >= 'a' && prev <= 'f'))
+ {
+ int c1 = phase4_getc ();
+ if ((c1 >= '0' && c1 <= '9')
+ || (c1 >= 'A' && c1 <= 'F')
+ || (c1 >= 'a' && c1 <= 'f'))
+ {
+ if (bufpos >= bufmax)
+ {
+ bufmax = 2 * bufmax + 10;
+ buffer = xrealloc (buffer, bufmax);
+ }
+ buffer[bufpos++] = c;
+ c = c1;
+ continue;
+ }
+ /* The two phase4_getc() calls that returned c and c1
+ did nothing more than to call phase3_getc(),
+ without any lookahead. Therefore 2 pushback
+ characters are supported in this case. */
+ phase4_ungetc (c1);
+ }
+ }
+ }
FALLTHROUGH;
default:
phase4_ungetc (c);
_("after string")
static double d = 10e-1;
_("after double")
+static int x = 0x2a;
+_("after hex integer")
+static int b = 0b101011;
+_("after binary integer")
+static int i_c23 = 1'000;
+_("after integer with digit separator")
+static int x_c23 = 0xFE23'FFFF'FFFF'4321;
+_("after hex integer with digit separator")
+static double d_c23 = 0.333'333;
+_("after double with digit separator")
EOF
: ${XGETTEXT=xgettext}
msgid "after double"
msgstr ""
+
+msgid "after hex integer"
+msgstr ""
+
+msgid "after binary integer"
+msgstr ""
+
+msgid "after integer with digit separator"
+msgstr ""
+
+msgid "after hex integer with digit separator"
+msgstr ""
+
+msgid "after double with digit separator"
+msgstr ""
EOF
: ${DIFF=diff}