From 8aecd09a8641c4cd408ee4ab1b97ff6fd3a39c58 Mon Sep 17 00:00:00 2001 From: Bruno Haible Date: Tue, 28 Jan 2025 11:04:52 +0100 Subject: [PATCH] format-ruby: Fix error handling. * gettext-tools/src/format-ruby.c (format_parse): Respect FDI_SET constraint. --- gettext-tools/src/format-ruby.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/gettext-tools/src/format-ruby.c b/gettext-tools/src/format-ruby.c index 8fd277c05..e24db7402 100644 --- a/gettext-tools/src/format-ruby.c +++ b/gettext-tools/src/format-ruby.c @@ -1,5 +1,5 @@ /* Ruby format strings. - Copyright (C) 2001-2024 Free Software Foundation, Inc. + Copyright (C) 2001-2025 Free Software Foundation, Inc. Written by Bruno Haible , 2020. This program is free software: you can redistribute it and/or modify @@ -301,13 +301,13 @@ format_parse (const char *format, bool translated, char *fdi, if (seen_precision) { *invalid_reason = INVALID_WIDTH_AFTER_PRECISION (spec.directives); - FDI_SET (format, FMTDIR_ERROR); + FDI_SET (*format == '\0' ? format - 1 : format, FMTDIR_ERROR); goto bad_format; } if (seen_width) { *invalid_reason = INVALID_WIDTH_TWICE (spec.directives); - FDI_SET (format, FMTDIR_ERROR); + FDI_SET (*format == '\0' ? format - 1 : format, FMTDIR_ERROR); goto bad_format; } seen_width = true; @@ -496,7 +496,7 @@ format_parse (const char *format, bool translated, char *fdi, if (seen_precision) { *invalid_reason = INVALID_PRECISION_TWICE (spec.directives); - FDI_SET (format, FMTDIR_ERROR); + FDI_SET (*format == '\0' ? format - 1 : format, FMTDIR_ERROR); goto bad_format; } seen_precision = true; -- 2.47.3