Set LC_ALL=C before sed.
[glibc.git] / string / strings.h
blobdad0a04467edbc8795c44ab9cd0104a587b845fe
1 /* Copyright (C) 1991-2013 Free Software Foundation, Inc.
2 This file is part of the GNU C Library.
4 The GNU C Library is free software; you can redistribute it and/or
5 modify it under the terms of the GNU Lesser General Public
6 License as published by the Free Software Foundation; either
7 version 2.1 of the License, or (at your option) any later version.
9 The GNU C Library is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 Lesser General Public License for more details.
14 You should have received a copy of the GNU Lesser General Public
15 License along with the GNU C Library; if not, see
16 <http://www.gnu.org/licenses/>. */
18 #ifndef _STRINGS_H
19 #define _STRINGS_H 1
21 /* We don't need and should not read this file if <string.h> was already
22 read. The one exception being that if __USE_BSD isn't defined, then
23 these aren't defined in string.h, so we need to define them here. */
24 #if !defined _STRING_H || !defined __USE_BSD
26 # include <features.h>
27 # define __need_size_t
28 # include <stddef.h>
30 /* Tell the caller that we provide correct C++ prototypes. */
31 # if defined __cplusplus && __GNUC_PREREQ (4, 4)
32 # define __CORRECT_ISO_CPP_STRINGS_H_PROTO
33 # endif
35 __BEGIN_DECLS
37 # if defined __USE_MISC || !defined __USE_XOPEN2K8
38 /* Compare N bytes of S1 and S2 (same as memcmp). */
39 extern int bcmp (const void *__s1, const void *__s2, size_t __n)
40 __THROW __attribute_pure__;
42 /* Copy N bytes of SRC to DEST (like memmove, but args reversed). */
43 extern void bcopy (const void *__src, void *__dest, size_t __n) __THROW;
45 /* Set N bytes of S to 0. */
46 extern void bzero (void *__s, size_t __n) __THROW;
48 /* Find the first occurrence of C in S (same as strchr). */
49 # ifdef __CORRECT_ISO_CPP_STRINGS_H_PROTO
50 extern "C++"
52 extern char *index (char *__s, int __c)
53 __THROW __asm ("index") __attribute_pure__ __nonnull ((1));
54 extern const char *index (const char *__s, int __c)
55 __THROW __asm ("index") __attribute_pure__ __nonnull ((1));
57 # if defined __OPTIMIZE__ && !defined __CORRECT_ISO_CPP_STRING_H_PROTO
58 __extern_always_inline char *
59 index (char *__s, int __c) __THROW
61 return __builtin_index (__s, __c);
64 __extern_always_inline const char *
65 index (const char *__s, int __c) __THROW
67 return __builtin_index (__s, __c);
69 # endif
71 # else
72 extern char *index (const char *__s, int __c)
73 __THROW __attribute_pure__ __nonnull ((1));
74 # endif
76 /* Find the last occurrence of C in S (same as strrchr). */
77 # ifdef __CORRECT_ISO_CPP_STRINGS_H_PROTO
78 extern "C++"
80 extern char *rindex (char *__s, int __c)
81 __THROW __asm ("rindex") __attribute_pure__ __nonnull ((1));
82 extern const char *rindex (const char *__s, int __c)
83 __THROW __asm ("rindex") __attribute_pure__ __nonnull ((1));
85 # if defined __OPTIMIZE__ && !defined __CORRECT_ISO_CPP_STRING_H_PROTO
86 __extern_always_inline char *
87 rindex (char *__s, int __c) __THROW
89 return __builtin_rindex (__s, __c);
92 __extern_always_inline const char *
93 rindex (const char *__s, int __c) __THROW
95 return __builtin_rindex (__s, __c);
97 # endif
99 # else
100 extern char *rindex (const char *__s, int __c)
101 __THROW __attribute_pure__ __nonnull ((1));
102 # endif
103 # endif
105 #if defined __USE_MISC || !defined __USE_XOPEN2K8 || defined __USE_XOPEN2K8XSI
106 /* Return the position of the first bit set in I, or 0 if none are set.
107 The least-significant bit is position 1, the most-significant 32. */
108 extern int ffs (int __i) __THROW __attribute__ ((const));
109 #endif
111 /* Compare S1 and S2, ignoring case. */
112 extern int strcasecmp (const char *__s1, const char *__s2)
113 __THROW __attribute_pure__;
115 /* Compare no more than N chars of S1 and S2, ignoring case. */
116 extern int strncasecmp (const char *__s1, const char *__s2, size_t __n)
117 __THROW __attribute_pure__;
119 #ifdef __USE_XOPEN2K8
120 /* The following functions are equivalent to the both above but they
121 take the locale they use for the collation as an extra argument.
122 This is not standardsized but something like will come. */
123 # include <xlocale.h>
125 /* Again versions of a few functions which use the given locale instead
126 of the global one. */
127 extern int strcasecmp_l (const char *__s1, const char *__s2, __locale_t __loc)
128 __THROW __attribute_pure__ __nonnull ((1, 2, 3));
130 extern int strncasecmp_l (const char *__s1, const char *__s2,
131 size_t __n, __locale_t __loc)
132 __THROW __attribute_pure__ __nonnull ((1, 2, 4));
133 #endif
135 __END_DECLS
137 #endif /* string.h */
139 #endif /* strings.h */