9 Commits

Author SHA1 Message Date
Bruno Haible
5a22e428a6 javascript-format: Reject null precision.
Proof that it's invalid:
------------------------------- foo.js -------------------------------
const Format = imports.format;
String.prototype.format = Format.format;
print("%.f".format(3.1415916535));
----------------------------------------------------------------------
$ gjs foo.js

* gettext-tools/src/format-invalid.h (INVALID_PRECISION_MISSING): New macro.
* gettext-tools/src/format-java-printf.c (INVALID_PRECISION_MISSING): Remove
macro.
* gettext-tools/src/format-javascript.c: Fix comment regarding the precision.
(format_parse): Report an error if the precision is null (empty).
* gettext-tools/tests/format-javascript-1: Add a test case with null precision.
2025-06-22 01:20:32 +02:00
Daiki Ueno
59d9b55bb2 tests: Use Exit instead of exit if init.sh is used
* gettext-tools/tests/*: Use Exit instead of exit, as suggested by
init.sh.
2016-06-08 15:28:49 +09:00
Daiki Ueno
3b5753977d tests: Add more tests for JavaScript format string
* gettext-tools/tests/format-javascript-1: Add test for multiple uses of
same argument.
* gettext-tools/tests/format-javascript-2: Use proper flag to activate
javascript format checker.
2016-05-23 12:04:23 +09:00
Daiki Ueno
9b9ebf8f96 javascript: Support '%m$' in format strings
Gjs has had support for numbered arguments in format strings since 1.40.
Recognize it as well in format-javascript, so msgfmt -c doesn't fail
when numbered arguments are in msgstr.  Reported by Sean Burke in:
https://lists.gnu.org/archive/html/bug-gettext/2015-10/msg00002.html
* gettext-tools/src/format-javascript.c (struct numbered_arg): New
struct.
(struct spec): Rename format_args_count to numbered_arg_count.  Add
NUMBERED field in place of FORMAT_ARGS.  All callers changed.
(numbered_arg_compare): New function.
(format_parse): Handle numbered arguments.  Based on format-awk.c.
(format_check): Add check for numbered arguments.
* gettext-tools/tests/format-javascript-1: Add tests for numbered
arguments.
* gettext-tools/tests/lang-javascript: Use numbered argument in format
strings.  Add check for Gjs version >= 1.40.
2016-02-08 12:40:23 +09:00
Daiki Ueno
ec84e32c72 tests: Undo the previous unintended file mode changes 2014-03-10 21:10:01 +09:00
Daiki Ueno
d66197a3ca tests: Remove unnecessary tempfile cleanup code
Cleanup code like "rm -fr $tmpfiles" are no longer needed, since
'init.sh' takes care of that.
2014-03-10 18:24:15 +09:00
Daiki Ueno
6c0abd26de gettext-tools: convert tests to use init.sh from Gnulib 2013-07-10 18:34:09 +09:00
Daiki Ueno
700f69a4f1 Minor fixes for the JavaScript support. 2013-04-19 10:57:01 +09:00
Andreas Stricker
fe8db3b5b4 Support for JavaScript. 2013-04-17 17:51:07 +09:00