Commit d9bbcb5d by Alan Mishchenko

Handling C++-style comments in Liberty parser.

parent e49e123b
......@@ -173,6 +173,7 @@ int Scl_LibertyCountItems( char * pBeg, char * pEnd )
return Counter;
}
// removes C-style comments
/*
void Scl_LibertyWipeOutComments( char * pBeg, char * pEnd )
{
char * pCur, * pStart;
......@@ -186,6 +187,31 @@ void Scl_LibertyWipeOutComments( char * pBeg, char * pEnd )
break;
}
}
*/
void Scl_LibertyWipeOutComments( char * pBeg, char * pEnd )
{
char * pCur, * pStart;
for ( pCur = pBeg; pCur < pEnd-1; pCur++ )
if ( pCur[0] == '/' && pCur[1] == '*' )
{
for ( pStart = pCur; pCur < pEnd-1; pCur++ )
if ( pCur[0] == '*' && pCur[1] == '/' )
{
for ( ; pStart < pCur + 2; pStart++ )
if ( *pStart != '\n' ) *pStart = ' ';
break;
}
}
else if ( pCur[0] == '/' && pCur[1] == '/' )
{
for ( pStart = pCur; pCur < pEnd; pCur++ )
if ( pCur[0] == '\n' || pCur == pEnd-1 )
{
for ( ; pStart < pCur; pStart++ ) *pStart = ' ';
break;
}
}
}
static inline int Scl_LibertyCharIsSpace( char c )
{
return c == ' ' || c == '\t' || c == '\r' || c == '\n' || c == '\\';
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment