From: Bruno Haible Date: Sat, 21 Feb 2026 00:48:07 +0000 (+0100) Subject: csharpcomp: Use str_endswith. X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=bdb76c4ac202c52d6646e0f5e6dcf2ec98ee1173;p=thirdparty%2Fgnulib.git csharpcomp: Use str_endswith. Suggested by Paul Eggert in . * 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. --- diff --git a/ChangeLog b/ChangeLog index 0dc39d4c6d..7928d80893 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,13 @@ +2026-02-20 Bruno Haible + + csharpcomp: Use str_endswith. + Suggested by Paul Eggert in + . + * 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 i-ring: Relicense under LGPLv2+. diff --git a/lib/csharpcomp.c b/lib/csharpcomp.c index afbd65a9da..1a17addcf1 100644 --- a/lib/csharpcomp.c +++ b/lib/csharpcomp.c @@ -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; diff --git a/modules/csharpcomp b/modules/csharpcomp index 0e9c226fae..76d7ddb268 100644 --- a/modules/csharpcomp +++ b/modules/csharpcomp @@ -19,6 +19,7 @@ alphasort sh-quote safe-read stringeq +str_endswith xmalloca xvasprintf gettext-h