#include "main.c" #include "ast.c" #include "insn.c" #include "symbol.c" #include "token.c" #include "type.c"
struct GenContext gen_ctx = {
parse_ctx.scope,
0, 0, 0, {}, {-1, -1}, 0, {}, print_ast, 0
}; 0, 0, 0, {0}, {-1, -1}, 0, {0}, print_ast, 0
#include <stdio.h>
#include <string.h>
char* my_dirname(char* path) {
static char buffer[256];
char* last_slash;
// パスがNULLまたは空の場合、"."を返す
if (path == NULL || *path == '\0') {
return ".";
}
// パスをコピー
strncpy(buffer, path, sizeof(buffer) - 1);
buffer[sizeof(buffer) - 1] = '\0';
// 最後のスラッシュを探す
last_slash = strrchr(buffer, '/');
// スラッシュが見つからない場合、"."を返す
if (last_slash == NULL) {
return ".";
}
// スラッシュの後ろを終端文字に置き換える
if (last_slash != buffer) {
*last_slash = '\0';
} else {
// ルートディレクトリの場合
*(last_slash + 1) = '\0';
}
return buffer;
}