Skip to content

Commit b2a94c7

Browse files
committed
Moved removeWhiteSpace() into the QCString class
1 parent c0b85fe commit b2a94c7

File tree

2 files changed

+20
-16
lines changed

2 files changed

+20
-16
lines changed

src/qcstring.h

+19
Original file line numberDiff line numberDiff line change
@@ -239,6 +239,7 @@ class QCString
239239
return QCString(convertUTF8ToUpper(m_rep));
240240
}
241241

242+
/// returns a copy of this string with leading and trailing whitespace removed
242243
QCString stripWhiteSpace() const
243244
{
244245
int sl = (uint)m_rep.size();
@@ -250,6 +251,24 @@ class QCString
250251
return QCString(m_rep.substr(start,1+end-start));
251252
}
252253

254+
/// returns a copy of this string with all whitespace removed
255+
QCString removeWhiteSpace() const
256+
{
257+
size_t sl = (uint)m_rep.size();
258+
if (sl==0) return *this;
259+
std::string result = m_rep;
260+
size_t src=0,dst=0;
261+
while (src<sl)
262+
{
263+
if (!qisspace(m_rep[src])) result[dst++]=m_rep[src];
264+
src++;
265+
}
266+
if (dst<m_rep.size()) result.resize(dst);
267+
return QCString(result);
268+
}
269+
270+
/// return a copy of this string with leading and trailing whitespace removed and multiple
271+
/// whitespace characters replaced by a single space
253272
QCString simplifyWhiteSpace() const;
254273

255274
QCString &insert( uint index, const QCString &s )

src/scanner.l

+1-16
Original file line numberDiff line numberDiff line change
@@ -226,8 +226,6 @@ static void addKnRArgInfo(yyscan_t yyscanner,const QCString &type,const QCString
226226
const QCString &brief,const QCString &docs);
227227
static yy_size_t yyread(yyscan_t yyscanner,char *buf,yy_size_t max_size);
228228

229-
static QCString removeWhiteSpace(const QCString &s);
230-
231229
/* ----------------------------------------------------------------- */
232230
#undef YY_INPUT
233231
#define YY_INPUT(buf,result,max_size) result=yyread(yyscanner,buf,max_size);
@@ -2346,7 +2344,7 @@ NONLopt [^\n]*
23462344
BEGIN(FindMembers);
23472345
}
23482346
}
2349-
yyextra->current->name = removeWhiteSpace(yyextra->current->name);
2347+
yyextra->current->name = yyextra->current->name.removeWhiteSpace();
23502348
}
23512349
<StaticAssert>"(" {
23522350
yyextra->lastSkipRoundContext = FindMembers;
@@ -7706,19 +7704,6 @@ static void parsePrototype(yyscan_t yyscanner,const QCString &text)
77067704
//printf("**** parsePrototype end\n");
77077705
}
77087706
7709-
// removeRedundantWhiteSpace does not work as it will leave e.g. "foo:: bar"
7710-
static QCString removeWhiteSpace(const QCString &s)
7711-
{
7712-
QCString res;
7713-
uint l=s.length();
7714-
const char *src=s.data();
7715-
for (uint i = 0;i<l;i++)
7716-
{
7717-
if (!isspace((uchar)src[i])) res += src[i];
7718-
}
7719-
return res;
7720-
}
7721-
77227707
//static void handleGroupStartCommand(const char *header)
77237708
//{
77247709
// memberGroupHeader=header;

0 commit comments

Comments
 (0)