| 96 | } |
| 97 | |
| 98 | bool findIncludeStatement( const std::string &line, std::string *out ) |
| 99 | { |
| 100 | const int INCLUDE_KEYWORD_LEN = 7; |
| 101 | const char *resultStart = nullptr; |
| 102 | const char *c = line.c_str(); |
| 103 | consumeWhiteSpace( &c ); |
| 104 | // leading '#' |
| 105 | if( ( isTerminated( c ) ) || ( *c != '#' ) ) |
| 106 | return false; |
| 107 | ++c; |
| 108 | consumeWhiteSpace( &c ); |
| 109 | if( isTerminated( c ) ) |
| 110 | return false; |
| 111 | // include keyword |
| 112 | if( strncmp( c, "include", INCLUDE_KEYWORD_LEN ) ) |
| 113 | return false; |
| 114 | c += INCLUDE_KEYWORD_LEN; |
| 115 | consumeWhiteSpace( &c ); |
| 116 | // leading quote or angle bracket |
| 117 | if( ( isTerminated( c ) ) || ( *c != '\"' && *c != '<' ) ) |
| 118 | return false; |
| 119 | ++c; |
| 120 | resultStart = c; |
| 121 | while( ( ! isTerminated( c ) ) && *c != '\"' && *c != '>' ) |
| 122 | ++c; |
| 123 | if( isTerminated( c ) ) // we hit the terminus before the closing symbol |
| 124 | return false; |
| 125 | if( out ) |
| 126 | *out = std::string( resultStart, c ); |
| 127 | return true; |
| 128 | } |
| 129 | |
| 130 | bool findVersionStatement( const char *lineStart, int *versionNumberOut ) |
| 131 | { |
no test coverage detected