]> git.ipfire.org Git - thirdparty/gettext.git/commitdiff
Simplify strtoul() invocation.
authorBruno Haible <bruno@clisp.org>
Fri, 21 Mar 2025 21:37:12 +0000 (22:37 +0100)
committerBruno Haible <bruno@clisp.org>
Fri, 21 Mar 2025 21:37:12 +0000 (22:37 +0100)
* gnulib-local/lib/markup.c: Don't include <errno.h>.
(unescape_string_inplace): Don't reset or test errno.

gnulib-local/lib/markup.c

index a3a96146189dfec488957746fec78bba465d49ec..7c17d41fae049bef08e5508227380c16efe8f39f 100644 (file)
@@ -35,7 +35,6 @@
 #include <string.h>
 #include <stdio.h>
 #include <stdlib.h>
-#include <errno.h>
 
 /* Specification */
 #include "markup.h"
@@ -513,8 +512,10 @@ unescape_string_inplace (markup_parse_context_ty *context,
                 }
 
               if (!(base == 16 ? c_isxdigit (*from) : c_isdigit (*from))
-                  || (errno = 0,
-                      l = strtoul (from, &end, base),
+                  || /* No need to reset and test errno here, because in case
+                        of overflow, l will be == ULONG_MAX, which is
+                        > 0x10FFFF.  */
+                     (l = strtoul (from, &end, base),
                       end == from))
                 {
                   char *error_text =
@@ -533,10 +534,9 @@ unescape_string_inplace (markup_parse_context_ty *context,
                   free (error_text);
                   return false;
                 }
-              else if (errno == 0
-                       /* characters XML 1.1 permits */
-                       && ((0 < l && l <= 0xD7FF)
-                           || (0xE000 <= l && l <= 0xFFFD) || (0x10000 <= l && l <= 0x10FFFF)))
+              else if (/* characters XML 1.1 permits */
+                       (0 < l && l <= 0xD7FF)
+                       || (0xE000 <= l && l <= 0xFFFD) || (0x10000 <= l && l <= 0x10FFFF))
                 {
                   char buf[8];
                   int length;