aboutsummaryrefslogtreecommitdiff
path: root/libstdc++-v3/include/c_std
diff options
context:
space:
mode:
authorStephen M. Webb <stephen@bregmasoft.com>2001-04-02 22:51:25 +0000
committerBenjamin Kosnik <bkoz@gcc.gnu.org>2001-04-02 22:51:25 +0000
commit92c3688a97530f013adfd64a394b9a286a20128f (patch)
treec4a0641c9e6392439c1bed0971833e323ca163a6 /libstdc++-v3/include/c_std
parent57df35602ed39e18c94da7f88b8764423f6040e9 (diff)
downloadgcc-92c3688a97530f013adfd64a394b9a286a20128f.zip
gcc-92c3688a97530f013adfd64a394b9a286a20128f.tar.gz
gcc-92c3688a97530f013adfd64a394b9a286a20128f.tar.bz2
std_cstring.h: Fix for const-correctness.
2001-04-02 Stephen M. Webb <stephen@bregmasoft.com> * include/c_std/bits/std_cstring.h: Fix for const-correctness. * include/c_std/bits/std_cwchar.h: Same. * testsuite/21_strings/c_strings.cc: Add. From-SVN: r41019
Diffstat (limited to 'libstdc++-v3/include/c_std')
-rw-r--r--libstdc++-v3/include/c_std/bits/std_cstring.h35
-rw-r--r--libstdc++-v3/include/c_std/bits/std_cwchar.h35
2 files changed, 60 insertions, 10 deletions
diff --git a/libstdc++-v3/include/c_std/bits/std_cstring.h b/libstdc++-v3/include/c_std/bits/std_cstring.h
index 7429e657..52b4902 100644
--- a/libstdc++-v3/include/c_std/bits/std_cstring.h
+++ b/libstdc++-v3/include/c_std/bits/std_cstring.h
@@ -79,13 +79,38 @@ namespace std
extern "C" int strcoll(const char*, const char*);
extern "C" int strncmp(const char*, const char*, size_t);
extern "C" size_t strxfrm(char*, const char*, size_t);
- extern "C" void* memchr(const void*, int, size_t);
- extern "C" char* strchr(const char*, int);
+ extern "C" const void* memchr(const void*, int, size_t);
+ inline void*
+ memchr(void* __p, int __c, size_t __n)
+ {
+ return const_cast<void*>(memchr(const_cast<const void*>(__p), __c, __n));
+ }
+ extern "C" const char* strchr(const char*, int);
+ inline char*
+ strchr(char* __s1, int __n)
+ {
+ return const_cast<char*>(strchr(const_cast<const char*>(__s1), __n));
+ }
extern "C" size_t strcspn(const char*, const char*);
- extern "C" char* strpbrk(const char*, const char*);
- extern "C" char* strrchr(const char*, int);
+ extern "C" const char* strpbrk(const char*, const char*);
+ inline char*
+ strpbrk(char* __s1, const char* __s2)
+ {
+ return const_cast<char*>(strpbrk(const_cast<const char*>(__s1), __s2));
+ }
+ extern "C" const char* strrchr(const char*, int);
+ inline char*
+ strrchr(char* __s1, int __n)
+ {
+ return const_cast<char*>(strrchr(const_cast<const char*>(__s1), __n));
+ }
extern "C" size_t strspn(const char*, const char*);
- extern "C" char* strstr(const char*, const char*);
+ extern "C" const char* strstr(const char*, const char*);
+ inline char*
+ strstr(char* __s1, const char* __s2)
+ {
+ return const_cast<char*>(strstr(const_cast<const char*>(__s1), __s2));
+ }
extern "C" char* strtok(char*, const char*);
extern "C" void* memset(void*, int, size_t);
extern "C" char* strerror(int);
diff --git a/libstdc++-v3/include/c_std/bits/std_cwchar.h b/libstdc++-v3/include/c_std/bits/std_cwchar.h
index d2ac5bb..e9e987a 100644
--- a/libstdc++-v3/include/c_std/bits/std_cwchar.h
+++ b/libstdc++-v3/include/c_std/bits/std_cwchar.h
@@ -157,15 +157,40 @@ namespace std
extern "C" int wcscoll(const wchar_t*, const wchar_t*);
extern "C" int wcsncmp(const wchar_t*, const wchar_t*, size_t);
extern "C" size_t wcsxfrm(wchar_t*, const wchar_t*, size_t);
- extern "C" wchar_t* wcschr(const wchar_t*, wchar_t);
+ extern "C" const wchar_t* wcschr(const wchar_t*, wchar_t);
+ inline wchar_t*
+ wcschr(wchar_t* __p, wchar_t __c)
+ {
+ return const_cast<wchar_t*>(wcschr(const_cast<const wchar_t*>(__p), __c));
+ }
extern "C" size_t wcscspn(const wchar_t*, const wchar_t*);
extern "C" size_t wcslen(const wchar_t*);
- extern "C" wchar_t* wcspbrk(const wchar_t*, const wchar_t*);
- extern "C" wchar_t* wcsrchr(const wchar_t*, wchar_t);
+ extern "C" const wchar_t* wcspbrk(const wchar_t*, const wchar_t*);
+ inline wchar_t*
+ wcspbrk(wchar_t* __s1, wchar_t* __s2)
+ {
+ return const_cast<wchar_t*>(wcspbrk(const_cast<const wchar_t*>(__s1), __s2));
+ }
+ extern "C" const wchar_t* wcsrchr(const wchar_t*, wchar_t);
+ inline wchar_t*
+ wcsrchr(wchar_t* __p, wchar_t __c)
+ {
+ return const_cast<wchar_t*>(wcsrchr(const_cast<const wchar_t*>(__p), __c));
+ }
extern "C" size_t wcsspn(const wchar_t*, const wchar_t*);
- extern "C" wchar_t* wcsstr(const wchar_t*, const wchar_t*);
+ extern "C" const wchar_t* wcsstr(const wchar_t*, const wchar_t*);
+ inline wchar_t*
+ wcsstr(wchar_t* __s1, wchar_t* __s2)
+ {
+ return const_cast<wchar_t*>(wcsstr(const_cast<const wchar_t*>(__s1), __s2));
+ }
extern "C" wchar_t* wcstok(wchar_t*, const wchar_t*, wchar_t**);
- extern "C" wchar_t* wmemchr(const wchar_t*, wchar_t, size_t);
+ extern "C" const wchar_t* wmemchr(const wchar_t*, wchar_t, size_t);
+ inline wchar_t*
+ wmemchr(wchar_t* __p, wchar_t __c, size_t __n)
+ {
+ return const_cast<wchar_t*>(wmemchr(const_cast<const wchar_t*>(__p), __c, __n));
+ }
extern "C" int wmemcmp(const wchar_t*, const wchar_t*, size_t);
//extern "C" int wmemcmp(wchar_t*, const wchar_t*, size_t);
extern "C" wchar_t* wmemcpy(wchar_t*, const wchar_t*, size_t);