]> git.ipfire.org Git - thirdparty/gnulib.git/commitdiff
csharpcomp: Use str_endswith.
authorBruno Haible <bruno@clisp.org>
Sat, 21 Feb 2026 00:48:07 +0000 (01:48 +0100)
committerBruno Haible <bruno@clisp.org>
Sat, 21 Feb 2026 00:48:07 +0000 (01:48 +0100)
Suggested by Paul Eggert in
<https://lists.gnu.org/archive/html/bug-gnulib/2026-02/msg00129.html>.

* lib/csharpcomp.c (compile_csharp_using_mono,
compile_csharp_using_dotnet, compile_csharp_using_sscli,
compile_csharp_class): Use str_endswith.
* modules/csharpcomp (Depends-on): Add str_endswith.

ChangeLog
lib/csharpcomp.c
modules/csharpcomp

index 0dc39d4c6deb59da0ab06b813d8d0953fd7c236e..7928d808932e94e22fea23aabac278d5d5cf5075 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,13 @@
+2026-02-20  Bruno Haible  <bruno@clisp.org>
+
+       csharpcomp: Use str_endswith.
+       Suggested by Paul Eggert in
+       <https://lists.gnu.org/archive/html/bug-gnulib/2026-02/msg00129.html>.
+       * lib/csharpcomp.c (compile_csharp_using_mono,
+       compile_csharp_using_dotnet, compile_csharp_using_sscli,
+       compile_csharp_class): Use str_endswith.
+       * modules/csharpcomp (Depends-on): Add str_endswith.
+
 2026-02-20  Bruno Haible  <bruno@clisp.org>
 
        i-ring: Relicense under LGPLv2+.
index afbd65a9dac92368464a62bfa3f09acc2c891ac3..1a17addcf1c1a1a351836cd5381cf45731641b69 100644 (file)
@@ -177,9 +177,7 @@ compile_csharp_using_mono (const char * const *sources,
         for (unsigned int i = 0; i < sources_count; i++)
           {
             const char *source_file = sources[i];
-            if (strlen (source_file) >= 10
-                && memeq (source_file + strlen (source_file) - 10,
-                          ".resources", 10))
+            if (str_endswith (source_file, ".resources"))
               {
                 char *option = (char *) xmalloca (10 + strlen (source_file) + 1);
 
@@ -588,10 +586,7 @@ compile_csharp_using_dotnet (const char * const *sources,
             const char *source_file = sources[i];
             char *source_file_converted = cygpath_w (source_file);
             *mallocedp++ = source_file_converted;
-            if (strlen (source_file_converted) >= 10
-                && memeq ((source_file_converted
-                           + strlen (source_file_converted) - 10),
-                          ".resources", 10))
+            if (str_endswith (source_file_converted, ".resources"))
               {
                 char *option =
                   (char *) xmalloc (10 + strlen (source_file_converted) + 1);
@@ -771,10 +766,7 @@ compile_csharp_using_dotnet (const char * const *sources,
                 const char *source_file = sources[i];
                 char *source_file_converted = cygpath_w (source_file);
                 *mallocedp++ = source_file_converted;
-                if (strlen (source_file_converted) >= 10
-                    && memeq ((source_file_converted
-                               + strlen (source_file_converted) - 10),
-                              ".resources", 10))
+                if (str_endswith (source_file_converted, ".resources"))
                   {
                     char *option =
                       (char *) xmalloc (10 + strlen (source_file_converted) + 1);
@@ -934,10 +926,7 @@ compile_csharp_using_sscli (const char * const *sources,
             const char *source_file = sources[i];
             char *source_file_converted = cygpath_w (source_file);
             *mallocedp++ = source_file_converted;
-            if (strlen (source_file_converted) >= 10
-                && memeq ((source_file_converted
-                           + strlen (source_file_converted) - 10),
-                          ".resources", 10))
+            if (str_endswith (source_file_converted, ".resources"))
               {
                 char *option =
                   (char *) xmalloc (10 + strlen (source_file_converted) + 1);
@@ -990,9 +979,7 @@ compile_csharp_class (const char * const *sources,
                       bool optimize, bool debug,
                       bool verbose)
 {
-  bool output_is_library =
-    (strlen (output_file) >= 4
-     && memeq (output_file + strlen (output_file) - 4, ".dll", 4));
+  bool output_is_library = str_endswith (output_file, ".dll");
 
   int result;
 
index 0e9c226fae95f86a08ae49284621d3bee5cb81fa..76d7ddb268445e3de83b30bfa6fe7394c7d9a277 100644 (file)
@@ -19,6 +19,7 @@ alphasort
 sh-quote
 safe-read
 stringeq
+str_endswith
 xmalloca
 xvasprintf
 gettext-h