summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDimitri van Heesch <doxygen@gmail.com>2021-03-26 18:23:12 (GMT)
committerDimitri van Heesch <doxygen@gmail.com>2021-03-26 18:23:12 (GMT)
commit0dac69c7d148cfa63b746d83e1798f89b2da2251 (patch)
tree0bc7b8f0ed16bb8fd1ccbeea5cef900a62f2dd2e
parent1b03538eb097fd32896554749fb6cefc9e195e61 (diff)
downloadDoxygen-0dac69c7d148cfa63b746d83e1798f89b2da2251.zip
Doxygen-0dac69c7d148cfa63b746d83e1798f89b2da2251.tar.gz
Doxygen-0dac69c7d148cfa63b746d83e1798f89b2da2251.tar.bz2
Avoid using std::isspace and friends on potentially multibyte characters
-rw-r--r--src/qcstring.cpp16
-rw-r--r--src/qcstring.h10
2 files changed, 15 insertions, 11 deletions
diff --git a/src/qcstring.cpp b/src/qcstring.cpp
index 2a595cd..0ed5a99 100644
--- a/src/qcstring.cpp
+++ b/src/qcstring.cpp
@@ -188,9 +188,9 @@ QCString QCString::simplifyWhiteSpace() const
char *first = to;
while ( TRUE )
{
- while ( *from && isspace((uchar) *from) )
+ while ( *from && qisspace(*from) )
from++;
- while ( *from && !isspace((uchar)*from) )
+ while ( *from && !qisspace(*from) )
*to++ = *from++;
if ( *from )
*to++ = 0x20; // ' '
@@ -262,7 +262,7 @@ long QCString::toLong(bool *ok,int base) const
int neg = 0;
if ( !p )
goto bye;
- while ( l && isspace(*p) ) // skip leading space
+ while ( l && qisspace(*p) ) // skip leading space
l--,p++;
if ( l && *p == '-' ) {
l--;
@@ -294,7 +294,7 @@ long QCString::toLong(bool *ok,int base) const
}
if ( neg )
val = -val;
- while ( l && isspace(*p) ) // skip trailing space
+ while ( l && qisspace(*p) ) // skip trailing space
l--,p++;
if ( !l )
is_ok = TRUE;
@@ -313,7 +313,7 @@ ulong QCString::toULong(bool *ok,int base) const
bool is_ok = FALSE;
if ( !p )
goto bye;
- while ( l && isspace(*p) ) // skip leading space
+ while ( l && qisspace(*p) ) // skip leading space
l--,p++;
if ( *p == '+' )
l--,p++;
@@ -338,7 +338,7 @@ ulong QCString::toULong(bool *ok,int base) const
p++;
}
- while ( l && isspace(*p) ) // skip trailing space
+ while ( l && qisspace(*p) ) // skip trailing space
l--,p++;
if ( !l )
is_ok = TRUE;
@@ -357,7 +357,7 @@ uint64 QCString::toUInt64(bool *ok,int base) const
bool is_ok = FALSE;
if ( !p )
goto bye;
- while ( l && isspace(*p) ) // skip leading space
+ while ( l && qisspace(*p) ) // skip leading space
l--,p++;
if ( *p == '+' )
l--,p++;
@@ -382,7 +382,7 @@ uint64 QCString::toUInt64(bool *ok,int base) const
p++;
}
- while ( l && isspace(*p) ) // skip trailing space
+ while ( l && qisspace(*p) ) // skip trailing space
l--,p++;
if ( !l )
is_ok = TRUE;
diff --git a/src/qcstring.h b/src/qcstring.h
index 6e2802d..7cf6dd3 100644
--- a/src/qcstring.h
+++ b/src/qcstring.h
@@ -82,10 +82,14 @@ inline int qstrncmp( const char *str1, const char *str2, uint len )
{ return (str1 && str2) ? strncmp(str1,str2,len) :
(int)((intptr_t)str2 - (intptr_t)str1); }
+inline bool qisspace(char c)
+{ return c==' ' || c=='\t' || c=='\n' || c=='\r'; }
+
int qstricmp( const char *str1, const char *str2 );
int qstrnicmp( const char *str1, const char *str2, uint len );
+
/** This is an alternative implementation of QCString. It provides basically
* the same functions but uses std::string as the underlying string type
*/
@@ -231,11 +235,11 @@ class QCString
QCString stripWhiteSpace() const
{
int sl = (uint)m_rep.size();
- if (sl==0 || (!std::isspace(m_rep[0]) && !std::isspace(m_rep[sl-1]))) return *this;
+ if (sl==0 || (!qisspace(m_rep[0]) && !qisspace(m_rep[sl-1]))) return *this;
int start=0,end=sl-1;
- while (start<sl && std::isspace(m_rep[start])) start++;
+ while (start<sl && qisspace(m_rep[start])) start++;
if (start==sl) return QCString(); // only whitespace
- while (end>start && std::isspace(m_rep[end])) end--;
+ while (end>start && qisspace(m_rep[end])) end--;
return QCString(m_rep.substr(start,1+end-start));
}