From 5d0281a264e33ec3477bd7f6a9dcef79a6ef8eeb Mon Sep 17 00:00:00 2001 From: Dimitri van Heesch Date: Tue, 23 Mar 2021 19:44:37 +0100 Subject: Refactoring: replace QGString by std::ostringstream --- qtools/CMakeLists.txt | 1 - qtools/qcstring.cpp | 11 -- qtools/qcstring.h | 6 - qtools/qgstring.cpp | 258 -------------------------- qtools/qgstring.h | 139 -------------- src/code.l | 19 +- src/context.cpp | 64 ++++--- src/dot.cpp | 4 +- src/dotdirdeps.cpp | 2 +- src/dotfilepatcher.cpp | 4 +- src/dotgfxhierarchytable.cpp | 2 +- src/dotgraph.cpp | 6 +- src/dotgroupcollaboration.cpp | 2 +- src/dotlegendgraph.cpp | 4 +- src/doxygen.cpp | 16 +- src/entry.cpp | 12 +- src/entry.h | 7 +- src/fortranscanner.l | 10 +- src/htmlgen.cpp | 6 +- src/index.cpp | 16 +- src/latexgen.cpp | 6 +- src/lexscanner.l | 2 +- src/msc.cpp | 2 +- src/pyscanner.l | 189 +++++++++---------- src/qhpxmlwriter.cpp | 3 +- src/qhpxmlwriter.h | 2 +- src/scanner.l | 412 +++++++++++++++++++++--------------------- src/sqlite3gen.cpp | 2 +- src/template.cpp | 6 +- src/utf8.cpp | 2 +- src/util.cpp | 32 ++-- 31 files changed, 418 insertions(+), 829 deletions(-) delete mode 100644 qtools/qgstring.cpp delete mode 100644 qtools/qgstring.h diff --git a/qtools/CMakeLists.txt b/qtools/CMakeLists.txt index 732449c..1107072 100644 --- a/qtools/CMakeLists.txt +++ b/qtools/CMakeLists.txt @@ -12,7 +12,6 @@ qgarray.cpp qgdict.cpp qglist.cpp qglobal.cpp -qgstring.cpp qiodevice.cpp qregexp.cpp qstring.cpp diff --git a/qtools/qcstring.cpp b/qtools/qcstring.cpp index 7e496fd..4f30a42 100644 --- a/qtools/qcstring.cpp +++ b/qtools/qcstring.cpp @@ -14,7 +14,6 @@ */ #include "qcstring.h" -#include "qgstring.h" #include #include @@ -585,16 +584,6 @@ QDataStream &operator>>( QDataStream &s, QCString &str ) #endif //QT_NO_DATASTREAM -inline QCString operator+( const QCString &s1, const QGString &s2 ) -{ - return s1.str()+s2.data(); -} - -inline QCString operator+( const QGString &s1, const QCString &s2 ) -{ - return s1.data()+s2.str(); -} - /// substitute all occurrences of \a src in \a s by \a dst QCString substitute(const QCString &s,const QCString &src,const QCString &dst) { diff --git a/qtools/qcstring.h b/qtools/qcstring.h index fb93246..2efdc2d 100644 --- a/qtools/qcstring.h +++ b/qtools/qcstring.h @@ -31,8 +31,6 @@ #include #include -class QGString; - /***************************************************************************** Safe and portable C string functions; extensions to standard string.h *****************************************************************************/ @@ -464,10 +462,6 @@ inline QCString operator+( const QCString &s1, const QCString &s2 ) } -inline QCString operator+( const QCString &s1, const QGString &s2 ); -inline QCString operator+( const QGString &s1, const QCString &s2 ); - - inline QCString operator+( const QCString &s1, const char *s2 ) { QCString tmp(s1); diff --git a/qtools/qgstring.cpp b/qtools/qgstring.cpp deleted file mode 100644 index 8b15675..0000000 --- a/qtools/qgstring.cpp +++ /dev/null @@ -1,258 +0,0 @@ -/****************************************************************************** - * - * Copyright (C) 1997-2004 by Dimitri van Heesch. - * - * Permission to use, copy, modify, and distribute this software and its - * documentation under the terms of the GNU General Public License is hereby - * granted. No representations are made about the suitability of this software - * for any purpose. It is provided "as is" without express or implied warranty. - * See the GNU General Public License for more details. - * - * Documents produced by Doxygen are derivative works derived from the - * input used in their production; they are not affected by this license. - * - */ - -#include -#include "qgstring.h" - -#include - -#define BLOCK_SIZE 64 -#define ROUND_SIZE(x) ((x)+BLOCK_SIZE-1)&~(BLOCK_SIZE-1) - -#define DBG_STR(x) do { } while(0) -//#define DBG_STR(x) printf x - -QGString::QGString() // make null string - : m_data(0), m_len(0), m_memSize(0) -{ - DBG_STR(("%p: QGString::QGString() %d:%s\n",this,m_len,m_data?m_data:"")); -} - -QGString::QGString(uint size) -{ - if (size==0) - { - m_data=0; - m_len=0; - } - else - { - m_memSize = ROUND_SIZE(size+1); - m_data = (char*)malloc(m_memSize); - memset(m_data,' ',size); - m_data[size]='\0'; - m_len=size; - } - DBG_STR(("%p: QGString::QGString(uint size=%d) %d:%s\n", - this,size,m_len,m_data?m_data:"")); -} - -QGString::QGString( const QGString &s ) -{ - if (s.m_memSize==0) - { - m_data = 0; - m_len = 0; - m_memSize = 0; - } - else - { - m_data = (char *)malloc(s.m_memSize); - m_len = s.m_len; - m_memSize = s.m_memSize; - qstrcpy(m_data,s.m_data); - } - DBG_STR(("%p: QGString::QGString(const QGString &) %d:%s\n",this,m_len,m_data?m_data:"")); -} - -QGString::QGString( const char *str ) -{ - if (str==0) - { - m_data=0; - m_len=0; - m_memSize=0; - } - else - { - m_len = qstrlen(str); - m_memSize = ROUND_SIZE(m_len+1); - assert(m_memSize>=m_len+1); - m_data = (char *)malloc(m_memSize); - qstrcpy(m_data,str); - } - DBG_STR(("%p: QGString::QGString(const char *) %d:%s\n",this,m_len,m_data?m_data:"")); -} - -QGString::~QGString() -{ - free(m_data); - m_data=0; - DBG_STR(("%p: QGString::~QGString() %d:%s\n",this,m_len,m_data?m_data:"")); -} - -bool QGString::resize( uint newlen ) -{ - m_len = 0; - if (newlen==0) - { - if (m_data) { free(m_data); m_data=0; } - m_memSize=0; - DBG_STR(("%p: 1.QGString::resize() %d:%s\n",this,m_len,m_data?m_data:"")); - return TRUE; - } - m_memSize = ROUND_SIZE(newlen+1); - assert(m_memSize>=newlen+1); - if (m_data==0) - { - m_data = (char *)malloc(m_memSize); - } - else - { - m_data = (char *)realloc(m_data,m_memSize); - } - if (m_data==0) - { - DBG_STR(("%p: 2.QGString::resize() %d:%s\n",this,m_len,m_data?m_data:"")); - return FALSE; - } - m_data[newlen]='\0'; - m_len = qstrlen(m_data); - DBG_STR(("%p: 3.QGString::resize() %d:%s\n",this,m_len,m_data?m_data:"")); - return TRUE; -} - -bool QGString::enlarge( uint newlen ) -{ - if (newlen==0) - { - if (m_data) { free(m_data); m_data=0; } - m_memSize=0; - m_len=0; - return TRUE; - } - uint newMemSize = ROUND_SIZE(newlen+1); - if (newMemSize==m_memSize) return TRUE; - m_memSize = newMemSize; - if (m_data==0) - { - m_data = (char *)malloc(m_memSize); - } - else - { - m_data = (char *)realloc(m_data,m_memSize); - } - if (m_data==0) - { - return FALSE; - } - m_data[newlen-1]='\0'; - if (m_len>newlen) m_len=newlen; - return TRUE; -} - -void QGString::setLen( uint newlen ) -{ - m_len = newlen<=m_memSize ? newlen : m_memSize; -} - -QGString &QGString::operator=( const QGString &s ) -{ - if (m_data) free(m_data); - if (s.m_memSize==0) // null string - { - m_data = 0; - m_len = 0; - m_memSize = 0; - } - else - { - m_len = s.m_len; - m_memSize = s.m_memSize; - m_data = (char*)malloc(m_memSize); - qstrcpy(m_data,s.m_data); - } - DBG_STR(("%p: QGString::operator=(const QGString &%p) %d:%s\n", - this,&s,m_len,m_data?m_data:"")); - return *this; -} - -QGString &QGString::operator=( const char *str ) -{ - if (m_data) free(m_data); - if (str==0) // null string - { - m_data = 0; - m_len = 0; - m_memSize = 0; - } - else - { - m_len = qstrlen(str); - m_memSize = ROUND_SIZE(m_len+1); - assert(m_memSize>=m_len+1); - m_data = (char*)malloc(m_memSize); - qstrcpy(m_data,str); - } - DBG_STR(("%p: QGString::operator=(const char *) %d:%s\n",this,m_len,m_data?m_data:"")); - return *this; -} - -QGString &QGString::operator+=( const QGString &s ) -{ - if (s.m_memSize==0) return *this; - uint len1 = length(); - uint len2 = s.length(); - uint memSize = ROUND_SIZE(len1 + len2 + 1); - assert(memSize>=len1+len2+1); - char *newData = memSize!=m_memSize ? (char*)realloc( m_data, memSize ) : m_data; - m_memSize = memSize; - if (newData) - { - m_data = newData; - memcpy( m_data + len1, s, len2 + 1 ); - } - m_len = len1+len2; - DBG_STR(("%p: QGString::operator+=(const QGString &) %d:%s\n",this,m_len,m_data?m_data:"")); - return *this; -} - -QGString &QGString::operator+=( const char *str ) -{ - if (!str) return *this; - uint len1 = length(); - uint len2 = qstrlen(str); - uint memSize = ROUND_SIZE(len1 + len2 + 1); - assert(memSize>=len1+len2+1); - char *newData = memSize!=m_memSize ? (char *)realloc( m_data, memSize ) : m_data; - m_memSize = memSize; - if (newData) - { - m_data = newData; - memcpy( m_data + len1, str, len2 + 1 ); - } - m_len+=len2; - DBG_STR(("%p: QGString::operator+=(const char *) %d:%s\n",this,m_len,m_data?m_data:"")); - return *this; -} - -QGString &QGString::operator+=( char c ) -{ - uint len = m_len; - uint memSize = ROUND_SIZE(len+2); - assert(memSize>=len+2); - char *newData = memSize!=m_memSize ? (char *)realloc( m_data, memSize ) : m_data; - m_memSize = memSize; - if (newData) - { - m_data = newData; - m_data[len] = c; - m_data[len+1] = '\0'; - } - m_len++; - DBG_STR(("%p: QGString::operator+=(char s) %d:%s\n",this,m_len,m_data?m_data:"")); - return *this; -} - diff --git a/qtools/qgstring.h b/qtools/qgstring.h deleted file mode 100644 index 0af1045..0000000 --- a/qtools/qgstring.h +++ /dev/null @@ -1,139 +0,0 @@ -#ifndef QGSTRING_H -#define QGSTRING_H - -#include -#include - -#if defined(_OS_SUN_) && defined(_CC_GNU_) -#include -#endif - -#include "qcstring.h" - -/***************************************************************************** - Fixes and workarounds for some platforms - *****************************************************************************/ - -/** This is an alternative implementation of QCString. - */ -class QGString -{ - public: - QGString(); // make null string - QGString(uint size); - QGString( const QGString &s ); - QGString( const char *str ); - ~QGString() ; - - bool resize( uint newlen ); - bool enlarge( uint newlen ); - void setLen( uint newlen ); - - QGString &operator=( const QGString &s ); - QGString &operator=( const char *str ); - QGString &operator+=( const QGString &s ); - QGString &operator+=( const char *str ); - QGString &operator+=( char c ); - - bool isNull() const { return m_data==0; } - bool isEmpty() const { return m_len==0; } - uint length() const { return m_len; } - uint size() const { return m_memSize; } - char * data() const { return m_data; } - bool truncate( uint pos ) { return resize(pos+1); } - operator const char *() const { return (const char *)data(); } - char &at( uint index ) const { return m_data[index]; } - char &operator[]( uint i ) const { return at(i); } - - private: - char * m_data; - uint m_len; - uint m_memSize; -}; - -/***************************************************************************** - QGString non-member operators - *****************************************************************************/ - -Q_EXPORT inline bool operator==( const QGString &s1, const QGString &s2 ) -{ return qstrcmp(s1.data(),s2.data()) == 0; } - -Q_EXPORT inline bool operator==( const QGString &s1, const char *s2 ) -{ return qstrcmp(s1.data(),s2) == 0; } - -Q_EXPORT inline bool operator==( const char *s1, const QGString &s2 ) -{ return qstrcmp(s1,s2.data()) == 0; } - -Q_EXPORT inline bool operator!=( const QGString &s1, const QGString &s2 ) -{ return qstrcmp(s1.data(),s2.data()) != 0; } - -Q_EXPORT inline bool operator!=( const QGString &s1, const char *s2 ) -{ return qstrcmp(s1.data(),s2) != 0; } - -Q_EXPORT inline bool operator!=( const char *s1, const QGString &s2 ) -{ return qstrcmp(s1,s2.data()) != 0; } - -Q_EXPORT inline bool operator<( const QGString &s1, const QGString& s2 ) -{ return qstrcmp(s1.data(),s2.data()) < 0; } - -Q_EXPORT inline bool operator<( const QGString &s1, const char *s2 ) -{ return qstrcmp(s1.data(),s2) < 0; } - -Q_EXPORT inline bool operator<( const char *s1, const QGString &s2 ) -{ return qstrcmp(s1,s2.data()) < 0; } - -Q_EXPORT inline bool operator<=( const QGString &s1, const char *s2 ) -{ return qstrcmp(s1.data(),s2) <= 0; } - -Q_EXPORT inline bool operator<=( const char *s1, const QGString &s2 ) -{ return qstrcmp(s1,s2.data()) <= 0; } - -Q_EXPORT inline bool operator>( const QGString &s1, const char *s2 ) -{ return qstrcmp(s1.data(),s2) > 0; } - -Q_EXPORT inline bool operator>( const char *s1, const QGString &s2 ) -{ return qstrcmp(s1,s2.data()) > 0; } - -Q_EXPORT inline bool operator>=( const QGString &s1, const char *s2 ) -{ return qstrcmp(s1.data(),s2) >= 0; } - -Q_EXPORT inline bool operator>=( const char *s1, const QGString &s2 ) -{ return qstrcmp(s1,s2.data()) >= 0; } - -Q_EXPORT inline QGString operator+( const QGString &s1, const QGString &s2 ) -{ - QGString tmp( s1.data() ); - tmp += s2; - return tmp; -} - -Q_EXPORT inline QGString operator+( const QGString &s1, const char *s2 ) -{ - QGString tmp( s1.data() ); - tmp += s2; - return tmp; -} - -Q_EXPORT inline QGString operator+( const char *s1, const QGString &s2 ) -{ - QGString tmp( s1 ); - tmp += s2; - return tmp; -} - -Q_EXPORT inline QGString operator+( const QGString &s1, char c2 ) -{ - QGString tmp( s1.data() ); - tmp += c2; - return tmp; -} - -Q_EXPORT inline QGString operator+( char c1, const QGString &s2 ) -{ - QGString tmp; - tmp += c1; - tmp += s2; - return tmp; -} - -#endif // QGSTRING_H diff --git a/src/code.l b/src/code.l index 90c1ff3..a0ace11 100644 --- a/src/code.l +++ b/src/code.l @@ -34,6 +34,7 @@ #include #include #include +#include #include #include @@ -74,10 +75,11 @@ // context for an Objective-C method call struct ObjCCallCtx { + ObjCCallCtx() : comment(std::ios_base::ate) {} int id; QCString methodName; QCString objectTypeOrName; - QGString comment; + std::ostringstream comment; const ClassDef *objectType; const MemberDef *objectVar; const MemberDef *method; @@ -1435,18 +1437,19 @@ ENDQopt ("const"|"volatile"|"sealed"|"override")({BN}+("const"|"volatile"|"seale } {CCS} { yyextra->lastObjCCallContext = YY_START; - yyextra->currentCtx->comment=yytext; + yyextra->currentCtx->comment.str(yytext); BEGIN(ObjCCallComment); } {CCE} { - yyextra->currentCtx->comment+=yytext; - yyextra->currentCtx->format+=escapeComment(yyscanner,yyextra->currentCtx->comment); + yyextra->currentCtx->comment << yytext; + std::string commentStr = yyextra->currentCtx->comment.str(); + yyextra->currentCtx->format+=escapeComment(yyscanner,commentStr.c_str()); BEGIN(yyextra->lastObjCCallContext); } -[^*\n]+ { yyextra->currentCtx->comment+=yytext; } -{CPPC}|{CCS} { yyextra->currentCtx->comment+=yytext; } -\n { yyextra->currentCtx->comment+=*yytext; } -. { yyextra->currentCtx->comment+=*yytext; } +[^*\n]+ { yyextra->currentCtx->comment << yytext; } +{CPPC}|{CCS} { yyextra->currentCtx->comment << yytext; } +\n { yyextra->currentCtx->comment << *yytext; } +. { yyextra->currentCtx->comment << *yytext; } {ID} { yyextra->currentCtx->format+=escapeObject(yyscanner,yytext); if (yyextra->braceCount==0) diff --git a/src/context.cpp b/src/context.cpp index ec1d7a4..dec48c9 100644 --- a/src/context.cpp +++ b/src/context.cpp @@ -1259,7 +1259,7 @@ static TemplateVariant parseDoc(const Definition *def,const QCString &file,int l TemplateVariant result; DocRoot *root = validatingParseDoc(file,line,def,0,docStr,TRUE,FALSE, 0,isBrief,FALSE,Config_getBool(MARKDOWN_SUPPORT)); - std::stringstream ts; + std::ostringstream ts(std::ios_base::ate); switch (g_globals.outputFormat) { case ContextOutputFormat_Html: @@ -1281,12 +1281,12 @@ static TemplateVariant parseDoc(const Definition *def,const QCString &file,int l err("context.cpp: output format not yet supported\n"); break; } - QCString docs = ts.str().c_str(); + std::string docs = ts.str(); bool isEmpty = root->isEmpty(); if (isEmpty) result = ""; else - result = TemplateVariant(docs,TRUE); + result = TemplateVariant(docs.c_str(),TRUE); delete root; return result; } @@ -1296,7 +1296,7 @@ static TemplateVariant parseCode(MemberDef *md,const QCString &scopeName,const Q { auto intf = Doxygen::parserManager->getCodeParser(md->getDefFileExtension()); intf->resetCodeParserState(); - std::stringstream t; + std::ostringstream t(std::ios_base::ate); switch (g_globals.outputFormat) { case ContextOutputFormat_Html: @@ -1327,7 +1327,7 @@ static TemplateVariant parseCode(const FileDef *fd,const QCString &relPath) static bool filterSourceFiles = Config_getBool(FILTER_SOURCE_FILES); auto intf = Doxygen::parserManager->getCodeParser(fd->getDefFileExtension()); intf->resetCodeParserState(); - std::stringstream t; + std::ostringstream t(std::ios_base::ate); switch (g_globals.outputFormat) { case ContextOutputFormat_Html: @@ -1949,7 +1949,7 @@ class ClassContext::Private : public DefinitionContext } TemplateVariant inheritanceDiagram() const { - std::stringstream t; + std::ostringstream t(std::ios_base::ate); static bool haveDot = Config_getBool(HAVE_DOT); static bool classDiagrams = Config_getBool(CLASS_DIAGRAMS); static bool classGraph = Config_getBool(CLASS_GRAPH); @@ -1990,13 +1990,13 @@ class ClassContext::Private : public DefinitionContext { case ContextOutputFormat_Html: { - std::stringstream tt; + std::ostringstream tt(std::ios_base::ate); QCString name = convertToHtml(m_classDef->displayName()); d.writeImage(tt,g_globals.outputDir, relPathAsString(), m_classDef->getOutputFileBase()); - if (tt.tellg()>0) + if (tt.tellp()>0) { t << "
\n"; t << " TemplateVariant collaborationDiagram() const { static bool haveDot = Config_getBool(HAVE_DOT); - std::stringstream t; + std::ostringstream t(std::ios_base::ate); if (haveDot) { DotClassGraph *cg = getCollaborationGraph(); @@ -3054,7 +3054,7 @@ class FileContext::Private : public DefinitionContext TemplateVariant includeGraph() const { static bool haveDot = Config_getBool(HAVE_DOT); - std::stringstream t; + std::ostringstream t(std::ios_base::ate); if (haveDot) { DotInclDepGraph *cg = getIncludeGraph(); @@ -3106,7 +3106,7 @@ class FileContext::Private : public DefinitionContext TemplateVariant includedByGraph() const { static bool haveDot = Config_getBool(HAVE_DOT); - std::stringstream t; + std::ostringstream t(std::ios_base::ate); if (haveDot) { DotInclDepGraph *cg = getIncludedByGraph(); @@ -3512,7 +3512,7 @@ class DirContext::Private : public DefinitionContext } TemplateVariant dirGraph() const { - std::stringstream t; + std::ostringstream t(std::ios_base::ate); static bool haveDot = Config_getBool(HAVE_DOT); static bool dirGraph = Config_getBool(DIRECTORY_GRAPH); if (haveDot && dirGraph) @@ -3896,7 +3896,7 @@ class TextGeneratorFactory TemplateVariant createLinkedText(const Definition *def,const QCString &relPath,const QCString &text) { - std::stringstream ts; + std::ostringstream ts(std::ios_base::ate); TextGeneratorIntf *tg = TextGeneratorFactory::instance()->create(ts,relPath); if (tg) { @@ -4937,7 +4937,7 @@ class MemberContext::Private : public DefinitionContext if (hasCallGraph().toBool()) { DotCallGraph *cg = getCallGraph(); - std::stringstream t; + std::ostringstream t(std::ios_base::ate); switch (g_globals.outputFormat) { case ContextOutputFormat_Html: @@ -5009,7 +5009,7 @@ class MemberContext::Private : public DefinitionContext if (hasCallerGraph().toBool()) { DotCallGraph *cg = getCallerGraph(); - std::stringstream t; + std::ostringstream t(std::ios_base::ate); switch (g_globals.outputFormat) { case ContextOutputFormat_Html: @@ -5273,7 +5273,7 @@ class ModuleContext::Private : public DefinitionContext } TemplateVariant groupGraph() const { - std::stringstream t; + std::ostringstream t(std::ios_base::ate); static bool haveDot = Config_getBool(HAVE_DOT); static bool groupGraphs = Config_getBool(GROUP_GRAPHS); if (haveDot && groupGraphs) @@ -8291,7 +8291,7 @@ class InheritanceGraphContext::Private } TemplateVariant graph() const { - std::stringstream t; + std::ostringstream t(std::ios_base::ate); static bool haveDot = Config_getBool(HAVE_DOT); static bool graphicalHierarchy = Config_getBool(GRAPHICAL_HIERARCHY); if (haveDot && graphicalHierarchy) @@ -9892,7 +9892,7 @@ class LatexSpaceless : public TemplateSpacelessIntf void reset() { } QCString remove(const QCString &s) { - QGString result; + std::ostringstream result(std::ios_base::ate); const char *p = s.data(); char c; while ((c=*p++)) @@ -9902,12 +9902,11 @@ class LatexSpaceless : public TemplateSpacelessIntf case '\t': case ' ': case '\n': break; default: - result+=c; + result << c; break; } } - result+='\0'; - return result.data(); + return result.str(); } private: }; @@ -9926,7 +9925,7 @@ class HtmlSpaceless : public TemplateSpacelessIntf } QCString remove(const QCString &s) { - QGString result; + std::ostringstream result(std::ios_base::ate); const char *p = s.data(); char c; while ((c=*p++)) @@ -9935,15 +9934,15 @@ class HtmlSpaceless : public TemplateSpacelessIntf { case '<': // start of a tag if (!m_insideString) m_insideTag=TRUE,m_removeSpaces=FALSE; - result+=c; + result << c; break; case '>': // end of a tag if (!m_insideString) m_insideTag=FALSE,m_removeSpaces=TRUE; - result+=c; + result << c; break; case '\\': // escaped character in a string - result+=c; - if (m_insideString && *p) result+=*p++; + result << c; + if (m_insideString && *p) result << *p++; break; case '"': case '\'': if (m_insideTag) @@ -9957,7 +9956,7 @@ class HtmlSpaceless : public TemplateSpacelessIntf m_insideString=c; } } - result+=c; + result << c; break; case ' ': case '\t': case '\n': // whitespace if (!m_insideTag) // outside tags strip consecutive whitespace @@ -9966,20 +9965,19 @@ class HtmlSpaceless : public TemplateSpacelessIntf } else { - result+=' '; + result << ' '; } break; default: //if (m_removeSpaces) result+=' '; - result+=c; + result << c; m_removeSpaces=FALSE; break; } } - result+='\0'; //printf("HtmlSpaceless::remove({%s})={%s} m_insideTag=%d m_insideString=%c (%d) removeSpaces=%d\n",s.data(),result.data(), // m_insideTag,m_insideString,m_insideString,m_removeSpaces); - return result.data(); + return result.str(); } private: bool m_insideTag; @@ -10117,7 +10115,7 @@ void generateOutputViaTemplate() HtmlSpaceless spl; ctx->setSpacelessIntf(&spl); ctx->setOutputDirectory(g_globals.outputDir); - std::stringstream ts; + std::ostringstream ts(std::ios_base::ate); tpl->render(ts,ctx); e.unload(tpl); } @@ -10142,7 +10140,7 @@ void generateOutputViaTemplate() LatexSpaceless spl; ctx->setSpacelessIntf(&spl); ctx->setOutputDirectory(g_globals.outputDir); - std::stringstream ts; + std::ostringstream ts(std::ios_base::ate); tpl->render(ts,ctx); e.unload(tpl); } diff --git a/src/dot.cpp b/src/dot.cpp index 8deb0d8..6a38a6e 100644 --- a/src/dot.cpp +++ b/src/dot.cpp @@ -354,11 +354,11 @@ void writeDotImageMapFromFile(std::ostream &t, } else // bitmap graphics { - std::stringstream tt; + std::ostringstream tt(std::ios_base::ate); t << "\""\n"; DotFilePatcher::convertMapFile(tt, absOutFile, relPath ,TRUE, context); - if (tt.tellg()>0) + if (tt.tellp()>0) { t << ""; t << tt.str(); diff --git a/src/dotdirdeps.cpp b/src/dotdirdeps.cpp index 8e203c7..680b2f7 100644 --- a/src/dotdirdeps.cpp +++ b/src/dotdirdeps.cpp @@ -199,7 +199,7 @@ QCString DotDirDeps::getBaseName() const void DotDirDeps::computeTheGraph() { // compute md5 checksum of the graph were are about to generate - std::stringstream md5stream; + std::ostringstream md5stream(std::ios_base::ate); //m_dir->writeDepGraph(md5stream); writeDotDirDepGraph(md5stream,m_dir,m_linkRelations); m_theGraph = md5stream.str(); diff --git a/src/dotfilepatcher.cpp b/src/dotfilepatcher.cpp index 2d934f0..d19dc4a 100644 --- a/src/dotfilepatcher.cpp +++ b/src/dotfilepatcher.cpp @@ -411,12 +411,12 @@ bool DotFilePatcher::run() const int n = sscanf(line.data()+i,"