several fixes

This commit is contained in:
Nishi 2026-09-23 10:38:16 +09:00
commit b1babd4b88
4 changed files with 6 additions and 4 deletions

View file

@ -190,7 +190,7 @@ int sj4_from_utf16(u_char* out, const u_char* in, int len) {
out += eucjp_write(out, n); out += eucjp_write(out, n);
} }
return out - o_out; return (out - o_out) * sizeof(wchar_t);
} }
static u_int eucjp_read(const u_char* in) { static u_int eucjp_read(const u_char* in) {
@ -287,7 +287,7 @@ int sj4_to_utf16(u_char* out, const u_char* in, int len) {
} }
} }
return w_out - o_out; return (w_out - o_out) * sizeof(wchar_t);
} }
#endif #endif

View file

@ -79,6 +79,8 @@ Sj4Context* alloccontext(const char* dic) {
DictFile* dict; DictFile* dict;
DICTL* node; DICTL* node;
if(ctx == NULL) return NULL;
if((ctx->work = calloc(1, sizeof(*ctx->work))) == NULL) { if((ctx->work = calloc(1, sizeof(*ctx->work))) == NULL) {
free(ctx); free(ctx);

View file

@ -173,7 +173,7 @@ void sj4_ime_key(Sj4Ime* ime, int key) {
key = toupper(key); key = toupper(key);
if(ime->romabuf[strlen(ime->romabuf) - 1] == 'N' && !(key == 'A' || key == 'I' || key == 'U' || key == 'E' || key == 'O' || key == 'Y' || key == 'N')) { if(strlen(ime->romabuf) > 0 && ime->romabuf[strlen(ime->romabuf) - 1] == 'N' && !(key == 'A' || key == 'I' || key == 'U' || key == 'E' || key == 'O' || key == 'Y' || key == 'N')) {
ime->romabuf[strlen(ime->romabuf) + 1] = 0; ime->romabuf[strlen(ime->romabuf) + 1] = 0;
ime->romabuf[strlen(ime->romabuf)] = 'N'; ime->romabuf[strlen(ime->romabuf)] = 'N';
} }