printf: simplify conversion specifier

We already compute the length of the substring we want to print in Rust.
Passing that length as the precision to let printf formatting limit the
length is brittle, as it requires that the same semantics for "length"
are used.

Simplifying conversion specifiers also makes the transition to Fluent
easier.

Part of #12119
This commit is contained in:
Daniel Rainer
2025-11-28 01:10:13 +01:00
committed by danielrainer
parent 5130fc6f17
commit 8a75bccf00
9 changed files with 37 additions and 35 deletions

View File

@@ -79,10 +79,6 @@ msgstr ""
msgid "$status is not valid as a command. See `help %s`"
msgstr "$status ist kein gültiger Befehl. Siehe `help %s`"
#, c-format
msgid "%.*s: invalid conversion specification"
msgstr "%.*s: Ungültige Umwandlungsspezifikation"
#, c-format
msgid "%s"
msgstr ""
@@ -727,6 +723,10 @@ msgstr "%s: Brauche Funktionsnamen"
msgid "%s: given %d indexes but %d values\n"
msgstr ""
#, c-format
msgid "%s: invalid conversion specification"
msgstr "%s: Ungültige Umwandlungsspezifikation"
#, c-format
msgid "%s: invalid option combination\n"
msgstr "%s: ungültige Optionskombination\n"

View File

@@ -77,10 +77,6 @@ msgstr ""
msgid "$status is not valid as a command. See `help %s`"
msgstr ""
#, c-format
msgid "%.*s: invalid conversion specification"
msgstr "%.*s: invalid conversion specification"
#, c-format
msgid "%s"
msgstr ""
@@ -725,6 +721,10 @@ msgstr ""
msgid "%s: given %d indexes but %d values\n"
msgstr ""
#, c-format
msgid "%s: invalid conversion specification"
msgstr "%s: invalid conversion specification"
#, c-format
msgid "%s: invalid option combination\n"
msgstr ""

View File

@@ -208,10 +208,6 @@ msgstr "$@ nest pas supporté. Dans fish, veuillez utiliser $argv."
msgid "$status is not valid as a command. See `help %s`"
msgstr "$status nest pas une commande valide. Voir « help %s »"
#, c-format
msgid "%.*s: invalid conversion specification"
msgstr "%.*s : spécification de conversion invalide"
#, c-format
msgid "%s"
msgstr "%s"
@@ -856,6 +852,10 @@ msgstr ""
msgid "%s: given %d indexes but %d values\n"
msgstr ""
#, c-format
msgid "%s: invalid conversion specification"
msgstr "%s : spécification de conversion invalide"
#, c-format
msgid "%s: invalid option combination\n"
msgstr ""

View File

@@ -73,10 +73,6 @@ msgstr "$@ nie jest obsługiwane. W fish używane jest $argv."
msgid "$status is not valid as a command. See `help %s`"
msgstr ""
#, c-format
msgid "%.*s: invalid conversion specification"
msgstr ""
#, c-format
msgid "%s"
msgstr ""
@@ -721,6 +717,10 @@ msgstr ""
msgid "%s: given %d indexes but %d values\n"
msgstr ""
#, c-format
msgid "%s: invalid conversion specification"
msgstr ""
#, c-format
msgid "%s: invalid option combination\n"
msgstr ""

View File

@@ -78,10 +78,6 @@ msgstr ""
msgid "$status is not valid as a command. See `help %s`"
msgstr ""
#, c-format
msgid "%.*s: invalid conversion specification"
msgstr "%.*s: especificação de conversão inválida"
#, c-format
msgid "%s"
msgstr ""
@@ -726,6 +722,10 @@ msgstr ""
msgid "%s: given %d indexes but %d values\n"
msgstr ""
#, c-format
msgid "%s: invalid conversion specification"
msgstr "%s: especificação de conversão inválida"
#, c-format
msgid "%s: invalid option combination\n"
msgstr ""

View File

@@ -74,10 +74,6 @@ msgstr ""
msgid "$status is not valid as a command. See `help %s`"
msgstr ""
#, c-format
msgid "%.*s: invalid conversion specification"
msgstr ""
#, c-format
msgid "%s"
msgstr ""
@@ -722,6 +718,10 @@ msgstr ""
msgid "%s: given %d indexes but %d values\n"
msgstr ""
#, c-format
msgid "%s: invalid conversion specification"
msgstr ""
#, c-format
msgid "%s: invalid option combination\n"
msgstr ""

View File

@@ -100,10 +100,6 @@ msgstr "不支持 $@。在 fish 中,请使用 $argv。"
msgid "$status is not valid as a command. See `help %s`"
msgstr "$status 不是有效的命令。参见 `help %s`"
#, c-format
msgid "%.*s: invalid conversion specification"
msgstr "%.*s: 无效的转换规范"
#, c-format
msgid "%s"
msgstr "%s"
@@ -748,6 +744,10 @@ msgstr "%s: 函数名称是必须的"
msgid "%s: given %d indexes but %d values\n"
msgstr "%s: 给定索引 %d 但只有 %d 个值\n"
#, c-format
msgid "%s: invalid conversion specification"
msgstr "%s: 无效的转换规范"
#, c-format
msgid "%s: invalid option combination\n"
msgstr "%s: 无效的选项组合\n"

View File

@@ -73,10 +73,6 @@ msgstr "不支援 $@。在 fish 中請使用 $argv。"
msgid "$status is not valid as a command. See `help %s`"
msgstr "$status 不是有效的命令。參見「help %s」"
#, c-format
msgid "%.*s: invalid conversion specification"
msgstr "%.*s轉換規格無效"
#, c-format
msgid "%s"
msgstr "%s"
@@ -721,6 +717,10 @@ msgstr "%s需要函式名稱"
msgid "%s: given %d indexes but %d values\n"
msgstr "%s指定了 %d 個索引卻有 %d 個值\n"
#, c-format
msgid "%s: invalid conversion specification"
msgstr "%s轉換規格無效"
#, c-format
msgid "%s: invalid option combination\n"
msgstr "%s無效的選項組合\n"

View File

@@ -526,10 +526,12 @@ fn print_formatted(&mut self, format: &wstr, mut argv: &[&wstr]) -> usize {
let conversion = f.char_at(0);
if (conversion as usize) > 0xFF || !ok[conversion as usize] {
let directive = &directive_start[0..directive_start
.len()
.min(wstr_offset_in(f, directive_start) + 1)];
self.fatal_error(wgettext_fmt!(
"%.*s: invalid conversion specification",
wstr_offset_in(f, directive_start) + 1,
directive_start
"%s: invalid conversion specification",
directive
));
return 0;
}