From: Bruno Haible Date: Fri, 3 Jan 2025 09:12:08 +0000 (+0100) Subject: git-merge-changelog, gen-uni-tables: Use str_startswith. X-Git-Url: https://gitweb.git.savannah.gnu.org/gitweb/?a=commitdiff_plain;h=b20e8f40ea47cb80ef2f6f01dd34093b4eaca23b;p=gnulib.git git-merge-changelog, gen-uni-tables: Use str_startswith. * lib/git-merge-changelog.c (main): Use str_startswith. * lib/gen-uni-tables.c (output_predicate, is_property_composite, is_nonspacing): Likewise. * modules/git-merge-changelog (Depends-on): Add str_startswith. * modules/gen-uni-tables (Depends-on): Likewise. --- diff --git a/ChangeLog b/ChangeLog index b57ea5cae1..1355aa2361 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,12 @@ +2025-01-03 Bruno Haible + + git-merge-changelog, gen-uni-tables: Use str_startswith. + * lib/git-merge-changelog.c (main): Use str_startswith. + * lib/gen-uni-tables.c (output_predicate, is_property_composite, + is_nonspacing): Likewise. + * modules/git-merge-changelog (Depends-on): Add str_startswith. + * modules/gen-uni-tables (Depends-on): Likewise. + 2025-01-03 Bruno Haible str_endswith: Add tests. diff --git a/lib/gen-uni-tables.c b/lib/gen-uni-tables.c index ff515854e0..c676660b07 100644 --- a/lib/gen-uni-tables.c +++ b/lib/gen-uni-tables.c @@ -776,7 +776,7 @@ output_predicate (const char *filename, bool (*predicate) (unsigned int), const fprintf (stream, "\n"); output_library_license (stream, strcmp (filename, "unictype/categ_M.h") == 0 - || strncmp (filename, "unictype/ctype_", 15) == 0 + || str_startswith (filename, "unictype/ctype_") || strcmp (filename, "uniwidth/width2.h") == 0); fprintf (stream, "\n"); @@ -3883,7 +3883,7 @@ is_property_composite (unsigned int ch) if (decomp[0] == ' ') decomp++; } - return strchr (decomp, ' ') != NULL && strncmp (decomp, "0020 ", 5) != 0; + return strchr (decomp, ' ') != NULL && str_startswith (decomp, "0020 "); } return false; } @@ -6827,7 +6827,7 @@ is_nonspacing (unsigned int ch) || is_category_Cc (ch) || (is_category_Cf (ch) && !is_property_prepended_concatenation_mark (ch)) - || strncmp (unicode_attributes[ch].name, "ZERO WIDTH ", 11) == 0 + || str_startswith (unicode_attributes[ch].name, "ZERO WIDTH ") || (ch >= 0x1160 && ch <= 0x11A7) || (ch >= 0xD7B0 && ch <= 0xD7C6) /* jungseong */ || (ch >= 0x11A8 && ch <= 0x11FF) || (ch >= 0xD7CB && ch <= 0xD7FB) /* jongseong */ ) ); diff --git a/lib/git-merge-changelog.c b/lib/git-merge-changelog.c index 74b6a5b63a..190dafc140 100644 --- a/lib/git-merge-changelog.c +++ b/lib/git-merge-changelog.c @@ -1163,9 +1163,9 @@ There is NO WARRANTY, to the extent permitted by law.\n\ printf ("GIT_REFLOG_ACTION=|%s|\n", var); #endif if (var != NULL - && ((strncmp (var, "pull", 4) == 0 + && ((str_startswith (var, "pull") && c_strstr (var, " --rebase") == NULL) - || strncmp (var, "merge origin", 12) == 0)) + || str_startswith (var, "merge origin"))) downstream = true; else { diff --git a/modules/gen-uni-tables b/modules/gen-uni-tables index c61d34194c..561a39690b 100644 --- a/modules/gen-uni-tables +++ b/modules/gen-uni-tables @@ -12,6 +12,7 @@ memcmp bool strdup strstr-simple +str_startswith configure.ac: AC_REQUIRE([AC_C_INLINE]) diff --git a/modules/git-merge-changelog b/modules/git-merge-changelog index 1ef3e1102f..9ff56dcc86 100644 --- a/modules/git-merge-changelog +++ b/modules/git-merge-changelog @@ -22,6 +22,7 @@ xalloc xmalloca fstrcmp minmax +str_startswith c-strstr fwriteerror memchr