]> git.ipfire.org Git - thirdparty/gettext.git/commitdiff
Refactor: Use function str_startswith.
authorBruno Haible <bruno@clisp.org>
Fri, 3 Jan 2025 15:19:12 +0000 (16:19 +0100)
committerBruno Haible <bruno@clisp.org>
Wed, 8 Jan 2025 09:03:23 +0000 (10:03 +0100)
* libtextstyle/gnulib-local/lib/term-ostream.oo.c (should_enable_hyperlinks):
Use str_startswith.
* libtextstyle/gnulib-local/modules/term-ostream (Depends-on): Add
str_startswith.
* gettext-tools/src/cldr-plural.y (yylex): Use str_startswith.
* gettext-tools/src/format-java.c (message_format_parse, choice_format_parse):
Likewise.
* gettext-tools/src/msgl-check.c (plural_help, check_header_entry): Likewise.
* gettext-tools/src/read-catalog-abstract.c (parse_comment_filepos): Likewise.
* gettext-tools/src/read-csharp.c (msgdomain_read_csharp): Likewise.
* gettext-tools/src/write-csharp.c (msgdomain_write_csharp): Likewise.
* gettext-tools/src/x-perl.c (skip_pod): Likewise.
* autogen.sh (GNULIB_MODULES_TOOLS_FOR_SRC, GNULIB_MODULES_LIBGETTEXTPO): Add
str_startswith.

autogen.sh
gettext-tools/src/cldr-plural.y
gettext-tools/src/format-java.c
gettext-tools/src/msgl-check.c
gettext-tools/src/read-catalog-abstract.c
gettext-tools/src/read-csharp.c
gettext-tools/src/write-csharp.c
gettext-tools/src/x-perl.c
libtextstyle/gnulib-local/lib/term-ostream.oo.c
libtextstyle/gnulib-local/modules/term-ostream

index a0e2ce1c430c3f7014c04c534f7d455e5f55aa1b..11bdca36f630ccea8e02697f51c60eeb52b3f9ad 100755 (executable)
@@ -6,7 +6,7 @@
 #
 # This script requires autoconf-2.64..2.72 and automake-1.13..1.17 in the PATH.
 
-# Copyright (C) 2003-2024 Free Software Foundation, Inc.
+# Copyright (C) 2003-2025 Free Software Foundation, Inc.
 #
 # This program is free software: you can redistribute it and/or modify
 # it under the terms of the GNU General Public License as published by
@@ -241,6 +241,7 @@ if ! $skip_gnulib; then
     stdlib-h
     stpcpy
     stpncpy
+    str_startswith
     strchrnul
     strcspn
     strerror
@@ -390,6 +391,7 @@ if ! $skip_gnulib; then
     stdlib-h
     stpcpy
     stpncpy
+    str_startswith
     strchrnul
     strerror
     string-desc
index 49c7bddb1904ecb823072dc6d9614ab9cfa8aac6..19c272b947d007eec9f0f6ca53a3273d05b2e6dc 100644 (file)
@@ -1,5 +1,5 @@
 /* Unicode CLDR plural rule parser and converter.
-   Copyright (C) 2015-2024 Free Software Foundation, Inc.
+   Copyright (C) 2015-2025 Free Software Foundation, Inc.
 
    This file was written by Daiki Ueno <ueno@gnu.org>, 2015.
 
@@ -326,27 +326,27 @@ yylex (YYSTYPE *lval, struct cldr_plural_parse_args *arg)
       arg->cp = exp + length;
       return ELLIPSIS;
     }
-  else if (strncmp ("...", exp, 3) == 0)
+  else if (str_startswith (exp, "..."))
     {
       arg->cp = exp + 3;
       return ELLIPSIS;
     }
-  else if (strncmp ("..", exp, 2) == 0)
+  else if (str_startswith (exp, ".."))
     {
       arg->cp = exp + 2;
       return RANGE;
     }
-  else if (strncmp ("other", exp, 5) == 0)
+  else if (str_startswith (exp, "other"))
     {
       arg->cp = exp + 5;
       return OTHER;
     }
-  else if (strncmp ("@integer", exp, 8) == 0)
+  else if (str_startswith (exp, "@integer"))
     {
       arg->cp = exp + 8;
       return AT_INTEGER;
     }
-  else if (strncmp ("@decimal", exp, 8) == 0)
+  else if (str_startswith (exp, "@decimal"))
     {
       arg->cp = exp + 8;
       return AT_DECIMAL;
index 7de2bceaea45c308a11675a8d1f327ac141d1c2c..c957b06e5e50b8ba3badd30cbc20c83aac1c4414 100644 (file)
@@ -1,5 +1,5 @@
 /* Java MessageFormat format strings.
-   Copyright (C) 2001-2004, 2006-2007, 2009, 2019, 2023 Free Software Foundation, Inc.
+   Copyright (C) 2001-2025 Free Software Foundation, Inc.
    Written by Bruno Haible <haible@clisp.cons.org>, 2001.
 
    This program is free software: you can redistribute it and/or modify
@@ -219,8 +219,8 @@ message_format_parse (const char *format, char *fdi, struct spec *spec,
           type = FAT_OBJECT;
           if (*element == '\0')
             ;
-          else if (strncmp (element, ",time", 5) == 0
-                   || strncmp (element, ",date", 5) == 0)
+          else if (str_startswith (element, ",time")
+                   || str_startswith (element, ",date"))
             {
               type = FAT_DATE;
               element += 5;
@@ -255,7 +255,7 @@ message_format_parse (const char *format, char *fdi, struct spec *spec,
                   return false;
                 }
             }
-          else if (strncmp (element, ",number", 7) == 0)
+          else if (str_startswith (element, ",number"))
             {
               type = FAT_NUMBER;
               element += 7;
@@ -289,7 +289,7 @@ message_format_parse (const char *format, char *fdi, struct spec *spec,
                   return false;
                 }
             }
-          else if (strncmp (element, ",choice", 7) == 0)
+          else if (str_startswith (element, ",choice"))
             {
               type = FAT_NUMBER; /* because ChoiceFormat extends NumberFormat */
               element += 7;
@@ -543,7 +543,7 @@ choice_format_parse (const char *format, struct spec *spec,
       number_nonempty = false;
       while (*format != '\0'
              && !(!quoting && (*format == '<' || *format == '#'
-                               || strncmp (format, "\\u2264", 6) == 0
+                               || str_startswith (format, "\\u2264")
                                || *format == '|')))
         {
           if (format[0] == '\\')
@@ -576,7 +576,7 @@ choice_format_parse (const char *format, struct spec *spec,
 
       if (*format == '<' || *format == '#')
         format += 1;
-      else if (strncmp (format, "\\u2264", 6) == 0)
+      else if (str_startswith (format, "\\u2264"))
         format += 6;
       else
         {
index 3d944dcc8969f7690d236200761886fd8c83f604..46471cc56552c2b35659c9f5ed65545d9b7dd397 100644 (file)
@@ -1,5 +1,5 @@
 /* Checking of messages in PO files.
-   Copyright (C) 1995-2023 Free Software Foundation, Inc.
+   Copyright (C) 1995-2025 Free Software Foundation, Inc.
    Written by Ulrich Drepper <drepper@gnu.ai.mit.edu>, April 1995.
 
    This program is free software: you can redistribute it and/or modify
@@ -213,9 +213,7 @@ plural_help (const char *nullentry)
 
           language += 15;
           for (j = 0; j < plural_table_size; j++)
-            if (strncmp (language,
-                         plural_table[j].language,
-                         strlen (plural_table[j].language)) == 0)
+            if (str_startswith (language, plural_table[j].language))
               {
                 ptentry = &plural_table[j];
                 break;
@@ -782,8 +780,7 @@ check_header_entry (const message_ty *mp, const char *msgstr_string,
               if (*p == ' ')
                 p++;
               if (default_values[cnt] != NULL
-                  && strncmp (p, default_values[cnt],
-                              strlen (default_values[cnt])) == 0)
+                  && str_startswith (p, default_values[cnt]))
                 {
                   p += strlen (default_values[cnt]);
                   if (*p == '\0' || *p == '\n')
index ea455c10eddeca95fb18e95b8868470cc35ac199..e42b6b8f8db5fb65f68c9e43b1972bb1cec76ee9 100644 (file)
@@ -1,5 +1,5 @@
 /* Reading textual message catalogs (such as PO files), abstract class.
-   Copyright (C) 1995-2024 Free Software Foundation, Inc.
+   Copyright (C) 1995-2025 Free Software Foundation, Inc.
 
    This file was written by Peter Miller <millerp@canb.auug.org.au>
 
@@ -261,8 +261,7 @@ parse_comment_filepos (abstract_catalog_reader_ty *catr, const char *s)
         {
           bool isolated_filename =
             (catr->po_lex_isolate_start != NULL
-             && strncmp (s, catr->po_lex_isolate_start,
-                         strlen (catr->po_lex_isolate_start)) == 0);
+             && str_startswith (s, catr->po_lex_isolate_start));
           if (isolated_filename)
             s += strlen (catr->po_lex_isolate_start);
 
@@ -278,8 +277,7 @@ parse_comment_filepos (abstract_catalog_reader_ty *catr, const char *s)
                       filename_end = s;
                       break;
                     }
-                  if (strncmp (s, catr->po_lex_isolate_end,
-                               strlen (catr->po_lex_isolate_end)) == 0)
+                  if (str_startswith (s, catr->po_lex_isolate_end))
                     {
                       filename_end = s;
                       s += strlen (catr->po_lex_isolate_end);
index bc02dd64bc30a3b872b811c924b9dabcf76cf5b7..de6602346edc97f7887e18018ec65985ea175958 100644 (file)
@@ -1,5 +1,5 @@
 /* Reading C# satellite assemblies.
-   Copyright (C) 2003-2024 Free Software Foundation, Inc.
+   Copyright (C) 2003-2025 Free Software Foundation, Inc.
    Written by Bruno Haible <bruno@clisp.org>, 2003.
 
    This program is free software: you can redistribute it and/or modify
@@ -117,7 +117,7 @@ msgdomain_read_csharp (const char *resource_name, const char *locale_name,
     for (p = culture_name; *p != '\0'; p++)
       if (*p == '_')
         *p = '-';
-    if (strncmp (culture_name, "sr-CS", 5) == 0)
+    if (str_startswith (culture_name, "sr-CS"))
       memcpy (culture_name, "sr-SP", 5);
     p = strchr (culture_name, '@');
     if (p != NULL)
index dac983d8f20306562631d137549e41712c22ff23..c0250eadf8419d91e0ee190143038b6cc7b87d07 100644 (file)
@@ -1,5 +1,5 @@
 /* Writing C# satellite assemblies.
-   Copyright (C) 2003-2024 Free Software Foundation, Inc.
+   Copyright (C) 2003-2025 Free Software Foundation, Inc.
    Written by Bruno Haible <bruno@clisp.org>, 2003.
 
    This program is free software: you can redistribute it and/or modify
@@ -674,7 +674,7 @@ msgdomain_write_csharp (message_list_ty *mlp, const char *canon_encoding,
     for (p = culture_name; *p != '\0'; p++)
       if (*p == '_')
         *p = '-';
-    if (strncmp (culture_name, "sr-CS", 5) == 0)
+    if (str_startswith (culture_name, "sr-CS"))
       memcpy (culture_name, "sr-SP", 5);
     p = strchr (culture_name, '@');
     if (p != NULL)
index 60c25efd69e2fe162632f0874fc10557225439a8..77826490abdcb6edf1d16b7d749890df20ac5035 100644 (file)
@@ -536,7 +536,7 @@ skip_pod (struct perl_extractor *xp)
 
       ++(xp->line_number);
 
-      if (strncmp ("=cut", xp->linebuf, 4) == 0)
+      if (str_startswith (xp->linebuf, "=cut"))
         {
           /* Force reading of a new line on next call to phase1_getc().  */
           xp->linepos = xp->linesize;
index 932231459f053b9f9230f70e79f3409e678353a6..a7b08bb70fe2be8cd54d55f02b18622495f98955 100644 (file)
@@ -2351,7 +2351,7 @@ should_enable_hyperlinks (const char *term)
            --------------------+-------------+---------------------
            emacs-terminal 26.1 | eterm-color | produces garbage
        */
-      if (strncmp (term, "eterm", 5) == 0)
+      if (str_startswith (term, "eterm"))
         return false;
 
       /* xterm-compatible terminal emulators:
@@ -2368,13 +2368,13 @@ should_enable_hyperlinks (const char *term)
 
          TODO: Revisit this table periodically.
        */
-      if (strncmp (term, "xterm", 5) == 0)
+      if (str_startswith (term, "xterm"))
         {
           char *progname = get_terminal_emulator_progname ();
           if (progname != NULL)
             {
               bool known_buggy =
-                strncmp (progname, "python", 6) == 0 /* guake */
+                str_startswith (progname, "python") /* guake */
                 || strcmp (progname, "lilyterm") == 0
                 || strcmp (progname, "lterm") == 0
                 || strcmp (progname, "lxterminal") == 0
index c68f28136c7968882960f76216c77f99fcb75185..f63d01979d6b55521db73be049e19984c01474bf 100644 (file)
@@ -18,6 +18,7 @@ gettimeofday
 get_ppid_of
 get_progname_of
 stdint-h
+str_startswith
 terminfo-h
 xalloc
 xgethostname