diff --git a/reactos/tools/xml.cpp b/reactos/tools/xml.cpp index 12b81f01e1d..58e1f0554dd 100644 --- a/reactos/tools/xml.cpp +++ b/reactos/tools/xml.cpp @@ -58,6 +58,35 @@ static const char* WSEQ = " =\t\r\n"; string working_directory; +std::vector vectorize(const std::string &str) +{ + std::vector result( str.size() + 1 ); + strcpy( &result[0], str.c_str() ); + return result; +} + +void vectappend(std::vector &strvec, const char *str) +{ + if (*str) { strvec[strlen(&strvec[0])] = *str; str++; } + while (*str) + { + strvec.push_back(*str); + str++; + } + strvec.push_back(0); +} + +void vectappend(std::vector &strvec, const std::string &str) +{ + vectappend(strvec, str.c_str()); +} + +void vectappend(std::vector &strvec, char ch) +{ + strvec[strlen(&strvec[0])] = ch; + strvec.push_back(0); +} + XMLException::XMLException ( const std::string& location, const char* format, ... ) @@ -158,7 +187,7 @@ Path::Fixup ( const string& file, bool include_filename ) const return file; } vector pathtmp ( path ); - string tmp ( file ); + vector tmp = vectorize( file ); const char* prev = strtok ( &tmp[0], "/\\" ); const char* p = strtok ( NULL, "/\\" ); while ( p ) @@ -184,18 +213,18 @@ Path::Fixup ( const string& file, bool include_filename ) const pathtmp.push_back ( prev ); // reuse tmp variable to return recombined path - tmp.resize(0); + tmp = vectorize(""); for ( size_t i = 0; i < pathtmp.size(); i++ ) { // this squirreliness is b/c win32 has drive letters and *nix doesn't... #ifdef WIN32 - if ( i ) tmp += "/"; + if ( i ) vectappend(tmp, "/"); #else - tmp += "/"; + vectappend(tmp, "/"); #endif - tmp += pathtmp[i]; + vectappend(tmp, pathtmp[i]); } - return tmp; + return &tmp[0]; } string diff --git a/reactos/tools/xml.h b/reactos/tools/xml.h index c3c8d25c380..29783f3e627 100644 --- a/reactos/tools/xml.h +++ b/reactos/tools/xml.h @@ -236,4 +236,9 @@ XMLLoadFile ( XMLElement* XMLLoadFile ( const std::string& filename ); +std::vector vectorize(const std::string &str); +void vectappend(std::vector &strvec, char ch); +void vectappend(std::vector &strvec, const char *charstr); +void vectappend(std::vector &strvec, const std::string &str); + #endif // XML_H