Import patches from pkgsrc

* Adjust paths to modern conventions.
* Avoid opening /dev/console.
* Consistently provide lowercase and MixedCase options.
* Don't abuse an int as a pointer (optarg).
* Fix compilation errors on NetBSD and DragonFly BSD.
* Fix documentation.
* Import headers and remove redundant declarations.

Signed-off-by: Masanori Ogino <mogino@acm.org>
This commit is contained in:
Masanori Ogino 2023-11-27 10:29:45 +09:00
commit 381c676eda
26 changed files with 143 additions and 98 deletions

2
.gitignore vendored
View file

@ -3,3 +3,5 @@
build/
patches/
*.orig

View file

@ -124,7 +124,7 @@ char *filename;
{
struct stat buf;
#if defined(__NetBSD__) || defined(__FreeBSD__)
#if defined(__NetBSD__) || defined(__FreeBSD__) || defined(__DragonFly__)
if (stat(filename, &buf) == 0) return (long)buf.st_size;
#else
if (stat(filename, &buf) == 0) return buf.st_size;

View file

@ -56,7 +56,7 @@ JIS
.IP ・
メイン辞書、ユーザ辞書、学習ファイルは、接続するサーバの動作しているマシン上のものが使用されます。
.br
これらのファイルは、デフォルトではディレクトリ \fB/usr/dict/sj3\fP の下におかれますが、サーバのセットアップファイルにより変更が可能です。
これらのファイルは、デフォルトではディレクトリ \fB/usr/local/lib/sj3/dict\fP の下におかれますが、サーバのセットアップファイルにより変更が可能です。
.IP ・
ユーザ辞書と学習ファイルは、関数 sj3_open で指定されたユーザ名を USER と
すれば、\fBuser/USER/private.dic\fP と \fBuser/USER/study.dat\fP です。
@ -91,7 +91,7 @@ char *uname; /*
サーバと正常に接続できたときには 0 を、何かエラーのあったときには 0 以外の
エラーステータスを返します。
.sp
エラーステータスはヘッダファイル \fB/usr/include/sj3lib.h\fP で
エラーステータスはヘッダファイル \fB/usr/local/include/sj3lib.h\fP で
定義されるビットアサインされた値で、詳細は以下のとおりです。
.sp
.IP "\fBSJ3_SERVER_DEAD\fP
@ -138,7 +138,7 @@ sj3_close()
サーバとの使用を正常に終了できたときには 0 を、
何かエラーのあったときには 0 以外のエラーステータスを返します。
.sp
エラーステータスはヘッダファイル \fB/usr/include/sj3lib.h\fP で
エラーステータスはヘッダファイル \fB/usr/local/include/sj3lib.h\fP で
定義されるビットアサインされた値で、詳細は以下のとおりです。
.sp
.IP "\fBSJ3_SERVER_DEAD\fP
@ -187,7 +187,7 @@ int knjsiz; /*
変換結果の漢字文字列を、配列 \fBstruct bunsetu bun[]\fP に
各文節に関する情報をセットします。
.br
\fBstruct bunsetu\fP はヘッダファイル \fB/usr/include/sj3lib.h\fP で
\fBstruct bunsetu\fP はヘッダファイル \fB/usr/local/include/sj3lib.h\fP で
宣言されている以下のような構造体です。
.sp
.RS
@ -417,7 +417,7 @@ int hinsi; /*
なりません。
またその長さは、最大でも 32 文字を越えてはなりません。
.sp
品詞コードはヘッダファイル \fB/usr/include/sj3lib.h\fP で
品詞コードはヘッダファイル \fB/usr/local/include/sj3lib.h\fP で
定義される以下の品詞のうちの一つです。
.sp
.RS
@ -445,7 +445,7 @@ SJ3_H_ADJECT
登録できたときには 0 が、登録できなかったときにはそれ以外の
エラーステータスが返されます。
.sp
エラーステータスはヘッダファイル \fB/usr/include/sj3lib.h\fP で
エラーステータスはヘッダファイル \fB/usr/local/include/sj3lib.h\fP で
定義され、詳細は以下のとおりです。
.sp
.IP "\fBSJ3_DICT_ERROR\fP
@ -519,7 +519,7 @@ int hinsi; /*
なりません。
またその長さは、最大でも 32 文字を越えてはなりません。
.sp
品詞コードは \fB/usr/include/sj3lib.h\fP で定義される以下の品詞の
品詞コードは \fB/usr/local/include/sj3lib.h\fP で定義される以下の品詞の
うちの一つです。
.sp
.RS
@ -547,7 +547,7 @@ SJ3_H_ADJECT
削除できたときには 0 が、削除できなかったときにはそれ以外の
エラーステータスが返されます。
.sp
エラーステータスは \fB/usr/include/sj3lib.h\fP で定義され、
エラーステータスは \fB/usr/local/include/sj3lib.h\fP で定義され、
詳細は以下のとおりです。
.sp
.IP "\fBSJ3_DICT_ERROR\fP

View file

@ -111,7 +111,7 @@ DictDir \fIdirectory_name\fP
そのファイル名を絶対パスとして辞書にアクセスしますが、\'/\'以外のときには、
ここで指定されるディレクトリからの相対パスとして辞書にアクセスします。
.br
デフォルトは /usr/dict/sj3 です。
デフォルトは /usr/local/lib/sj3/dict です。
.RE
.sp
.NH 3

View file

@ -109,13 +109,13 @@ sj3 \-
.SH 関連ファイル
.PD 0
.TP 15
/usr/dict/sj3/user/$USER/private.dic
/usr/local/lib/sj3/dict/user/$USER/private.dic
仮名漢字変換ユーザ辞書
.TP
/usr/dict/sj3/user/$USER/study.dat
/usr/local/lib/sj3/dict/user/$USER/study.dat
仮名漢字変換学習ファイル
.TP
/usr/lib/sj3/sjrk
/usr/local/lib/sj3/sjrk
デフォルトローマ字仮名変換規則定義ファイル
.SH 関連事項
sj3serv(1), sj3lib(3)

View file

@ -105,16 +105,16 @@ sj3dic \- sj3
.SH 関連ファイル
.PD 0
.TP \w'\ \ \ \ user/\fIusername\fP/private.dic'u+2n
/usr/bin/sj3serv
/usr/local/bin/sj3serv
かな漢字変換サーバ
.TP
/usr/lib/sj3/serverrc
/usr/local/lib/sj3/serverrc
かな漢字変換サーバ セットアップファイル
.TP
/usr/bin/sj3
/usr/local/bin/sj3
日本語入力フロントエンドプロセッサ
.TP
/usr/dict/sj3/
/usr/local/lib/sj3/dict/
かな漢字変換サーバ デフォルト辞書ディレクトリ
.TP
sj3main.dic
@ -126,10 +126,10 @@ sj3dic \- sj3
user/\fIusername\fP/study.dat
かな漢字変換学習ファイル
.TP
/usr/include/sj3lib.h
/usr/local/include/sj3lib.h
かな漢字変換ライブラリ用インクルードファイル
.TP
/usr/lib/libsj3lib.a
/usr/local/lib/libsj3lib.a
かな漢字変換ライブラリ
.\".TP
.\"/usr/sony/demo/sj3/*

View file

@ -539,16 +539,16 @@
.SH ファイル
.PD 0
.TP \w'\ \ \ \ user/\f2username\f1/private.dic'u+2n
.B /usr/bin/sj3serv
.B /usr/local/bin/sj3serv
かな漢字変換サーバ
.TP
.B /usr/lib/sj3/serverrc
.B /usr/local/lib/sj3/serverrc
かな漢字変換サーバ セットアップファイル
.TP
.B /usr/bin/sj3
.B /usr/local/bin/sj3
日本語入力フロントエンドプロセッサ
.TP
.B /usr/dict/sj3/
.B /usr/local/lib/sj3/dict/
かな漢字変換サーバ デフォルト辞書ディレクトリ
.TP
.B " sj3main.dic
@ -560,14 +560,14 @@
.B " user/\f2username\f1/study.dat
かな漢字変換学習ファイル
.TP
.B /usr/include/sj3lib.h
.B /usr/local/include/sj3lib.h
かな漢字変換ライブラリ用インクルードファイル
.TP
.B /usr/lib/libsj3lib.a
.B /usr/local/lib/libsj3lib.a
かな漢字変換ライブラリ
.TP
\f3/usr/demo/sj3/ *\f1
かな漢字変換ライブラリ 使用法サンプル
.\".TP
.\"\f3/usr/local/demo/sj3/ *\f1
.\"かな漢字変換ライブラリ 使用法サンプル
.PD
.SH 関連項目
\f4sj3\f1 (1),

View file

@ -47,17 +47,17 @@ sj3serv \-
このオプションは、\fIsj3serv\fP の読み込むセットアップファイルを指定します。
.br
\fIsj3serv\fP はデフォルトではセットアップファイル
‘/usr/lib/sj3/serverrc’を読み込みますが、
‘/usr/local/lib/sj3/serverrc’を読み込みますが、
このオプションが指定されたときにはかわりに
コマンドラインで指定されたセットアップファイルを読み込みます。
.br
.SH 関連ファイル
.PD 0
.TP \w'\ \ \ \ user/\fIusername\fP/private.dic'u+2n
/usr/lib/sj3/serverrc
/usr/local/lib/sj3/serverrc
デフォルト仮名変換サーバ セットアップファイル
.TP
/usr/sony/dict/sj3/
/usr/local/lib/sj3/dict/
かな漢字変換サーバ デフォルト辞書ディレクトリ
.TP
sj3main.dic

View file

@ -70,7 +70,15 @@
#define ProtoName "tcp"
#define PortNumber "3000"
#else
/*
* Change the default Port number of sj3 for FreeBSD.
* Patched by Hidekazu Kuroki(hidekazu@cs.titech.ac.jp) 1996/8/20
*/
#if defined(__FreeBSD__) || defined(__NetBSD__) || defined(__OpenBSD__) || defined(__DragonFly__)
#define PortNumber 3086
#else /* ! __FreeBSD__ __NetBSD__ __OpenBSD__ */
#define PortNumber 3000
#endif /* ! __FreeBSD__ __NetBSD__ __OpenBSD__ */
#endif
#define DirectryMode 0755
#define DictFileMode 0644

View file

@ -33,7 +33,22 @@
* $SonyDate: 1997/01/23 11:20:55 $
*/
#define ErrorOutFile "/dev/console"
/*
* Change ErrotOutFile variable.
* Because suppress a error when sj3serv start up, change to "/dev/stderr".
* This error is "Cannot Open "/dev/console".".
* Patched by Hidekazu Kuroki(hidekazu@cs.titech.ac.jp) 1996/8/10
*
* Change ErrotOutFile variable.
* This default value is "/dev/null" in document.
* Patched by Hidekazu Kuroki(hidekazu@cs.titech.ac.jp) 1996/8/11
*/
#if !defined(__FreeBSD__) && !defined(__NetBSD__) && !defined(__OpenBSD__) && !defined(__DragonFly__)
#define ErrorOutFile "/dev/console"
#else
/* #define ErrorOutFile "/dev/stderr" */ /* for test */
#define ErrorOutFile "/dev/null"
#endif
#define SocketName "/tmp/sj3sock"
#define LockFile "/tmp/SJ3SERV.EXIST"

View file

@ -50,7 +50,6 @@
# define FD_CLR __FD_CLR
#endif
extern int errno;
extern int serv_errno;
extern Global *work_base;
char *malloc();
@ -318,7 +317,7 @@ char *passwd;
serv_errno = SJ3_IncorrectPasswd; goto error1;
}
#if defined(__NetBSD__) || defined(__FreeBSD__) || defined(__bsdi__)
#if defined(__NetBSD__) || defined(__FreeBSD__) || defined(__bsdi__) || defined(__DragonFly__)
if ((dp = (Uchar *)malloc((long)sbuf.st_size)) == NULL) {
#else
if ((dp = (Uchar *)malloc(sbuf.st_size)) == NULL) {
@ -330,7 +329,7 @@ char *passwd;
}
memset(dfp, '\0', sizeof(*dfp));
#if defined(__NetBSD__) || defined(__FreeBSD__) || defined(__bsdi__)
#if defined(__NetBSD__) || defined(__FreeBSD__) || defined(__bsdi__) || defined(__DragonFly__)
if (fgetfile(fp, 0L, (long)sbuf.st_size, dp) == ERROR) goto error3;
#else
if (fgetfile(fp, 0L, sbuf.st_size, dp) == ERROR) goto error3;

View file

@ -98,7 +98,6 @@ extern char *proto_name;
extern int port_number;
#endif
extern int max_client;
extern int errno;
static int fd_inet = -1;
static int fd_unix = -1;

View file

@ -53,8 +53,6 @@
#define SJIS_PROTO 1
#define EUC_PROTO 2
extern int errno;
extern Global *work_base;
extern STDY *stdy_base;
extern int serv_errno;
@ -82,7 +80,6 @@ static Client *cur_cli;
static Uchar defaultchar[2] = {(Uchar)0x81, (Uchar)0x40};
static int defuse=0, defuse2=0;
char *malloc();
DictFile *opendict();
int closedict();
StdyFile *openstdy();

View file

@ -215,9 +215,11 @@ char **argv;
(void) setlocale(LC_CTYPE, "ja_JP.EUC");
#endif
opening();
#ifndef __NetBSD__
if (setuid(geteuid())) {
fprintf(stderr, "error at setuid.\r\n"); exit(1);
}
#endif
parse_arg(argc, argv);
read_runcmd();

View file

@ -139,10 +139,13 @@ u_char *src, *dst;
static u_char *get_str(p, dst)
static u_char *get_str(p, pv_dst)
u_char *p;
char **dst;
void *pv_dst;
{
char **dst;
dst = pv_dst;
if (!*dst) {
*dst = malloc(strlen((char *)p) + 1);
if (!*dst) RcError("no more memory");
@ -151,21 +154,26 @@ char **dst;
while (*p++) ;
return p;
}
static u_char *get_int(p, dst)
static u_char *get_int(p, pv_dst)
u_char *p;
int *dst;
void *pv_dst;
{
register char *fmt;
int *dst;
dst = pv_dst;
fmt = (*p == '0') ? "%o" : "%d";
if (sscanf((char *)p, fmt, dst) != 1) RcError("bad integer");
while (*p++) ;
return p;
}
static u_char *get_flag(p, dst)
static u_char *get_flag(p, pv_dst)
u_char *p;
int *dst;
void *pv_dst;
{
int *dst;
dst = pv_dst;
if (sscanf((char *)p, "%d", dst) == 1)
;
else if (!cmpstr("on", p))
@ -219,33 +227,56 @@ StrList **dst;
struct optlist {
char *optname;
u_char *(*optfunc)();
int optarg;
void *optarg;
} option[] = {
"DebugOut", get_str, (int)&debug_file,
"DebugLevel", get_int, (int)&debug_level,
"ForkFlag", get_flag, (int)&fork_flag,
/*
* Add option flag.
* Because They are lacked in here. See document.
* Patched by Hidekazu Kuroki(hidekazu@cs.titech.ac.jp) 1996/8/10
*/
"DebugOut", get_str, &debug_file,
"debugout", get_str, &debug_file,
"DebugLevel", get_int, &debug_level,
"debuglevel", get_int, &debug_level,
"ForkFlag", get_flag, &fork_flag,
"forkflag", get_flag, &fork_flag,
"PortName", get_str, (int)&port_name,
"PortName", get_str, &port_name,
"portname", get_str, &port_name,
#ifdef TLI
"PortNumber", get_str, (int)&port_number,
"ProtoName", get_str, (int)&proto_name,
"PortNumber", get_str, &port_number,
"portnumber", get_str, &port_number,
"ProtoName", get_str, &proto_name,
"protoname", get_str, &proto_name,
#else
"PortNumber", get_int, (int)&port_number,
"PortNumber", get_int, &port_number,
"portnumber", get_int, &port_number,
#endif
"SocketName", get_str, (int)&socket_name,
"SocketName", get_str, &socket_name,
"socketname", get_str, &socket_name,
#ifdef LOCK_FILE
"LockFile", get_str, (int)&lock_file;
"LockFile", get_str, &lock_file;
"lockfile", get_str, &lock_file;
#endif
"maxclient", get_int, (int)&max_client,
"dictdir", get_str, (int)&dict_dir,
"readdict", get_list, (int)&read_dict,
"opendict", get_list, (int)&open_dict,
"errorout", get_str, (int)&error_file,
"logout", get_str, (int)&log_file,
"dirmode", get_int, (int)&dir_mode,
"filemode", get_int, (int)&file_mode,
"allowuser", get_list, (int)&allow_user,
"MaxClient", get_int, &max_client,
"maxclient", get_int, &max_client,
"DictDir", get_str, &dict_dir,
"dictdir", get_str, &dict_dir,
"ReadDict", get_list, &read_dict,
"readdict", get_list, &read_dict,
"OpenDict", get_list, &open_dict,
"opendict", get_list, &open_dict,
"ErrorOut", get_str, &error_file,
"errorout", get_str, &error_file,
"LogOut", get_str, &log_file,
"logout", get_str, &log_file,
"DirMode", get_int, &dir_mode,
"dirmode", get_int, &dir_mode,
"FileMode", get_int, &file_mode,
"filemode", get_int, &file_mode,
"AllowUser", get_list, &allow_user,
"allowuser", get_list, &allow_user,
0, 0, 0
};

View file

@ -32,12 +32,12 @@
* $SonyDate: 1997/01/23 11:20:57 $
*/
SJ3TOP = /usr/local
SJ3TOP = $(PREFIX)
SJ3BINDIR = $(SJ3TOP)/bin
SJ3HDRDIR = $(SJ3TOP)/include
SJ3LIBDIR = $(SJ3TOP)/lib
SJ3CONFDIR = $(SJ3TOP)/lib/sj3
SJ3DICTDIR = $(SJ3CONFDIR)/dict
SJ3CONFDIR = $(SJ3TOP)/share/sj3
SJ3DICTDIR = $(IMDICTDIR)/sj3
/*
* Change for FreeBSD.
@ -45,10 +45,11 @@ SJ3DICTDIR = $(SJ3CONFDIR)/dict
* return NULL, use it in library libxpg4
* Patched by Hidekazu Kuroki(hidekazu@cs.titech.ac.jp) 1996/8/10
*/
#if 0
#if defined(FreeBSDArchitecture)
CODE_LIBS = -lxpg4
SJ3OWNER = root
SJ3OWNER = bin
SJ3GROUP = bin
#else
@ -62,3 +63,4 @@ SJ3GROUP = staff
#endif
#endif
#endif

View file

@ -35,7 +35,7 @@
#include <sys/errno.h>
#include <errno.h>
#include "wchar16.h"
#include "select.h"
#include "key.h"
@ -204,7 +204,6 @@ register int *count;
register int n;
SELECT_FD ifds;
struct timeval t;
extern int errno;
register wchar16_t *s;
int value;

View file

@ -36,7 +36,7 @@
#include "sj_sysvdef.h"
#include <sys/errno.h>
#include <errno.h>
#include "common.h"
#include "inkey.h"
#include "select.h"
@ -201,7 +201,6 @@ master_flush ()
SELECT_FD ifds;
int nc;
struct timeval t;
extern int errno;
do {
cont:

View file

@ -40,14 +40,13 @@
#include <string.h>
#include <unistd.h>
char *ttyname();
char *getttys();
char *strrchr();
static char *getttys();
static char *ttys = "/etc/ttys";
#define NULL 0

View file

@ -38,14 +38,12 @@
#include "sj_sysvdef.h"
#include "wchar16.h"
#include <signal.h>
#include <sys/errno.h>
#if defined(__NetBSD__) || defined(__FreeBSD__) || defined(__bsdi__)
#if defined(__NetBSD__) || defined(__bsdi__)
#include <errno.h>
#if defined(__NetBSD__) || defined(__FreeBSD__) || defined(__bsdi__) || defined(__DragonFly__)
#define USE_OLD_TTY
#if defined(__NetBSD__)
#define LACKOF_SETLOCALE
#endif
#endif
#include <curses.h>
#endif
@ -473,7 +471,7 @@ getmaster ()
* Because FreeBSD's master pseudo-devices are pty[p-sP-S][0-9a-v].
* Patched by Hidekazu Kuroki(hidekazu@cs.titech.ac.jp) 1996/8/10
*/
#if defined(__FreeBSD__)
#if defined(__FreeBSD__) || defined(__DragonFly__)
struct stat stb;
int h, i, j, k1, k2;
#else /* !__FreeBSD__ */
@ -492,7 +490,7 @@ getmaster ()
* Because FreeBSD's master pseudo-devices are pty[p-sP-S][0-9a-v].
* Patched by Hidekazu Kuroki(hidekazu@cs.titech.ac.jp) 1996/8/10
*/
#if defined(__FreeBSD__)
#if defined(__FreeBSD__) || defined(__DragonFly__)
for (h = 0; h < 8; h++) {
line[k1] = "pqrsPQRS"[h];
line[k2] = '0';
@ -852,7 +850,7 @@ shellprocess ()
SCPYN(Utmp.ut_line, strrchr (slave_name, '/') + 1);
time (&Utmp.ut_time);
#if defined(__NetBSD__) || defined(__FreeBSD__) || defined(__bsdi__)
#if defined(__NetBSD__) || defined(__FreeBSD__) || defined(__bsdi__) || defined(__DragonFly__)
if (setsid() < 0)
perror("setsid()");
#else
@ -937,7 +935,7 @@ getslave ()
done2 ();
}
#ifndef SYSV_TERMIOS
#if defined(__NetBSD__) || defined(__FreeBSD__) || defined(__bsdi__)
#if defined(__NetBSD__) || defined(__FreeBSD__) || defined(__bsdi__) || defined(__DragonFly__)
ioctl(slave, TIOCSCTTY, NULL);
#endif
ioctl (slave, TIOCSETP, (char *)&b);
@ -1085,7 +1083,6 @@ suspend ()
SELECT_FD ifds;
int nc;
struct timeval t;
extern int errno;
clear_guide_line ();

View file

@ -48,14 +48,12 @@
#include <sys/types.h>
#include <sys/fcntl.h>
#endif
#if defined(__NetBSD__) || defined(__FreeBSD__) || defined(__bsdi__)
#if defined(__NetBSD__) || defined(__bsdi__)
#if defined(__NetBSD__) || defined(__FreeBSD__) || defined(__bsdi__) || defined(__DragonFly__)
#define USE_OLD_TTY
#endif
#include <curses.h>
#endif
#include <sys/errno.h>
#include <errno.h>
#include <sys/file.h>
#include "sj2.h"
#include "select.h"
@ -72,7 +70,6 @@ static wchar16_t backup = (wchar16_t) 0;
static int eucmode = 0;
extern int master;
extern int errno;
wchar16_t SJ_getchar()
{

View file

@ -35,7 +35,7 @@
#include <string.h>
#include <stdio.h>
#include <ctype.h>
#include <locale.h>

View file

@ -35,7 +35,7 @@
#include <string.h>
#include <stdio.h>
#include <ctype.h>

View file

@ -36,7 +36,7 @@
#include <string.h>
#include <stdio.h>
#include <locale.h>
#include <ctype.h>
@ -108,9 +108,8 @@ sjset_code()
getsjrc ()
{
FILE *fd, *fopen();
FILE *fd;
register char *p;
char *getenv();
sjset_code();
RCfile[0] = '\0';

View file

@ -303,7 +303,7 @@ static open_unix()
}
len = strlen(sunix.sun_path)+sizeof(sunix.sun_family);
#if defined(__NetBSD__) || defined(__FreeBSD__)
#if defined(__NetBSD__) || defined(__FreeBSD__) || defined(__DragonFly__)
len += sizeof(sunix.sun_len);
#endif
if (connect(fd, (struct sockaddr *)&sunix, len)

View file

@ -33,7 +33,7 @@
* $SonyDate: 1995/02/10 06:02:25 $
*/
#include <string.h>
#include "wchar16.h"
#include "sj.h"