Commit a9ebaa2b by Carlo Wood Committed by Benjamin Kosnik

demangle.h: Do not use cctype functions that depend on locale.


2003-08-07  Carlo Wood  <carlo@alinoe.com>

        * include/bits/demangle.h: Do not use cctype functions that depend
	on locale.

From-SVN: r70228
parent 97b3d0f0
2003-08-07 Carlo Wood <carlo@alinoe.com>
* include/bits/demangle.h: Do not use cctype functions that depend
on locale.
2003-08-05 Phil Edwards <pme@gcc.gnu.org> 2003-08-05 Phil Edwards <pme@gcc.gnu.org>
* configure.in: Rename... * configure.in: Rename...
......
...@@ -31,10 +31,8 @@ ...@@ -31,10 +31,8 @@
#ifndef _DEMANGLER_H #ifndef _DEMANGLER_H
#define _DEMANGLER_H 1 #define _DEMANGLER_H 1
#include <limits>
#include <vector> #include <vector>
#include <string> #include <string>
#include <cctype>
#ifndef _GLIBCXX_DEMANGLER_DEBUG #ifndef _GLIBCXX_DEMANGLER_DEBUG
#define _GLIBCXX_DEMANGLER_CWDEBUG 0 #define _GLIBCXX_DEMANGLER_CWDEBUG 0
...@@ -453,6 +451,14 @@ namespace __gnu_cxx ...@@ -453,6 +451,14 @@ namespace __gnu_cxx
} }
} }
// We don't want to depend on locale (or include <cctype> for that matter).
// We also don't want to use "safe-ctype.h" because that headerfile is not
// available to the users.
inline bool isdigit(char c) { return c >= '0' && c <= '9'; }
inline bool islower(char c) { return c >= 'a' && c <= 'z'; }
inline bool isupper(char c) { return c >= 'A' && c <= 'Z'; }
inline char tolower(char c) { return isupper(c) ? c - 'A' + 'a' : c; }
// //
// <decimal-integer> ::= 0 // <decimal-integer> ::= 0
// ::= 1|2|3|4|5|6|7|8|9 [<digit>+] // ::= 1|2|3|4|5|6|7|8|9 [<digit>+]
...@@ -468,7 +474,7 @@ namespace __gnu_cxx ...@@ -468,7 +474,7 @@ namespace __gnu_cxx
output += '0'; output += '0';
eat_current(); eat_current();
} }
else if (!std::isdigit(c)) else if (!isdigit(c))
M_result = false; M_result = false;
else else
{ {
...@@ -476,7 +482,7 @@ namespace __gnu_cxx ...@@ -476,7 +482,7 @@ namespace __gnu_cxx
{ {
output += c; output += c;
} }
while (std::isdigit((c = next()))); while (isdigit((c = next())));
} }
return M_result; return M_result;
} }
...@@ -699,7 +705,7 @@ namespace __gnu_cxx ...@@ -699,7 +705,7 @@ namespace __gnu_cxx
default: default:
for(;; c = next()) for(;; c = next())
{ {
if (std::isdigit(c)) if (isdigit(c))
value = value * 36 + c - '0'; value = value * 36 + c - '0';
else if (isupper(c)) else if (isupper(c))
value = value * 36 + c - 'A' + 10; value = value * 36 + c - 'A' + 10;
...@@ -782,7 +788,7 @@ namespace __gnu_cxx ...@@ -782,7 +788,7 @@ namespace __gnu_cxx
char c; char c;
if ((c = next()) != '_') if ((c = next()) != '_')
{ {
while(std::isdigit(c)) while(isdigit(c))
{ {
value = value * 10 + c - '0'; value = value * 10 + c - '0';
c = next(); c = next();
...@@ -1903,7 +1909,7 @@ namespace __gnu_cxx ...@@ -1903,7 +1909,7 @@ namespace __gnu_cxx
int length = current() - '0'; int length = current() - '0';
if (length < 1 || length > 9) if (length < 1 || length > 9)
_GLIBCXX_DEMANGLER_FAILURE; _GLIBCXX_DEMANGLER_FAILURE;
while(std::isdigit(next())) while(isdigit(next()))
length = 10 * length + current() - '0'; length = 10 * length + current() - '0';
char const* ptr = &M_str[M_pos]; char const* ptr = &M_str[M_pos];
if (length > 11 && !strncmp(ptr, "_GLOBAL_", 8) && ptr[9] == 'N' if (length > 11 && !strncmp(ptr, "_GLOBAL_", 8) && ptr[9] == 'N'
...@@ -1932,7 +1938,7 @@ namespace __gnu_cxx ...@@ -1932,7 +1938,7 @@ namespace __gnu_cxx
session<Allocator>::decode_unqualified_name(string_type& output) session<Allocator>::decode_unqualified_name(string_type& output)
{ {
_GLIBCXX_DEMANGLER_DOUT_ENTERING("decode_unqualified_name"); _GLIBCXX_DEMANGLER_DOUT_ENTERING("decode_unqualified_name");
if (std::isdigit(current())) if (isdigit(current()))
{ {
if (!M_inside_template_args) if (!M_inside_template_args)
{ {
...@@ -2187,7 +2193,7 @@ namespace __gnu_cxx ...@@ -2187,7 +2193,7 @@ namespace __gnu_cxx
eat_current(); eat_current();
if (!decode_type(first)) if (!decode_type(first))
_GLIBCXX_DEMANGLER_FAILURE; _GLIBCXX_DEMANGLER_FAILURE;
while(std::isdigit(current())) while(isdigit(current()))
eat_current(); eat_current();
if (eat_current() != '_') if (eat_current() != '_')
_GLIBCXX_DEMANGLER_FAILURE; _GLIBCXX_DEMANGLER_FAILURE;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment