mirror of
https://github.com/reactos/reactos.git
synced 2025-08-05 01:55:39 +00:00
sped up strip_comments, and added File::SaveFromString() in the process of hunting down a recursive c include.
svn path=/trunk/; revision=6731
This commit is contained in:
parent
8a095f86fc
commit
ef60bea82e
4 changed files with 22 additions and 5 deletions
|
@ -118,3 +118,12 @@ void File::close()
|
||||||
s.resize ( len );
|
s.resize ( len );
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*static*/ bool File::SaveFromString ( const char* filename, const std::string& s, bool binary )
|
||||||
|
{
|
||||||
|
File out ( filename, binary ? "wb" : "w" );
|
||||||
|
if ( !out.isopened() )
|
||||||
|
return false;
|
||||||
|
out.write ( s.c_str(), s.size() );
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
|
@ -99,6 +99,7 @@ public:
|
||||||
}
|
}
|
||||||
|
|
||||||
static bool LoadIntoString ( std::string& s, const char* filename );
|
static bool LoadIntoString ( std::string& s, const char* filename );
|
||||||
|
static bool SaveFromString ( const char* filename, const std::string& s, bool binary );
|
||||||
|
|
||||||
private:
|
private:
|
||||||
File(const File&) {}
|
File(const File&) {}
|
||||||
|
|
|
@ -58,6 +58,7 @@ const char* libc_includes[] =
|
||||||
{
|
{
|
||||||
"basestd.h",
|
"basestd.h",
|
||||||
"except.h",
|
"except.h",
|
||||||
|
"float.h",
|
||||||
"limits.h",
|
"limits.h",
|
||||||
"stdarg.h",
|
"stdarg.h",
|
||||||
"stddef.h",
|
"stddef.h",
|
||||||
|
@ -87,6 +88,8 @@ BOOL FileEnumProc ( PWIN32_FIND_DATA pwfd, const char* filename, long lParam )
|
||||||
|
|
||||||
void main()
|
void main()
|
||||||
{
|
{
|
||||||
|
//import_file ( "coff.h" );
|
||||||
|
|
||||||
File f ( "input.lst", "r" );
|
File f ( "input.lst", "r" );
|
||||||
if ( !f.isopened() )
|
if ( !f.isopened() )
|
||||||
{
|
{
|
||||||
|
@ -133,7 +136,7 @@ bool import_file ( const char* filename )
|
||||||
/*{
|
/*{
|
||||||
string no_comments ( filename );
|
string no_comments ( filename );
|
||||||
no_comments += ".nocom.txt";
|
no_comments += ".nocom.txt";
|
||||||
File::SaveFromString ( s, no_comments );
|
File::SaveFromString ( no_comments.c_str(), s, false );
|
||||||
}*/
|
}*/
|
||||||
|
|
||||||
Header* h = new Header ( filename );
|
Header* h = new Header ( filename );
|
||||||
|
|
|
@ -23,10 +23,14 @@ void strip_comments ( std::string& s, bool strip_lf )
|
||||||
else if ( src[0] == '/' && src[1] == '*' )
|
else if ( src[0] == '/' && src[1] == '*' )
|
||||||
{
|
{
|
||||||
src += 2;
|
src += 2;
|
||||||
while ( *src && ( src[0] != '*' || src[1] != '/' ) )
|
char* newsrc = strstr ( src, "*/" );
|
||||||
src++;
|
if ( !newsrc )
|
||||||
if ( *src )
|
break;
|
||||||
src += 2;
|
src = newsrc;
|
||||||
|
//while ( *src && ( src[0] != '*' || src[1] != '/' ) )
|
||||||
|
// src++;
|
||||||
|
if ( *src ) src++;
|
||||||
|
if ( *src ) src++;
|
||||||
}
|
}
|
||||||
else if ( src[0] == '\r' && strip_lf )
|
else if ( src[0] == '\r' && strip_lf )
|
||||||
src++;
|
src++;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue