ReactOS 0.4.15-dev-7953-g1f49173
strip_comments.cpp
Go to the documentation of this file.
1// strip_comments.cpp
2
3#ifdef _MSC_VER
4#pragma warning ( disable : 4786 )
5#endif//_MSC_VER
6
7#include "strip_comments.h"
8
9void strip_comments ( std::string& s, bool strip_lf )
10{
11 char* src = &s[0];
12 char* dst = src;
13 while ( *src )
14 {
15 if ( src[0] == '/' && src[1] == '/' )
16 {
17 src += 2;
18 while ( *src && *src != '\n' )
19 src++;
20 if ( *src )
21 src++; // skip newline
22 }
23 else if ( src[0] == '/' && src[1] == '*' )
24 {
25 src += 2;
26 char* newsrc = strstr ( src, "*/" );
27 if ( !newsrc )
28 break;
29 src = newsrc;
30 //while ( *src && ( src[0] != '*' || src[1] != '/' ) )
31 // src++;
32 if ( *src ) src++;
33 if ( *src ) src++;
34 }
35 else if ( src[0] == '\r' && strip_lf )
36 src++;
37 else
38 *dst++ = *src++;
39 }
40 *dst = '\0';
41
42 s.resize ( dst-&s[0] );
43}
char * strstr(char *String1, char *String2)
Definition: utclib.c:653
GLdouble s
Definition: gl.h:2039
GLenum src
Definition: glext.h:6340
GLenum GLenum dst
Definition: glext.h:6340
void strip_comments(std::string &s, bool strip_lf)