Skip to content

Commit 96ddcaf

Browse files
committed
use re
1 parent c940598 commit 96ddcaf

File tree

1 file changed

+6
-13
lines changed

1 file changed

+6
-13
lines changed

Header_File_constructor.cpp

Lines changed: 6 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,9 @@ std::regex ifndef_reg("^#[ \t]*ifndef[ \t]+([a-zA-Z_][a-zA-Z0-9_]*)[ \t]*");
2222
std::regex ifndef_reg2("^#[ \t]*if[ \t]+!defined[ \t]*\\([ \t]*([a-zA-Z_][a-zA-Z0-9_]*)[ \t]*\\)[ \t]*");
2323
std::regex endif_reg("^#[ \t]*endif[ \t]*");
2424

25+
std::regex simple_block_comment_begin_reg("^[ \t]*/\\*[ \t]*$");
26+
std::regex simple_block_comment_end_reg("^[ \t]*\\*/[ \t]*$");
27+
2528
std::map<std::string, std::string> define_map;
2629

2730
class NullStream: public std::ostream {
@@ -106,25 +109,15 @@ void process_file(std::filesystem::path in_file, std::istream& in, std::ostream&
106109
}
107110
std::smatch result;
108111
//skip_simple_block_comment
109-
if(arg_info::skip_simple_block_comment && line == "/*") {
112+
if(arg_info::skip_simple_block_comment && std::regex_match(line, result, simple_block_comment_begin_reg)) {
110113
//skip this line and all lines until */
111114
re_inblock:
112115
while(std::getline(in, line)) {
113116
line_num++;
114-
if(line == "*/") {
117+
if(std::regex_match(line, result, simple_block_comment_end_reg)) {
115118
while(std::getline(in, line)) {
116119
line_num++;
117-
line_begin_of_this_line.clear();
118-
if(arg_info::format_line_beginning)
119-
line_begin_of_this_line = line_begin;
120-
{
121-
auto pos = line.find_first_not_of(" \t");
122-
if(pos != std::string::npos) {
123-
line_begin_of_this_line += line.substr(0, pos);
124-
line = line.substr(pos);
125-
}
126-
}
127-
if(line == "/*")
120+
if(std::regex_match(line, result, simple_block_comment_begin_reg))
128121
goto re_inblock;
129122
else if(!line.empty())
130123
break;

0 commit comments

Comments
 (0)