@@ -18,6 +18,7 @@ int main(int argc, char **argv)
18
18
bool error = false ;
19
19
const char *filename = nullptr ;
20
20
bool use_istream = false ;
21
+ bool keep_comments = false ;
21
22
22
23
// Settings..
23
24
simplecpp::DUI dui;
@@ -70,6 +71,10 @@ int main(int argc, char **argv)
70
71
error_only = true ;
71
72
found = true ;
72
73
break ;
74
+ case ' C' :
75
+ keep_comments = true ;
76
+ found = true ;
77
+ break ;
73
78
}
74
79
if (!found) {
75
80
std::cout << " error: option '" << arg << " ' is unknown." << std::endl;
@@ -102,10 +107,11 @@ int main(int argc, char **argv)
102
107
std::cout << " -q Quiet mode (no output)." << std::endl;
103
108
std::cout << " -is Use std::istream interface." << std::endl;
104
109
std::cout << " -e Output errors only." << std::endl;
110
+ std::cout << " -C Keep comments." << std::endl;
105
111
std::exit (0 );
106
112
}
107
113
108
- dui.removeComments = true ;
114
+ dui.removeComments = !keep_comments ;
109
115
110
116
// Perform preprocessing
111
117
simplecpp::OutputList outputList;
@@ -121,7 +127,8 @@ int main(int argc, char **argv)
121
127
} else {
122
128
rawtokens = new simplecpp::TokenList (filename,files,&outputList);
123
129
}
124
- rawtokens->removeComments ();
130
+ if (!keep_comments)
131
+ rawtokens->removeComments ();
125
132
simplecpp::TokenList outputTokens (files);
126
133
std::map<std::string, simplecpp::TokenList*> filedata;
127
134
simplecpp::preprocess (outputTokens, *rawtokens, files, filedata, dui, &outputList);
0 commit comments