From 60822e0b57d2b5303fdfb5af829fb4dcf77626f1 Mon Sep 17 00:00:00 2001 From: Ulrich Drepper Date: Fri, 30 Jan 2009 00:08:29 +0000 Subject: [PATCH] cstring (memchr, [...]): Provide inlines only if __CORRECT_ISO_CPP_STRING_H_PROTO is not defined. * include/c_std/cstring (memchr, strchr, strpbrk, strrchr, strstr): Provide inlines only if __CORRECT_ISO_CPP_STRING_H_PROTO is not defined. * include/c_std/cwchar (wcschr, wcspbrk, wcsrchr, wcsstr, wmemchr): Provide inlines only if __CORRECT_ISO_CPP_WCHAR_H_PROTO is not defined. * include/c_global/cstring (memchr, strchr, strpbrk, strrchr, strstr): Provide inlines only if __CORRECT_ISO_CPP_STRING_H_PROTO is not defined. * include/c_global/cwchar (wcschr, wcspbrk, wcsrchr, wcsstr, wmemchr): Provide inlines only if __CORRECT_ISO_CPP_WCHAR_H_PROTO is not defined. * testsuite/21_strings/c_strings/char_t/2.cc (test02): If first argument is const char *, assign result to const char * var, not char *. * testsuite/21_strings/c_strings/wchar_t/2.cc (test02): If first argument is const wchar_t *, assign result to const wchar_t * var, not wchar_t *. Co-Authored-By: Jakub Jelinek From-SVN: r143773 --- libstdc++-v3/ChangeLog | 22 +++++++++++++++++++ libstdc++-v3/include/c_global/cstring | 16 ++++++-------- libstdc++-v3/include/c_global/cwchar | 17 ++++++-------- libstdc++-v3/include/c_std/cstring | 17 ++++++-------- libstdc++-v3/include/c_std/cwchar | 17 ++++++-------- .../testsuite/21_strings/c_strings/char/2.cc | 13 ++++++----- .../21_strings/c_strings/wchar_t/2.cc | 11 +++++----- 7 files changed, 63 insertions(+), 50 deletions(-) diff --git a/libstdc++-v3/ChangeLog b/libstdc++-v3/ChangeLog index 06472ac6252..3fb9031007a 100644 --- a/libstdc++-v3/ChangeLog +++ b/libstdc++-v3/ChangeLog @@ -1,3 +1,25 @@ +2009-01-30 Ulrich Drepper + Jakub Jelinek + + * include/c_std/cstring (memchr, strchr, strpbrk, strrchr, strstr): + Provide inlines only if __CORRECT_ISO_CPP_STRING_H_PROTO is not + defined. + * include/c_std/cwchar (wcschr, wcspbrk, wcsrchr, wcsstr, wmemchr): + Provide inlines only if __CORRECT_ISO_CPP_WCHAR_H_PROTO is not + defined. + * include/c_global/cstring (memchr, strchr, strpbrk, strrchr, strstr): + Provide inlines only if __CORRECT_ISO_CPP_STRING_H_PROTO is not + defined. + * include/c_global/cwchar (wcschr, wcspbrk, wcsrchr, wcsstr, wmemchr): + Provide inlines only if __CORRECT_ISO_CPP_WCHAR_H_PROTO is not + defined. + * testsuite/21_strings/c_strings/char_t/2.cc (test02): If first + argument is const char *, assign result to const char * var, not + char *. + * testsuite/21_strings/c_strings/wchar_t/2.cc (test02): If first + argument is const wchar_t *, assign result to const wchar_t * var, not + wchar_t *. + 2009-01-29 Jonathan Wakely * include/std/thread: Remove unused headers. diff --git a/libstdc++-v3/include/c_global/cstring b/libstdc++-v3/include/c_global/cstring index 9ad0683422f..5035e4c1279 100644 --- a/libstdc++-v3/include/c_global/cstring +++ b/libstdc++-v3/include/c_global/cstring @@ -1,7 +1,7 @@ // -*- C++ -*- forwarding header. // Copyright (C) 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, -// 2006, 2007, 2008 +// 2006, 2007, 2008, 2009 // Free Software Foundation, Inc. // // This file is part of the GNU ISO C++ Library. This library is free @@ -96,34 +96,32 @@ _GLIBCXX_BEGIN_NAMESPACE(std) using ::strspn; using ::strtok; using ::strxfrm; + using ::strchr; + using ::strpbrk; + using ::strrchr; + using ::strstr; +#ifndef __CORRECT_ISO_CPP_STRING_H_PROTO inline void* memchr(void* __p, int __c, size_t __n) { return memchr(const_cast(__p), __c, __n); } - using ::strchr; - inline char* strchr(char* __s1, int __n) { return __builtin_strchr(const_cast(__s1), __n); } - using ::strpbrk; - inline char* strpbrk(char* __s1, const char* __s2) { return __builtin_strpbrk(const_cast(__s1), __s2); } - using ::strrchr; - inline char* strrchr(char* __s1, int __n) { return __builtin_strrchr(const_cast(__s1), __n); } - using ::strstr; - inline char* strstr(char* __s1, const char* __s2) { return __builtin_strstr(const_cast(__s1), __s2); } +#endif _GLIBCXX_END_NAMESPACE diff --git a/libstdc++-v3/include/c_global/cwchar b/libstdc++-v3/include/c_global/cwchar index 48b901ddd61..7284f3df9d4 100644 --- a/libstdc++-v3/include/c_global/cwchar +++ b/libstdc++-v3/include/c_global/cwchar @@ -1,7 +1,7 @@ // -*- C++ -*- forwarding header. // Copyright (C) 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, -// 2006, 2007, 2008 +// 2006, 2007, 2008, 2009 // Free Software Foundation, Inc. // // This file is part of the GNU ISO C++ Library. This library is free @@ -204,36 +204,33 @@ _GLIBCXX_BEGIN_NAMESPACE(std) using ::wmemset; using ::wprintf; using ::wscanf; - using ::wcschr; + using ::wcspbrk; + using ::wcsrchr; + using ::wcsstr; + using ::wmemchr; +#ifndef __CORRECT_ISO_CPP_WCHAR_H_PROTO inline wchar_t* wcschr(wchar_t* __p, wchar_t __c) { return wcschr(const_cast(__p), __c); } - using ::wcspbrk; - inline wchar_t* wcspbrk(wchar_t* __s1, const wchar_t* __s2) { return wcspbrk(const_cast(__s1), __s2); } - using ::wcsrchr; - inline wchar_t* wcsrchr(wchar_t* __p, wchar_t __c) { return wcsrchr(const_cast(__p), __c); } - using ::wcsstr; - inline wchar_t* wcsstr(wchar_t* __s1, const wchar_t* __s2) { return wcsstr(const_cast(__s1), __s2); } - using ::wmemchr; - inline wchar_t* wmemchr(wchar_t* __p, wchar_t __c, size_t __n) { return wmemchr(const_cast(__p), __c, __n); } +#endif _GLIBCXX_END_NAMESPACE diff --git a/libstdc++-v3/include/c_std/cstring b/libstdc++-v3/include/c_std/cstring index 5fef6b0086e..608e219cd7f 100644 --- a/libstdc++-v3/include/c_std/cstring +++ b/libstdc++-v3/include/c_std/cstring @@ -1,6 +1,6 @@ // -*- C++ -*- forwarding header. -// Copyright (C) 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005 +// Copyright (C) 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2009 // Free Software Foundation, Inc. // // This file is part of the GNU ISO C++ Library. This library is free @@ -94,36 +94,33 @@ _GLIBCXX_BEGIN_NAMESPACE(std) using ::memset; using ::strerror; using ::strlen; - using ::memchr; + using ::strchr; + using ::strpbrk; + using ::strrchr; + using ::strstr; +#ifndef __CORRECT_ISO_CPP_STRING_H_PROTO inline void* memchr(void* __p, int __c, size_t __n) { return memchr(const_cast(__p), __c, __n); } - using ::strchr; - inline char* strchr(char* __s1, int __n) { return __builtin_strchr(const_cast(__s1), __n); } - using ::strpbrk; - inline char* strpbrk(char* __s1, const char* __s2) { return __builtin_strpbrk(const_cast(__s1), __s2); } - using ::strrchr; - inline char* strrchr(char* __s1, int __n) { return __builtin_strrchr(const_cast(__s1), __n); } - using ::strstr; - inline char* strstr(char* __s1, const char* __s2) { return __builtin_strstr(const_cast(__s1), __s2); } +#endif _GLIBCXX_END_NAMESPACE diff --git a/libstdc++-v3/include/c_std/cwchar b/libstdc++-v3/include/c_std/cwchar index 19ce17deceb..a6ffe0ab466 100644 --- a/libstdc++-v3/include/c_std/cwchar +++ b/libstdc++-v3/include/c_std/cwchar @@ -1,7 +1,7 @@ // -*- C++ -*- forwarding header. // Copyright (C) 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, -// 2006, 2007 +// 2006, 2007, 2009 // Free Software Foundation, Inc. // // This file is part of the GNU ISO C++ Library. This library is free @@ -204,36 +204,33 @@ _GLIBCXX_BEGIN_NAMESPACE(std) using ::wmemset; using ::wprintf; using ::wscanf; - using ::wcschr; + using ::wcspbrk; + using ::wcsrchr; + using ::wcsstr; + using ::wmemchr; +#ifndef __CORRECT_ISO_CPP_WCHAR_H_PROTO inline wchar_t* wcschr(wchar_t* __p, wchar_t __c) { return wcschr(const_cast(__p), __c); } - using ::wcspbrk; - inline wchar_t* wcspbrk(wchar_t* __s1, const wchar_t* __s2) { return wcspbrk(const_cast(__s1), __s2); } - using ::wcsrchr; - inline wchar_t* wcsrchr(wchar_t* __p, wchar_t __c) { return wcsrchr(const_cast(__p), __c); } - using ::wcsstr; - inline wchar_t* wcsstr(wchar_t* __s1, const wchar_t* __s2) { return wcsstr(const_cast(__s1), __s2); } - using ::wmemchr; - inline wchar_t* wmemchr(wchar_t* __p, wchar_t __c, size_t __n) { return wmemchr(const_cast(__p), __c, __n); } +#endif _GLIBCXX_END_NAMESPACE diff --git a/libstdc++-v3/testsuite/21_strings/c_strings/char/2.cc b/libstdc++-v3/testsuite/21_strings/c_strings/char/2.cc index 51e8826aeab..ab1e5b0b05f 100644 --- a/libstdc++-v3/testsuite/21_strings/c_strings/char/2.cc +++ b/libstdc++-v3/testsuite/21_strings/c_strings/char/2.cc @@ -1,6 +1,6 @@ // 2001-04-02 Benjamin Kosnik -// Copyright (C) 2001, 2003 Free Software Foundation, Inc. +// Copyright (C) 2001, 2003, 2009 Free Software Foundation, Inc. // // This file is part of the GNU ISO C++ Library. This library is free // software; you can redistribute it and/or modify it under the @@ -32,13 +32,14 @@ void test02() char carray[50]; strcpy(carray, ccarray1); const void* cv = ccarray1; - void* v; + const void* cv1; + const char* cc; char* c; - v = memchr(cv, '/', 3); - c = strchr(ccarray1, '/'); - c = strrchr(ccarray1, 'c'); - c = strpbrk(ccarray1, ccarray2); + cv1 = memchr(cv, '/', 3); + cc = strchr(ccarray1, '/'); + cc = strrchr(ccarray1, 'c'); + cc = strpbrk(ccarray1, ccarray2); c = strstr(carray, carray); } diff --git a/libstdc++-v3/testsuite/21_strings/c_strings/wchar_t/2.cc b/libstdc++-v3/testsuite/21_strings/c_strings/wchar_t/2.cc index 67d9d84aedf..aefc1a784e3 100644 --- a/libstdc++-v3/testsuite/21_strings/c_strings/wchar_t/2.cc +++ b/libstdc++-v3/testsuite/21_strings/c_strings/wchar_t/2.cc @@ -1,6 +1,6 @@ // 2001-04-02 Benjamin Kosnik -// Copyright (C) 2001 Free Software Foundation, Inc. +// Copyright (C) 2001, 2009 Free Software Foundation, Inc. // // This file is part of the GNU ISO C++ Library. This library is free // software; you can redistribute it and/or modify it under the @@ -32,12 +32,13 @@ void test02() const wchar_t* ccarray2 = L"san francisco sunny-day park inspectors"; wchar_t carray[50]; wcscpy(carray, ccarray1); + const wchar_t* cw; wchar_t* w; - w = wmemchr(ccarray1, L'/', 3); - w = wcschr(ccarray1, L'/'); - w = wcspbrk(ccarray1, ccarray2); - w = wcsrchr(ccarray1, L'c'); + cw = wmemchr(ccarray1, L'/', 3); + cw = wcschr(ccarray1, L'/'); + cw = wcspbrk(ccarray1, ccarray2); + cw = wcsrchr(ccarray1, L'c'); w = wcsstr(carray, carray); } -- 2.30.2