strings.in.h 4.0 KB

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