diff --git a/src/asset_manager.c b/src/asset_manager.c index 1cfea02..5038855 100644 --- a/src/asset_manager.c +++ b/src/asset_manager.c @@ -104,7 +104,7 @@ void asset_manager_init(void) char *d_name; if (!(dir = opendir_utf8(config.game_dir))) { - ERROR("Failed to open directory: %s", config.game_dir); + ERROR("Failed to open directory: %s", display_utf0(config.game_dir)); } char *base = get_base_name(config.ain_filename); @@ -121,7 +121,7 @@ void asset_manager_init(void) if (!strcasecmp(ext, "ald")) { int dno = toupper(d_name[base_len+1]) - 'A'; if (dno < 0 || dno >= ALD_FILEMAX) { - WARNING("Invalid ALD index: %s", d_name); + WARNING("Invalid ALD index: %s", display_utf0(d_name)); goto loop_next; } @@ -147,7 +147,7 @@ void asset_manager_init(void) ald_count[ASSET_DATA] = max(ald_count[ASSET_DATA], dno+1); break; default: - WARNING("Unhandled ALD file: %s", d_name); + WARNING("Unhandled ALD file: %s", display_utf0(d_name)); break; } } else if (!strcasecmp(ext, "bgi")) { @@ -245,7 +245,7 @@ static void add_cg_to_index(struct archive_data *data, possibly_unused void *_) { int logical_no = cg_name_to_int(data->name); if (logical_no < 0) { - WARNING("Can't determine logical index for CG: %s", data->name); + WARNING("Can't determine logical index for CG: %s", display_sjis0(data->name)); return; } diff --git a/src/audio_meta.c b/src/audio_meta.c index bc9b2a4..c494281 100644 --- a/src/audio_meta.c +++ b/src/audio_meta.c @@ -18,8 +18,10 @@ #include #include "system4.h" #include "system4/file.h" + #include "mixer.h" #include "little_endian.h" +#include "xsystem4.h" #define BGI_MAX 100 @@ -46,7 +48,7 @@ void bgi_read(const char *path) { FILE *fp = file_open_utf8(path, "rb"); if (!fp) { - WARNING("Failed to open bgi file: %s", path); + WARNING("Failed to open bgi file: %s", display_utf0(path)); return; } @@ -104,7 +106,7 @@ void wai_load(const char *path) uint8_t *file = file_read(path, &len); if (len < 48 || file[0] != 'X' || file[1] != 'I' || file[2] != '2' || file[3] != '\0') { - WARNING("Not a .wai file: %s", path); + WARNING("Not a .wai file: %s", display_utf0(path)); goto end; } int count = LittleEndian_getDW(file, 8) - 1; diff --git a/src/debug.c b/src/debug.c index 402fba5..b8e71f7 100644 --- a/src/debug.c +++ b/src/debug.c @@ -103,7 +103,7 @@ bool dbg_set_function_breakpoint(const char *_name, void(*cb)(struct breakpoint* free(name); if (fno < 0) { - DBG_ERROR("No function with name '%s'", _name); + DBG_ERROR("No function with name '%s'", display_sjis0(_name)); return false; } @@ -113,11 +113,11 @@ bool dbg_set_function_breakpoint(const char *_name, void(*cb)(struct breakpoint* breakpoints[nr_breakpoints].cb = cb; breakpoints[nr_breakpoints].data = data; breakpoints[nr_breakpoints].message = xmalloc(512); - snprintf(breakpoints[nr_breakpoints].message, 511, "Hit breakpoint at function '%s' (0x%08x)", _name, f->address); + snprintf(breakpoints[nr_breakpoints].message, 511, "Hit breakpoint at function '%s' (0x%08x)", display_sjis0(_name), f->address); LittleEndian_putW(ain->code, f->address, BREAKPOINT + nr_breakpoints); nr_breakpoints++; - NOTICE("Set breakpoint at function '%s' (0x%08x)", _name, f->address); + NOTICE("Set breakpoint at function '%s' (0x%08x)", display_sjis0(_name), f->address); return true; } @@ -171,9 +171,7 @@ void dbg_print_stack_trace(void) { for (int i = call_stack_ptr - 1, j = 0; i >= 0; i--, j++) { struct ain_function *f = &ain->functions[call_stack[i].fno]; - char *u = sjis2utf(f->name, strlen(f->name)); uint32_t addr = (i == call_stack_ptr - 1) ? instr_ptr : call_stack[i+1].call_address; - NOTICE("#%d 0x%08x in %s", j, addr, u); - free(u); + NOTICE("#%d 0x%08x in %s", j, addr, display_sjis0(f->name)); } } diff --git a/src/dungeon/dungeon.c b/src/dungeon/dungeon.c index b939e93..2e3a484 100644 --- a/src/dungeon/dungeon.c +++ b/src/dungeon/dungeon.c @@ -91,9 +91,9 @@ static GLuint *load_event_textures(int *nr_textures_out) int error = ARCHIVE_SUCCESS; struct alk_archive *alk = alk_open(path, ARCHIVE_MMAP, &error); if (error == ARCHIVE_FILE_ERROR) { - WARNING("alk_open(\"%s\"): %s", path, strerror(errno)); + WARNING("alk_open(\"%s\"): %s", display_utf0(path), strerror(errno)); } else if (error == ARCHIVE_BAD_ARCHIVE_ERROR) { - WARNING("alk_open(\"%s\"): invalid .alk file", path); + WARNING("alk_open(\"%s\"): invalid .alk file", display_utf0(path)); } free(path); if (!alk) @@ -138,9 +138,9 @@ bool dungeon_load(struct dungeon_context *ctx, int num) int error = ARCHIVE_SUCCESS; struct archive *dlf = (struct archive *)dlf_open(path, ARCHIVE_MMAP, &error); if (error == ARCHIVE_FILE_ERROR) { - WARNING("dlf_open(\"%s\"): %s", path, strerror(errno)); + WARNING("dlf_open(\"%s\"): %s", display_utf0(path), strerror(errno)); } else if (error == ARCHIVE_BAD_ARCHIVE_ERROR) { - WARNING("dlf_open(\"%s\"): invalid .dlf file", path); + WARNING("dlf_open(\"%s\"): invalid .dlf file", display_utf0(path)); } free(path); if (!dlf) diff --git a/src/ffi.c b/src/ffi.c index 29a179f..fa3c1ea 100644 --- a/src/ffi.c +++ b/src/ffi.c @@ -98,9 +98,7 @@ static void trace_hll_call(struct ain_library *lib, struct ain_hll_function *f, else if (!strcmp(lib->name, "SengokuRanceFont")); else goto notrace; - char *u = sjis2utf(ain->functions[call_stack[call_stack_ptr-1].fno].name, 0); - sys_message("(%s) ", u); - free(u); + sys_message("(%s) ", display_sjis0(ain->functions[call_stack[call_stack_ptr-1].fno].name)); sys_message("%s.%s(", lib->name, f->name); union vm_value **args = _args; @@ -108,7 +106,7 @@ static void trace_hll_call(struct ain_library *lib, struct ain_hll_function *f, if (i > 0) { sys_message(", "); } - sys_message("%s=", f->arguments[i].name); + sys_message("%s=", display_sjis0(f->arguments[i].name)); switch (f->arguments[i].type.data) { case AIN_INT: case AIN_LONG_INT: @@ -120,9 +118,7 @@ static void trace_hll_call(struct ain_library *lib, struct ain_hll_function *f, case AIN_STRING: { struct string ***strs = _args; struct string *s = *strs[i]; - char *u = sjis2utf(s->text, s->size); - sys_message("\"%s\"", u); - free(u); + sys_message("\"%s\"", display_sjis0(s->text)); break; } case AIN_BOOL: @@ -156,7 +152,7 @@ static void trace_hll_call(struct ain_library *lib, struct ain_hll_function *f, sys_message(" -> %f", r->f); break; case AIN_STRING: - sys_message(" -> \"%s\"", ((struct string*)r->ref)->text); + sys_message(" -> \"%s\"", display_sjis0(((struct string*)r->ref)->text)); break; case AIN_BOOL: sys_message(" -> %s", r->i ? "true" : "false"); @@ -169,10 +165,10 @@ static void trace_hll_call(struct ain_library *lib, struct ain_hll_function *f, union vm_value ***args = _args; switch (f->arguments[i].type.data) { case AIN_REF_INT: - sys_message(" (%s=%d)", f->arguments[i].name, (*args[i])->i); + sys_message(" (%s=%d)", display_sjis0(f->arguments[i].name), (*args[i])->i); break; case AIN_REF_FLOAT: - sys_message(" (%s=%f)", f->arguments[i].name, (*args[i])->f); + sys_message(" (%s=%f)", display_sjis0(f->arguments[i].name), (*args[i])->f); break; default: break; diff --git a/src/hll/ACXLoader.c b/src/hll/ACXLoader.c index 9e9ac1b..f59c178 100644 --- a/src/hll/ACXLoader.c +++ b/src/hll/ACXLoader.c @@ -50,9 +50,9 @@ static bool ACXLoader_Load(struct string *filename) } if (error == ACX_ERROR_FILE) { - WARNING("acx_load(\"%s\"): %s", path, strerror(errno)); + WARNING("acx_load(\"%s\"): %s", display_utf0(path), strerror(errno)); } else if (error == ACX_ERROR_INVALID) { - WARNING("acx_load(\"%s\"): invalid .acx file"); + WARNING("acx_load(\"%s\"): invalid .acx file", display_utf0(path)); } free(path); return !!acx; diff --git a/src/hll/BanMisc.c b/src/hll/BanMisc.c index a890d3e..5a9a986 100644 --- a/src/hll/BanMisc.c +++ b/src/hll/BanMisc.c @@ -32,7 +32,7 @@ static int BanMisc_SaveStruct(struct page *page, struct string *file_name) char *path = unix_path(file_name->text); FILE *fp = file_open_utf8(path, "w"); if (!fp) { - WARNING("Failed to open file '%s': %s", path, strerror(errno)); + WARNING("Failed to open file '%s': %s", display_utf0(path), strerror(errno)); free(path); return 0; } @@ -62,7 +62,7 @@ static int BanMisc_LoadStruct(struct page **_page, struct string *file_name) char *path = unix_path(file_name->text); FILE *fp = file_open_utf8(path, "r"); if (!fp) { - WARNING("Failed to open file '%s': %s", path, strerror(errno)); + WARNING("Failed to open file '%s': %s", display_utf0(path), strerror(errno)); free(path); return 0; } diff --git a/src/hll/CrayfishLogViewer.c b/src/hll/CrayfishLogViewer.c index da9c4cc..f8bff4d 100644 --- a/src/hll/CrayfishLogViewer.c +++ b/src/hll/CrayfishLogViewer.c @@ -17,7 +17,9 @@ #include "system4.h" #include "system4/string.h" #include "system4/utfsjis.h" + #include "hll.h" +#include "xsystem4.h" bool is_opened = false; @@ -43,9 +45,7 @@ HLL_WARN_UNIMPLEMENTED( , void, CrayfishLogViewer, SetWindowTitleName, static bool CrayfishLogViewer_AddText(struct string *text) { - char *u = sjis2utf(text->text, 0); - sys_message("%s", u); - free(u); + sys_message("%s", display_sjis0(text->text)); return true; } diff --git a/src/hll/File.c b/src/hll/File.c index 838b56f..a68f2f4 100644 --- a/src/hll/File.c +++ b/src/hll/File.c @@ -54,7 +54,7 @@ static int File_Open(struct string *filename, int type) char *path = unix_path(filename->text); current_file = file_open_utf8(path, mode); if (!current_file) { - WARNING("Failed to open file '%s': %s", path, strerror(errno)); + WARNING("Failed to open file '%s': %s", display_utf0(path), strerror(errno)); } free(path); diff --git a/src/hll/FileOperation.c b/src/hll/FileOperation.c index 9252f6f..de44e94 100644 --- a/src/hll/FileOperation.c +++ b/src/hll/FileOperation.c @@ -55,7 +55,7 @@ static bool get_file_list(struct string *folder_name, struct page **out, bool fo UDIR *d = opendir_utf8(dir_name); if (!d) { - WARNING("opendir(\"%s\"): %s", dir_name, strerror(errno)); + WARNING("opendir(\"%s\"): %s", display_utf0(dir_name), strerror(errno)); free(dir_name); return false; } @@ -75,7 +75,7 @@ static bool get_file_list(struct string *folder_name, struct page **out, bool fo ustat s; if (stat_utf8(utf8_path, &s) < 0) { - WARNING("stat(\"%s\"): %s", utf8_path, strerror(errno)); + WARNING("stat(\"%s\"): %s", display_utf0(utf8_path), strerror(errno)); goto loop_next; } if (folders) { diff --git a/src/hll/Gpx2Plus.c b/src/hll/Gpx2Plus.c index 2deaf6f..10363ef 100644 --- a/src/hll/Gpx2Plus.c +++ b/src/hll/Gpx2Plus.c @@ -420,7 +420,7 @@ static void Gpx2Plus_SetFontName(struct string *name) else if (!strcmp(u, "MS 明朝")) gfx_set_font_face(FONT_MINCHO); else - WARNING("Unknown font name '%s'", u); + WARNING("Unknown font name '%s'", display_utf0(u)); free(u); } diff --git a/src/hll/MainEXFile.c b/src/hll/MainEXFile.c index 82c9d73..2b957fd 100644 --- a/src/hll/MainEXFile.c +++ b/src/hll/MainEXFile.c @@ -105,7 +105,7 @@ static void MainEXFile_ModuleInit(void) { // load .ex file if (!config.ex_path || !(ex = ex_read_file(config.ex_path))) - ERROR("Failed to load .ex file: %s", config.ex_path); + ERROR("Failed to load .ex file: %s", display_utf0(config.ex_path)); // assign IDs to each ex_value int id = 1; diff --git a/src/hll/MsgSkip.c b/src/hll/MsgSkip.c index 62cc0f4..c35ed46 100644 --- a/src/hll/MsgSkip.c +++ b/src/hll/MsgSkip.c @@ -41,7 +41,7 @@ static void msgskip_save(void) { FILE *f = file_open_utf8(save_path, "wb"); if (!f) - ERROR("fopen: '%s': %s", save_path, strerror(errno)); + ERROR("fopen: '%s': %s", display_utf0(save_path), strerror(errno)); fwrite(flags, nr_flags, 1, f); fclose(f); @@ -66,7 +66,7 @@ static int MsgSkip_Init(struct string *name) data_size = ain->nr_messages; } if (data_size != (size_t)ain->nr_messages) { - WARNING("Incorrect file size for MsgSkip file '%s'", save_path); + WARNING("Incorrect file size for MsgSkip file '%s'", display_utf0(save_path)); if (data_size < (size_t)ain->nr_messages) { data = xrealloc_array(data, data_size, ain->nr_messages, 1); } diff --git a/src/hll/OutputLog.c b/src/hll/OutputLog.c index 440889d..6ce06bc 100644 --- a/src/hll/OutputLog.c +++ b/src/hll/OutputLog.c @@ -15,15 +15,17 @@ */ #include -#include "hll.h" + +#include "system4.h" #include "system4/string.h" #include "system4/utfsjis.h" +#include "hll.h" +#include "xsystem4.h" + static void OutputLog_Output(int handle, struct string *s) { - char *u = sjis2utf(s->text, s->size); - printf("%s", u); - free(u); + sys_message("%s", display_sjis0(s->text)); } HLL_WARN_UNIMPLEMENTED(0, int, OutputLog, Create, struct string *name); diff --git a/src/hll/PassRegister.c b/src/hll/PassRegister.c index 2405590..5d7de44 100644 --- a/src/hll/PassRegister.c +++ b/src/hll/PassRegister.c @@ -67,18 +67,18 @@ static void write_register(unsigned handle) FILE *f = file_open_utf8(reg->filename, "wb"); if (!f) { - WARNING("Failed to open PassRegister file: %s: %s", reg->filename, strerror(errno)); + WARNING("Failed to open PassRegister file: %s: %s", display_utf0(reg->filename), strerror(errno)); return; } cJSON *json = register_to_json(handle); char *str = cJSON_Print(json); if (fwrite(str, strlen(str), 1, f) != 1) { - WARNING("Failed to write PassRegister file: %s: %s", reg->filename, strerror(errno)); + WARNING("Failed to write PassRegister file: %s: %s", display_utf0(reg->filename), strerror(errno)); goto end; } if (fclose(f)) { - WARNING("Error writing to save file: %s: %s", reg->filename, strerror(errno)); + WARNING("Error writing to save file: %s: %s", display_utf0(reg->filename), strerror(errno)); goto end; } end: diff --git a/src/hll/SengokuRanceFont.c b/src/hll/SengokuRanceFont.c index e19f779..00fedc1 100644 --- a/src/hll/SengokuRanceFont.c +++ b/src/hll/SengokuRanceFont.c @@ -297,7 +297,7 @@ static void SengokuRanceFont_ModuleInit(void) char path[PATH_MAX]; if (!(dir = opendir_utf8(config.game_dir))) { - ERROR("Failed to open directory: %s", config.game_dir); + ERROR("Failed to open directory: %s", display_utf0(config.game_dir)); } while ((d_name = readdir_utf8(dir))) { @@ -310,7 +310,7 @@ static void SengokuRanceFont_ModuleInit(void) snprintf(path, PATH_MAX, "%s/%s", config.game_dir, d_name); fontlib = fnl_open(path); if (!(fontlib = fnl_open(path))) - ERROR("Error opening font library '%s'", path); + ERROR("Error opening font library '%s'", display_utf0(path)); if (fontlib->nr_fonts < 1) ERROR("Font library doesn't contain any fonts"); break; diff --git a/src/hll/VSFile.c b/src/hll/VSFile.c index 9c3f967..0800ce6 100644 --- a/src/hll/VSFile.c +++ b/src/hll/VSFile.c @@ -25,6 +25,7 @@ #include "little_endian.h" #include "hll.h" +#include "xsystem4.h" static bool vs_read = false; static FILE *vs_file = NULL; @@ -99,7 +100,7 @@ static bool vsfile_open(struct string *filename, bool read) vs_read = read; vs_file = file_open_utf8(u, read ? "rb" : "wb"); if (!vs_file) { - WARNING("Failed to open '%s': %s", u, strerror(errno)); + WARNING("Failed to open '%s': %s", display_utf0(u), strerror(errno)); } free(u); return !!vs_file; diff --git a/src/resume.c b/src/resume.c index cb9fa8b..30e563f 100644 --- a/src/resume.c +++ b/src/resume.c @@ -344,7 +344,7 @@ void vm_load_image(const char *key, const char *path) { cJSON *save = read_image(key, path); if (!save) { - VM_ERROR("Failed to read VM image: '%s'", path); + VM_ERROR("Failed to read VM image: '%s'", display_sjis0(path)); } cJSON *ip = type_check(cJSON_Number, cJSON_GetObjectItem(save, "ip")); load_heap(type_check(cJSON_Array, cJSON_GetObjectItem(save, "heap"))); diff --git a/src/savedata.c b/src/savedata.c index 9051b45..b0a8d1d 100644 --- a/src/savedata.c +++ b/src/savedata.c @@ -103,7 +103,7 @@ int save_json(const char *filename, cJSON *json) char *path = savedir_path(filename); FILE *f = file_open_utf8(path, "w"); if (!f) { - WARNING("Failed to open save file: %s: %s", filename, strerror(errno)); + WARNING("Failed to open save file: %s: %s", display_utf0(filename), strerror(errno)); free(path); return 0; } @@ -117,7 +117,7 @@ int save_json(const char *filename, cJSON *json) return 0; } if (fclose(f)) { - WARNING("Error writing save to file: %s: %s", filename, strerror(errno)); + WARNING("Error writing save to file: %s: %s", display_utf0(filename), strerror(errno)); free(str); return 0; } @@ -159,7 +159,7 @@ int save_group(const char *keyname, const char *filename, const char *group_name int group; if ((group = get_group_index(group_name)) < 0) { - WARNING("Unregistered global group: %s", group_name); + WARNING("Unregistered global group: %s", display_sjis0(group_name)); return 0; } @@ -281,7 +281,7 @@ static cJSON *read_save_file(const char *filename) char *path = savedir_path(filename); if (!(f = file_open_utf8(path, "r"))) { - WARNING("Failed to open save file: %s: %s", filename, strerror(errno)); + WARNING("Failed to open save file: %s: %s", display_utf0(filename), strerror(errno)); free(path); return NULL; } @@ -294,7 +294,7 @@ static cJSON *read_save_file(const char *filename) buf = xmalloc(len+1); buf[len] = '\0'; if (fread(buf, len, 1, f) != 1) { - WARNING("Failed to read save file: %s", filename); + WARNING("Failed to read save file: %s", display_utf0(filename)); free(buf); return 0; } @@ -318,7 +318,7 @@ int load_globals(const char *keyname, const char *filename, const char *group_na cJSON *key = cJSON_GetObjectItem(save, "key"); if (!key || strcmp(keyname, cJSON_GetStringValue(key))) - VM_ERROR("Attempted to load save data with wrong key: %s", keyname); + VM_ERROR("Attempted to load save data with wrong key: %s", display_sjis0(keyname)); if (group_name) { // TODO? @@ -373,7 +373,7 @@ int delete_save_file(const char *filename) return 0; } if (remove(path)) { - WARNING("remove(\"%s\"): %s", path, strerror(errno)); + WARNING("remove(\"%s\"): %s", display_utf0(path), strerror(errno)); free(path); return 0; } diff --git a/src/sprite.c b/src/sprite.c index 6595012..b1e7553 100644 --- a/src/sprite.c +++ b/src/sprite.c @@ -124,7 +124,7 @@ int sprite_save_cg(struct sact_sprite *sp, const char *path) }; FILE *fp = file_open_utf8(path, "wb"); if (!fp) { - WARNING("Failed to open %s: %s", path, strerror(errno)); + WARNING("Failed to open %s: %s", display_utf0(path), strerror(errno)); free(pixels); return 0; } diff --git a/src/text.c b/src/text.c index d73675d..89d7a83 100644 --- a/src/text.c +++ b/src/text.c @@ -239,9 +239,7 @@ void gfx_set_font_name(const char *name) } else if (!strcmp(name, gothic_name)) { font_metrics.face = FONT_GOTHIC; } else { - char *u = sjis2utf(name, 0); - WARNING("Unhandled font name: \"%s\"", u); - free(u); + WARNING("Unhandled font name: \"%s\"", display_sjis0(name)); } } @@ -249,7 +247,7 @@ static void get_glyph(TTF_Font *f, Texture *dst, char *msg, SDL_Color color) { SDL_Surface *s = TTF_RenderUTF8_Blended(f, msg, color); if (!s) { - WARNING("Text rendering failed: %s", msg); + WARNING("Text rendering failed: %s", display_utf0(msg)); return; } if (s->format->format != SDL_PIXELFORMAT_RGBA32) { diff --git a/src/vm.c b/src/vm.c index 3676257..61578d3 100644 --- a/src/vm.c +++ b/src/vm.c @@ -256,7 +256,7 @@ static int alloc_scenario_page(const char *fname) struct ain_function *f; if ((fno = get_function_by_name(fname)) < 0) - VM_ERROR("Invalid scenario function: %s", fname); + VM_ERROR("Invalid scenario function: %s", display_sjis0(fname)); f = &ain->functions[fno]; slot = heap_alloc_slot(VM_PAGE); @@ -444,30 +444,25 @@ static void system_call(enum syscall_code code) } case SYS_OUTPUT: {// system.Output(string szText) struct string *str = stack_peek_string(0); - char *utf = sjis2utf(str->text, str->size); - sys_message("%s", utf); - free(utf); + sys_message("%s", display_sjis0(str->text)); // XXX: caller S_POPs break; } case SYS_MSGBOX: { struct string *str = stack_peek_string(0); - char *utf = sjis2utf(str->text, str->size); - SDL_ShowSimpleMessageBox(0, "xsystem4", utf, NULL); - free(utf); + SDL_ShowSimpleMessageBox(0, "xsystem4", display_sjis0(str->text), NULL); // XXX: caller S_POPs break; } case SYS_MSGBOX_OK_CANCEL: { int result = 0; struct string *str = stack_peek_string(0); - char *utf = sjis2utf(str->text, str->size); const SDL_MessageBoxData mbox = { SDL_MESSAGEBOX_INFORMATION, NULL, "xsystem4", - utf, + display_sjis0(str->text), SDL_arraysize(buttons), buttons, NULL @@ -475,8 +470,6 @@ static void system_call(enum syscall_code code) if (SDL_ShowMessageBox(&mbox, &result)) { WARNING("Error displaying message box"); } - // ... - free(utf); heap_unref(stack_pop().i); stack_push(result); break; @@ -542,9 +535,7 @@ static void system_call(enum syscall_code code) } case SYS_ERROR: {// system.Error(string szText) struct string *str = stack_peek_string(0); - char *utf = sjis2utf(str->text, str->size); - sys_warning("*GAME ERROR*: %s\n", utf); - free(utf); + sys_warning("*GAME ERROR*: %s\n", display_sjis0(str->text)); // XXX: caller S_POPs break; } @@ -961,11 +952,10 @@ static enum opcode execute_instruction(enum opcode opcode) int file = stack_pop().i; // filename int expr = stack_pop().i; // expression if (!stack_pop().i) { - char *filename = sjis2utf(heap_get_string(file)->text, heap[file].s->size); - char *value = sjis2utf(heap_get_string(expr)->text, heap[expr].s->size); - sys_message("Assertion failed at %s:%d: %s\n", filename, line, value); - free(filename); - free(value); + sys_message("Assertion failed at %s:%d: %s\n", + display_sjis0(heap_get_string(file)->text), + line, + display_sjis0(heap_get_string(expr)->text)); vm_exit(1); } heap_unref(file); @@ -2347,19 +2337,13 @@ static void describe_page(struct page *page) sys_message("GLOBAL_PAGE\n"); break; case LOCAL_PAGE: - u = sjis2utf(ain->functions[page->index].name, 0); - sys_message("LOCAL_PAGE: %s\n", u); - free(u); + sys_message("LOCAL_PAGE: %s\n", display_sjis0(ain->functions[page->index].name)); break; case STRUCT_PAGE: - u = sjis2utf(ain->structures[page->index].name, 0); - sys_message("STRUCT_PAGE: %s\n", u); - free(u); + sys_message("STRUCT_PAGE: %s\n", display_sjis0(ain->structures[page->index].name)); break; case ARRAY_PAGE: - u = sjis2utf(ain_strtype(ain, page->a_type, page->array.struct_type), 0); - sys_message("ARRAY_PAGE: %s\n", u); - free(u); + sys_message("ARRAY_PAGE: %s\n", display_sjis0(ain_strtype(ain, page->a_type, page->array.struct_type))); break; case DELEGATE_PAGE: // TODO: list function names @@ -2377,9 +2361,7 @@ static void describe_slot(size_t slot) break; case VM_STRING: if (heap[slot].s) { - char *u = sjis2utf(heap[slot].s->text, heap[slot].s->size); - sys_message("STRING: %s\n", u); - free(u); + sys_message("STRING: %s\n", display_sjis0(heap[slot].s->text)); } else { sys_message("STRING: NULL\n"); }