strings.in.h 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122
  1. /* A substitute <strings.h>.
  2. Copyright (C) 2007-2021 Free Software Foundation, Inc.
  3. This program is free software; you can redistribute it and/or modify
  4. it under the terms of the GNU General Public License as published by
  5. the Free Software Foundation; either version 3, or (at your option)
  6. any later version.
  7. This program is distributed in the hope that it will be useful,
  8. but WITHOUT ANY WARRANTY; without even the implied warranty of
  9. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  10. GNU General Public License for more details.
  11. You should have received a copy of the GNU General Public License
  12. along with this program; if not, see <https://www.gnu.org/licenses/>. */
  13. #ifndef _@GUARD_PREFIX@_STRINGS_H
  14. #if __GNUC__ >= 3
  15. @PRAGMA_SYSTEM_HEADER@
  16. #endif
  17. @PRAGMA_COLUMNS@
  18. /* Minix 3.1.8 has a bug: <sys/types.h> must be included before <strings.h>.
  19. But avoid namespace pollution on glibc systems. */
  20. #if defined __minix && !defined __GLIBC__
  21. # include <sys/types.h>
  22. #endif
  23. /* The include_next requires a split double-inclusion guard. */
  24. #if @HAVE_STRINGS_H@
  25. # @INCLUDE_NEXT@ @NEXT_STRINGS_H@
  26. #endif
  27. #ifndef _@GUARD_PREFIX@_STRINGS_H
  28. #define _@GUARD_PREFIX@_STRINGS_H
  29. #if ! @HAVE_DECL_STRNCASECMP@
  30. /* Get size_t. */
  31. # include <stddef.h>
  32. #endif
  33. /* The definitions of _GL_FUNCDECL_RPL etc. are copied here. */
  34. /* The definition of _GL_ARG_NONNULL is copied here. */
  35. /* The definition of _GL_WARN_ON_USE is copied here. */
  36. #ifdef __cplusplus
  37. extern "C" {
  38. #endif
  39. /* Find the index of the least-significant set bit. */
  40. #if @GNULIB_FFS@
  41. # if !@HAVE_FFS@
  42. _GL_FUNCDECL_SYS (ffs, int, (int i));
  43. # endif
  44. _GL_CXXALIAS_SYS (ffs, int, (int i));
  45. _GL_CXXALIASWARN (ffs);
  46. #elif defined GNULIB_POSIXCHECK
  47. # undef ffs
  48. # if HAVE_RAW_DECL_FFS
  49. _GL_WARN_ON_USE (ffs, "ffs is not portable - use the ffs module");
  50. # endif
  51. #endif
  52. /* Compare strings S1 and S2, ignoring case, returning less than, equal to or
  53. greater than zero if S1 is lexicographically less than, equal to or greater
  54. than S2.
  55. Note: This function does not work in multibyte locales. */
  56. #if ! @HAVE_STRCASECMP@
  57. extern int strcasecmp (char const *s1, char const *s2)
  58. _GL_ARG_NONNULL ((1, 2));
  59. #endif
  60. #if defined GNULIB_POSIXCHECK
  61. /* strcasecmp() does not work with multibyte strings:
  62. POSIX says that it operates on "strings", and "string" in POSIX is defined
  63. as a sequence of bytes, not of characters. */
  64. # undef strcasecmp
  65. # if HAVE_RAW_DECL_STRCASECMP
  66. _GL_WARN_ON_USE (strcasecmp, "strcasecmp cannot work correctly on character "
  67. "strings in multibyte locales - "
  68. "use mbscasecmp if you care about "
  69. "internationalization, or use c_strcasecmp , "
  70. "gnulib module c-strcase) if you want a locale "
  71. "independent function");
  72. # endif
  73. #endif
  74. /* Compare no more than N bytes of strings S1 and S2, ignoring case,
  75. returning less than, equal to or greater than zero if S1 is
  76. lexicographically less than, equal to or greater than S2.
  77. Note: This function cannot work correctly in multibyte locales. */
  78. #if ! @HAVE_DECL_STRNCASECMP@
  79. extern int strncasecmp (char const *s1, char const *s2, size_t n)
  80. _GL_ARG_NONNULL ((1, 2));
  81. #endif
  82. #if defined GNULIB_POSIXCHECK
  83. /* strncasecmp() does not work with multibyte strings:
  84. POSIX says that it operates on "strings", and "string" in POSIX is defined
  85. as a sequence of bytes, not of characters. */
  86. # undef strncasecmp
  87. # if HAVE_RAW_DECL_STRNCASECMP
  88. _GL_WARN_ON_USE (strncasecmp, "strncasecmp cannot work correctly on character "
  89. "strings in multibyte locales - "
  90. "use mbsncasecmp or mbspcasecmp if you care about "
  91. "internationalization, or use c_strncasecmp , "
  92. "gnulib module c-strcase) if you want a locale "
  93. "independent function");
  94. # endif
  95. #endif
  96. #ifdef __cplusplus
  97. }
  98. #endif
  99. #endif /* _@GUARD_PREFIX@_STRING_H */
  100. #endif /* _@GUARD_PREFIX@_STRING_H */