ReactOS 0.4.15-dev-7918-g2a2556c
strip_comments.h File Reference
#include <string>
Include dependency graph for strip_comments.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Functions

void strip_comments (std::string &s, bool strip_lf=false)
 

Function Documentation

◆ strip_comments()

void strip_comments ( std::string &  s,
bool  strip_lf = false 
)

Definition at line 9 of file strip_comments.cpp.

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

Referenced by import_file().