several fixes

This commit is contained in:
Nishi 2026-09-23 11:11:15 +09:00
commit 75ca07fc8c
3 changed files with 38 additions and 7 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);
}
return (out - o_out) * sizeof(wchar_t);
return out - o_out;
}
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) * sizeof(wchar_t);
return w_out - o_out;
}
#endif

View file

@ -48,7 +48,7 @@ Sj4Lib* sj4_open(int charset, const char* dic) {
len = sj4_charset_to(ctx->charset, ctx->wrk2buf, ctx->wrkbuf, len); \
if(ctx->charset == SJ4UTF16) { \
int i; \
for(i = 0; i < sizeof(wchar_t); i++) ctx->wrk2buf[len * sizeof(wchar_t) + i] = 0; \
((wchar_t*)ctx->wrk2buf)[len] = 0; \
} else { \
ctx->wrk2buf[len] = 0; \
} \
@ -64,6 +64,10 @@ Sj4Lib* sj4_open(int charset, const char* dic) {
int sj4_getkan(Sj4Lib* ctx, const void* input, int len, Sj4Kouho* kouho) {
int len2;
if(sizeof(ctx->inbuf) < (len * ((ctx->charset == SJ4UTF16 || ctx->charset == SJ4SJIS) ? sizeof(wchar_t) : 1))) {
return 0;
}
memset(kouho, 0, sizeof(*kouho));
ctx->kouho = kouho;