]> Savannah Git Hosting - gnulib.git/commitdiff
*_startswith, *_endswith: Change return type to 'bool'.
authorBruno Haible <bruno@clisp.org>
Sat, 4 Jan 2025 09:17:39 +0000 (10:17 +0100)
committerBruno Haible <bruno@clisp.org>
Sat, 4 Jan 2025 09:17:39 +0000 (10:17 +0100)
Suggested by Paul Eggert.

* lib/string.in.h (str_startswith, str_endswith, mbs_startswith,
mbs_endswith): Change return type to 'bool'.
* lib/str_startswith.c (str_startswith): Likewise.
* lib/str_endswith.c (str_endswith): Likewise.
* lib/mbs_endswith.c (mbs_endswith): Likewise.
* modules/str_startswith (Depends-on): Add bool.
* modules/str_endswith (Depends-on): Likewise.
* modules/mbs_startswith (Depends-on): Likewise.
* modules/mbs_endswith (Depends-on): Likewise.

ChangeLog
lib/mbs_endswith.c
lib/str_endswith.c
lib/str_startswith.c
lib/string.in.h
modules/mbs_endswith
modules/mbs_startswith
modules/str_endswith
modules/str_startswith

index 01529c0411f44a52254231b6bc9b887bdb59c7ba..cce0804a22cd3846535f8ae94ed5deca37bd3d80 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,17 @@
+2025-01-04  Bruno Haible  <bruno@clisp.org>
+
+       *_startswith, *_endswith: Change return type to 'bool'.
+       Suggested by Paul Eggert.
+       * lib/string.in.h (str_startswith, str_endswith, mbs_startswith,
+       mbs_endswith): Change return type to 'bool'.
+       * lib/str_startswith.c (str_startswith): Likewise.
+       * lib/str_endswith.c (str_endswith): Likewise.
+       * lib/mbs_endswith.c (mbs_endswith): Likewise.
+       * modules/str_startswith (Depends-on): Add bool.
+       * modules/str_endswith (Depends-on): Likewise.
+       * modules/mbs_startswith (Depends-on): Likewise.
+       * modules/mbs_endswith (Depends-on): Likewise.
+
 2025-01-03  Bruno Haible  <bruno@clisp.org>
 
        doc: Mention the new modules.
index 5007a445ecb41d419a2604812c3437a27833bb19..8f163e1aa5ad78379000c5976e15a61871c076cc 100644 (file)
@@ -25,7 +25,7 @@
 
 #include <stdlib.h>
 
-int
+bool
 mbs_endswith (const char *string, const char *suffix)
 {
   if ((unsigned char) suffix[0] < 0x30)
index f33ac6997c7537c09710d8667fdb5b164085e545..87728cf62c5d210a049f71dca9d1c1d8ffad6867 100644 (file)
@@ -22,7 +22,7 @@
 #include <string.h>
 
 
-int
+bool
 str_endswith (const char *string, const char *suffix)
 {
   size_t len = strlen (string);
index 381236ec2a27de89ebb81aa01e8637142e0c0b47..ff7ab59584590b19ccf624e7e94187aa5bdbe5cb 100644 (file)
@@ -22,7 +22,7 @@
 #include <string.h>
 
 
-int
+bool
 str_startswith (const char *string, const char *prefix)
 {
   return strncmp (string, prefix, strlen (prefix)) == 0;
index 6b9e342a1a2fb881234fb5ce7e996823b0c6cba1..ce488299006f30b9323601e5d2241c6399344f2c 100644 (file)
@@ -1080,7 +1080,7 @@ _GL_WARN_ON_USE (strtok_r, "strtok_r is unportable - "
 #if @GNULIB_STR_STARTSWITH@
 /* Returns true if STRING starts with PREFIX.
    Returns false otherwise.  */
-_GL_EXTERN_C int str_startswith (const char *string, const char *prefix)
+_GL_EXTERN_C bool str_startswith (const char *string, const char *prefix)
      _GL_ATTRIBUTE_PURE
      _GL_ARG_NONNULL ((1, 2));
 #endif
@@ -1088,7 +1088,7 @@ _GL_EXTERN_C int str_startswith (const char *string, const char *prefix)
 #if @GNULIB_STR_ENDSWITH@
 /* Returns true if STRING ends with SUFFIX.
    Returns false otherwise.  */
-_GL_EXTERN_C int str_endswith (const char *string, const char *prefix)
+_GL_EXTERN_C bool str_endswith (const char *string, const char *prefix)
      _GL_ATTRIBUTE_PURE
      _GL_ARG_NONNULL ((1, 2));
 #endif
@@ -1320,7 +1320,7 @@ _GL_EXTERN_C char * mbstok_r (char *restrict string, const char *delim,
 #if @GNULIB_MBS_STARTSWITH@
 /* Returns true if STRING starts with PREFIX.
    Returns false otherwise.  */
-_GL_EXTERN_C int mbs_startswith (const char *string, const char *prefix)
+_GL_EXTERN_C bool mbs_startswith (const char *string, const char *prefix)
      _GL_ATTRIBUTE_PURE
      _GL_ARG_NONNULL ((1, 2));
 /* No extra code is needed for multibyte locales for this function.  */
@@ -1332,7 +1332,7 @@ _GL_EXTERN_C int mbs_startswith (const char *string, const char *prefix)
    Returns false otherwise.
    Unlike str_endswith(), this function works correctly in multibyte locales.
  */
-_GL_EXTERN_C int mbs_endswith (const char *string, const char *suffix)
+_GL_EXTERN_C bool mbs_endswith (const char *string, const char *suffix)
      _GL_ATTRIBUTE_PURE
      _GL_ARG_NONNULL ((1, 2));
 #endif
index 19ead99cd5c0e11632a4209054e14e61ee2e8a16..73ef26c1f5c8f07f91b650e443fd43fa149074c8 100644 (file)
@@ -6,6 +6,7 @@ lib/mbs_endswith.c
 
 Depends-on:
 string-h
+bool
 str_endswith
 mbslen
 mbiter
index b7145de03421573093a7b2c126a39c9619f76c48..2e909c67e6c51900c9990306a9216b4ea658ae9a 100644 (file)
@@ -5,6 +5,7 @@ Files:
 
 Depends-on:
 string-h
+bool
 str_startswith
 
 configure.ac:
index c04b2c8eb0962dab7dce29823715ee2f16df1c3e..aceb295ca8f7ee8e20a8d5df4362273188ba4600 100644 (file)
@@ -6,6 +6,7 @@ lib/str_endswith.c
 
 Depends-on:
 string-h
+bool
 
 configure.ac:
 gl_STRING_MODULE_INDICATOR([str_endswith])
index 4b1754e34146836df83d0664f3f0a11eccb03b4d..535449c40ac598e91c5e8366f9757e1fdc3a1904 100644 (file)
@@ -6,6 +6,7 @@ lib/str_startswith.c
 
 Depends-on:
 string-h
+bool
 
 configure.ac:
 gl_STRING_MODULE_INDICATOR([str_startswith])