diff options
author | Alan Mishchenko <alanmi@berkeley.edu> | 2014-01-28 17:45:44 +0800 |
---|---|---|
committer | Alan Mishchenko <alanmi@berkeley.edu> | 2014-01-28 17:45:44 +0800 |
commit | d9bbcb5dc9acba57ac39a9700f531add29dd761f (patch) | |
tree | c533c6a2ab4f72d7bee71dfec3e87712e60d37f7 /src/map/scl | |
parent | e49e123bb717f5d747efcb090955dea17aff2d62 (diff) | |
download | abc-d9bbcb5dc9acba57ac39a9700f531add29dd761f.tar.gz abc-d9bbcb5dc9acba57ac39a9700f531add29dd761f.tar.bz2 abc-d9bbcb5dc9acba57ac39a9700f531add29dd761f.zip |
Handling C++-style comments in Liberty parser.
Diffstat (limited to 'src/map/scl')
-rw-r--r-- | src/map/scl/sclLiberty.c | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/src/map/scl/sclLiberty.c b/src/map/scl/sclLiberty.c index d86e154d..e128b515 100644 --- a/src/map/scl/sclLiberty.c +++ b/src/map/scl/sclLiberty.c @@ -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 == '\\'; |