]> Savannah Git Hosting - gnulib.git/commitdiff
gen-uni-tables, get-rusage-data, isatty: Use str_endswith.
authorBruno Haible <bruno@clisp.org>
Fri, 3 Jan 2025 09:38:58 +0000 (10:38 +0100)
committerBruno Haible <bruno@clisp.org>
Fri, 3 Jan 2025 09:38:58 +0000 (10:38 +0100)
* lib/gen-uni-tables.c (fill_attributes): Use str_endswith.
* lib/get-rusage-data.c (get_rusage_data_via_setrlimit): Likewise.
* lib/isatty.c (IsCygwinConsoleHandle): Likewise.
* modules/gen-uni-tables (Depends-on): Add str_endswith.
* modules/get-rusage-data (Depends-on): Likewise.
* modules/isatty (Depends-on): Likewise.

ChangeLog
lib/gen-uni-tables.c
lib/get-rusage-data.c
lib/isatty.c
modules/gen-uni-tables
modules/get-rusage-data
modules/isatty

index 50b3f2e22e0cfaa81db0333c4b6d74ea2ace0d4e..b6a71b15e2356445405b527cfb48c6782fb0ccf6 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,13 @@
+2025-01-03  Bruno Haible  <bruno@clisp.org>
+
+       gen-uni-tables, get-rusage-data, isatty: Use str_endswith.
+       * lib/gen-uni-tables.c (fill_attributes): Use str_endswith.
+       * lib/get-rusage-data.c (get_rusage_data_via_setrlimit): Likewise.
+       * lib/isatty.c (IsCygwinConsoleHandle): Likewise.
+       * modules/gen-uni-tables (Depends-on): Add str_endswith.
+       * modules/get-rusage-data (Depends-on): Likewise.
+       * modules/isatty (Depends-on): Likewise.
+
 2025-01-03  Bruno Haible  <bruno@clisp.org>
 
        tests: Use str_startswith.
index c676660b073ff6d0a7ec86c617123b69b200ae30..2bac68c2da5be7bf3b68e0316b0259a7576e82dd 100644 (file)
@@ -219,7 +219,7 @@ fill_attributes (const char *unicodedata_filename)
       i = strtoul (field0, NULL, 16);
       if (field1[0] == '<'
           && strlen (field1) >= 9
-          && strcmp (field1 + strlen (field1) - 8, ", First>") == 0)
+          && str_endswith (field1, ", First>"))
         {
           /* Deal with a range. */
           lineno++;
@@ -246,7 +246,7 @@ fill_attributes (const char *unicodedata_filename)
             }
           if (!(field1[0] == '<'
                 && strlen (field1) >= 8
-                && strcmp (field1 + strlen (field1) - 7, ", Last>") == 0))
+                && str_endswith (field1, ", Last>")))
             {
               fprintf (stderr, "missing end range in '%s':%d\n",
                        unicodedata_filename, lineno);
index b4df73f766ea4d56fb061de5848887ccf6740f08..0fafc75a20c0b29a597cf1dd7db9cecab27d82c9 100644 (file)
@@ -174,9 +174,8 @@ get_rusage_data_via_setrlimit (void)
     struct utsname buf;
 
     if (uname (&buf) == 0
-        && strlen (buf.release) >= 5
-        && (strcmp (buf.release + strlen (buf.release) - 5, "11.00") == 0
-            || strcmp (buf.release + strlen (buf.release) - 5, "11.11") == 0))
+        && (str_endswith (buf.release, "11.00")
+            || str_endswith (buf.release, "11.11")))
       return 0;
   }
 #  endif
index 69371af607715cd3725040b9d47b775df2e179cc..23e3ab8f6df72146adc827573ca144aa895bda2f 100644 (file)
@@ -130,8 +130,7 @@ static BOOL IsCygwinConsoleHandle (HANDLE h)
              or higher.  */
           if (QueryFullProcessImageNameFunc (processHandle, 0, buf, &bufsize))
             {
-              if (strlen (buf) >= 11
-                  && strcmp (buf + strlen (buf) - 11, "\\mintty.exe") == 0)
+              if (str_endswith (buf, "\\mintty.exe"))
                 result = TRUE;
             }
           CloseHandle (processHandle);
index 561a39690b8050a7476980c589370afbfca22ad2..5808aef3ada34c5653bf73a495f14a2abe99b791 100644 (file)
@@ -13,6 +13,7 @@ bool
 strdup
 strstr-simple
 str_startswith
+str_endswith
 
 configure.ac:
 AC_REQUIRE([AC_C_INLINE])
index 1a7bf899035f31c806e66c268d01eee133ed2f3e..8d9110ac16f33499459233a163d0043c258c51b9 100644 (file)
@@ -12,6 +12,7 @@ unistd-h
 extensions
 getpagesize
 vma-iter
+str_endswith
 
 configure.ac:
 AC_CHECK_FUNCS_ONCE([sbrk setrlimit])
index e2fd7f09cd0fa3a7b39ea4cde62498c715e983b8..7499b53933e9beb818fd60860e8da408c6351382 100644 (file)
@@ -9,6 +9,7 @@ Depends-on:
 unistd-h
 msvc-inval      [test $REPLACE_ISATTY = 1]
 msvc-nothrow    [test $REPLACE_ISATTY = 1]
+str_endswith    [test $REPLACE_ISATTY = 1]
 
 configure.ac:
 gl_FUNC_ISATTY