refactor(argparse): 将null替换为nullptr以提高C++兼容性

- 在argparse库中将所有null指针常量替换为nullptr
- 更新头文件和源文件中的指针初始化和比较操作
- 修改测试文件中的相关断言检查
- 更新AST定义文件中的注释说明
This commit is contained in:
zzy
2026-04-05 20:18:09 +08:00
parent 27d86d5685
commit 4144f7841c
76 changed files with 1430 additions and 998 deletions

View File

@@ -69,7 +69,7 @@ int main(int argc, const char **argv, const char **envp) {
#endif
scc_argparse_lang_t argparse_lang = SCC_DEFAULT_ARGPARSE_LANG;
for (const char **env = envp; *env != null; env++) {
for (const char **env = envp; *env != nullptr; env++) {
const char *env_str = *env;
if (scc_strcmp(env_str, "LANG=zh_CN.UTF-8") == 0) {
argparse_lang = SCC_ARGPARSE_LANG_ZH;
@@ -77,9 +77,9 @@ int main(int argc, const char **argv, const char **envp) {
}
scc_config_t config = {
.input_file = null,
.input_file = nullptr,
.verbose = 0,
.output_file = null,
.output_file = nullptr,
.emit_ast = false,
.emit_ir = false,
.target_description = "x86_64-pc-windows-msvc",
@@ -95,12 +95,12 @@ int main(int argc, const char **argv, const char **envp) {
}
scc_argparse_drop(&argparse);
scc_file_t fp = null;
scc_file_t fp = nullptr;
if (config.output_file) {
cbool is_stdout = scc_strcmp(config.output_file, "-") == 0;
if (!is_stdout) {
fp = scc_fopen(config.output_file, SCC_FILE_WRITE);
if (fp == null) {
if (fp == nullptr) {
LOG_FATAL("Failed to open file %s", config.output_file);
return 1;
}
@@ -122,8 +122,8 @@ int main(int argc, const char **argv, const char **envp) {
scc_lexer_init(&lexer, scc_sstream_to_ring(&sstream));
if (config.emit_lex) {
scc_lexer_tok_ring_t *tok_ring =
scc_lexer_to_ring(&lexer, 8, fp == null ? false : true);
if (fp == null) {
scc_lexer_to_ring(&lexer, 8, fp == nullptr ? false : true);
if (fp == nullptr) {
print_ring(tok_ring, config.verbose);
} else {
print_file(tok_ring, fp);
@@ -166,7 +166,7 @@ int main(int argc, const char **argv, const char **envp) {
if (config.emit_pp) {
scc_lexer_tok_ring_t *tok_ring =
scc_pproc_to_ring(&pproc, 8, true, true);
if (fp == null) {
if (fp == nullptr) {
print_ring(tok_ring, config.verbose);
} else {
print_file(tok_ring, fp);
@@ -198,14 +198,14 @@ sstream_drop:
if (config.emit_ast) {
scc_tree_dump_t tree_dump;
if (fp == null) {
if (fp == nullptr) {
scc_tree_dump_init(&tree_dump, true);
} else {
scc_tree_dump_init(&tree_dump, false);
}
scc_ast_dump_node(&tree_dump, (scc_ast_node_t *)translation_unit);
scc_tree_dump_flush(&tree_dump, tree_dump_output,
fp == null ? scc_stdout : fp);
fp == nullptr ? scc_stdout : fp);
scc_tree_dump_drop(&tree_dump);
return 0;
}
@@ -221,7 +221,7 @@ sstream_drop:
if (config.emit_ir) {
scc_ir_dump_ctx_t ir_dump_ctx;
scc_tree_dump_t tree_dump;
if (fp == null) {
if (fp == nullptr) {
scc_tree_dump_init(&tree_dump, true);
} else {
scc_tree_dump_init(&tree_dump, false);
@@ -231,7 +231,7 @@ sstream_drop:
scc_ir_dump_cprog_linear(&ir_dump_ctx);
scc_tree_dump_flush(&tree_dump, tree_dump_output,
fp == null ? scc_stdout : fp);
fp == nullptr ? scc_stdout : fp);
scc_tree_dump_drop(&tree_dump);
return 0;
}
@@ -247,7 +247,7 @@ sstream_drop:
scc_pe_builder_t pe_builder;
sccf2pe(&pe_builder, sccf);
if (fp == null) {
if (fp == nullptr) {
scc_printf("output exe at %s\n", config.output_file);
} else {
scc_pe_dump_to_file(&pe_builder, config.output_file);