fix(pproc): 修复预处理器对空行的处理逻辑
- 移除了错误的ENDLINE类型提前返回逻辑 - 将ENDLINE类型的处理移到正确的位置 - 添加了针对条件编译中空行的测试用例 fix(cli): 更新include路径参数的帮助文本 - 修正英文帮助文本为"Add directory to the include search paths" - 修正中文帮助文本为"添加系统头文件到搜索路径"
This commit is contained in:
@@ -20,11 +20,6 @@ CONTINUE:
|
||||
if (ok == false) {
|
||||
return false;
|
||||
}
|
||||
if (tok.type == SCC_TOK_ENDLINE) {
|
||||
scc_ring_next_consume(*stream, *out, ok);
|
||||
pp->at_line_start = true;
|
||||
return true;
|
||||
}
|
||||
|
||||
if (pp->at_line_start) {
|
||||
if (tok.type == SCC_TOK_SHARP) {
|
||||
@@ -51,7 +46,11 @@ CONTINUE:
|
||||
goto CONTINUE;
|
||||
}
|
||||
|
||||
if (tok.type == SCC_TOK_IDENT) {
|
||||
if (tok.type == SCC_TOK_ENDLINE) {
|
||||
scc_ring_next_consume(*stream, *out, ok);
|
||||
pp->at_line_start = true;
|
||||
return true;
|
||||
} else if (tok.type == SCC_TOK_IDENT) {
|
||||
// maybe expanded
|
||||
scc_pproc_macro_t *macro =
|
||||
scc_pproc_macro_table_get(&pp->macro_table, &tok.lexeme);
|
||||
|
||||
@@ -273,6 +273,24 @@ static void test_conditional_ifdef(void) {
|
||||
"#endif\n",
|
||||
"foo\n");
|
||||
|
||||
CHECK_PP_OUTPUT_EXACT("#ifdef FOO\n"
|
||||
"\n"
|
||||
"#endif\n",
|
||||
"");
|
||||
|
||||
CHECK_PP_OUTPUT_EXACT("#ifdef FOO\n"
|
||||
"#endif\n",
|
||||
"");
|
||||
|
||||
CHECK_PP_OUTPUT_EXACT("#ifndef FOO\n"
|
||||
"\n"
|
||||
"#endif\n",
|
||||
"\n");
|
||||
|
||||
CHECK_PP_OUTPUT_EXACT("#ifndef FOO\n"
|
||||
"#endif\n",
|
||||
"");
|
||||
|
||||
// ifdef + else
|
||||
CHECK_PP_OUTPUT_EXACT("#define FOO\n"
|
||||
"#ifdef FOO\n"
|
||||
|
||||
Reference in New Issue
Block a user