]>
Commit | Line | Data |
---|---|---|
6599da04 JM |
1 | // The -*- C++ -*- null-terminated string header. |
2 | // This file is part of the GNU ANSI C++ Library. | |
3 | ||
4 | #ifndef __CSTRING__ | |
5 | #define __CSTRING__ | |
6 | ||
7 | #include <string.h> | |
8 | ||
9 | #if 0 // Let's not bother with this just yet. | |
10 | #include <cstddef> | |
11 | ||
12 | #ifdef __GNUG__ | |
13 | #pragma interface "cstring" | |
14 | #endif | |
15 | ||
16 | // The ANSI C prototypes for these functions have a const argument type and | |
17 | // non-const return type, so we can't use them. | |
18 | ||
19 | extern "C++" { | |
20 | extern inline const char * | |
21 | _G_strchr (const char *s, int c) | |
22 | { | |
23 | return strchr (s, c); | |
24 | } | |
25 | ||
26 | extern inline char * | |
27 | _G_strchr (char *s, int c) | |
28 | { | |
29 | return const_cast<char *> (strchr (s, c)); | |
30 | } | |
31 | ||
32 | extern inline const char * | |
33 | _G_strpbrk (const char *s1, const char *s2) | |
34 | { | |
35 | return strpbrk (s1, s2); | |
36 | } | |
37 | ||
38 | extern inline char * | |
39 | _G_strpbrk (char *s1, const char *s2) | |
40 | { | |
41 | return const_cast<char *> (strpbrk (s1, s2)); | |
42 | } | |
43 | ||
44 | extern inline const char * | |
45 | _G_strrchr (const char *s, int c) | |
46 | { | |
47 | return strrchr (s, c); | |
48 | } | |
49 | ||
50 | extern inline char * | |
51 | _G_strrchr (char *s, int c) | |
52 | { | |
53 | return const_cast<char *> (strrchr (s, c)); | |
54 | } | |
55 | ||
56 | extern inline const char * | |
57 | _G_strstr (const char *s1, const char *s2) | |
58 | { | |
59 | return strstr (s1, s2); | |
60 | } | |
61 | ||
62 | extern inline char * | |
63 | _G_strstr (char *s1, const char *s2) | |
64 | { | |
65 | return const_cast<char *> (strstr (s1, s2)); | |
66 | } | |
67 | ||
68 | extern inline const void * | |
69 | _G_memchr (const void *s, int c, size_t n) | |
70 | { | |
71 | return memchr (s, c, n); | |
72 | } | |
73 | ||
74 | extern inline void * | |
75 | _G_memchr (void *s, int c, size_t n) | |
76 | { | |
77 | return const_cast<void *> (memchr (s, c, n)); | |
78 | } | |
79 | } // extern "C++" | |
80 | ||
81 | // Lose any vendor macros for these functions. | |
82 | #undef strchr | |
83 | #undef strpbrk | |
84 | #undef strrchr | |
85 | #undef strstr | |
86 | #undef memchr | |
87 | ||
88 | // Ewww, namespace pollution. Anyone have a better idea? | |
89 | #define strchr _G_strchr | |
90 | #define strpbrk _G_strpbrk | |
91 | #define strrchr _G_strrchr | |
92 | #define strstr _G_strstr | |
93 | #define memchr _G_memchr | |
94 | #endif // 0 | |
95 | ||
96 | #endif // !defined (__CSTRING__) |