-Wall -Werror -W -pedantic clean

This commit is contained in:
tg 2004-10-28 11:03:24 +00:00
parent 06411e2978
commit 7ad780aa98
28 changed files with 442 additions and 465 deletions

View File

@ -1,4 +1,4 @@
# $MirBSD: Makefile,v 1.6 2004/07/15 16:21:04 tg Stab $ # $MirBSD: Makefile,v 1.7 2004/10/28 11:03:21 tg Exp $
# $OpenBSD: Makefile,v 1.18 2004/02/16 19:07:19 deraadt Exp $ # $OpenBSD: Makefile,v 1.18 2004/02/16 19:07:19 deraadt Exp $
PROG= ksh PROG= ksh
@ -9,7 +9,7 @@ SRCS= alloc.c c_ksh.c c_sh.c c_test.c c_ulimit.c edit.c emacs.c \
MAN= ksh.1tbl sh.1tbl MAN= ksh.1tbl sh.1tbl
CPPFLAGS+= -DHAVE_CONFIG_H -I. -DKSH CPPFLAGS+= -DHAVE_CONFIG_H -I. -DKSH
CFLAGS+= -Wall -Werror CFLAGS+= -Wall -Werror -W -pedantic
CLEANFILES+= siglist.out emacs.out CLEANFILES+= siglist.out emacs.out
LINKS= ${BINDIR}/ksh ${BINDIR}/rksh LINKS= ${BINDIR}/ksh ${BINDIR}/rksh

20
c_ksh.c
View File

@ -1,4 +1,4 @@
/** $MirBSD: c_ksh.c,v 1.6 2004/09/21 11:57:07 tg Exp $ */ /** $MirBSD: c_ksh.c,v 1.7 2004/10/28 11:03:21 tg Exp $ */
/* $OpenBSD: c_ksh.c,v 1.18 2004/02/10 13:03:36 jmc Exp $ */ /* $OpenBSD: c_ksh.c,v 1.18 2004/02/10 13:03:36 jmc Exp $ */
/* /*
@ -13,6 +13,8 @@
#include <sys/cygwin.h> #include <sys/cygwin.h>
#endif /* __CYGWIN__ */ #endif /* __CYGWIN__ */
__RCSID("$MirBSD: c_ksh.c,v 1.7 2004/10/28 11:03:21 tg Exp $");
int int
c_cd(wp) c_cd(wp)
char **wp; char **wp;
@ -331,7 +333,7 @@ c_print(wp)
Xinit(xs, xp, 128, ATEMP); Xinit(xs, xp, 128, ATEMP);
while (*wp != NULL) { while (*wp != NULL) {
register int c; int c;
s = *wp; s = *wp;
while ((c = *s++) != '\0') { while ((c = *s++) != '\0') {
Xcheck(xs, xp); Xcheck(xs, xp);
@ -1016,8 +1018,8 @@ int
c_unalias(wp) c_unalias(wp)
char **wp; char **wp;
{ {
register struct table *t = &aliases; struct table *t = &aliases;
register struct tbl *ap; struct tbl *ap;
int rv = 0, all = 0; int rv = 0, all = 0;
int optc; int optc;
@ -1152,8 +1154,8 @@ c_fgbg(wp)
#endif #endif
struct kill_info { struct kill_info {
int num_width; size_t num_width;
int name_width; size_t name_width;
}; };
static char *kill_fmt_entry ARGS((void *arg, int i, char *buf, int buflen)); static char *kill_fmt_entry ARGS((void *arg, int i, char *buf, int buflen));
@ -1246,8 +1248,8 @@ c_kill(wp)
shprintf("%s%s", p, sigtraps[i].name); shprintf("%s%s", p, sigtraps[i].name);
shprintf(newline); shprintf(newline);
} else { } else {
int w, i; int i;
int mess_width; size_t w, mess_width;
struct kill_info ki; struct kill_info ki;
for (i = SIGNALS, ki.num_width = 1; i >= 10; i /= 10) for (i = SIGNALS, ki.num_width = 1; i >= 10; i /= 10)
@ -1408,7 +1410,7 @@ c_bind(wp)
char **wp; char **wp;
{ {
int rv = 0, macro = 0, list = 0; int rv = 0, macro = 0, list = 0;
register char *cp; char *cp;
int optc; int optc;
while ((optc = ksh_getopt(wp, &builtin_opt, "lm")) != EOF) while ((optc = ksh_getopt(wp, &builtin_opt, "lm")) != EOF)

37
c_sh.c
View File

@ -1,4 +1,4 @@
/** $MirBSD: c_sh.c,v 1.4 2004/09/21 11:57:07 tg Exp $ */ /** $MirBSD: c_sh.c,v 1.5 2004/10/28 11:03:22 tg Exp $ */
/* $OpenBSD: c_sh.c,v 1.17 2003/03/13 09:03:07 deraadt Exp $ */ /* $OpenBSD: c_sh.c,v 1.17 2003/03/13 09:03:07 deraadt Exp $ */
/* /*
@ -10,6 +10,8 @@
#include "ksh_time.h" #include "ksh_time.h"
#include "ksh_times.h" #include "ksh_times.h"
__RCSID("$MirBSD: c_sh.c,v 1.5 2004/10/28 11:03:22 tg Exp $");
static char *clocktos ARGS((clock_t t)); static char *clocktos ARGS((clock_t t));
@ -25,8 +27,8 @@ int
c_shift(wp) c_shift(wp)
char **wp; char **wp;
{ {
register struct block *l = e->loc; struct block *l = e->loc;
register int n; int n;
long val; long val;
char *arg; char *arg;
@ -57,8 +59,8 @@ int
c_umask(wp) c_umask(wp)
char **wp; char **wp;
{ {
register int i; int i;
register char *cp; char *cp;
int symbolic = 0; int symbolic = 0;
int old_umask; int old_umask;
int optc; int optc;
@ -239,11 +241,11 @@ int
c_read(wp) c_read(wp)
char **wp; char **wp;
{ {
register int c = 0; int c = 0;
int expand = 1, history = 0; int expand = 1, history = 0;
int expanding; int expanding;
int ecode = 0; int ecode = 0;
register char *cp; char *cp;
int fd = 0; int fd = 0;
struct shf *shf; struct shf *shf;
int optc; int optc;
@ -425,7 +427,7 @@ int
c_eval(wp) c_eval(wp)
char **wp; char **wp;
{ {
register struct source *s; struct source *s;
if (ksh_getopt(wp, &builtin_opt, null) == '?') if (ksh_getopt(wp, &builtin_opt, null) == '?')
return 1; return 1;
@ -468,7 +470,7 @@ c_trap(wp)
{ {
int i; int i;
char *s; char *s;
register Trap *p; Trap *p;
if (ksh_getopt(wp, &builtin_opt, null) == '?') if (ksh_getopt(wp, &builtin_opt, null) == '?')
return 1; return 1;
@ -625,7 +627,7 @@ c_set(wp)
{ {
int argi, setargs; int argi, setargs;
struct block *l = e->loc; struct block *l = e->loc;
register char **owp = wp; char **owp = wp;
if (wp[1] == NULL) { if (wp[1] == NULL) {
static const char *const args [] = { "set", "-", NULL }; static const char *const args [] = { "set", "-", NULL };
@ -659,7 +661,7 @@ int
c_unset(wp) c_unset(wp)
char **wp; char **wp;
{ {
register char *id; char *id;
int optc, unset_var = 1; int optc, unset_var = 1;
int ret = 0; int ret = 0;
@ -694,8 +696,7 @@ c_unset(wp)
} }
int int
c_times(wp) c_times(char **wp GCC_FUNC_ATTR(unused))
char **wp;
{ {
struct tms all; struct tms all;
@ -808,8 +809,8 @@ clocktos(t)
clock_t t; clock_t t;
{ {
static char temp[22]; /* enough for 64 bit clock_t */ static char temp[22]; /* enough for 64 bit clock_t */
register int i; int i;
register char *cp = temp + sizeof(temp); char *cp = temp + sizeof(temp);
/* note: posix says must use max precision, ie, if clk_tck is /* note: posix says must use max precision, ie, if clk_tck is
* 1000, must print 3 places after decimal (if non-zero, else 1). * 1000, must print 3 places after decimal (if non-zero, else 1).
@ -830,8 +831,7 @@ clocktos(t)
/* exec with no args - args case is taken care of in comexec() */ /* exec with no args - args case is taken care of in comexec() */
int int
c_exec(wp) c_exec(char **wp GCC_FUNC_ATTR(unused))
char ** wp;
{ {
int i; int i;
@ -858,8 +858,7 @@ c_exec(wp)
/* dummy function, special case in comexec() */ /* dummy function, special case in comexec() */
int int
c_builtin(wp) c_builtin(char **wp GCC_FUNC_ATTR(unused))
char ** wp;
{ {
return 0; return 0;
} }

View File

@ -1,4 +1,4 @@
/** $MirBSD: c_test.c,v 1.4 2004/09/21 11:57:07 tg Exp $ */ /** $MirBSD: c_test.c,v 1.5 2004/10/28 11:03:22 tg Exp $ */
/* $OpenBSD: c_test.c,v 1.10 2003/10/10 19:09:07 millert Exp $ */ /* $OpenBSD: c_test.c,v 1.10 2003/10/10 19:09:07 millert Exp $ */
/* /*
@ -14,6 +14,8 @@
#include "ksh_stat.h" #include "ksh_stat.h"
#include "c_test.h" #include "c_test.h"
__RCSID("$MirBSD: c_test.c,v 1.5 2004/10/28 11:03:22 tg Exp $");
/* test(1) accepts the following grammar: /* test(1) accepts the following grammar:
oexpr ::= aexpr | aexpr "-o" oexpr ; oexpr ::= aexpr | aexpr "-o" oexpr ;
aexpr ::= nexpr | nexpr "-a" aexpr ; aexpr ::= nexpr | nexpr "-a" aexpr ;
@ -623,10 +625,7 @@ ptest_isa(te, meta)
} }
static const char * static const char *
ptest_getopnd(te, op, do_eval) ptest_getopnd(Test_env *te, Test_op op, int do_eval GCC_FUNC_ATTR(unused))
Test_env *te;
Test_op op;
int do_eval;
{ {
if (te->pos.wp >= te->wp_end) if (te->pos.wp >= te->wp_end)
return op == TO_FILTT ? "1" : (const char *) 0; return op == TO_FILTT ? "1" : (const char *) 0;

View File

@ -1,4 +1,4 @@
/** $MirBSD: c_ulimit.c,v 1.6 2004/09/21 11:57:07 tg Exp $ */ /** $MirBSD: c_ulimit.c,v 1.7 2004/10/28 11:03:22 tg Exp $ */
/* $OpenBSD: c_ulimit.c,v 1.10 2003/10/22 07:40:38 jmc Exp $ */ /* $OpenBSD: c_ulimit.c,v 1.10 2003/10/22 07:40:38 jmc Exp $ */
/* /*
@ -32,6 +32,8 @@ extern long ulimit();
# endif /* HAVE_ULIMIT */ # endif /* HAVE_ULIMIT */
#endif /* HAVE_ULIMIT_H */ #endif /* HAVE_ULIMIT_H */
__RCSID("$MirBSD: c_ulimit.c,v 1.7 2004/10/28 11:03:22 tg Exp $");
#define SOFT 0x1 #define SOFT 0x1
#define HARD 0x2 #define HARD 0x2
@ -115,9 +117,9 @@ c_ulimit(wp)
# endif /* UL_GMEMLIM */ # endif /* UL_GMEMLIM */
#endif /* RLIMIT_VMEM */ #endif /* RLIMIT_VMEM */
#ifdef RLIMIT_SWAP #ifdef RLIMIT_SWAP
{ "swap(KiB)", RLIMIT_SWAP, RLIMIT_SWAP, 1024, 'w' }, { "swap(KiB)", RLIMIT, RLIMIT_SWAP, RLIMIT_SWAP, 1024, 'w' },
#endif #endif
{ (char *) 0 } { NULL, RLIMIT, 0, 0, 0, 0 }
}; };
static char options[3 + NELEM(limits)]; static char options[3 + NELEM(limits)];
rlim_t UNINITIALIZED(val); rlim_t UNINITIALIZED(val);
@ -200,7 +202,10 @@ c_ulimit(wp)
val = limit.rlim_cur; val = limit.rlim_cur;
else if (how & HARD) else if (how & HARD)
val = limit.rlim_max; val = limit.rlim_max;
} else }
#ifdef HAVE_ULIMIT
else
#endif
#endif /* HAVE_SETRLIMIT */ #endif /* HAVE_SETRLIMIT */
#ifdef HAVE_ULIMIT #ifdef HAVE_ULIMIT
{ {
@ -244,7 +249,10 @@ c_ulimit(wp)
else if (how & HARD) else if (how & HARD)
val = limit.rlim_max; val = limit.rlim_max;
} }
} else }
#ifdef HAVE_ULIMIT
else
#endif
#endif /* HAVE_SETRLIMIT */ #endif /* HAVE_SETRLIMIT */
#ifdef HAVE_ULIMIT #ifdef HAVE_ULIMIT
{ {

15
edit.c
View File

@ -1,4 +1,4 @@
/** $MirBSD: edit.c,v 1.7 2004/09/21 11:57:08 tg Exp $ */ /** $MirBSD: edit.c,v 1.8 2004/10/28 11:03:22 tg Exp $ */
/* $OpenBSD: edit.c,v 1.18 2003/08/22 18:17:10 fgsch Exp $ */ /* $OpenBSD: edit.c,v 1.18 2003/08/22 18:17:10 fgsch Exp $ */
/* /*
@ -22,6 +22,7 @@
#include <ctype.h> #include <ctype.h>
#include "ksh_stat.h" #include "ksh_stat.h"
__RCSID("$MirBSD: edit.c,v 1.8 2004/10/28 11:03:22 tg Exp $");
#if defined(TIOCGWINSZ) #if defined(TIOCGWINSZ)
static RETSIGTYPE x_sigwinch ARGS((int sig)); static RETSIGTYPE x_sigwinch ARGS((int sig));
@ -82,8 +83,7 @@ x_init()
#if defined(TIOCGWINSZ) #if defined(TIOCGWINSZ)
static RETSIGTYPE static RETSIGTYPE
x_sigwinch(sig) x_sigwinch(int sig GCC_FUNC_ATTR(unused))
int sig;
{ {
got_sigwinch = 1; got_sigwinch = 1;
return RETSIGVAL; return RETSIGVAL;
@ -385,7 +385,7 @@ set_editmode(ed)
#endif #endif
}; };
char *rcp; char *rcp;
int i; unsigned i;
if ((rcp = ksh_strrchr_dirsep(ed))) if ((rcp = ksh_strrchr_dirsep(ed)))
ed = ++rcp; ed = ++rcp;
@ -548,11 +548,8 @@ x_print_expansions(nwords, words, is_command)
* - returns number of matching strings * - returns number of matching strings
*/ */
static int static int
x_file_glob(flags, str, slen, wordsp) x_file_glob(int flags GCC_FUNC_ATTR(unused), const char *str,
int flags; int slen, char ***wordsp)
const char *str;
int slen;
char ***wordsp;
{ {
char *toglob; char *toglob;
char **words; char **words;

251
emacs.c
View File

@ -1,4 +1,4 @@
/** $MirBSD: emacs.c,v 1.9 2004/09/21 11:57:08 tg Exp $ */ /** $MirBSD: emacs.c,v 1.10 2004/10/28 11:03:22 tg Exp $ */
/* $OpenBSD: emacs.c,v 1.28 2003/10/22 07:40:38 jmc Exp $ */ /* $OpenBSD: emacs.c,v 1.28 2003/10/22 07:40:38 jmc Exp $ */
/* /*
@ -19,6 +19,8 @@
#include <locale.h> #include <locale.h>
#include "edit.h" #include "edit.h"
__RCSID("$MirBSD: emacs.c,v 1.10 2004/10/28 11:03:22 tg Exp $");
static Area aedit; static Area aedit;
#define AEDIT &aedit /* area for kill ring and macro defns */ #define AEDIT &aedit /* area for kill ring and macro defns */
@ -403,8 +405,7 @@ x_emacs(buf, len)
} }
static int static int
x_insert(c) x_insert(int c GCC_FUNC_ATTR(unused))
int c;
{ {
char str[2]; char str[2];
@ -423,8 +424,7 @@ x_insert(c)
} }
static int static int
x_ins_string(c) x_ins_string(int c GCC_FUNC_ATTR(unused))
int c;
{ {
if (macroptr) { if (macroptr) {
x_e_putc(BEL); x_e_putc(BEL);
@ -462,7 +462,7 @@ x_ins(s)
char *s; char *s;
{ {
char *cp = xcp; char *cp = xcp;
register int adj = x_adj_done; int adj = x_adj_done;
if (x_do_ins(s, strlen(s)) < 0) if (x_do_ins(s, strlen(s)) < 0)
return -1; return -1;
@ -501,8 +501,7 @@ x_emacs_putbuf(s, len)
} }
static int static int
x_del_back(c) x_del_back(int c GCC_FUNC_ATTR(unused))
int c;
{ {
int col = xcp - xbuf; int col = xcp - xbuf;
@ -518,8 +517,7 @@ x_del_back(c)
} }
static int static int
x_del_char(c) x_del_char(int c GCC_FUNC_ATTR(unused))
int c;
{ {
int nleft = xep - xcp; int nleft = xep - xcp;
@ -592,32 +590,28 @@ x_delete(nc, push)
} }
static int static int
x_del_bword(c) x_del_bword(int c GCC_FUNC_ATTR(unused))
int c;
{ {
x_delete(x_bword(), TRUE); x_delete(x_bword(), TRUE);
return KSTD; return KSTD;
} }
static int static int
x_mv_bword(c) x_mv_bword(int c GCC_FUNC_ATTR(unused))
int c;
{ {
(void)x_bword(); (void)x_bword();
return KSTD; return KSTD;
} }
static int static int
x_mv_fword(c) x_mv_fword(int c GCC_FUNC_ATTR(unused))
int c;
{ {
x_goto(xcp + x_fword()); x_goto(xcp + x_fword());
return KSTD; return KSTD;
} }
static int static int
x_del_fword(c) x_del_fword(int c GCC_FUNC_ATTR(unused))
int c;
{ {
x_delete(x_fword(), TRUE); x_delete(x_fword(), TRUE);
return KSTD; return KSTD;
@ -627,7 +621,7 @@ static int
x_bword() x_bword()
{ {
int nc = 0; int nc = 0;
register char *cp = xcp; char *cp = xcp;
if (cp == xbuf) { if (cp == xbuf) {
x_e_putc(BEL); x_e_putc(BEL);
@ -654,7 +648,7 @@ static int
x_fword() x_fword()
{ {
int nc = 0; int nc = 0;
register char *cp = xcp; char *cp = xcp;
if (cp == xep) { if (cp == xep) {
x_e_putc(BEL); x_e_putc(BEL);
@ -678,7 +672,7 @@ x_fword()
static void static void
x_goto(cp) x_goto(cp)
register char *cp; char *cp;
{ {
if (cp < xbp || cp >= (xbp + x_displen)) if (cp < xbp || cp >= (xbp + x_displen))
{ {
@ -705,10 +699,9 @@ x_goto(cp)
} }
static void static void
x_bs(c) x_bs(int c GCC_FUNC_ATTR(unused))
int c;
{ {
register int i; int i;
i = x_size(c); i = x_size(c);
while (i--) while (i--)
x_e_putc('\b'); x_e_putc('\b');
@ -716,17 +709,16 @@ x_bs(c)
static int static int
x_size_str(cp) x_size_str(cp)
register char *cp; char *cp;
{ {
register int size = 0; int size = 0;
while (*cp) while (*cp)
size += x_size(*cp++); size += x_size(*cp++);
return size; return size;
} }
static int static int
x_size(c) x_size(int c GCC_FUNC_ATTR(unused))
int c;
{ {
if (c=='\t') if (c=='\t')
return 4; /* Kludge, tabs are always four spaces. */ return 4; /* Kludge, tabs are always four spaces. */
@ -737,9 +729,9 @@ x_size(c)
static void static void
x_zots(str) x_zots(str)
register char *str; char *str;
{ {
register int adj = x_adj_done; int adj = x_adj_done;
x_lastcp(); x_lastcp();
while (*str && str < xlp && adj == x_adj_done) while (*str && str < xlp && adj == x_adj_done)
@ -747,8 +739,7 @@ x_zots(str)
} }
static void static void
x_zotc(c) x_zotc(int c GCC_FUNC_ATTR(unused))
int c;
{ {
if (c == '\t') { if (c == '\t') {
/* Kludge, tabs are always four spaces. */ /* Kludge, tabs are always four spaces. */
@ -761,8 +752,7 @@ x_zotc(c)
} }
static int static int
x_mv_back(c) x_mv_back(int c GCC_FUNC_ATTR(unused))
int c;
{ {
int col = xcp - xbuf; int col = xcp - xbuf;
@ -777,8 +767,7 @@ x_mv_back(c)
} }
static int static int
x_mv_forw(c) x_mv_forw(int c GCC_FUNC_ATTR(unused))
int c;
{ {
int nleft = xep - xcp; int nleft = xep - xcp;
@ -793,8 +782,7 @@ x_mv_forw(c)
} }
static int static int
x_search_char_forw(c) x_search_char_forw(int c GCC_FUNC_ATTR(unused))
int c;
{ {
char *cp = xcp; char *cp = xcp;
@ -814,8 +802,7 @@ x_search_char_forw(c)
} }
static int static int
x_search_char_back(c) x_search_char_back(int c GCC_FUNC_ATTR(unused))
int c;
{ {
char *cp = xcp, *p; char *cp = xcp, *p;
@ -836,8 +823,7 @@ x_search_char_back(c)
} }
static int static int
x_newline(c) x_newline(int c GCC_FUNC_ATTR(unused))
int c;
{ {
x_e_putc('\r'); x_e_putc('\r');
x_e_putc('\n'); x_e_putc('\n');
@ -847,27 +833,45 @@ x_newline(c)
} }
static int static int
x_end_of_text(c) x_end_of_text(int c GCC_FUNC_ATTR(unused))
int c;
{ {
return KEOL; return KEOL;
} }
static int x_beg_hist(c) int c; { x_load_hist(history); return KSTD;} static int
x_beg_hist(int c GCC_FUNC_ATTR(unused))
{
x_load_hist(history);
return KSTD;
}
static int x_end_hist(c) int c; { x_load_hist(histptr); return KSTD;} static int
x_end_hist(int c GCC_FUNC_ATTR(unused))
{
x_load_hist(histptr);
return KSTD;
}
static int x_prev_com(c) int c; { x_load_hist(x_histp - x_arg); return KSTD;} static int
x_prev_com(int c GCC_FUNC_ATTR(unused))
{
x_load_hist(x_histp - x_arg);
return KSTD;
}
static int x_next_com(c) int c; { x_load_hist(x_histp + x_arg); return KSTD;} static int
x_next_com(int c GCC_FUNC_ATTR(unused))
{
x_load_hist(x_histp + x_arg);
return KSTD;
}
/* Goto a particular history number obtained from argument. /* Goto a particular history number obtained from argument.
* If no argument is given history 1 is probably not what you * If no argument is given history 1 is probably not what you
* want so we'll simply go to the oldest one. * want so we'll simply go to the oldest one.
*/ */
static int static int
x_goto_hist(c) x_goto_hist(int c GCC_FUNC_ATTR(unused))
int c;
{ {
if (x_arg_defaulted) if (x_arg_defaulted)
x_load_hist(history); x_load_hist(history);
@ -878,7 +882,7 @@ x_goto_hist(c)
static void static void
x_load_hist(hp) x_load_hist(hp)
register char **hp; char **hp;
{ {
int oldsize; int oldsize;
@ -918,12 +922,11 @@ x_eot_del(c)
/* reverse incremental history search */ /* reverse incremental history search */
static int static int
x_search_hist(c) x_search_hist(int c GCC_FUNC_ATTR(unused))
int c;
{ {
int offset = -1; /* offset of match in xbuf, else -1 */ int offset = -1; /* offset of match in xbuf, else -1 */
char pat [256+1]; /* pattern buffer */ char pat [256+1]; /* pattern buffer */
register char *p = pat; char *p = pat;
Findex f; Findex f;
*p = '\0'; *p = '\0';
@ -986,7 +989,7 @@ x_search(pat, sameline, offset)
int sameline; int sameline;
int offset; int offset;
{ {
register char **hp; char **hp;
int i; int i;
for (hp = x_histp - (sameline ? 0 : 1) ; hp >= history; --hp) { for (hp = x_histp - (sameline ? 0 : 1) ; hp >= history; --hp) {
@ -1018,8 +1021,7 @@ x_match(str, pat)
} }
static int static int
x_del_line(c) x_del_line(int c GCC_FUNC_ATTR(unused))
int c;
{ {
int i, j; int i, j;
@ -1037,24 +1039,21 @@ x_del_line(c)
} }
static int static int
x_mv_end(c) x_mv_end(int c GCC_FUNC_ATTR(unused))
int c;
{ {
x_goto(xep); x_goto(xep);
return KSTD; return KSTD;
} }
static int static int
x_mv_begin(c) x_mv_begin(int c GCC_FUNC_ATTR(unused))
int c;
{ {
x_goto(xbuf); x_goto(xbuf);
return KSTD; return KSTD;
} }
static int static int
x_draw_line(c) x_draw_line(int c GCC_FUNC_ATTR(unused))
int c;
{ {
x_redraw(-1); x_redraw(-1);
return KSTD; return KSTD;
@ -1122,8 +1121,7 @@ x_redraw(limit)
} }
static int static int
x_transpose(c) x_transpose(int c GCC_FUNC_ATTR(unused))
int c;
{ {
char tmp; char tmp;
@ -1175,24 +1173,21 @@ x_transpose(c)
} }
static int static int
x_literal(c) x_literal(int c GCC_FUNC_ATTR(unused))
int c;
{ {
x_curprefix = -1; x_curprefix = -1;
return KSTD; return KSTD;
} }
static int static int
x_meta1(c) x_meta1(int c GCC_FUNC_ATTR(unused))
int c;
{ {
x_curprefix = 1; x_curprefix = 1;
return KSTD; return KSTD;
} }
static int static int
x_meta2(c) x_meta2(int c GCC_FUNC_ATTR(unused))
int c;
{ {
x_curprefix = 2; x_curprefix = 2;
return KSTD; return KSTD;
@ -1200,8 +1195,7 @@ x_meta2(c)
#ifdef OS2 #ifdef OS2
static int static int
x_meta3(c) x_meta3(int c GCC_FUNC_ATTR(unused))
int c;
{ {
x_curprefix = 3; x_curprefix = 3;
return KSTD; return KSTD;
@ -1209,8 +1203,7 @@ x_meta3(c)
#endif /* OS2 */ #endif /* OS2 */
static int static int
x_kill(c) x_kill(int c GCC_FUNC_ATTR(unused))
int c;
{ {
int col = xcp - xbuf; int col = xcp - xbuf;
int lastcol = xep - xbuf; int lastcol = xep - xbuf;
@ -1241,8 +1234,7 @@ x_push(nchars)
} }
static int static int
x_yank(c) x_yank(int c GCC_FUNC_ATTR(unused))
int c;
{ {
if (killsp == 0) if (killsp == 0)
killtp = KILLSIZE; killtp = KILLSIZE;
@ -1260,8 +1252,7 @@ x_yank(c)
} }
static int static int
x_meta_yank(c) x_meta_yank(int c GCC_FUNC_ATTR(unused))
int c;
{ {
int len; int len;
if ((x_last_command != XFUNC_yank && x_last_command != XFUNC_meta_yank) if ((x_last_command != XFUNC_yank && x_last_command != XFUNC_meta_yank)
@ -1285,8 +1276,7 @@ x_meta_yank(c)
} }
static int static int
x_abort(c) x_abort(int c GCC_FUNC_ATTR(unused))
int c;
{ {
/* x_zotc(c); */ /* x_zotc(c); */
xlp = xep = xcp = xbp = xbuf; xlp = xep = xcp = xbp = xbuf;
@ -1296,16 +1286,14 @@ x_abort(c)
} }
static int static int
x_error(c) x_error(int c GCC_FUNC_ATTR(unused))
int c;
{ {
x_e_putc(BEL); x_e_putc(BEL);
return KSTD; return KSTD;
} }
static int static int
x_stuffreset(c) x_stuffreset(int c GCC_FUNC_ATTR(unused))
int c;
{ {
#ifdef TIOCSTI #ifdef TIOCSTI
(void)x_stuff(c); (void)x_stuff(c);
@ -1321,8 +1309,7 @@ x_stuffreset(c)
} }
static int static int
x_stuff(c) x_stuff(int c GCC_FUNC_ATTR(unused))
int c;
{ {
#if 0 || defined TIOCSTI #if 0 || defined TIOCSTI
char ch = c; char ch = c;
@ -1367,11 +1354,10 @@ x_mapin(cp)
} }
static char * static char *
x_mapout(c) x_mapout(int c GCC_FUNC_ATTR(unused))
int c;
{ {
static char buf[8]; static char buf[8];
register char *p = buf; char *p = buf;
#ifdef OS2 #ifdef OS2
if (c == 0xE0) { if (c == 0xE0) {
@ -1507,7 +1493,8 @@ x_bind(a1, a2, macro, list)
void void
x_init_emacs() x_init_emacs()
{ {
register int i, j; unsigned i;
int j;
char *locale; char *locale;
ainit(AEDIT); ainit(AEDIT);
@ -1571,16 +1558,14 @@ x_emacs_keys(ec)
} }
static int static int
x_set_mark(c) x_set_mark(int c GCC_FUNC_ATTR(unused))
int c;
{ {
xmp = xcp; xmp = xcp;
return KSTD; return KSTD;
} }
static int static int
x_kill_region(c) x_kill_region(int c GCC_FUNC_ATTR(unused))
int c;
{ {
int rsize; int rsize;
char *xr; char *xr;
@ -1603,8 +1588,7 @@ x_kill_region(c)
} }
static int static int
x_xchg_point_mark(c) x_xchg_point_mark(int c GCC_FUNC_ATTR(unused))
int c;
{ {
char *tmp; char *tmp;
@ -1619,8 +1603,7 @@ x_xchg_point_mark(c)
} }
static int static int
x_version(c) x_version(int c GCC_FUNC_ATTR(unused))
int c;
{ {
char *o_xbuf = xbuf, *o_xend = xend; char *o_xbuf = xbuf, *o_xend = xend;
char *o_xbp = xbp, *o_xep = xep, *o_xcp = xcp; char *o_xbp = xbp, *o_xep = xep, *o_xcp = xcp;
@ -1649,19 +1632,17 @@ x_version(c)
} }
static int static int
x_noop(c) x_noop(int c GCC_FUNC_ATTR(unused))
int c;
{ {
return KSTD; return KSTD;
} }
#ifdef SILLY #ifdef SILLY
static int static int
x_game_of_life(c) x_game_of_life(int c GCC_FUNC_ATTR(unused))
int c;
{ {
char newbuf [256+1]; char newbuf [256+1];
register char *ip, *op; char *ip, *op;
int i, len; int i, len;
i = xep - xbuf; i = xep - xbuf;
@ -1714,57 +1695,49 @@ x_game_of_life(c)
static int static int
x_comp_comm(c) x_comp_comm(int c GCC_FUNC_ATTR(unused))
int c;
{ {
do_complete(XCF_COMMAND, CT_COMPLETE); do_complete(XCF_COMMAND, CT_COMPLETE);
return KSTD; return KSTD;
} }
static int static int
x_list_comm(c) x_list_comm(int c GCC_FUNC_ATTR(unused))
int c;
{ {
do_complete(XCF_COMMAND, CT_LIST); do_complete(XCF_COMMAND, CT_LIST);
return KSTD; return KSTD;
} }
static int static int
x_complete(c) x_complete(int c GCC_FUNC_ATTR(unused))
int c;
{ {
do_complete(XCF_COMMAND_FILE, CT_COMPLETE); do_complete(XCF_COMMAND_FILE, CT_COMPLETE);
return KSTD; return KSTD;
} }
static int static int
x_enumerate(c) x_enumerate(int c GCC_FUNC_ATTR(unused))
int c;
{ {
do_complete(XCF_COMMAND_FILE, CT_LIST); do_complete(XCF_COMMAND_FILE, CT_LIST);
return KSTD; return KSTD;
} }
static int static int
x_comp_file(c) x_comp_file(int c GCC_FUNC_ATTR(unused))
int c;
{ {
do_complete(XCF_FILE, CT_COMPLETE); do_complete(XCF_FILE, CT_COMPLETE);
return KSTD; return KSTD;
} }
static int static int
x_list_file(c) x_list_file(int c GCC_FUNC_ATTR(unused))
int c;
{ {
do_complete(XCF_FILE, CT_LIST); do_complete(XCF_FILE, CT_LIST);
return KSTD; return KSTD;
} }
static int static int
x_comp_list(c) x_comp_list(int c GCC_FUNC_ATTR(unused))
int c;
{ {
do_complete(XCF_COMMAND_FILE, CT_COMPLIST); do_complete(XCF_COMMAND_FILE, CT_COMPLIST);
return KSTD; return KSTD;
} }
static int static int
x_expand(c) x_expand(int c GCC_FUNC_ATTR(unused))
int c;
{ {
char **words; char **words;
int nwords = 0; int nwords = 0;
@ -1881,8 +1854,7 @@ x_adjust()
static int unget_char = -1; static int unget_char = -1;
static void static void
x_e_ungetc(c) x_e_ungetc(int c GCC_FUNC_ATTR(unused))
int c;
{ {
unget_char = c; unget_char = c;
} }
@ -1908,8 +1880,7 @@ x_e_getc()
} }
static void static void
x_e_putc(c) x_e_putc(int c GCC_FUNC_ATTR(unused))
int c;
{ {
if (c == '\r' || c == '\n') if (c == '\r' || c == '\n')
x_col = 0; x_col = 0;
@ -1939,8 +1910,7 @@ x_e_putc(c)
#ifdef DEBUG #ifdef DEBUG
static int static int
x_debug_info(c) x_debug_info(int c GCC_FUNC_ATTR(unused))
int c;
{ {
x_flush(); x_flush();
shellf("\nksh debug:\n"); shellf("\nksh debug:\n");
@ -1960,7 +1930,7 @@ static void
x_e_puts(s) x_e_puts(s)
const char *s; const char *s;
{ {
register int adj = x_adj_done; int adj = x_adj_done;
while (*s && adj == x_adj_done) while (*s && adj == x_adj_done)
x_e_putc(*s++); x_e_putc(*s++);
@ -1977,8 +1947,7 @@ x_e_puts(s)
*/ */
static int static int
x_set_arg(c) x_set_arg(int c GCC_FUNC_ATTR(unused))
int c;
{ {
int n = 0; int n = 0;
int first = 1; int first = 1;
@ -2001,8 +1970,7 @@ x_set_arg(c)
/* Comment or uncomment the current line. */ /* Comment or uncomment the current line. */
static int static int
x_comment(c) x_comment(int c GCC_FUNC_ATTR(unused))
int c;
{ {
int oldsize = x_size_str(xbuf); int oldsize = x_size_str(xbuf);
int len = xep - xbuf; int len = xep - xbuf;
@ -2038,10 +2006,9 @@ x_comment(c)
*/ */
static int static int
x_prev_histword(c) x_prev_histword(int c GCC_FUNC_ATTR(unused))
int c;
{ {
register char *rcp; char *rcp;
char *cp; char *cp;
cp = *histptr; cp = *histptr;
@ -2088,24 +2055,21 @@ x_prev_histword(c)
/* Uppercase N(1) words */ /* Uppercase N(1) words */
static int static int
x_fold_upper(c) x_fold_upper(int c GCC_FUNC_ATTR(unused))
int c;
{ {
return x_fold_case('U'); return x_fold_case('U');
} }
/* Lowercase N(1) words */ /* Lowercase N(1) words */
static int static int
x_fold_lower(c) x_fold_lower(int c GCC_FUNC_ATTR(unused))
int c;
{ {
return x_fold_case('L'); return x_fold_case('L');
} }
/* Lowercase N(1) words */ /* Lowercase N(1) words */
static int static int
x_fold_capitalize(c) x_fold_capitalize(int c GCC_FUNC_ATTR(unused))
int c;
{ {
return x_fold_case('C'); return x_fold_case('C');
} }
@ -2122,8 +2086,7 @@ x_fold_capitalize(c)
*/ */
static int static int
x_fold_case(c) x_fold_case(int c GCC_FUNC_ATTR(unused))
int c;
{ {
char *cp = xcp; char *cp = xcp;
@ -2192,8 +2155,8 @@ x_fold_case(c)
static char * static char *
x_lastcp() x_lastcp()
{ {
register char *rcp; char *rcp;
register int i; int i;
if (!xlp_valid) if (!xlp_valid)
{ {

46
eval.c
View File

@ -1,4 +1,4 @@
/** $MirBSD: eval.c,v 1.3 2004/09/21 11:57:08 tg Exp $ */ /** $MirBSD: eval.c,v 1.4 2004/10/28 11:03:22 tg Exp $ */
/* $OpenBSD: eval.c,v 1.14 2003/11/10 21:26:39 millert Exp $ */ /* $OpenBSD: eval.c,v 1.14 2003/11/10 21:26:39 millert Exp $ */
/* /*
@ -10,6 +10,8 @@
#include "ksh_dir.h" #include "ksh_dir.h"
#include "ksh_stat.h" #include "ksh_stat.h"
__RCSID("$MirBSD: eval.c,v 1.4 2004/10/28 11:03:22 tg Exp $");
/* /*
* string expansion * string expansion
* *
@ -80,7 +82,7 @@ substitute(cp, f)
*/ */
char ** char **
eval(ap, f) eval(ap, f)
register char **ap; char **ap;
int f; int f;
{ {
XPtrV w; XPtrV w;
@ -125,7 +127,7 @@ evalstr(cp, f)
*/ */
char * char *
evalonestr(cp, f) evalonestr(cp, f)
register char *cp; char *cp;
int f; int f;
{ {
XPtrV w; XPtrV w;
@ -161,14 +163,14 @@ typedef struct SubType {
void void
expand(cp, wp, f) expand(cp, wp, f)
char *cp; /* input word */ char *cp; /* input word */
register XPtrV *wp; /* output words */ XPtrV *wp; /* output words */
int f; /* DO* flags */ int f; /* DO* flags */
{ {
register int UNINITIALIZED(c); int UNINITIALIZED(c);
register int type; /* expansion type */ int type; /* expansion type */
register int quote = 0; /* quoted */ int quote = 0; /* quoted */
XString ds; /* destination string */ XString ds; /* destination string */
register char *dp, *sp; /* dest., source */ char *dp, *sp; /* dest., source */
int fdo, word; /* second pass flags; have word */ int fdo, word; /* second pass flags; have word */
int doblank; /* field splitting of parameter/command subst */ int doblank; /* field splitting of parameter/command subst */
Expand x; /* expansion variables */ Expand x; /* expansion variables */
@ -335,7 +337,7 @@ expand(cp, wp, f)
* expected) * expected)
*/ */
*dp++ = MAGIC; *dp++ = MAGIC;
*dp++ = '@' + 0x80; *dp++ = (char)('@' + 0x80);
break; break;
case '=': case '=':
/* Enabling tilde expansion /* Enabling tilde expansion
@ -841,11 +843,11 @@ varsub(xp, sp, word, stypep, slenp)
*/ */
static int static int
comsub(xp, cp) comsub(xp, cp)
register Expand *xp; Expand *xp;
char *cp; char *cp;
{ {
Source *s, *sold; Source *s, *sold;
register struct op *t; struct op *t;
struct shf *shf; struct shf *shf;
s = pushs(SSTRING, ATEMP); s = pushs(SSTRING, ATEMP);
@ -859,7 +861,7 @@ comsub(xp, cp)
if (t != NULL && t->type == TCOM && /* $(<file) */ if (t != NULL && t->type == TCOM && /* $(<file) */
*t->args == NULL && *t->vars == NULL && t->ioact != NULL) { *t->args == NULL && *t->vars == NULL && t->ioact != NULL) {
register struct ioword *io = *t->ioact; struct ioword *io = *t->ioact;
char *name; char *name;
if ((io->flag&IOTYPE) != IOREAD) if ((io->flag&IOTYPE) != IOREAD)
@ -895,12 +897,12 @@ comsub(xp, cp)
static char * static char *
trimsub(str, pat, how) trimsub(str, pat, how)
register char *str; char *str;
char *pat; char *pat;
int how; int how;
{ {
register char *end = strchr(str, 0); char *end = strchr(str, 0);
register char *p, c; char *p, c;
switch (how&0xff) { /* UCHAR_MAX maybe? */ switch (how&0xff) { /* UCHAR_MAX maybe? */
case '#': /* shortest at beginning */ case '#': /* shortest at beginning */
@ -949,7 +951,7 @@ trimsub(str, pat, how)
static void static void
glob(cp, wp, markdirs) glob(cp, wp, markdirs)
char *cp; char *cp;
register XPtrV *wp; XPtrV *wp;
int markdirs; int markdirs;
{ {
int oldsize = XPsize(*wp); int oldsize = XPsize(*wp);
@ -991,10 +993,10 @@ globit(xs, xpp, sp, wp, check)
XString *xs; /* dest string */ XString *xs; /* dest string */
char **xpp; /* ptr to dest end */ char **xpp; /* ptr to dest end */
char *sp; /* source path */ char *sp; /* source path */
register XPtrV *wp; /* output list */ XPtrV *wp; /* output list */
int check; /* GF_* flags */ int check; /* GF_* flags */
{ {
register char *np; /* next source component */ char *np; /* next source component */
char *xp = *xpp; char *xp = *xpp;
char *se; char *se;
char odirsep; char odirsep;
@ -1187,10 +1189,10 @@ debunk(dp, sp, dlen)
char *d, *s; char *d, *s;
if ((s = strchr(sp, MAGIC))) { if ((s = strchr(sp, MAGIC))) {
if (s - sp >= dlen) if ((size_t)(s - sp) >= dlen)
return dp; return dp;
memcpy(dp, sp, s - sp); memcpy(dp, sp, s - sp);
for (d = dp + (s - sp); *s && (d - dp < dlen); s++) for (d = dp + (s - sp); *s && ((size_t)(d - dp) < dlen); s++)
if (!ISMAGIC(*s) || !(*++s & 0x80) if (!ISMAGIC(*s) || !(*++s & 0x80)
|| !strchr("*+?@! ", *s & 0x7f)) || !strchr("*+?@! ", *s & 0x7f))
*d++ = *s; *d++ = *s;
@ -1198,7 +1200,7 @@ debunk(dp, sp, dlen)
/* extended pattern operators: *+?@! */ /* extended pattern operators: *+?@! */
if ((*s & 0x7f) != ' ') if ((*s & 0x7f) != ' ')
*d++ = *s & 0x7f; *d++ = *s & 0x7f;
if (d - dp < dlen) if ((size_t)(d - dp) < dlen)
*d++ = '('; *d++ = '(';
} }
*d = '\0'; *d = '\0';
@ -1284,7 +1286,7 @@ static char *
homedir(name) homedir(name)
char *name; char *name;
{ {
register struct tbl *ap; struct tbl *ap;
ap = tenter(&homedirs, name, hash(name)); ap = tenter(&homedirs, name, hash(name));
if (!(ap->flag & ISSET)) { if (!(ap->flag & ISSET)) {

28
exec.c
View File

@ -1,4 +1,4 @@
/** $MirBSD: exec.c,v 1.3 2004/09/21 11:57:08 tg Exp $ */ /** $MirBSD: exec.c,v 1.4 2004/10/28 11:03:23 tg Exp $ */
/* $OpenBSD: exec.c,v 1.31 2003/12/15 05:25:52 otto Exp $ */ /* $OpenBSD: exec.c,v 1.31 2003/12/15 05:25:52 otto Exp $ */
/* /*
@ -449,13 +449,13 @@ static int
comexec(t, tp, ap, flags) comexec(t, tp, ap, flags)
struct op *t; struct op *t;
struct tbl *volatile tp; struct tbl *volatile tp;
register char **ap; char **ap;
int volatile flags; int volatile flags;
{ {
int i; int i;
volatile int rv = 0; volatile int rv = 0;
register char *cp; char *cp;
register char **lastp; char **lastp;
static struct op texec; /* Must be static (XXX but why?) */ static struct op texec; /* Must be static (XXX but why?) */
int type_flags; int type_flags;
int keepasn_ok; int keepasn_ok;
@ -753,8 +753,8 @@ comexec(t, tp, ap, flags)
static void static void
scriptexec(tp, ap) scriptexec(tp, ap)
register struct op *tp; struct op *tp;
register char **ap; char **ap;
{ {
char *shell; char *shell;
@ -768,8 +768,8 @@ scriptexec(tp, ap)
#ifdef SHARPBANG #ifdef SHARPBANG
{ {
char buf[LINE]; char buf[LINE];
register char *cp; char *cp;
register int fd, n; int fd, n;
buf[0] = '\0'; buf[0] = '\0';
if ((fd = open(tp->str, O_RDONLY)) >= 0) { if ((fd = open(tp->str, O_RDONLY)) >= 0) {
@ -867,9 +867,9 @@ scriptexec(tp, ap)
int int
shcomexec(wp) shcomexec(wp)
register char **wp; char **wp;
{ {
register struct tbl *tp; struct tbl *tp;
tp = tsearch(&builtins, *wp, hash(*wp)); tp = tsearch(&builtins, *wp, hash(*wp));
if (tp == NULL) if (tp == NULL)
@ -959,7 +959,7 @@ builtin(name, func)
const char *name; const char *name;
int (*func) ARGS((char **)); int (*func) ARGS((char **));
{ {
register struct tbl *tp; struct tbl *tp;
Tflag flag; Tflag flag;
/* see if any flags should be set for this builtin */ /* see if any flags should be set for this builtin */
@ -1293,10 +1293,10 @@ call_builtin(tp, wp)
*/ */
static int static int
iosetup(iop, tp) iosetup(iop, tp)
register struct ioword *iop; struct ioword *iop;
struct tbl *tp; struct tbl *tp;
{ {
register int u = -1; int u = -1;
char *cp = iop->name; char *cp = iop->name;
int iotype = iop->flag & IOTYPE; int iotype = iop->flag & IOTYPE;
int do_open = 1, do_close = 0, UNINITIALIZED(flags); int do_open = 1, do_close = 0, UNINITIALIZED(flags);
@ -1508,7 +1508,7 @@ herein(content, sub)
*/ */
static char * static char *
do_selectargs(ap, print_menu) do_selectargs(ap, print_menu)
register char **ap; char **ap;
bool_t print_menu; bool_t print_menu;
{ {
static const char *const read_args[] = { static const char *const read_args[] = {

View File

@ -1,4 +1,4 @@
/** $MirBSD: expand.h,v 1.3 2004/09/21 11:57:09 tg Exp $ */ /** $MirBSD: expand.h,v 1.4 2004/10/28 11:03:23 tg Exp $ */
/* $OpenBSD: expand.h,v 1.3 2001/03/26 16:19:45 todd Exp $ */ /* $OpenBSD: expand.h,v 1.3 2001/03/26 16:19:45 todd Exp $ */
/* /*
@ -70,7 +70,7 @@ typedef char * XStringP;
#define Xsavepos(xs, xp) ((xp) - (xs).beg) #define Xsavepos(xs, xp) ((xp) - (xs).beg)
#define Xrestpos(xs, xp, n) ((xs).beg + (n)) #define Xrestpos(xs, xp, n) ((xs).beg + (n))
char * Xcheck_grow_ ARGS((XString *xsp, char *xp, int more)); char * Xcheck_grow_ ARGS((XString *xsp, char *xp, size_t more));
/* /*
* expandable vector of generic pointers * expandable vector of generic pointers
@ -82,7 +82,7 @@ typedef struct XPtrV {
} XPtrV; } XPtrV;
#define XPinit(x, n) do { \ #define XPinit(x, n) do { \
register void **vp__; \ void **vp__; \
vp__ = (void**) alloc(sizeofN(void*, n), ATEMP); \ vp__ = (void**) alloc(sizeofN(void*, n), ATEMP); \
(x).cur = (x).beg = vp__; \ (x).cur = (x).beg = vp__; \
(x).end = vp__ + n; \ (x).end = vp__ + n; \

4
expr.c
View File

@ -1,4 +1,4 @@
/** $MirBSD: expr.c,v 1.4 2004/09/21 11:57:09 tg Exp $ */ /** $MirBSD: expr.c,v 1.5 2004/10/28 11:03:23 tg Exp $ */
/* $OpenBSD: expr.c,v 1.9 2003/10/22 07:40:38 jmc Exp $ */ /* $OpenBSD: expr.c,v 1.9 2003/10/22 07:40:38 jmc Exp $ */
/* /*
@ -567,7 +567,7 @@ assign_check(es, op, vasn)
static struct tbl * static struct tbl *
tempvar() tempvar()
{ {
register struct tbl *vp; struct tbl *vp;
vp = (struct tbl*) alloc(sizeof(struct tbl), ATEMP); vp = (struct tbl*) alloc(sizeof(struct tbl), ATEMP);
vp->flag = ISSET|INTEGER; vp->flag = ISSET|INTEGER;

View File

@ -1,4 +1,4 @@
/** $MirBSD: history.c,v 1.11 2004/09/21 11:57:09 tg Exp $ */ /** $MirBSD: history.c,v 1.12 2004/10/28 11:03:23 tg Exp $ */
/* $OpenBSD: history.c,v 1.24 2004/08/03 12:44:59 danh Exp $ */ /* $OpenBSD: history.c,v 1.24 2004/08/03 12:44:59 danh Exp $ */
/* /*
@ -617,7 +617,7 @@ histsave(lno, cmd, dowrite)
const char *cmd; const char *cmd;
int dowrite; /* ignored (compatibility with COMPLEX_HISTORY) */ int dowrite; /* ignored (compatibility with COMPLEX_HISTORY) */
{ {
register char **hp = histptr; char **hp = histptr;
char *cp; char *cp;
if (++hp >= history + histsize) { /* remove oldest command */ if (++hp >= history + histsize) { /* remove oldest command */
@ -737,8 +737,8 @@ hist_finish()
{ {
static int once; static int once;
FILE *fh; FILE *fh;
register int i; int i;
register char **hp; char **hp;
if (once++) if (once++)
return; return;
@ -776,7 +776,7 @@ histsave(lno, cmd, dowrite)
const char *cmd; const char *cmd;
int dowrite; int dowrite;
{ {
register char **hp; char **hp;
char *c, *cp; char *c, *cp;
c = str_save(cmd, APERM); c = str_save(cmd, APERM);
@ -901,8 +901,8 @@ typedef enum state {
static int static int
hist_count_lines(base, bytes) hist_count_lines(base, bytes)
register unsigned char *base; unsigned char *base;
register int bytes; int bytes;
{ {
State state = shdr; State state = shdr;
int lines = 0; int lines = 0;
@ -994,8 +994,8 @@ hist_skip_back(base, bytes, no)
int *bytes; int *bytes;
int no; int no;
{ {
register int lines = 0; int lines = 0;
register unsigned char *ep; unsigned char *ep;
for (ep = base + *bytes; --ep > base; ) { for (ep = base + *bytes; --ep > base; ) {
/* this doesn't really work: the 4 byte line number that is /* this doesn't really work: the 4 byte line number that is
@ -1020,8 +1020,8 @@ hist_skip_back(base, bytes, no)
static void static void
histload(s, base, bytes) histload(s, base, bytes)
Source *s; Source *s;
register unsigned char *base; unsigned char *base;
register int bytes; int bytes;
{ {
State state; State state;
int lno = 0; int lno = 0;
@ -1076,7 +1076,7 @@ histinsert(s, lno, line)
int lno; int lno;
unsigned char *line; unsigned char *line;
{ {
register char **hp; char **hp;
if (lno >= s->line-(histptr-history) && lno <= s->line) { if (lno >= s->line-(histptr-history) && lno <= s->line) {
hp = &histptr[lno-s->line]; hp = &histptr[lno-s->line];

6
io.c
View File

@ -1,4 +1,4 @@
/** $MirBSD: io.c,v 1.5 2004/09/21 11:57:09 tg Exp $ */ /** $MirBSD: io.c,v 1.6 2004/10/28 11:03:23 tg Exp $ */
/* $OpenBSD: io.c,v 1.13 2003/11/10 21:26:39 millert Exp $ */ /* $OpenBSD: io.c,v 1.13 2003/11/10 21:26:39 millert Exp $ */
/* /*
@ -330,7 +330,7 @@ restfd(fd, ofd)
void void
openpipe(pv) openpipe(pv)
register int *pv; int *pv;
{ {
if (pipe(pv) < 0) if (pipe(pv) < 0)
errorf("can't create pipe - try again"); errorf("can't create pipe - try again");
@ -340,7 +340,7 @@ openpipe(pv)
void void
closepipe(pv) closepipe(pv)
register int *pv; int *pv;
{ {
close(pv[0]); close(pv[0]);
close(pv[1]); close(pv[1]);

7
jobs.c
View File

@ -1,4 +1,4 @@
/** $MirBSD: jobs.c,v 1.5 2004/09/21 11:57:10 tg Exp $ */ /** $MirBSD: jobs.c,v 1.6 2004/10/28 11:03:23 tg Exp $ */
/* $OpenBSD: jobs.c,v 1.21 2003/11/10 21:26:39 millert Exp $ */ /* $OpenBSD: jobs.c,v 1.21 2003/11/10 21:26:39 millert Exp $ */
/* /*
@ -31,6 +31,8 @@
#include "ksh_times.h" #include "ksh_times.h"
#include "tty.h" #include "tty.h"
__RCSID("$MirBSD: jobs.c,v 1.6 2004/10/28 11:03:23 tg Exp $");
/* Start of system configuration stuff */ /* Start of system configuration stuff */
/* We keep CHILD_MAX zombie processes around (exact value isn't critical) */ /* We keep CHILD_MAX zombie processes around (exact value isn't critical) */
@ -1309,8 +1311,7 @@ j_waitj(j, flags, where)
* If jobs are compiled in then this routine expects sigchld to be blocked. * If jobs are compiled in then this routine expects sigchld to be blocked.
*/ */
static RETSIGTYPE static RETSIGTYPE
j_sigchld(sig) j_sigchld(int sig GCC_FUNC_ATTR(unused))
int sig;
{ {
int errno_ = errno; int errno_ = errno;
Job *j; Job *j;

18
lex.c
View File

@ -1,4 +1,4 @@
/** $MirBSD: lex.c,v 1.4 2004/09/21 11:57:12 tg Exp $ */ /** $MirBSD: lex.c,v 1.5 2004/10/28 11:03:23 tg Exp $ */
/* $OpenBSD: lex.c,v 1.18 2003/08/06 21:08:05 millert Exp $ */ /* $OpenBSD: lex.c,v 1.18 2003/08/06 21:08:05 millert Exp $ */
/* /*
@ -103,9 +103,9 @@ yylex(cf)
{ {
Lex_state states[STATE_BSIZE], *statep; Lex_state states[STATE_BSIZE], *statep;
State_info state_info; State_info state_info;
register int c, state; int c, state;
XString ws; /* expandable output word */ XString ws; /* expandable output word */
register char *wp; /* output word pointer */ char *wp; /* output word pointer */
char *sp, *dp; char *sp, *dp;
int c2; int c2;
@ -750,7 +750,7 @@ Done:
if ((cf & ALIAS) && (p = tsearch(&aliases, ident, h)) if ((cf & ALIAS) && (p = tsearch(&aliases, ident, h))
&& (p->flag & ISSET)) && (p->flag & ISSET))
{ {
register Source *s; Source *s;
for (s = source; s->type == SALIAS; s = s->next) for (s = source; s->type == SALIAS; s = s->next)
if (s->u.tblp == p) if (s->u.tblp == p)
@ -772,7 +772,7 @@ Done:
static void static void
gethere() gethere()
{ {
register struct ioword **p; struct ioword **p;
for (p = heres; p < herep; p++) for (p = heres; p < herep; p++)
readhere(*p); readhere(*p);
@ -787,7 +787,7 @@ static void
readhere(iop) readhere(iop)
struct ioword *iop; struct ioword *iop;
{ {
register int c; int c;
char *volatile eof; char *volatile eof;
char *eofp; char *eofp;
int skiptabs; int skiptabs;
@ -874,7 +874,7 @@ pushs(type, areap)
int type; int type;
Area *areap; Area *areap;
{ {
register Source *s; Source *s;
s = (Source *) alloc(sizeof(Source), areap); s = (Source *) alloc(sizeof(Source), areap);
s->type = type; s->type = type;
@ -897,8 +897,8 @@ pushs(type, areap)
static int static int
getsc__() getsc__()
{ {
register Source *s = source; Source *s = source;
register int c; int c;
while ((c = *s->str++) == 0) { while ((c = *s->str++) == 0) {
s->str = NULL; /* return 0 for EOF by default */ s->str = NULL; /* return 0 for EOF by default */

18
mail.c
View File

@ -1,4 +1,4 @@
/** $MirBSD: mail.c,v 1.3 2004/09/21 11:57:13 tg Exp $ */ /** $MirBSD: mail.c,v 1.4 2004/10/28 11:03:23 tg Exp $ */
/* $OpenBSD: mail.c,v 1.9 1999/06/15 01:18:35 millert Exp $ */ /* $OpenBSD: mail.c,v 1.9 1999/06/15 01:18:35 millert Exp $ */
/* /*
@ -40,7 +40,7 @@ static void mprintit ARGS((mbox_t *mbp));
void void
mcheck() mcheck()
{ {
register mbox_t *mbp; mbox_t *mbp;
time_t now; time_t now;
struct tbl *vp; struct tbl *vp;
struct stat stbuf; struct stat stbuf;
@ -90,7 +90,7 @@ mcset(interval)
void void
mbset(p) mbset(p)
register char *p; char *p;
{ {
struct stat stbuf; struct stat stbuf;
@ -109,10 +109,10 @@ mbset(p)
void void
mpset(mptoparse) mpset(mptoparse)
register char *mptoparse; char *mptoparse;
{ {
register mbox_t *mbp; mbox_t *mbp;
register char *mpath, *mmsg, *mval; char *mpath, *mmsg, *mval;
char *p; char *p;
munset( mplist ); munset( mplist );
@ -149,9 +149,9 @@ mpset(mptoparse)
static void static void
munset(mlist) munset(mlist)
register mbox_t *mlist; mbox_t *mlist;
{ {
register mbox_t *mbp; mbox_t *mbp;
while (mlist != NULL) { while (mlist != NULL) {
mbp = mlist; mbp = mlist;
@ -168,7 +168,7 @@ mballoc(p, m)
char *m; char *m;
{ {
struct stat stbuf; struct stat stbuf;
register mbox_t *mbp; mbox_t *mbp;
mbp = (mbox_t *)alloc(sizeof(mbox_t), APERM); mbp = (mbox_t *)alloc(sizeof(mbox_t), APERM);
mbp->mb_next = NULL; mbp->mb_next = NULL;

20
main.c
View File

@ -1,4 +1,4 @@
/** $MirBSD: main.c,v 1.9 2004/08/27 14:08:35 tg Stab $ */ /** $MirBSD: main.c,v 1.10 2004/10/28 11:03:23 tg Exp $ */
/* $OpenBSD: main.c,v 1.28 2004/08/23 14:56:32 millert Exp $ */ /* $OpenBSD: main.c,v 1.28 2004/08/23 14:56:32 millert Exp $ */
/* /*
@ -11,6 +11,8 @@
#include "ksh_stat.h" #include "ksh_stat.h"
#include "ksh_time.h" #include "ksh_time.h"
__RCSID("$MirBSD: main.c,v 1.10 2004/10/28 11:03:23 tg Exp $");
extern char **environ; extern char **environ;
/* /*
@ -86,7 +88,7 @@ static const char *const initcoms [] = {
int int
main(int argc, char *argv[]) main(int argc, char *argv[])
{ {
register int i; int i;
int argi; int argi;
Source *s; Source *s;
struct block *l; struct block *l;
@ -458,7 +460,7 @@ include(name, argc, argv, intr_ok)
char **argv; char **argv;
int intr_ok; int intr_ok;
{ {
register Source *volatile s = NULL; Source *volatile s = NULL;
struct shf *shf; struct shf *shf;
char **volatile old_argv; char **volatile old_argv;
volatile int old_argc; volatile int old_argc;
@ -527,7 +529,7 @@ int
command(comm) command(comm)
const char *comm; const char *comm;
{ {
register Source *s; Source *s;
s = pushs(SSTRING, ATEMP); s = pushs(SSTRING, ATEMP);
s->start = s->str = comm; s->start = s->str = comm;
@ -687,7 +689,7 @@ void
newenv(type) newenv(type)
int type; int type;
{ {
register struct env *ep; struct env *ep;
ep = (struct env *) alloc(sizeof(*ep), ATEMP); ep = (struct env *) alloc(sizeof(*ep), ATEMP);
ep->type = type; ep->type = type;
@ -703,8 +705,8 @@ newenv(type)
void void
quitenv() quitenv()
{ {
register struct env *ep = e; struct env *ep = e;
register int fd; int fd;
if (ep->oenv && ep->oenv->loc != ep->loc) if (ep->oenv && ep->oenv->loc != ep->loc)
popblock(); popblock();
@ -856,9 +858,7 @@ is_restricted(name)
} }
void void
aerror(ap, msg) aerror(Area *ap GCC_FUNC_ATTR(unused), const char *msg)
Area *ap;
const char *msg;
{ {
internal_errorf(1, "alloc: %s", msg); internal_errorf(1, "alloc: %s", msg);
errorf(null); /* this is never executed - keeps gcc quiet */ errorf(null); /* this is never executed - keeps gcc quiet */

69
misc.c
View File

@ -1,4 +1,4 @@
/** $MirBSD: misc.c,v 1.9 2004/09/21 11:57:13 tg Exp $ */ /** $MirBSD: misc.c,v 1.10 2004/10/28 11:03:23 tg Exp $ */
/* $OpenBSD: misc.c,v 1.20 2003/10/22 07:40:38 jmc Exp $ */ /* $OpenBSD: misc.c,v 1.20 2003/10/22 07:40:38 jmc Exp $ */
/* /*
@ -11,6 +11,8 @@
# include <limits.h> # include <limits.h>
#endif #endif
__RCSID("$MirBSD: misc.c,v 1.10 2004/10/28 11:03:23 tg Exp $");
#ifndef UCHAR_MAX #ifndef UCHAR_MAX
# define UCHAR_MAX 0xFF # define UCHAR_MAX 0xFF
#endif #endif
@ -27,10 +29,10 @@ static const unsigned char *cclass ARGS((const unsigned char *p, int sub));
*/ */
void void
setctypes(s, t) setctypes(s, t)
register const char *s; const char *s;
register int t; int t;
{ {
register int i; unsigned i;
if (t & C_IFS) { if (t & C_IFS) {
for (i = 0; i < UCHAR_MAX+1; i++) for (i = 0; i < UCHAR_MAX+1; i++)
@ -44,7 +46,7 @@ setctypes(s, t)
void void
initctypes() initctypes()
{ {
register int c; int c;
for (c = 'a'; c <= 'z'; c++) for (c = 'a'; c <= 'z'; c++)
ctypes[c] |= C_ALPHA; ctypes[c] |= C_ALPHA;
@ -64,10 +66,10 @@ initctypes()
char * char *
ulton(n, base) ulton(n, base)
register unsigned long n; unsigned long n;
int base; int base;
{ {
register char *p; char *p;
static char buf [20]; static char buf [20];
p = &buf[sizeof(buf)]; p = &buf[sizeof(buf)];
@ -81,7 +83,7 @@ ulton(n, base)
char * char *
str_save(s, ap) str_save(s, ap)
register const char *s; const char *s;
Area *ap; Area *ap;
{ {
size_t len; size_t len;
@ -101,7 +103,7 @@ str_save(s, ap)
*/ */
char * char *
str_nsave(s, n, ap) str_nsave(s, n, ap)
register const char *s; const char *s;
int n; int n;
Area *ap; Area *ap;
{ {
@ -119,7 +121,7 @@ char *
Xcheck_grow_(xsp, xp, more) Xcheck_grow_(xsp, xp, more)
XString *xsp; XString *xsp;
char *xp; char *xp;
int more; size_t more;
{ {
char *old_beg = xsp->beg; char *old_beg = xsp->beg;
@ -196,7 +198,7 @@ int
option(n) option(n)
const char *n; const char *n;
{ {
int i; unsigned i;
for (i = 0; i < NELEM(options); i++) for (i = 0; i < NELEM(options); i++)
if (options[i].name && strcmp(options[i].name, n) == 0) if (options[i].name && strcmp(options[i].name, n) == 0)
@ -236,7 +238,7 @@ static void
printoptions(verbose) printoptions(verbose)
int verbose; int verbose;
{ {
int i; unsigned i;
if (verbose) { if (verbose) {
struct options_info oi; struct options_info oi;
@ -268,9 +270,9 @@ printoptions(verbose)
char * char *
getoptions() getoptions()
{ {
int i; unsigned i;
char m[(int) FNFLAGS + 1]; char m[(int) FNFLAGS + 1];
register char *cp = m; char *cp = m;
for (i = 0; i < NELEM(options); i++) for (i = 0; i < NELEM(options); i++)
if (options[i].c && Flag(i)) if (options[i].c && Flag(i))
@ -355,6 +357,7 @@ parse_args(argv, what, setargsp)
char *array = (char *) 0; char *array = (char *) 0;
Getopt go; Getopt go;
int i, optc, set, sortargs = 0, arrayset = 0; int i, optc, set, sortargs = 0, arrayset = 0;
unsigned u;
/* First call? Build option strings... */ /* First call? Build option strings... */
if (cmd_opts[0] == '\0') { if (cmd_opts[0] == '\0') {
@ -366,12 +369,12 @@ parse_args(argv, what, setargsp)
/* see set_opts[] declaration */ /* see set_opts[] declaration */
strlcpy(set_opts, "A:o;s", sizeof set_opts); strlcpy(set_opts, "A:o;s", sizeof set_opts);
q = set_opts + strlen(set_opts); q = set_opts + strlen(set_opts);
for (i = 0; i < NELEM(options); i++) { for (u = 0; u < NELEM(options); u++) {
if (options[i].c) { if (options[u].c) {
if (options[i].flags & OF_CMDLINE) if (options[u].flags & OF_CMDLINE)
*p++ = options[i].c; *p++ = options[u].c;
if (options[i].flags & OF_SET) if (options[u].flags & OF_SET)
*q++ = options[i].c; *q++ = options[u].c;
} }
} }
*p = '\0'; *p = '\0';
@ -434,15 +437,15 @@ parse_args(argv, what, setargsp)
sortargs = 1; sortargs = 1;
break; break;
} }
for (i = 0; i < NELEM(options); i++) for (u = 0; u < NELEM(options); u++)
if (optc == options[i].c if (optc == options[u].c
&& (what & options[i].flags)) && (what & options[u].flags))
{ {
change_flag((enum sh_flag) i, what, change_flag((enum sh_flag) u, what,
set); set);
break; break;
} }
if (i == NELEM(options)) { if (u == NELEM(options)) {
internal_errorf(1, "parse_args: '%c'", optc); internal_errorf(1, "parse_args: '%c'", optc);
return -1; /* not reached */ return -1; /* not reached */
} }
@ -538,7 +541,7 @@ gmatch(s, p, isfile)
* the pattern. If check fails, just to a strcmp(). * the pattern. If check fails, just to a strcmp().
*/ */
if (!isfile && !has_globbing(p, pe)) { if (!isfile && !has_globbing(p, pe)) {
int len = pe - p + 1; size_t len = pe - p + 1;
char tbuf[64]; char tbuf[64];
char *t = len <= sizeof(tbuf) ? tbuf char *t = len <= sizeof(tbuf) ? tbuf
: (char *) alloc(len, ATEMP); : (char *) alloc(len, ATEMP);
@ -627,7 +630,7 @@ do_gmatch(s, se, p, pe, isfile)
const unsigned char *se, *pe; const unsigned char *se, *pe;
int isfile; int isfile;
{ {
register int sc, pc; int sc, pc;
const unsigned char *prest, *psub, *pnext; const unsigned char *prest, *psub, *pnext;
const unsigned char *srest; const unsigned char *srest;
@ -759,9 +762,9 @@ do_gmatch(s, se, p, pe, isfile)
static const unsigned char * static const unsigned char *
cclass(p, sub) cclass(p, sub)
const unsigned char *p; const unsigned char *p;
register int sub; int sub;
{ {
register int c, d, not, found = 0; int c, d, not, found = 0;
const unsigned char *orig_p = p; const unsigned char *orig_p = p;
if ((not = (ISMAGIC(*p) && *++p == NOT))) if ((not = (ISMAGIC(*p) && *++p == NOT)))
@ -841,10 +844,10 @@ qsortp(base, n, f)
} }
#define swap2(a, b) {\ #define swap2(a, b) {\
register void *t; t = *(a); *(a) = *(b); *(b) = t;\ void *t; t = *(a); *(a) = *(b); *(b) = t;\
} }
#define swap3(a, b, c) {\ #define swap3(a, b, c) {\
register void *t; t = *(a); *(a) = *(c); *(c) = *(b); *(b) = t;\ void *t; t = *(a); *(a) = *(c); *(c) = *(b); *(b) = t;\
} }
static void static void
@ -852,8 +855,8 @@ qsort1(base, lim, f)
void **base, **lim; void **base, **lim;
int (*f) ARGS((void *, void *)); int (*f) ARGS((void *, void *));
{ {
register void **i, **j; void **i, **j;
register void **lptr, **hptr; void **lptr, **hptr;
size_t n; size_t n;
int c; int c;

10
path.c
View File

@ -1,9 +1,11 @@
/** $MirBSD: path.c,v 1.4 2004/09/21 14:03:58 tg Exp $ */ /** $MirBSD: path.c,v 1.5 2004/10/28 11:03:24 tg Exp $ */
/* $OpenBSD: path.c,v 1.9 2003/10/22 07:40:38 jmc Exp $ */ /* $OpenBSD: path.c,v 1.9 2003/10/22 07:40:38 jmc Exp $ */
#include "sh.h" #include "sh.h"
#include "ksh_stat.h" #include "ksh_stat.h"
__RCSID("$MirBSD: path.c,v 1.5 2004/10/28 11:03:24 tg Exp $");
/* /*
* Contains a routine to search a : separated list of * Contains a routine to search a : separated list of
* paths (a la CDPATH) and make appropriate file names. * paths (a la CDPATH) and make appropriate file names.
@ -241,8 +243,8 @@ do_phys_path(xsp, xp, path)
const char *path; const char *path;
{ {
const char *p, *q; const char *p, *q;
int len, llen; size_t len;
int savepos; int savepos, llen;
char lbuf[PATH_MAX]; char lbuf[PATH_MAX];
Xcheck(*xsp, xp); Xcheck(*xsp, xp);
@ -251,7 +253,7 @@ do_phys_path(xsp, xp, path)
p++; p++;
if (!*p) if (!*p)
break; break;
len = (q = ksh_strchr_dirsep(p)) ? q - p : strlen(p); len = (q = ksh_strchr_dirsep(p)) ? (size_t)(q - p) : strlen(p);
if (len == 1 && p[0] == '.') if (len == 1 && p[0] == '.')
continue; continue;
if (len == 2 && p[0] == '.' && p[1] == '.') { if (len == 2 && p[0] == '.' && p[1] == '.') {

View File

@ -1,4 +1,4 @@
/** $MirBSD: proto.h,v 1.5 2004/09/21 11:57:13 tg Exp $ */ /** $MirBSD: proto.h,v 1.6 2004/10/28 11:03:24 tg Exp $ */
/* $OpenBSD: proto.h,v 1.11 2003/05/16 19:58:57 jsyn Exp $ */ /* $OpenBSD: proto.h,v 1.11 2003/05/16 19:58:57 jsyn Exp $ */
/* $From: proto.h,v 1.3 1994/05/19 18:32:40 michael Exp michael $ */ /* $From: proto.h,v 1.3 1994/05/19 18:32:40 michael Exp michael $ */
@ -89,7 +89,7 @@ void hist_init ARGS((Source *s));
void hist_finish ARGS((void)); void hist_finish ARGS((void));
void histsave ARGS((int lno, const char *cmd, int dowrite)); void histsave ARGS((int lno, const char *cmd, int dowrite));
#ifdef HISTORY #ifdef HISTORY
int c_fc ARGS((register char **wp)); int c_fc ARGS((char **wp));
void sethistsize ARGS((int n)); void sethistsize ARGS((int n));
void sethistfile ARGS((const char *name)); void sethistfile ARGS((const char *name));
# ifdef EASY_HISTORY # ifdef EASY_HISTORY

View File

@ -1,5 +1,5 @@
#!/bin/sh #!/bin/sh
# $MirBSD: siglist.sh,v 1.2 2004/05/24 19:56:19 tg Stab $ # $MirBSD: siglist.sh,v 1.3 2004/10/28 11:03:24 tg Exp $
# $OpenBSD: siglist.sh,v 1.4 1997/06/19 13:58:47 kstailey Exp $ # $OpenBSD: siglist.sh,v 1.4 1997/06/19 13:58:47 kstailey Exp $
# #
# Script to generate a sorted, complete list of signals, suitable # Script to generate a sorted, complete list of signals, suitable
@ -18,9 +18,9 @@ CPP="${1-cc -E}"
# The trap here to make up for a bug in bash (1.14.3(1)) that calls the trap # The trap here to make up for a bug in bash (1.14.3(1)) that calls the trap
(trap $trapsigs; (trap $trapsigs;
echo '#include "sh.h"'; echo '#include "sh.h"';
echo ' { QwErTy SIGNALS , "DUMMY" , "hook for number of signals" },'; echo ' { QwErTy SIGNALS , "DUMMY" , "hook for number of signals", 0, 0, 0, 0, 0 },';
sed -e '/^[ ]*#/d' -e 's/^[ ]*\([^ ][^ ]*\)[ ][ ]*\(.*[^ ]\)[ ]*$/#ifdef SIG\1\ sed -e '/^[ ]*#/d' -e 's/^[ ]*\([^ ][^ ]*\)[ ][ ]*\(.*[^ ]\)[ ]*$/#ifdef SIG\1\
{ QwErTy SIG\1 , "\1", "\2" },\ { QwErTy SIG\1 , "\1", "\2", 0, 0, 0, 0, 0 },\
#endif/') > $in #endif/') > $in
$CPP $in > $out $CPP $in > $out
sed -n 's/{ QwErTy/{/p' < $out | awk '{print NR, $0}' | sort +2n +0n | sed -n 's/{ QwErTy/{/p' < $out | awk '{print NR, $0}' | sort +2n +0n |

65
syn.c
View File

@ -1,4 +1,4 @@
/** $MirBSD: syn.c,v 1.4 2004/09/21 11:57:14 tg Exp $ */ /** $MirBSD: syn.c,v 1.5 2004/10/28 11:03:24 tg Exp $ */
/* $OpenBSD: syn.c,v 1.14 2003/10/22 07:40:38 jmc Exp $ */ /* $OpenBSD: syn.c,v 1.14 2003/10/22 07:40:38 jmc Exp $ */
/* /*
@ -8,6 +8,8 @@
#include "sh.h" #include "sh.h"
#include "c_test.h" #include "c_test.h"
__RCSID("$MirBSD: syn.c,v 1.5 2004/10/28 11:03:24 tg Exp $");
struct nesting_state { struct nesting_state {
int start_token; /* token than began nesting (eg, FOR) */ int start_token; /* token than began nesting (eg, FOR) */
int start_line; /* line nesting began on */ int start_line; /* line nesting began on */
@ -79,7 +81,7 @@ static struct op *
pipeline(cf) pipeline(cf)
int cf; int cf;
{ {
register struct op *t, *p, *tl = NULL; struct op *t, *p, *tl = NULL;
t = get_command(cf); t = get_command(cf);
if (t != NULL) { if (t != NULL) {
@ -99,8 +101,8 @@ pipeline(cf)
static struct op * static struct op *
andor() andor()
{ {
register struct op *t, *p; struct op *t, *p;
register int c; int c;
t = pipeline(0); t = pipeline(0);
if (t != NULL) { if (t != NULL) {
@ -118,8 +120,8 @@ static struct op *
c_list(multi) c_list(multi)
int multi; int multi;
{ {
register struct op *t = NULL, *p, *tl = NULL; struct op *t = NULL, *p, *tl = NULL;
register int c; int c;
int have_sep; int have_sep;
while (1) { while (1) {
@ -156,7 +158,7 @@ static struct ioword *
synio(cf) synio(cf)
int cf; int cf;
{ {
register struct ioword *iop; struct ioword *iop;
int ishere; int ishere;
if (tpeek(cf) != REDIR) if (tpeek(cf) != REDIR)
@ -189,7 +191,7 @@ static struct op *
nested(type, smark, emark) nested(type, smark, emark)
int type, smark, emark; int type, smark, emark;
{ {
register struct op *t; struct op *t;
struct nesting_state old_nesting; struct nesting_state old_nesting;
nesting_push(&old_nesting, smark); nesting_push(&old_nesting, smark);
@ -203,8 +205,8 @@ static struct op *
get_command(cf) get_command(cf)
int cf; int cf;
{ {
register struct op *t; struct op *t;
register int c, iopn = 0, syniocf; int c, iopn = 0, syniocf;
struct ioword *iop, **iops; struct ioword *iop, **iops;
XPtrV args, vars; XPtrV args, vars;
struct nesting_state old_nesting; struct nesting_state old_nesting;
@ -419,8 +421,8 @@ get_command(cf)
static struct op * static struct op *
dogroup() dogroup()
{ {
register int c; int c;
register struct op *list; struct op *list;
c = token(CONTIN|KEYWORD|ALIAS); c = token(CONTIN|KEYWORD|ALIAS);
/* A {...} can be used instead of do...done for for/select loops /* A {...} can be used instead of do...done for for/select loops
@ -442,7 +444,7 @@ dogroup()
static struct op * static struct op *
thenpart() thenpart()
{ {
register struct op *t; struct op *t;
musthave(THEN, KEYWORD|ALIAS); musthave(THEN, KEYWORD|ALIAS);
t = newtp(0); t = newtp(0);
@ -456,7 +458,7 @@ thenpart()
static struct op * static struct op *
elsepart() elsepart()
{ {
register struct op *t; struct op *t;
switch (token(KEYWORD|ALIAS|VARASN)) { switch (token(KEYWORD|ALIAS|VARASN)) {
case ELSE: case ELSE:
@ -479,7 +481,7 @@ elsepart()
static struct op * static struct op *
caselist() caselist()
{ {
register struct op *t, *tl; struct op *t, *tl;
int c; int c;
c = token(CONTIN|KEYWORD|ALIAS); c = token(CONTIN|KEYWORD|ALIAS);
@ -506,8 +508,8 @@ static struct op *
casepart(endtok) casepart(endtok)
int endtok; int endtok;
{ {
register struct op *t; struct op *t;
register int c; int c;
XPtrV ptns; XPtrV ptns;
XPinit(ptns, 16); XPinit(ptns, 16);
@ -595,7 +597,7 @@ function_body(name, ksh_func)
static char ** static char **
wordlist() wordlist()
{ {
register int c; int c;
XPtrV args; XPtrV args;
XPinit(args, 16); XPinit(args, 16);
@ -628,7 +630,7 @@ block(type, t1, t2, wp)
struct op *t1, *t2; struct op *t1, *t2;
char **wp; char **wp;
{ {
register struct op *t; struct op *t;
t = newtp(type); t = newtp(type);
t->left = t1; t->left = t1;
@ -677,14 +679,14 @@ const struct tokeninfo {
#endif /* KSH */ #endif /* KSH */
/* and some special cases... */ /* and some special cases... */
{ "newline", '\n', FALSE }, { "newline", '\n', FALSE },
{ 0 } { NULL, 0, FALSE }
}; };
void void
initkeywords() initkeywords()
{ {
register struct tokeninfo const *tt; struct tokeninfo const *tt;
register struct tbl *p; struct tbl *p;
tinit(&keywords, APERM, 32); /* must be 2^n (currently 20 keywords) */ tinit(&keywords, APERM, 32); /* must be 2^n (currently 20 keywords) */
for (tt = tokentab; tt->name; tt++) { for (tt = tokentab; tt->name; tt++) {
@ -771,7 +773,7 @@ static struct op *
newtp(type) newtp(type)
int type; int type;
{ {
register struct op *t; struct op *t;
t = (struct op *) alloc(sizeof(*t), ATEMP); t = (struct op *) alloc(sizeof(*t), ATEMP);
t->type = type; t->type = type;
@ -901,10 +903,8 @@ dbtestp_isa(te, meta)
} }
static const char * static const char *
dbtestp_getopnd(te, op, do_eval) dbtestp_getopnd(Test_env *te, Test_op op GCC_FUNC_ATTR(unused),
Test_env *te; int do_eval GCC_FUNC_ATTR(unused))
Test_op op;
int do_eval;
{ {
int c = tpeek(ARRAYVAR); int c = tpeek(ARRAYVAR);
@ -918,12 +918,11 @@ dbtestp_getopnd(te, op, do_eval)
} }
static int static int
dbtestp_eval(te, op, opnd1, opnd2, do_eval) dbtestp_eval(Test_env *te GCC_FUNC_ATTR(unused),
Test_env *te; Test_op op GCC_FUNC_ATTR(unused),
Test_op op; const char *opnd1 GCC_FUNC_ATTR(unused),
const char *opnd1; const char *opnd2 GCC_FUNC_ATTR(unused),
const char *opnd2; int do_eval GCC_FUNC_ATTR(unused))
int do_eval;
{ {
return 1; return 1;
} }

42
table.c
View File

@ -1,4 +1,4 @@
/** $MirBSD: table.c,v 1.3 2004/09/21 11:57:15 tg Exp $ */ /** $MirBSD: table.c,v 1.4 2004/10/28 11:03:24 tg Exp $ */
/* $OpenBSD: table.c,v 1.5 1999/01/10 17:55:03 millert Exp $ */ /* $OpenBSD: table.c,v 1.5 1999/01/10 17:55:03 millert Exp $ */
/* /*
@ -15,9 +15,9 @@ static int tnamecmp ARGS((void *p1, void *p2));
unsigned int unsigned int
hash(n) hash(n)
register const char * n; const char * n;
{ {
register unsigned int h = 0; unsigned int h = 0;
while (*n != '\0') while (*n != '\0')
h = 2*h + *n++; h = 2*h + *n++;
@ -26,8 +26,8 @@ hash(n)
void void
tinit(tp, ap, tsize) tinit(tp, ap, tsize)
register struct table *tp; struct table *tp;
register Area *ap; Area *ap;
int tsize; int tsize;
{ {
tp->areap = ap; tp->areap = ap;
@ -39,12 +39,12 @@ tinit(tp, ap, tsize)
static void static void
texpand(tp, nsize) texpand(tp, nsize)
register struct table *tp; struct table *tp;
int nsize; int nsize;
{ {
register int i; int i;
register struct tbl *tblp, **p; struct tbl *tblp, **p;
register struct tbl **ntblp, **otblp = tp->tbls; struct tbl **ntblp, **otblp = tp->tbls;
int osize = tp->size; int osize = tp->size;
ntblp = (struct tbl**) alloc(sizeofN(struct tbl *, nsize), tp->areap); ntblp = (struct tbl**) alloc(sizeofN(struct tbl *, nsize), tp->areap);
@ -74,11 +74,11 @@ texpand(tp, nsize)
struct tbl * struct tbl *
tsearch(tp, n, h) tsearch(tp, n, h)
register struct table *tp; /* table */ struct table *tp; /* table */
register const char *n; /* name to enter */ const char *n; /* name to enter */
unsigned int h; /* hash(n) */ unsigned int h; /* hash(n) */
{ {
register struct tbl **pp, *p; struct tbl **pp, *p;
if (tp->size == 0) if (tp->size == 0)
return NULL; return NULL;
@ -97,12 +97,12 @@ tsearch(tp, n, h)
struct tbl * struct tbl *
tenter(tp, n, h) tenter(tp, n, h)
register struct table *tp; /* table */ struct table *tp; /* table */
register const char *n; /* name to enter */ const char *n; /* name to enter */
unsigned int h; /* hash(n) */ unsigned int h; /* hash(n) */
{ {
register struct tbl **pp, *p; struct tbl **pp, *p;
register int len; int len;
if (tp->size == 0) if (tp->size == 0)
texpand(tp, INIT_TBLS); texpand(tp, INIT_TBLS);
@ -139,7 +139,7 @@ tenter(tp, n, h)
void void
tdelete(p) tdelete(p)
register struct tbl *p; struct tbl *p;
{ {
p->flag = 0; p->flag = 0;
} }
@ -174,10 +174,10 @@ tnamecmp(p1, p2)
struct tbl ** struct tbl **
tsort(tp) tsort(tp)
register struct table *tp; struct table *tp;
{ {
register int i; int i;
register struct tbl **p, **sp, **dp; struct tbl **p, **sp, **dp;
p = (struct tbl **)alloc(sizeofN(struct tbl *, tp->size+1), ATEMP); p = (struct tbl **)alloc(sizeofN(struct tbl *, tp->size+1), ATEMP);
sp = tp->tbls; /* source */ sp = tp->tbls; /* source */
@ -212,7 +212,7 @@ tprintinfo(tp)
shellf(" Ncmp name\n"); shellf(" Ncmp name\n");
twalk(&ts, tp); twalk(&ts, tp);
while ((te = tnext(&ts))) { while ((te = tnext(&ts))) {
register struct tbl **pp, *p; struct tbl **pp, *p;
h = hash(n = te->name); h = hash(n = te->name);
ncmp = 0; ncmp = 0;

15
trap.c
View File

@ -1,4 +1,4 @@
/** $MirBSD: trap.c,v 1.3 2004/09/21 11:57:16 tg Exp $ */ /** $MirBSD: trap.c,v 1.4 2004/10/28 11:03:24 tg Exp $ */
/* $OpenBSD: trap.c,v 1.13 2003/02/28 09:45:09 jmc Exp $ */ /* $OpenBSD: trap.c,v 1.13 2003/02/28 09:45:09 jmc Exp $ */
/* /*
@ -9,15 +9,17 @@
#define FROM_TRAP_C #define FROM_TRAP_C
#include "sh.h" #include "sh.h"
__RCSID("$MirBSD: trap.c,v 1.4 2004/10/28 11:03:24 tg Exp $");
/* Table is indexed by signal number /* Table is indexed by signal number
* *
* The script siglist.sh generates siglist.out, which is a sorted, complete * The script siglist.sh generates siglist.out, which is a sorted, complete
* list of signals * list of signals
*/ */
Trap sigtraps[SIGNALS+1] = { Trap sigtraps[SIGNALS+1] = {
{ SIGEXIT_, "EXIT", "Signal 0" }, { SIGEXIT_, "EXIT", "Signal 0", NULL, 0, 0, 0, 0 },
#include "siglist.out" /* generated by siglist.sh */ #include "siglist.out" /* generated by siglist.sh */
{ SIGERR_, "ERR", "Error handler" }, { SIGERR_, "ERR", "Error handler", NULL, 0, 0, 0, 0 },
}; };
static struct sigaction Sigact_ign, Sigact_trap; static struct sigaction Sigact_ign, Sigact_trap;
@ -68,8 +70,7 @@ alarm_init()
} }
static RETSIGTYPE static RETSIGTYPE
alarm_catcher(sig) alarm_catcher(int sig GCC_FUNC_ATTR(unused))
int sig;
{ {
int errno_ = errno; int errno_ = errno;
@ -93,7 +94,7 @@ gettrap(name, igncase)
int igncase; int igncase;
{ {
int i; int i;
register Trap *p; Trap *p;
if (digit(*name)) { if (digit(*name)) {
int n; int n;
@ -201,7 +202,7 @@ runtraps(flag)
int flag; int flag;
{ {
int i; int i;
register Trap *p; Trap *p;
#ifdef KSH #ifdef KSH
if (ksh_tmout_state == TMOUT_LEAVING) { if (ksh_tmout_state == TMOUT_LEAVING) {

68
tree.c
View File

@ -1,4 +1,4 @@
/** $MirBSD: tree.c,v 1.3 2004/09/21 11:57:16 tg Exp $ */ /** $MirBSD: tree.c,v 1.4 2004/10/28 11:03:24 tg Exp $ */
/* $OpenBSD: tree.c,v 1.10 2002/02/27 19:37:09 dhartmei Exp $ */ /* $OpenBSD: tree.c,v 1.10 2002/02/27 19:37:09 dhartmei Exp $ */
/* /*
@ -7,6 +7,8 @@
#include "sh.h" #include "sh.h"
__RCSID("$MirBSD: tree.c,v 1.4 2004/10/28 11:03:24 tg Exp $");
#define INDENT 4 #define INDENT 4
#define tputc(c, shf) shf_putchar(c, shf); #define tputc(c, shf) shf_putchar(c, shf);
@ -24,11 +26,11 @@ static void iofree ARGS((struct ioword **iow, Area *ap));
static void static void
ptree(t, indent, shf) ptree(t, indent, shf)
register struct op *t; struct op *t;
int indent; int indent;
register struct shf *shf; struct shf *shf;
{ {
register char **w; char **w;
struct ioword **ioact; struct ioword **ioact;
struct op *t1; struct op *t1;
@ -211,9 +213,9 @@ ptree(t, indent, shf)
static void static void
pioact(shf, indent, iop) pioact(shf, indent, iop)
register struct shf *shf; struct shf *shf;
int indent; int indent;
register struct ioword *iop; struct ioword *iop;
{ {
int flag = iop->flag; int flag = iop->flag;
int type = flag & IOTYPE; int type = flag & IOTYPE;
@ -272,8 +274,8 @@ pioact(shf, indent, iop)
static void static void
tputC(c, shf) tputC(c, shf)
register int c; int c;
register struct shf *shf; struct shf *shf;
{ {
if ((c&0x60) == 0) { /* C0|C1 */ if ((c&0x60) == 0) { /* C0|C1 */
tputc((c&0x80) ? '$' : '^', shf); tputc((c&0x80) ? '$' : '^', shf);
@ -287,10 +289,10 @@ tputC(c, shf)
static void static void
tputS(wp, shf) tputS(wp, shf)
register char *wp; char *wp;
register struct shf *shf; struct shf *shf;
{ {
register int c, quoted=0; int c, quoted=0;
/* problems: /* problems:
* `...` -> $(...) * `...` -> $(...)
@ -415,17 +417,17 @@ snptreef(s, n, fmt, va_alist)
static void static void
vfptreef(shf, indent, fmt, va) vfptreef(shf, indent, fmt, va)
register struct shf *shf; struct shf *shf;
int indent; int indent;
const char *fmt; const char *fmt;
register va_list va; va_list va;
{ {
register int c; int c;
while ((c = *fmt++)) while ((c = *fmt++))
if (c == '%') { if (c == '%') {
register long n; long n;
register char *p; char *p;
int neg; int neg;
switch ((c = *fmt++)) { switch ((c = *fmt++)) {
@ -442,9 +444,9 @@ vfptreef(shf, indent, fmt, va)
tputS(p, shf); tputS(p, shf);
break; break;
case 'd': case 'u': /* decimal */ case 'd': case 'u': /* decimal */
n = (c == 'd') ? va_arg(va, int) n = (c == 'd') ? (long)(va_arg(va, int))
: va_arg(va, unsigned int); : (long)(va_arg(va, unsigned int));
neg = c=='d' && n<0; neg = (c == 'd') && (n < 0);
p = ulton((neg) ? -n : n, 10); p = ulton((neg) ? -n : n, 10);
if (neg) if (neg)
*--p = '-'; *--p = '-';
@ -487,11 +489,11 @@ vfptreef(shf, indent, fmt, va)
struct op * struct op *
tcopy(t, ap) tcopy(t, ap)
register struct op *t; struct op *t;
Area *ap; Area *ap;
{ {
register struct op *r; struct op *r;
register char **tw, **rw; char **tw, **rw;
if (t == NULL) if (t == NULL)
return NULL; return NULL;
@ -548,10 +550,10 @@ wdcopy(wp, ap)
/* return the position of prefix c in wp plus 1 */ /* return the position of prefix c in wp plus 1 */
char * char *
wdscan(wp, c) wdscan(wp, c)
register const char *wp; const char *wp;
register int c; int c;
{ {
register int nest = 0; int nest = 0;
while (1) while (1)
switch (*wp++) { switch (*wp++) {
@ -674,18 +676,18 @@ wdstrip(wp)
static struct ioword ** static struct ioword **
iocopy(iow, ap) iocopy(iow, ap)
register struct ioword **iow; struct ioword **iow;
Area *ap; Area *ap;
{ {
register struct ioword **ior; struct ioword **ior;
register int i; int i;
for (ior = iow; *ior++ != NULL; ) for (ior = iow; *ior++ != NULL; )
; ;
ior = (struct ioword **) alloc((ior - iow + 1) * sizeof(*ior), ap); ior = (struct ioword **) alloc((ior - iow + 1) * sizeof(*ior), ap);
for (i = 0; iow[i] != NULL; i++) { for (i = 0; iow[i] != NULL; i++) {
register struct ioword *p, *q; struct ioword *p, *q;
p = iow[i]; p = iow[i];
q = (struct ioword *) alloc(sizeof(*p), ap); q = (struct ioword *) alloc(sizeof(*p), ap);
@ -709,10 +711,10 @@ iocopy(iow, ap)
void void
tfree(t, ap) tfree(t, ap)
register struct op *t; struct op *t;
Area *ap; Area *ap;
{ {
register char **w; char **w;
if (t == NULL) if (t == NULL)
return; return;
@ -746,8 +748,8 @@ iofree(iow, ap)
struct ioword **iow; struct ioword **iow;
Area *ap; Area *ap;
{ {
register struct ioword **iop; struct ioword **iop;
register struct ioword *p; struct ioword *p;
for (iop = iow; (p = *iop++) != NULL; ) { for (iop = iow; (p = *iop++) != NULL; ) {
if (p->name != NULL) if (p->name != NULL)

9
tty.c
View File

@ -1,4 +1,4 @@
/** $MirBSD: tty.c,v 1.3 2004/09/21 11:57:16 tg Exp $ */ /** $MirBSD: tty.c,v 1.4 2004/10/28 11:03:24 tg Exp $ */
/* $OpenBSD: tty.c,v 1.2 1996/10/01 02:05:51 downsj Exp $ */ /* $OpenBSD: tty.c,v 1.2 1996/10/01 02:05:51 downsj Exp $ */
#include "sh.h" #include "sh.h"
@ -7,6 +7,8 @@
#include "tty.h" #include "tty.h"
#undef EXTERN #undef EXTERN
__RCSID("$MirBSD: tty.c,v 1.4 2004/10/28 11:03:24 tg Exp $");
int int
get_tty(fd, ts) get_tty(fd, ts)
int fd; int fd;
@ -38,10 +40,7 @@ get_tty(fd, ts)
} }
int int
set_tty(fd, ts, flags) set_tty(int fd, TTY_state *ts, int flags GCC_FUNC_ATTR(unused))
int fd;
TTY_state *ts;
int flags;
{ {
int ret = 0; int ret = 0;

76
var.c
View File

@ -1,4 +1,4 @@
/** $MirBSD: var.c,v 1.8 2004/09/21 11:57:17 tg Exp $ */ /** $MirBSD: var.c,v 1.9 2004/10/28 11:03:24 tg Exp $ */
/* $OpenBSD: var.c,v 1.17 2004/05/08 19:42:35 deraadt Exp $ */ /* $OpenBSD: var.c,v 1.17 2004/05/08 19:42:35 deraadt Exp $ */
#include "sh.h" #include "sh.h"
@ -34,7 +34,7 @@ static struct tbl *arraysearch ARGS((struct tbl *, int));
void void
newblock() newblock()
{ {
register struct block *l; struct block *l;
static char *const empty[] = {null}; static char *const empty[] = {null};
l = (struct block *) alloc(sizeof(struct block), ATEMP); l = (struct block *) alloc(sizeof(struct block), ATEMP);
@ -60,9 +60,9 @@ newblock()
void void
popblock() popblock()
{ {
register struct block *l = e->loc; struct block *l = e->loc;
register struct tbl *vp, **vpp = l->vars.tbls, *vq; struct tbl *vp, **vpp = l->vars.tbls, *vq;
register int i; int i;
e->loc = l->next; /* pop block */ e->loc = l->next; /* pop block */
for (i = l->vars.size; --i >= 0; ) for (i = l->vars.size; --i >= 0; )
@ -163,11 +163,11 @@ array_index_calc(n, arrayp, valp)
*/ */
struct tbl * struct tbl *
global(n) global(n)
register const char *n; const char *n;
{ {
register struct block *l = e->loc; struct block *l = e->loc;
register struct tbl *vp; struct tbl *vp;
register int c; int c;
unsigned h; unsigned h;
bool_t array; bool_t array;
int val; int val;
@ -246,11 +246,11 @@ global(n)
*/ */
struct tbl * struct tbl *
local(n, copy) local(n, copy)
register const char *n; const char *n;
bool_t copy; bool_t copy;
{ {
register struct block *l = e->loc; struct block *l = e->loc;
register struct tbl *vp; struct tbl *vp;
unsigned h; unsigned h;
bool_t array; bool_t array;
int val; int val;
@ -292,7 +292,7 @@ local(n, copy)
/* get variable string value */ /* get variable string value */
char * char *
str_val(vp) str_val(vp)
register struct tbl *vp; struct tbl *vp;
{ {
char *s; char *s;
@ -309,8 +309,8 @@ str_val(vp)
const char *digits = (vp->flag & UCASEV_AL) ? const char *digits = (vp->flag & UCASEV_AL) ?
"0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ" "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ"
: "0123456789abcdefghijklmnopqrstuvwxyz"; : "0123456789abcdefghijklmnopqrstuvwxyz";
register unsigned long n; unsigned long n;
register int base; int base;
s = strbuf + sizeof(strbuf); s = strbuf + sizeof(strbuf);
if (vp->flag & INT_U) if (vp->flag & INT_U)
@ -341,7 +341,7 @@ str_val(vp)
/* get variable integer value, with error checking */ /* get variable integer value, with error checking */
long long
intval(vp) intval(vp)
register struct tbl *vp; struct tbl *vp;
{ {
long num; long num;
int base; int base;
@ -356,7 +356,7 @@ intval(vp)
/* set variable to string value */ /* set variable to string value */
int int
setstr(vq, s, error_ok) setstr(vq, s, error_ok)
register struct tbl *vq; struct tbl *vq;
const char *s; const char *s;
int error_ok; int error_ok;
{ {
@ -400,11 +400,11 @@ setstr(vq, s, error_ok)
/* set variable to integer */ /* set variable to integer */
void void
setint(vq, n) setint(vq, n)
register struct tbl *vq; struct tbl *vq;
long n; long n;
{ {
if (!(vq->flag&INTEGER)) { if (!(vq->flag&INTEGER)) {
register struct tbl *vp = &vtemp; struct tbl *vp = &vtemp;
vp->flag = (ISSET|INTEGER); vp->flag = (ISSET|INTEGER);
vp->type = 0; vp->type = 0;
vp->areap = ATEMP; vp->areap = ATEMP;
@ -423,8 +423,8 @@ getint(vp, nump)
struct tbl *vp; struct tbl *vp;
long *nump; long *nump;
{ {
register char *s; char *s;
register int c; int c;
int base, neg; int base, neg;
int have_base = 0; int have_base = 0;
long num; long num;
@ -479,7 +479,7 @@ getint(vp, nump)
*/ */
struct tbl * struct tbl *
setint_v(vq, vp) setint_v(vq, vp)
register struct tbl *vq, *vp; struct tbl *vq, *vp;
{ {
int base; int base;
long num; long num;
@ -565,10 +565,10 @@ formatstr(vp, s)
*/ */
static void static void
export(vp, val) export(vp, val)
register struct tbl *vp; struct tbl *vp;
const char *val; const char *val;
{ {
register char *xp; char *xp;
char *op = (vp->flag&ALLOC) ? vp->val.s : NULL; char *op = (vp->flag&ALLOC) ? vp->val.s : NULL;
int namelen = strlen(vp->name); int namelen = strlen(vp->name);
int vallen = strlen(val) + 1; int vallen = strlen(val) + 1;
@ -591,11 +591,11 @@ export(vp, val)
*/ */
struct tbl * struct tbl *
typeset(var, set, clr, field, base) typeset(var, set, clr, field, base)
register const char *var; const char *var;
Tflag clr, set; Tflag clr, set;
int field, base; int field, base;
{ {
register struct tbl *vp; struct tbl *vp;
struct tbl *vpbase, *t; struct tbl *vpbase, *t;
char *tvar; char *tvar;
const char *val; const char *val;
@ -745,7 +745,7 @@ typeset(var, set, clr, field, base)
*/ */
void void
unset(vp, array_ref) unset(vp, array_ref)
register struct tbl *vp; struct tbl *vp;
int array_ref; int array_ref;
{ {
if (vp->flag & ALLOC) if (vp->flag & ALLOC)
@ -851,16 +851,16 @@ makenv()
{ {
struct block *l = e->loc; struct block *l = e->loc;
XPtrV env; XPtrV env;
register struct tbl *vp, **vpp; struct tbl *vp, **vpp;
register int i; int i;
XPinit(env, 64); XPinit(env, 64);
for (l = e->loc; l != NULL; l = l->next) for (l = e->loc; l != NULL; l = l->next)
for (vpp = l->vars.tbls, i = l->vars.size; --i >= 0; ) for (vpp = l->vars.tbls, i = l->vars.size; --i >= 0; )
if ((vp = *vpp++) != NULL if ((vp = *vpp++) != NULL
&& (vp->flag&(ISSET|EXPORT)) == (ISSET|EXPORT)) { && (vp->flag&(ISSET|EXPORT)) == (ISSET|EXPORT)) {
register struct block *l2; struct block *l2;
register struct tbl *vp2; struct tbl *vp2;
unsigned h = hash(vp->name); unsigned h = hash(vp->name);
/* unexport any redefined instances */ /* unexport any redefined instances */
@ -899,9 +899,9 @@ change_random()
/* Test if name is a special parameter */ /* Test if name is a special parameter */
static int static int
special(name) special(name)
register const char * name; const char * name;
{ {
register struct tbl *tp; struct tbl *tp;
tp = tsearch(&specials, name, hash(name)); tp = tsearch(&specials, name, hash(name));
return tp && (tp->flag & ISSET) ? tp->type : V_NONE; return tp && (tp->flag & ISSET) ? tp->type : V_NONE;
@ -910,9 +910,9 @@ special(name)
/* Make a variable non-special */ /* Make a variable non-special */
static void static void
unspecial(name) unspecial(name)
register const char * name; const char * name;
{ {
register struct tbl *tp; struct tbl *tp;
tp = tsearch(&specials, name, hash(name)); tp = tsearch(&specials, name, hash(name));
if (tp) if (tp)
@ -926,7 +926,7 @@ static int user_lineno; /* what user set $LINENO to */
static void static void
getspec(vp) getspec(vp)
register struct tbl *vp; struct tbl *vp;
{ {
switch (special(vp->name)) { switch (special(vp->name)) {
#ifdef KSH #ifdef KSH
@ -968,7 +968,7 @@ getspec(vp)
static void static void
setspec(vp) setspec(vp)
register struct tbl *vp; struct tbl *vp;
{ {
char *s; char *s;
@ -1069,7 +1069,7 @@ setspec(vp)
static void static void
unsetspec(vp) unsetspec(vp)
register struct tbl *vp; struct tbl *vp;
{ {
switch (special(vp->name)) { switch (special(vp->name)) {
case V_PATH: case V_PATH:

12
vi.c
View File

@ -1,4 +1,4 @@
/** $MirBSD: vi.c,v 1.7 2004/09/21 11:57:17 tg Exp $ */ /** $MirBSD: vi.c,v 1.8 2004/10/28 11:03:24 tg Exp $ */
/* $OpenBSD: vi.c,v 1.13 2004/05/10 16:28:47 pvalchev Exp $ */ /* $OpenBSD: vi.c,v 1.13 2004/05/10 16:28:47 pvalchev Exp $ */
/* /*
@ -15,6 +15,8 @@
#include "ksh_stat.h" /* completion */ #include "ksh_stat.h" /* completion */
#include "edit.h" #include "edit.h"
__RCSID("$MirBSD: vi.c,v 1.8 2004/10/28 11:03:24 tg Exp $");
#define Ctrl(c) (c&0x1f) #define Ctrl(c) (c&0x1f)
#define is_wordch(c) (letnum(c)) #define is_wordch(c) (letnum(c))
@ -238,7 +240,7 @@ x_vi(buf, len)
x_putc('\r'); x_putc('\n'); x_flush(); x_putc('\r'); x_putc('\n'); x_flush();
if (c == -1 || len <= es->linelen) if (c == -1 || len <= (size_t)es->linelen)
return -1; return -1;
if (es->cbuf != buf) if (es->cbuf != buf)
@ -1799,7 +1801,7 @@ outofwin()
static void static void
rewindow() rewindow()
{ {
register int tcur, tcol; int tcur, tcol;
int holdcur1, holdcol1; int holdcur1, holdcol1;
int holdcur2, holdcol2; int holdcur2, holdcol2;
@ -2115,9 +2117,7 @@ complete_word(command, count)
} }
static int static int
print_expansions(e, command) print_expansions(struct edstate *e, int command GCC_FUNC_ATTR(unused))
struct edstate *e;
int command;
{ {
int nwords; int nwords;
int start, end; int start, end;