From 9d4a7ddf4c1440dd70ef8e5e6ca1ed63fc944a80 Mon Sep 17 00:00:00 2001 From: Nishi Date: Mon, 22 Jun 2026 05:20:31 +0900 Subject: [PATCH] Fix win32 build script --- lib/sj4lib/sj.c | 2 +- tools/win32.sh | 43 ++++++++++++++++++++++++++++++++++++------- 2 files changed, 37 insertions(+), 8 deletions(-) diff --git a/lib/sj4lib/sj.c b/lib/sj4lib/sj.c index 48f2c6e..2153d08 100644 --- a/lib/sj4lib/sj.c +++ b/lib/sj4lib/sj.c @@ -24,7 +24,7 @@ struct sj4lib { #ifdef UCS static u_int ucs_to_euc(u_int in) { - if(0 <= in && in <= 0xffff) { + if(in <= 0xffff) { const T_U2E_BITMAP_INDEX* b = &utf16_to_euc_jp_table[(in >> 8) & 0xff]; if(b->byType == 2) { diff --git a/tools/win32.sh b/tools/win32.sh index aad317d..b12df3c 100755 --- a/tools/win32.sh +++ b/tools/win32.sh @@ -7,10 +7,25 @@ if [ "x$cmp" = "x" ]; then exit 1 fi +INCS="sj4common sj4core sj4rkcv sj4lib" +DEFS="UTF8 UCS ENGLISH" + +CFLAGS="" + if [ "$cmp" = "watcom" ]; then - : + for def in $DEFS; do + CFLAGS="$CFLAGS -D$def" + done + for inc in $INCS; do + CFLAGS="$CFLAGS -Iinclude/$inc" + done elif [ "$cmp" = "msvc" ]; then - : + for def in $DEFS; do + CFLAGS="$CFLAGS /D$def" + done + for inc in $INCS; do + CFLAGS="$CFLAGS /Iinclude/$inc" + done else echo "Invalid target" exit 1 @@ -26,12 +41,18 @@ library() { echo $i if [ "$cmp" = "watcom" ]; then - owcc -Iinclude/sj4common -Iinclude/sj4compat -Iinclude/$N -bnt -c -o $i.obj $i || exit 1 + owcc -bnt $CFLAGS -c -o $i.obj $i || exit 1 elif [ "$cmp" = "msvc" ]; then - cl.exe /nologo /Iinclude/sj4common /Iinclude/sj4compat /Iinclude/$N /c /Fo$i.obj $i || exit 1 + cl.exe /nologo $CFLAGS /c /Fo$i.obj $i || exit 1 fi done + if [ -f $N.lib ]; then + return + fi + + echo $N.lib + if [ "$cmp" = "watcom" ]; then find lib/$N -name "*.obj" | while read a; do echo "+$a" @@ -49,13 +70,20 @@ executable() { continue fi echo $i + if [ "$cmp" = "watcom" ]; then - owcc -DUTF8 -DENGLISH -Iinclude/sj4common -Iinclude/sj4core -bnt -c -o $i.obj $i || exit 1 + owcc -bnt $CFLAGS -c -o $i.obj $i || exit 1 elif [ "$cmp" = "msvc" ]; then - cl.exe /nologo /DUTF8 /DENGLISH /Iinclude/sj4common /Iinclude/sj4core /c /Fo$i.obj $i || exit 1 + cl.exe /nologo $CFLAGS /c /Fo$i.obj $i || exit 1 fi done + if [ -f $N.exe ]; then + return + fi + + echo "$N.exe" + if [ "$cmp" = "watcom" ]; then owcc -bnt -o $N.exe src/$N/*.obj $2 elif [ "$cmp" = "msvc" ]; then @@ -66,6 +94,7 @@ executable() { library sj4common library sj4core library sj4rkcv +library sj4lib executable sj4mkdic sj4common.lib -executable sj4test "sj4common.lib sj4core.lib" +executable sj4test "sj4common.lib sj4core.lib sj4lib.lib"