MSVC support, Watcom is still recommended
This commit is contained in:
parent
46f95f8314
commit
c17f7a56cc
10 changed files with 87 additions and 23 deletions
1
README
1
README
|
|
@ -32,6 +32,7 @@
|
|||
* Tested compilers
|
||||
GCC/Clang Debian GNU/Linux 13
|
||||
Open Watcom 2.0 Windows 11
|
||||
Visual C++ 6.0 Windows 11
|
||||
|
||||
* Differences
|
||||
- Multiple contexts can be created in SJ4. SJ3's behavior of using
|
||||
|
|
|
|||
31
include/sj4core/sj_compat.h
Normal file
31
include/sj4core/sj_compat.h
Normal file
|
|
@ -0,0 +1,31 @@
|
|||
#ifndef __SJ4_COMPAT_H__
|
||||
#define __SJ4_COMPAT_H__
|
||||
|
||||
#include <stddef.h>
|
||||
#include <stdarg.h>
|
||||
#include <stdio.h>
|
||||
|
||||
#if defined(_MSC_VER)
|
||||
|
||||
#if defined(_MSC_VER) && _MSC_VER < 1900
|
||||
static int __inline sj4_snprintf(char* buffer, size_t count, const char* fmt, ...){
|
||||
int st;
|
||||
va_list va;
|
||||
|
||||
va_start(va, fmt);
|
||||
st = vsprintf(buffer, fmt, va);
|
||||
va_end(va);
|
||||
|
||||
return st;
|
||||
}
|
||||
#else
|
||||
#define sj4_snprintf snprintf
|
||||
#endif
|
||||
|
||||
#define sj4_strlcpy(x, y, z) strcpy((x), (y))
|
||||
#else
|
||||
#define sj4_snprintf snprintf
|
||||
#define sj4_strlcpy strlcpy
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
|
@ -436,4 +436,6 @@
|
|||
|
||||
#define termtbl Jtermtbl
|
||||
|
||||
#include <sj_compat.h>
|
||||
|
||||
#endif
|
||||
|
|
|
|||
|
|
@ -62,7 +62,7 @@ int cl2knj(SJ4_CONTEXT u_char* yomi, int len, u_char* kouho) {
|
|||
}
|
||||
*ptr2 = 0;
|
||||
|
||||
strlcpy((char*)orgyomi, (char*)yomi, (int)(ptr1 - yomi) + 1);
|
||||
sj4_strlcpy((char*)orgyomi, (char*)yomi, (int)(ptr1 - yomi) + 1);
|
||||
|
||||
if(!hyomi[0]) return 0;
|
||||
|
||||
|
|
|
|||
|
|
@ -732,7 +732,7 @@ int set_stdypass(SJ4_CONTEXT char* pass) {
|
|||
|
||||
static void
|
||||
set_comment(u_char* buf, char* comment) {
|
||||
strlcpy((char*)buf + HEADERLENGTH, comment, COMMENTLENGTH);
|
||||
sj4_strlcpy((char*)buf + HEADERLENGTH, comment, COMMENTLENGTH);
|
||||
}
|
||||
|
||||
int set_dictcmnt(DictFile* dp, char* cmnt) {
|
||||
|
|
|
|||
|
|
@ -66,7 +66,7 @@ FILE* Fopen(char* filename, char* type) {
|
|||
fl = (FileList*)Malloc(sizeof(*fl));
|
||||
len = strlen(filename) + 1;
|
||||
fl->fname = Malloc(len);
|
||||
strlcpy(fl->fname, filename, len);
|
||||
sj4_strlcpy(fl->fname, filename, len);
|
||||
fl->fp = fp;
|
||||
fl->next = flist;
|
||||
|
||||
|
|
|
|||
|
|
@ -59,7 +59,7 @@ char* make_idxlist(char* name) {
|
|||
|
||||
i = strlen(name);
|
||||
p = Zalloc(i + 2);
|
||||
strlcpy(p, name, i + 2);
|
||||
sj4_strlcpy(p, name, i + 2);
|
||||
return p;
|
||||
}
|
||||
char* get_idxlist(char* name) {
|
||||
|
|
@ -180,7 +180,7 @@ void mark_file(FILE* out) {
|
|||
fputc('\n', out);
|
||||
Fclose(fp);
|
||||
} else {
|
||||
strlcpy(pathname, idxtop, sizeof(pathname));
|
||||
sj4_strlcpy(pathname, idxtop, sizeof(pathname));
|
||||
pos = infp ? Ftell(infp) : 0;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -430,7 +430,7 @@ void makehead(u_char* dict_name) {
|
|||
put4byte(header + VERSIONPOS, DICTVERSION);
|
||||
time(&i);
|
||||
p = header + COMMENTPOS;
|
||||
snprintf((char*)p, sizeof(header) - COMMENTPOS, "%s : %s", dict_name, ctime(&i));
|
||||
sj4_snprintf((char*)p, sizeof(header) - COMMENTPOS, "%s : %s", dict_name, ctime(&i));
|
||||
while(*p) {
|
||||
if(*p == '\n') {
|
||||
*p = 0;
|
||||
|
|
|
|||
|
|
@ -26,6 +26,7 @@
|
|||
#include <sys/stat.h>
|
||||
|
||||
#include "sj4_dict_struct.h"
|
||||
#include "sj_compat.h"
|
||||
|
||||
/* char.c */
|
||||
int cnvyomi(int);
|
||||
|
|
|
|||
45
win32.sh
45
win32.sh
|
|
@ -1,26 +1,45 @@
|
|||
#!/bin/sh
|
||||
|
||||
if [ "x$1" = "x" ]; then
|
||||
cmp="$1"
|
||||
|
||||
if [ "x$cmp" = "x" ]; then
|
||||
echo "Usage: $0 [watcom|msvc]"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
for i in lib/sj4core/*.c; do
|
||||
if [ "$cmp" = "watcom" ]; then
|
||||
:
|
||||
elif [ "$cmp" = "msvc" ]; then
|
||||
:
|
||||
else
|
||||
echo "Invalid target"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
library() {
|
||||
N=$1
|
||||
|
||||
for i in lib/$N/*.c; do
|
||||
if [ -f $i.obj ]; then
|
||||
continue
|
||||
fi
|
||||
echo $i
|
||||
|
||||
if [ "$1" = "watcom" ]; then
|
||||
cl /Iinclude/sj4common /Iinclude/sj4core /c /fo$i.obj $i || exit 1
|
||||
else
|
||||
owcc -Iinclude/sj4common -Iinclude/sj4core -bnt -c -o $i.obj $i || exit 1
|
||||
if [ "$cmp" = "watcom" ]; then
|
||||
owcc -Iinclude/sj4common /Iinclude/sj4compat -Iinclude/$N -bnt -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
|
||||
fi
|
||||
done
|
||||
|
||||
find lib/sj4core -name "*.obj" | while read a; do
|
||||
if [ "$cmp" = "watcom" ]; then
|
||||
find lib/$N -name "*.obj" | while read a; do
|
||||
echo "+$a"
|
||||
done | xargs wlib -q -b -fo -n sj4core.lib
|
||||
done | xargs wlib -q -b -fo -n $N.lib
|
||||
elif [ "$cmp" = "msvc" ]; then
|
||||
lib.exe /nologo /out:$N.lib lib/$N/*.obj
|
||||
fi
|
||||
}
|
||||
|
||||
executable() {
|
||||
N=$1
|
||||
|
|
@ -30,11 +49,21 @@ executable() {
|
|||
continue
|
||||
fi
|
||||
echo $i
|
||||
if [ "$cmp" = "watcom" ]; then
|
||||
owcc -DUTF8 -DENGLISH -Iinclude/sj4common -Iinclude/sj4core -bnt -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
|
||||
fi
|
||||
done
|
||||
|
||||
if [ "$cmp" = "watcom" ]; then
|
||||
owcc -bnt -o $N.exe src/$N/*.obj $2
|
||||
elif [ "$cmp" = "msvc" ]; then
|
||||
cl.exe /nologo /Fe$N.exe src/$N/*.obj /link $2
|
||||
fi
|
||||
}
|
||||
|
||||
library sj4core
|
||||
|
||||
executable sj4mkdic
|
||||
executable sj4test sj4core.lib
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue