de-register, de-inline, de-__P

This commit is contained in:
tg 2004-10-28 11:11:19 +00:00
parent 7ad780aa98
commit 75e25d6e50
36 changed files with 660 additions and 656 deletions

5
README
View File

@ -1,4 +1,4 @@
$MirBSD: README,v 1.3 2004/05/24 19:55:53 tg Stab $ $MirBSD: README,v 1.4 2004/10/28 11:11:16 tg Exp $
This is the README for mirbsdksh, developed as part of the MirBSD This is the README for mirbsdksh, developed as part of the MirBSD
operating system at The MirOS Project, and produced portably. operating system at The MirOS Project, and produced portably.
@ -143,8 +143,7 @@ Compiling/Installing:
in __start (perhaps our system doesn't have the full svr4 in __start (perhaps our system doesn't have the full svr4
environ?). Try compiling in the bsd43 environ instead (still not environ?). Try compiling in the bsd43 environ instead (still not
perfect - see BUG-REPORTS file), using gcc - cc has problems with perfect - see BUG-REPORTS file), using gcc - cc has problems with
macro expansions in the argument of a macro (in this case, the ARGS macro expansions in the argument of a macro.
macro).
* On TitanOS (Stardent/Titan), use 'CC="cc -43" configure ...'. * On TitanOS (Stardent/Titan), use 'CC="cc -43" configure ...'.
When configure finishes, edit config.h, undef HAVE_DIRENT_H and When configure finishes, edit config.h, undef HAVE_DIRENT_H and
define HAVE_SYS_DIR_H (the dirent.h header file is broken). define HAVE_SYS_DIR_H (the dirent.h header file is broken).

View File

@ -1,4 +1,4 @@
/** $MirBSD: c_ksh.c,v 1.7 2004/10/28 11:03:21 tg Exp $ */ /** $MirBSD: c_ksh.c,v 1.8 2004/10/28 11:11:16 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,7 +13,7 @@
#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 $"); __RCSID("$MirBSD: c_ksh.c,v 1.8 2004/10/28 11:11:16 tg Exp $");
int int
c_cd(wp) c_cd(wp)
@ -1157,7 +1157,7 @@ struct kill_info {
size_t num_width; size_t num_width;
size_t 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(void *arg, int i, char *buf, int buflen);
/* format a single kill item */ /* format a single kill item */
static char * static char *

10
c_sh.c
View File

@ -1,4 +1,4 @@
/** $MirBSD: c_sh.c,v 1.5 2004/10/28 11:03:22 tg Exp $ */ /** $MirBSD: c_sh.c,v 1.6 2004/10/28 11:11:17 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,9 +10,9 @@
#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 $"); __RCSID("$MirBSD: c_sh.c,v 1.6 2004/10/28 11:11:17 tg Exp $");
static char *clocktos ARGS((clock_t t)); static char *clocktos(clock_t t);
/* :, false and true */ /* :, false and true */
@ -863,8 +863,8 @@ c_builtin(char **wp GCC_FUNC_ATTR(unused))
return 0; return 0;
} }
extern int c_test ARGS((char **wp)); /* in c_test.c */ extern int c_test(char **wp); /* in c_test.c */
extern int c_ulimit ARGS((char **wp)); /* in c_ulimit.c */ extern int c_ulimit(char **wp); /* in c_ulimit.c */
/* A leading = means assignments before command are kept; /* A leading = means assignments before command are kept;
* a leading * means a POSIX special builtin; * a leading * means a POSIX special builtin;

View File

@ -1,4 +1,4 @@
/** $MirBSD: c_test.c,v 1.5 2004/10/28 11:03:22 tg Exp $ */ /** $MirBSD: c_test.c,v 1.6 2004/10/28 11:11:17 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,7 +14,7 @@
#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 $"); __RCSID("$MirBSD: c_test.c,v 1.6 2004/10/28 11:11:17 tg Exp $");
/* test(1) accepts the following grammar: /* test(1) accepts the following grammar:
oexpr ::= aexpr | aexpr "-o" oexpr ; oexpr ::= aexpr | aexpr "-o" oexpr ;
@ -90,17 +90,17 @@ static const struct t_op b_ops [] = {
{"", TO_NONOP } {"", TO_NONOP }
}; };
static int test_stat ARGS((const char *path, struct stat *statb)); static int test_stat(const char *path, struct stat *statb);
static int test_eaccess ARGS((const char *path, int mode)); static int test_eaccess(const char *path, int mode);
static int test_oexpr ARGS((Test_env *te, int do_eval)); static int test_oexpr(Test_env *te, int do_eval);
static int test_aexpr ARGS((Test_env *te, int do_eval)); static int test_aexpr(Test_env *te, int do_eval);
static int test_nexpr ARGS((Test_env *te, int do_eval)); static int test_nexpr(Test_env *te, int do_eval);
static int test_primary ARGS((Test_env *te, int do_eval)); static int test_primary(Test_env *te, int do_eval);
static int ptest_isa ARGS((Test_env *te, Test_meta meta)); static int ptest_isa(Test_env *te, Test_meta meta);
static const char *ptest_getopnd ARGS((Test_env *te, Test_op op, int do_eval)); static const char *ptest_getopnd(Test_env *te, Test_op op, int do_eval);
static int ptest_eval ARGS((Test_env *te, Test_op op, const char *opnd1, static int ptest_eval(Test_env *te, Test_op op, const char *opnd1,
const char *opnd2, int do_eval)); const char *opnd2, int do_eval);
static void ptest_error ARGS((Test_env *te, int offset, const char *msg)); static void ptest_error(Test_env *te, int offset, const char *msg);
int int
c_test(wp) c_test(wp)

View File

@ -1,4 +1,4 @@
/** $MirBSD: c_test.h,v 1.3 2004/09/21 11:57:07 tg Exp $ */ /** $MirBSD: c_test.h,v 1.4 2004/10/28 11:11:17 tg Exp $ */
/* $OpenBSD: c_test.h,v 1.2 2003/10/22 07:40:38 jmc Exp $ */ /* $OpenBSD: c_test.h,v 1.2 2003/10/22 07:40:38 jmc Exp $ */
/* Various types of operations. Keeping things grouped nicely /* Various types of operations. Keeping things grouped nicely
@ -43,14 +43,14 @@ struct test_env {
XPtrV *av; /* used by dbtestp_* */ XPtrV *av; /* used by dbtestp_* */
} pos; } pos;
char **wp_end; /* used by ptest_* */ char **wp_end; /* used by ptest_* */
int (*isa) ARGS((Test_env *te, Test_meta meta)); int (*isa)(Test_env *te, Test_meta meta);
const char *(*getopnd) ARGS((Test_env *te, Test_op op, int do_eval)); const char *(*getopnd)(Test_env *te, Test_op op, int do_eval);
int (*eval) ARGS((Test_env *te, Test_op op, const char *opnd1, int (*eval)(Test_env *te, Test_op op, const char *opnd1,
const char *opnd2, int do_eval)); const char *opnd2, int do_eval);
void (*error) ARGS((Test_env *te, int offset, const char *msg)); void (*error)(Test_env *te, int offset, const char *msg);
}; };
Test_op test_isop ARGS((Test_env *te, Test_meta meta, const char *s)); Test_op test_isop(Test_env *te, Test_meta meta, const char *s);
int test_eval ARGS((Test_env *te, Test_op op, const char *opnd1, int test_eval(Test_env *te, Test_op op, const char *opnd1,
const char *opnd2, int do_eval)); const char *opnd2, int do_eval);
int test_parse ARGS((Test_env *te)); int test_parse(Test_env *te);

36
edit.c
View File

@ -1,4 +1,4 @@
/** $MirBSD: edit.c,v 1.8 2004/10/28 11:03:22 tg Exp $ */ /** $MirBSD: edit.c,v 1.9 2004/10/28 11:11:17 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,20 +22,20 @@
#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 $"); __RCSID("$MirBSD: edit.c,v 1.9 2004/10/28 11:11:17 tg Exp $");
#if defined(TIOCGWINSZ) #if defined(TIOCGWINSZ)
static RETSIGTYPE x_sigwinch ARGS((int sig)); static RETSIGTYPE x_sigwinch(int sig);
static int got_sigwinch; static int got_sigwinch;
static void check_sigwinch ARGS((void)); static void check_sigwinch(void);
#endif /* TIOCGWINSZ */ #endif /* TIOCGWINSZ */
static int x_file_glob ARGS((int flags, const char *str, int slen, static int x_file_glob(int flags, const char *str, int slen,
char ***wordsp)); char ***wordsp);
static int x_command_glob ARGS((int flags, const char *str, int slen, static int x_command_glob(int flags, const char *str, int slen,
char ***wordsp)); char ***wordsp);
static int x_locate_word ARGS((const char *buf, int buflen, int pos, static int x_locate_word(const char *buf, int buflen, int pos,
int *startp, int *is_command)); int *startp, int *is_command);
static char vdisable_c; static char vdisable_c;
@ -90,7 +90,7 @@ x_sigwinch(int sig GCC_FUNC_ATTR(unused))
} }
static void static void
check_sigwinch ARGS((void)) check_sigwinch(void)
{ {
if (got_sigwinch) { if (got_sigwinch) {
struct winsize ws; struct winsize ws;
@ -455,14 +455,14 @@ x_do_comment(buf, bsize, lenp)
/* Common file/command completion code for vi/emacs */ /* Common file/command completion code for vi/emacs */
static char *add_glob ARGS((const char *str, int slen)); static char *add_glob(const char *str, int slen);
static void glob_table ARGS((const char *pat, XPtrV *wp, struct table *tp)); static void glob_table(const char *pat, XPtrV *wp, struct table *tp);
static void glob_path ARGS((int flags, const char *pat, XPtrV *wp, static void glob_path(int flags, const char *pat, XPtrV *wp,
const char *path)); const char *path);
#if 0 /* not used... */ #if 0 /* not used... */
int x_complete_word ARGS((const char *str, int slen, int is_command, int x_complete_word(const char *str, int slen, int is_command,
int *multiple, char **ret)); int *multiple, char **ret);
int int
x_complete_word(str, slen, is_command, nwordsp, ret) x_complete_word(str, slen, is_command, nwordsp, ret)
const char *str; const char *str;
@ -1051,7 +1051,7 @@ int
x_escape(s, len, putbuf_func) x_escape(s, len, putbuf_func)
const char *s; const char *s;
size_t len; size_t len;
int putbuf_func ARGS((const char *s, size_t len)); int putbuf_func(const char *s, size_t len);
{ {
size_t add, wlen; size_t add, wlen;
const char *ifs = str_val(local("IFS", 0)); const char *ifs = str_val(local("IFS", 0));

38
edit.h
View File

@ -1,4 +1,4 @@
/** $MirBSD: edit.h,v 1.3 2004/09/21 11:57:08 tg Exp $ */ /** $MirBSD: edit.h,v 1.4 2004/10/28 11:11:17 tg Exp $ */
/* $OpenBSD: edit.h,v 1.3 1999/11/14 22:04:02 d Exp $ */ /* $OpenBSD: edit.h,v 1.3 1999/11/14 22:04:02 d Exp $ */
/* $From: edit.h,v 1.2 1994/05/19 18:32:40 michael Exp michael $ */ /* $From: edit.h,v 1.2 1994/05/19 18:32:40 michael Exp michael $ */
@ -32,26 +32,26 @@ EXTERN X_chars edchars;
#define XCF_COMMAND_FILE (XCF_COMMAND|XCF_FILE) #define XCF_COMMAND_FILE (XCF_COMMAND|XCF_FILE)
/* edit.c */ /* edit.c */
int x_getc ARGS((void)); int x_getc(void);
void x_flush ARGS((void)); void x_flush(void);
void x_putc ARGS((int c)); void x_putc(int c);
void x_puts ARGS((const char *s)); void x_puts(const char *s);
bool_t x_mode ARGS((bool_t onoff)); bool_t x_mode(bool_t onoff);
int promptlen ARGS((const char *cp, const char **spp)); int promptlen(const char *cp, const char **spp);
int x_do_comment ARGS((char *buf, int bsize, int *lenp)); int x_do_comment(char *buf, int bsize, int *lenp);
void x_print_expansions ARGS((int nwords, char *const *words, int is_command)); void x_print_expansions(int nwords, char *const *words, int is_command);
int x_cf_glob ARGS((int flags, const char *buf, int buflen, int pos, int *startp, int x_cf_glob(int flags, const char *buf, int buflen, int pos, int *startp,
int *endp, char ***wordsp, int *is_commandp)); int *endp, char ***wordsp, int *is_commandp);
int x_longest_prefix ARGS((int nwords, char *const *words)); int x_longest_prefix(int nwords, char *const *words);
int x_basename ARGS((const char *s, const char *se)); int x_basename(const char *s, const char *se);
void x_free_words ARGS((int nwords, char **words)); void x_free_words(int nwords, char **words);
int x_escape ARGS((const char *, size_t, int (*)(const char *s, size_t len))); int x_escape(const char *, size_t, int (*)(const char *s, size_t len));
/* emacs.c */ /* emacs.c */
int x_emacs ARGS((char *buf, size_t len)); int x_emacs(char *buf, size_t len);
void x_init_emacs ARGS((void)); void x_init_emacs(void);
void x_emacs_keys ARGS((X_chars *ec)); void x_emacs_keys(X_chars *ec);
/* vi.c */ /* vi.c */
int x_vi ARGS((char *buf, size_t len)); int x_vi(char *buf, size_t len);
#ifdef DEBUG #ifdef DEBUG

View File

@ -1,5 +1,5 @@
#!/bin/sh #!/bin/sh
# $MirBSD: emacs-gen.sh,v 1.2 2004/05/24 19:56:05 tg Stab $ # $MirBSD: emacs-gen.sh,v 1.3 2004/10/28 11:11:17 tg Exp $
# $OpenBSD: emacs-gen.sh,v 1.1.1.1 1996/08/14 06:19:10 downsj Exp $ # $OpenBSD: emacs-gen.sh,v 1.1.1.1 1996/08/14 06:19:10 downsj Exp $
case $# in case $# in
@ -37,7 +37,7 @@ sed -e '1,/@START-FUNC-TAB@/d' -e '/@END-FUNC-TAB@/,$d' < $file |
fname = substr(fname, 1, length(fname) - 1); fname = substr(fname, 1, length(fname) - 1);
if (fname != "0") { if (fname != "0") {
printf "#define XFUNC_%s %d\n", substr(fname, 3, length(fname) - 2), nfunc; printf "#define XFUNC_%s %d\n", substr(fname, 3, length(fname) - 2), nfunc;
printf "static int %s ARGS((int c));\n", fname; printf "static int %s(int c);\n", fname;
nfunc++; nfunc++;
} }
}' || exit 1 }' || exit 1

63
emacs.c
View File

@ -1,4 +1,4 @@
/** $MirBSD: emacs.c,v 1.10 2004/10/28 11:03:22 tg Exp $ */ /** $MirBSD: emacs.c,v 1.11 2004/10/28 11:11:17 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,7 +19,7 @@
#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 $"); __RCSID("$MirBSD: emacs.c,v 1.11 2004/10/28 11:11:17 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 */
@ -37,7 +37,7 @@ static Area aedit;
#define KINTR 2 /* ^G, ^C */ #define KINTR 2 /* ^G, ^C */
struct x_ftab { struct x_ftab {
int (*xf_func) ARGS((int c)); int (*xf_func)(int c);
const char *xf_name; const char *xf_name;
short xf_flags; short xf_flags;
}; };
@ -123,34 +123,34 @@ static int x_curprefix;
static char *macroptr; static char *macroptr;
static int prompt_skip; static int prompt_skip;
static int x_ins ARGS((char *cp)); static int x_ins(char *cp);
static void x_delete ARGS((int nc, int push)); static void x_delete(int nc, int push);
static int x_bword ARGS((void)); static int x_bword(void);
static int x_fword ARGS((void)); static int x_fword(void);
static void x_goto ARGS((char *cp)); static void x_goto(char *cp);
static void x_bs ARGS((int c)); static void x_bs(int c);
static int x_size_str ARGS((char *cp)); static int x_size_str(char *cp);
static int x_size ARGS((int c)); static int x_size(int c);
static void x_zots ARGS((char *str)); static void x_zots(char *str);
static void x_zotc ARGS((int c)); static void x_zotc(int c);
static void x_load_hist ARGS((char **hp)); static void x_load_hist(char **hp);
static int x_search ARGS((char *pat, int sameline, int offset)); static int x_search(char *pat, int sameline, int offset);
static int x_match ARGS((char *str, char *pat)); static int x_match(char *str, char *pat);
static void x_redraw ARGS((int limit)); static void x_redraw(int limit);
static void x_push ARGS((int nchars)); static void x_push(int nchars);
static char * x_mapin ARGS((const char *cp)); static char * x_mapin(const char *cp);
static char * x_mapout ARGS((int c)); static char * x_mapout(int c);
static void x_print ARGS((int prefix, int key)); static void x_print(int prefix, int key);
static void x_adjust ARGS((void)); static void x_adjust(void);
static void x_e_ungetc ARGS((int c)); static void x_e_ungetc(int c);
static int x_e_getc ARGS((void)); static int x_e_getc(void);
static void x_e_putc ARGS((int c)); static void x_e_putc(int c);
static void x_e_puts ARGS((const char *s)); static void x_e_puts(const char *s);
static int x_comment ARGS((int c)); static int x_comment(int c);
static int x_fold_case ARGS((int c)); static int x_fold_case(int c);
static char *x_lastcp ARGS((void)); static char *x_lastcp(void);
static void do_complete ARGS((int flags, Comp_type type)); static void do_complete(int flags, Comp_type type);
static int x_emacs_putbuf ARGS((const char *s, size_t len)); static int x_emacs_putbuf(const char *s, size_t len);
/* The lines between START-FUNC-TAB .. END-FUNC-TAB are run through a /* The lines between START-FUNC-TAB .. END-FUNC-TAB are run through a
@ -2167,5 +2167,4 @@ x_lastcp()
xlp_valid = TRUE; xlp_valid = TRUE;
return (xlp); return (xlp);
} }
#endif /* EDIT */ #endif /* EDIT */

30
eval.c
View File

@ -1,4 +1,4 @@
/** $MirBSD: eval.c,v 1.4 2004/10/28 11:03:22 tg Exp $ */ /** $MirBSD: eval.c,v 1.5 2004/10/28 11:11:17 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,7 +10,7 @@
#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 $"); __RCSID("$MirBSD: eval.c,v 1.5 2004/10/28 11:11:17 tg Exp $");
/* /*
* string expansion * string expansion
@ -43,19 +43,19 @@ typedef struct Expand {
#define IFS_WS 1 /* have seen IFS white-space */ #define IFS_WS 1 /* have seen IFS white-space */
#define IFS_NWS 2 /* have seen IFS non-white-space */ #define IFS_NWS 2 /* have seen IFS non-white-space */
static int varsub ARGS((Expand *xp, char *sp, char *word, int *stypep, int *slenp)); static int varsub(Expand *xp, char *sp, char *word, int *stypep, int *slenp);
static int comsub ARGS((Expand *xp, char *cp)); static int comsub(Expand *xp, char *cp);
static char *trimsub ARGS((char *str, char *pat, int how)); static char *trimsub(char *str, char *pat, int how);
static void glob ARGS((char *cp, XPtrV *wp, int markdirs)); static void glob(char *cp, XPtrV *wp, int markdirs);
static void globit ARGS((XString *xs, char **xpp, char *sp, XPtrV *wp, static void globit(XString *xs, char **xpp, char *sp, XPtrV *wp,
int check)); int check);
static char *maybe_expand_tilde ARGS((char *p, XString *dsp, char **dpp, static char *maybe_expand_tilde(char *p, XString *dsp, char **dpp,
int isassign)); int isassign);
static char *tilde ARGS((char *acp)); static char *tilde(char *acp);
static char *homedir ARGS((char *name)); static char *homedir(char *name);
#ifdef BRACE_EXPAND #ifdef BRACE_EXPAND
static void alt_expand ARGS((XPtrV *wp, char *start, char *exp_start, static void alt_expand(XPtrV *wp, char *start, char *exp_start,
char *end, int fdo)); char *end, int fdo);
#endif #endif
/* compile and expand word */ /* compile and expand word */
@ -1139,7 +1139,7 @@ globit(xs, xpp, sp, wp, check)
/* Check if p contains something that needs globbing; if it does, 0 is /* Check if p contains something that needs globbing; if it does, 0 is
* returned; if not, p is copied into xs/xp after stripping any MAGICs * returned; if not, p is copied into xs/xp after stripping any MAGICs
*/ */
static int copy_non_glob ARGS((XString *xs, char **xpp, char *p)); static int copy_non_glob(XString *xs, char **xpp, char *p);
static int static int
copy_non_glob(xs, xpp, p) copy_non_glob(xs, xpp, p)
XString *xs; XString *xs;

38
exec.c
View File

@ -1,4 +1,4 @@
/** $MirBSD: exec.c,v 1.4 2004/10/28 11:03:23 tg Exp $ */ /** $MirBSD: exec.c,v 1.5 2004/10/28 11:11:18 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 $ */
/* /*
@ -10,6 +10,8 @@
#include <ctype.h> #include <ctype.h>
#include "ksh_stat.h" #include "ksh_stat.h"
__RCSID("$MirBSD: exec.c,v 1.5 2004/10/28 11:11:18 tg Exp $");
/* Does ps4 get parameter substitutions done? */ /* Does ps4 get parameter substitutions done? */
#ifdef KSH #ifdef KSH
# define PS4_SUBSTITUTE(s) substitute((s), 0) # define PS4_SUBSTITUTE(s) substitute((s), 0)
@ -17,25 +19,25 @@
# define PS4_SUBSTITUTE(s) (s) # define PS4_SUBSTITUTE(s) (s)
#endif /* KSH */ #endif /* KSH */
static int comexec ARGS((struct op *t, struct tbl *volatile tp, char **ap, static int comexec(struct op *t, struct tbl *volatile tp, char **ap,
int volatile flags)); int volatile flags);
static void scriptexec ARGS((struct op *tp, char **ap)); static void scriptexec(struct op *tp, char **ap);
static int call_builtin ARGS((struct tbl *tp, char **wp)); static int call_builtin(struct tbl *tp, char **wp);
static int iosetup ARGS((struct ioword *iop, struct tbl *tp)); static int iosetup(struct ioword *iop, struct tbl *tp);
static int herein ARGS((const char *content, int sub)); static int herein(const char *content, int sub);
#ifdef KSH #ifdef KSH
static char *do_selectargs ARGS((char **ap, bool_t print_menu)); static char *do_selectargs(char **ap, bool_t print_menu);
#endif /* KSH */ #endif /* KSH */
#ifdef KSH #ifdef KSH
static int dbteste_isa ARGS((Test_env *te, Test_meta meta)); static int dbteste_isa(Test_env *te, Test_meta meta);
static const char *dbteste_getopnd ARGS((Test_env *te, Test_op op, static const char *dbteste_getopnd(Test_env *te, Test_op op,
int do_eval)); int do_eval);
static int dbteste_eval ARGS((Test_env *te, Test_op op, const char *opnd1, static int dbteste_eval(Test_env *te, Test_op op, const char *opnd1,
const char *opnd2, int do_eval)); const char *opnd2, int do_eval);
static void dbteste_error ARGS((Test_env *te, int offset, const char *msg)); static void dbteste_error(Test_env *te, int offset, const char *msg);
#endif /* KSH */ #endif /* KSH */
#ifdef OS2 #ifdef OS2
static int search_access1 ARGS((const char *path, int mode, int *errnop)); static int search_access1(const char *path, int mode, int *errnop);
#endif /* OS2 */ #endif /* OS2 */
@ -957,7 +959,7 @@ define(name, t)
void void
builtin(name, func) builtin(name, func)
const char *name; const char *name;
int (*func) ARGS((char **)); int (*func)(char **);
{ {
struct tbl *tp; struct tbl *tp;
Tflag flag; Tflag flag;
@ -1545,7 +1547,7 @@ struct select_menu_info {
int num_width; int num_width;
} info; } info;
static char *select_fmt_entry ARGS((void *arg, int i, char *buf, int buflen)); static char *select_fmt_entry(void *arg, int i, char *buf, int buflen);
/* format a single select menu item */ /* format a single select menu item */
static char * static char *
@ -1607,7 +1609,7 @@ pr_menu(ap)
/* XXX: horrible kludge to fit within the framework */ /* XXX: horrible kludge to fit within the framework */
static char *plain_fmt_entry ARGS((void *arg, int i, char *buf, int buflen)); static char *plain_fmt_entry(void *arg, int i, char *buf, int buflen);
static char * static char *
plain_fmt_entry(arg, i, buf, buflen) plain_fmt_entry(arg, i, buf, buflen)

View File

@ -1,4 +1,4 @@
/** $MirBSD: expand.h,v 1.4 2004/10/28 11:03:23 tg Exp $ */ /** $MirBSD: expand.h,v 1.5 2004/10/28 11:11:18 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, size_t more)); char * Xcheck_grow_(XString *xsp, char *xp, size_t more);
/* /*
* expandable vector of generic pointers * expandable vector of generic pointers

23
expr.c
View File

@ -1,4 +1,4 @@
/** $MirBSD: expr.c,v 1.5 2004/10/28 11:03:23 tg Exp $ */ /** $MirBSD: expr.c,v 1.6 2004/10/28 11:11:18 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 $ */
/* /*
@ -8,6 +8,7 @@
#include "sh.h" #include "sh.h"
#include <ctype.h> #include <ctype.h>
__RCSID("$MirBSD: expr.c,v 1.6 2004/10/28 11:11:18 tg Exp $");
/* The order of these enums is constrained by the order of opinfo[] */ /* The order of these enums is constrained by the order of opinfo[] */
enum token { enum token {
@ -126,16 +127,16 @@ struct expr_state {
enum error_type { ET_UNEXPECTED, ET_BADLIT, ET_RECURSIVE, enum error_type { ET_UNEXPECTED, ET_BADLIT, ET_RECURSIVE,
ET_LVALUE, ET_RDONLY, ET_STR }; ET_LVALUE, ET_RDONLY, ET_STR };
static void evalerr ARGS((Expr_state *es, enum error_type type, static void evalerr(Expr_state *es, enum error_type type,
const char *str)) GCC_FUNC_ATTR(noreturn); const char *str) GCC_FUNC_ATTR(noreturn);
static struct tbl *evalexpr ARGS((Expr_state *es, enum prec prec)); static struct tbl *evalexpr(Expr_state *es, enum prec prec);
static void token ARGS((Expr_state *es)); static void token(Expr_state *es);
static struct tbl *do_ppmm ARGS((Expr_state *es, enum token op, static struct tbl *do_ppmm(Expr_state *es, enum token op,
struct tbl *vasn, bool_t is_prefix)); struct tbl *vasn, bool_t is_prefix);
static void assign_check ARGS((Expr_state *es, enum token op, static void assign_check(Expr_state *es, enum token op,
struct tbl *vasn)); struct tbl *vasn);
static struct tbl *tempvar ARGS((void)); static struct tbl *tempvar(void);
static struct tbl *intvar ARGS((Expr_state *es, struct tbl *vp)); static struct tbl *intvar(Expr_state *es, struct tbl *vp);
/* /*
* parse and evaluate expression * parse and evaluate expression

View File

@ -1,4 +1,4 @@
/** $MirBSD: history.c,v 1.12 2004/10/28 11:03:23 tg Exp $ */ /** $MirBSD: history.c,v 1.13 2004/10/28 11:11:18 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 $ */
/* /*
@ -21,6 +21,8 @@
#include "sh.h" #include "sh.h"
#include "ksh_stat.h" #include "ksh_stat.h"
__RCSID("$MirBSD: history.c,v 1.13 2004/10/28 11:11:18 tg Exp $");
#ifdef HISTORY #ifdef HISTORY
# ifdef EASY_HISTORY # ifdef EASY_HISTORY
@ -44,13 +46,13 @@
static int histfd; static int histfd;
static int hsize; static int hsize;
static int hist_count_lines ARGS((unsigned char *, int)); static int hist_count_lines(unsigned char *, int);
static int hist_shrink ARGS((unsigned char *, int)); static int hist_shrink(unsigned char *, int);
static unsigned char *hist_skip_back ARGS((unsigned char *,int *,int)); static unsigned char *hist_skip_back(unsigned char *,int *,int);
static void histload ARGS((Source *, unsigned char *, int)); static void histload(Source *, unsigned char *, int);
static void histinsert ARGS((Source *, int, unsigned char *)); static void histinsert(Source *, int, unsigned char *);
static void writehistfile ARGS((int, char *)); static void writehistfile(int, char *);
static int sprinkle ARGS((int)); static int sprinkle(int);
# ifdef MAP_FILE # ifdef MAP_FILE
# define MAP_FLAGS (MAP_FILE|MAP_PRIVATE) # define MAP_FLAGS (MAP_FILE|MAP_PRIVATE)
@ -60,13 +62,13 @@ static int sprinkle ARGS((int));
# endif /* of EASY_HISTORY */ # endif /* of EASY_HISTORY */
static int hist_execute ARGS((char *cmd)); static int hist_execute(char *cmd);
static int hist_replace ARGS((char **hp, const char *pat, const char *rep, static int hist_replace(char **hp, const char *pat, const char *rep,
int global)); int global);
static char **hist_get ARGS((const char *str, int approx, int allow_cur)); static char **hist_get(const char *str, int approx, int allow_cur);
static char **hist_get_newest ARGS((int allow_cur)); static char **hist_get_newest(int allow_cur);
static char **hist_get_oldest ARGS((void)); static char **hist_get_oldest(void);
static void histbackup ARGS((void)); static void histbackup(void);
static char **current; /* current position in history[] */ static char **current; /* current position in history[] */
static int curpos; /* current index in history[] */ static int curpos; /* current index in history[] */

32
jobs.c
View File

@ -1,4 +1,4 @@
/** $MirBSD: jobs.c,v 1.6 2004/10/28 11:03:23 tg Exp $ */ /** $MirBSD: jobs.c,v 1.7 2004/10/28 11:11:18 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,7 +31,7 @@
#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 $"); __RCSID("$MirBSD: jobs.c,v 1.7 2004/10/28 11:11:18 tg Exp $");
/* Start of system configuration stuff */ /* Start of system configuration stuff */
@ -59,8 +59,8 @@ __RCSID("$MirBSD: jobs.c,v 1.6 2004/10/28 11:03:23 tg Exp $");
# define getpgID() getpgrp() # define getpgID() getpgrp()
# endif # endif
# if defined(TTY_PGRP) && !defined(HAVE_TCSETPGRP) # if defined(TTY_PGRP) && !defined(HAVE_TCSETPGRP)
int tcsetpgrp ARGS((int fd, pid_t grp)); int tcsetpgrp(int fd, pid_t grp);
int tcgetpgrp ARGS((int fd)); int tcgetpgrp(int fd);
int int
tcsetpgrp(fd, grp) tcsetpgrp(fd, grp)
@ -213,18 +213,18 @@ static pid_t our_pgrp;
static int const tt_sigs[] = { SIGTSTP, SIGTTIN, SIGTTOU }; static int const tt_sigs[] = { SIGTSTP, SIGTTIN, SIGTTOU };
#endif /* TTY_PGRP */ #endif /* TTY_PGRP */
static void j_set_async ARGS((Job *j)); static void j_set_async(Job *j);
static void j_startjob ARGS((Job *j)); static void j_startjob(Job *j);
static int j_waitj ARGS((Job *j, int flags, const char *where)); static int j_waitj(Job *j, int flags, const char *where);
static RETSIGTYPE j_sigchld ARGS((int sig)); static RETSIGTYPE j_sigchld(int sig);
static void j_print ARGS((Job *j, int how, struct shf *shf)); static void j_print(Job *j, int how, struct shf *shf);
static Job *j_lookup ARGS((const char *cp, int *ecodep)); static Job *j_lookup(const char *cp, int *ecodep);
static Job *new_job ARGS((void)); static Job *new_job(void);
static Proc *new_proc ARGS((void)); static Proc *new_proc(void);
static void check_job ARGS((Job *j)); static void check_job(Job *j);
static void put_job ARGS((Job *j, int where)); static void put_job(Job *j, int where);
static void remove_job ARGS((Job *j, const char *where)); static void remove_job(Job *j, const char *where);
static int kill_job ARGS((Job *j, int sig)); static int kill_job(Job *j, int sig);
/* initialize job control */ /* initialize job control */
void void

View File

@ -1,4 +1,4 @@
/** $MirBSD: ksh_dir.h,v 1.3 2004/09/21 11:57:10 tg Exp $ */ /** $MirBSD: ksh_dir.h,v 1.4 2004/10/28 11:11:18 tg Exp $ */
/* $OpenBSD: ksh_dir.h,v 1.1.1.1 1996/08/14 06:19:11 downsj Exp $ */ /* $OpenBSD: ksh_dir.h,v 1.1.1.1 1996/08/14 06:19:11 downsj Exp $ */
/* Wrapper around the ugly dir includes/ifdefs */ /* Wrapper around the ugly dir includes/ifdefs */
@ -21,7 +21,7 @@
#endif /* HAVE_DIRENT_H */ #endif /* HAVE_DIRENT_H */
#ifdef OPENDIR_DOES_NONDIR #ifdef OPENDIR_DOES_NONDIR
extern DIR *ksh_opendir ARGS((const char *d)); extern DIR *ksh_opendir(const char *d);
#else /* OPENDIR_DOES_NONDIR */ #else /* OPENDIR_DOES_NONDIR */
# define ksh_opendir(d) opendir(d) # define ksh_opendir(d) opendir(d)
#endif /* OPENDIR_DOES_NONDIR */ #endif /* OPENDIR_DOES_NONDIR */

View File

@ -1,4 +1,4 @@
/** $MirBSD: ksh_time.h,v 1.3 2004/09/21 11:57:11 tg Exp $ */ /** $MirBSD: ksh_time.h,v 1.4 2004/10/28 11:11:18 tg Exp $ */
/* $OpenBSD: ksh_time.h,v 1.2 1996/10/01 02:05:40 downsj Exp $ */ /* $OpenBSD: ksh_time.h,v 1.2 1996/10/01 02:05:40 downsj Exp $ */
#ifndef KSH_TIME_H #ifndef KSH_TIME_H
@ -18,7 +18,7 @@
#endif /* TIME_WITH_SYS_TIME */ #endif /* TIME_WITH_SYS_TIME */
#ifndef TIME_DECLARED #ifndef TIME_DECLARED
extern time_t time ARGS((time_t *)); extern time_t time(time_t *);
#endif #endif
#ifndef CLK_TCK #ifndef CLK_TCK

View File

@ -1,4 +1,4 @@
/** $MirBSD: ksh_times.h,v 1.3 2004/09/21 11:57:12 tg Exp $ */ /** $MirBSD: ksh_times.h,v 1.4 2004/10/28 11:11:18 tg Exp $ */
/* $OpenBSD: ksh_times.h,v 1.2 1996/10/01 02:05:41 downsj Exp $ */ /* $OpenBSD: ksh_times.h,v 1.2 1996/10/01 02:05:41 downsj Exp $ */
#ifndef KSH_TIMES_H #ifndef KSH_TIMES_H
@ -10,12 +10,12 @@
#include <sys/times.h> #include <sys/times.h>
#ifdef TIMES_BROKEN #ifdef TIMES_BROKEN
extern clock_t ksh_times ARGS((struct tms *)); extern clock_t ksh_times(struct tms *);
#else /* TIMES_BROKEN */ #else /* TIMES_BROKEN */
# define ksh_times times # define ksh_times times
#endif /* TIMES_BROKEN */ #endif /* TIMES_BROKEN */
#ifdef HAVE_TIMES #ifdef HAVE_TIMES
extern clock_t times ARGS((struct tms *)); extern clock_t times(struct tms *);
#endif /* HAVE_TIMES */ #endif /* HAVE_TIMES */
#endif /* KSH_TIMES_H */ #endif /* KSH_TIMES_H */

25
lex.c
View File

@ -1,4 +1,4 @@
/** $MirBSD: lex.c,v 1.5 2004/10/28 11:03:23 tg Exp $ */ /** $MirBSD: lex.c,v 1.6 2004/10/28 11:11:18 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 $ */
/* /*
@ -8,6 +8,7 @@
#include "sh.h" #include "sh.h"
#include <ctype.h> #include <ctype.h>
__RCSID("$MirBSD: lex.c,v 1.6 2004/10/28 11:11:18 tg Exp $");
/* Structure to keep track of the lexing state and the various pieces of info /* Structure to keep track of the lexing state and the various pieces of info
* needed for each particular state. * needed for each particular state.
@ -53,16 +54,16 @@ struct State_info {
}; };
static void readhere ARGS((struct ioword *iop)); static void readhere(struct ioword *iop);
static int getsc__ ARGS((void)); static int getsc__(void);
static void getsc_line ARGS((Source *s)); static void getsc_line(Source *s);
static int getsc_bn ARGS((void)); static int getsc_bn(void);
static char *get_brace_var ARGS((XString *wsp, char *wp)); static char *get_brace_var(XString *wsp, char *wp);
static int arraysub ARGS((char **strp)); static int arraysub(char **strp);
static const char *ungetsc ARGS((int c)); static const char *ungetsc(int c);
static void gethere ARGS((void)); static void gethere(void);
static Lex_state *push_state_ ARGS((State_info *si, Lex_state *old_end)); static Lex_state *push_state_(State_info *si, Lex_state *old_end);
static Lex_state *pop_state_ ARGS((State_info *si, Lex_state *old_end)); static Lex_state *pop_state_(State_info *si, Lex_state *old_end);
static int backslash_skip; static int backslash_skip;
static int ignore_backslash_newline; static int ignore_backslash_newline;
@ -1343,7 +1344,7 @@ ungetsc(c)
/* Called to get a char that isn't a \newline sequence. */ /* Called to get a char that isn't a \newline sequence. */
static int static int
getsc_bn ARGS((void)) getsc_bn(void)
{ {
int c, c2; int c, c2;

10
mail.c
View File

@ -1,4 +1,4 @@
/** $MirBSD: mail.c,v 1.4 2004/10/28 11:03:23 tg Exp $ */ /** $MirBSD: mail.c,v 1.5 2004/10/28 11:11:18 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 $ */
/* /*
@ -13,6 +13,8 @@
#include "ksh_stat.h" #include "ksh_stat.h"
#include "ksh_time.h" #include "ksh_time.h"
__RCSID("$MirBSD: mail.c,v 1.5 2004/10/28 11:11:18 tg Exp $");
#define MBMESSAGE "you have mail in $_" #define MBMESSAGE "you have mail in $_"
typedef struct mbox { typedef struct mbox {
@ -33,9 +35,9 @@ static mbox_t mbox;
static time_t mlastchkd; /* when mail was last checked */ static time_t mlastchkd; /* when mail was last checked */
static time_t mailcheck_interval; static time_t mailcheck_interval;
static void munset ARGS((mbox_t *mlist)); /* free mlist and mval */ static void munset(mbox_t *mlist); /* free mlist and mval */
static mbox_t * mballoc ARGS((char *p, char *m)); /* allocate a new mbox */ static mbox_t * mballoc(char *p, char *m); /* allocate a new mbox */
static void mprintit ARGS((mbox_t *mbp)); static void mprintit(mbox_t *mbp);
void void
mcheck() mcheck()

10
main.c
View File

@ -1,4 +1,4 @@
/** $MirBSD: main.c,v 1.10 2004/10/28 11:03:23 tg Exp $ */ /** $MirBSD: main.c,v 1.11 2004/10/28 11:11:18 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,7 +11,7 @@
#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 $"); __RCSID("$MirBSD: main.c,v 1.11 2004/10/28 11:11:18 tg Exp $");
extern char **environ; extern char **environ;
@ -19,9 +19,9 @@ extern char **environ;
* global data * global data
*/ */
static void reclaim ARGS((void)); static void reclaim(void);
static void remove_temps ARGS((struct temp *tp)); static void remove_temps(struct temp *tp);
static int is_restricted ARGS((char *name)); static int is_restricted(char *name);
/* /*
* shell initialization * shell initialization

24
misc.c
View File

@ -1,4 +1,4 @@
/** $MirBSD: misc.c,v 1.10 2004/10/28 11:03:23 tg Exp $ */ /** $MirBSD: misc.c,v 1.11 2004/10/28 11:11:18 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,7 +11,7 @@
# include <limits.h> # include <limits.h>
#endif #endif
__RCSID("$MirBSD: misc.c,v 1.10 2004/10/28 11:03:23 tg Exp $"); __RCSID("$MirBSD: misc.c,v 1.11 2004/10/28 11:11:18 tg Exp $");
#ifndef UCHAR_MAX #ifndef UCHAR_MAX
# define UCHAR_MAX 0xFF # define UCHAR_MAX 0xFF
@ -19,10 +19,10 @@ __RCSID("$MirBSD: misc.c,v 1.10 2004/10/28 11:03:23 tg Exp $");
short ctypes [UCHAR_MAX+1]; /* type bits for unsigned char */ short ctypes [UCHAR_MAX+1]; /* type bits for unsigned char */
static int do_gmatch ARGS((const unsigned char *s, const unsigned char *p, static int do_gmatch(const unsigned char *s, const unsigned char *p,
const unsigned char *se, const unsigned char *pe, const unsigned char *se, const unsigned char *pe,
int isfile)); int isfile);
static const unsigned char *cclass ARGS((const unsigned char *p, int sub)); static const unsigned char *cclass(const unsigned char *p, int sub);
/* /*
* Fast character classes * Fast character classes
@ -215,8 +215,8 @@ struct options_info {
} opts[NELEM(options)]; } opts[NELEM(options)];
}; };
static char *options_fmt_entry ARGS((void *arg, int i, char *buf, int buflen)); static char *options_fmt_entry(void *arg, int i, char *buf, int buflen);
static void printoptions ARGS((int verbose)); static void printoptions(int verbose);
/* format a single select menu item */ /* format a single select menu item */
static char * static char *
@ -832,13 +832,13 @@ pat_scan(p, pe, match_sep)
/* /*
* quick sort of array of generic pointers to objects. * quick sort of array of generic pointers to objects.
*/ */
static void qsort1 ARGS((void **base, void **lim, int (*f)(void *, void *))); static void qsort1(void **base, void **lim, int (*f)(void *, void *));
void void
qsortp(base, n, f) qsortp(base, n, f)
void **base; /* base address */ void **base; /* base address */
size_t n; /* elements */ size_t n; /* elements */
int (*f) ARGS((void *, void *)); /* compare function */ int (*f)(void *, void *); /* compare function */
{ {
qsort1(base, base + n, f); qsort1(base, base + n, f);
} }
@ -853,7 +853,7 @@ qsortp(base, n, f)
static void static void
qsort1(base, lim, f) qsort1(base, lim, f)
void **base, **lim; void **base, **lim;
int (*f) ARGS((void *, void *)); int (*f)(void *, void *);
{ {
void **i, **j; void **i, **j;
void **lptr, **hptr; void **lptr, **hptr;
@ -1108,7 +1108,7 @@ void
print_columns(shf, n, func, arg, max_width, prefcol) print_columns(shf, n, func, arg, max_width, prefcol)
struct shf *shf; struct shf *shf;
int n; int n;
char *(*func) ARGS((void *, int, char *, int)); char *(*func)(void *, int, char *, int);
void *arg; void *arg;
int max_width; int max_width;
int prefcol; int prefcol;
@ -1325,7 +1325,7 @@ ksh_get_wd(buf, bsize)
return ret; return ret;
#else /* HAVE_GETCWD */ #else /* HAVE_GETCWD */
extern char *getwd ARGS((char *)); extern char *getwd(char *);
char *b; char *b;
int len; int len;

6
path.c
View File

@ -1,10 +1,10 @@
/** $MirBSD: path.c,v 1.5 2004/10/28 11:03:24 tg Exp $ */ /** $MirBSD: path.c,v 1.6 2004/10/28 11:11:19 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 $"); __RCSID("$MirBSD: path.c,v 1.6 2004/10/28 11:11:19 tg Exp $");
/* /*
* Contains a routine to search a : separated list of * Contains a routine to search a : separated list of
@ -16,7 +16,7 @@ __RCSID("$MirBSD: path.c,v 1.5 2004/10/28 11:03:24 tg Exp $");
*/ */
#ifdef S_ISLNK #ifdef S_ISLNK
static char *do_phys_path ARGS((XString *xsp, char *xp, const char *path)); static char *do_phys_path(XString *xsp, char *xp, const char *path);
#endif /* S_ISLNK */ #endif /* S_ISLNK */
/* /*

490
proto.h
View File

@ -1,4 +1,4 @@
/** $MirBSD: proto.h,v 1.6 2004/10/28 11:03:24 tg Exp $ */ /** $MirBSD: proto.h,v 1.7 2004/10/28 11:11:19 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 $ */
@ -8,300 +8,300 @@
*/ */
/* alloc.c */ /* alloc.c */
Area * ainit ARGS((Area *ap)); Area * ainit(Area *ap);
void afreeall ARGS((Area *ap)); void afreeall(Area *ap);
void * alloc ARGS((size_t size, Area *ap)); void * alloc(size_t size, Area *ap);
void * aresize ARGS((void *ptr, size_t size, Area *ap)); void * aresize(void *ptr, size_t size, Area *ap);
void afree ARGS((void *ptr, Area *ap)); void afree(void *ptr, Area *ap);
/* c_ksh.c */ /* c_ksh.c */
int c_hash ARGS((char **wp)); int c_hash(char **wp);
int c_cd ARGS((char **wp)); int c_cd(char **wp);
int c_pwd ARGS((char **wp)); int c_pwd(char **wp);
int c_print ARGS((char **wp)); int c_print(char **wp);
int c_whence ARGS((char **wp)); int c_whence(char **wp);
int c_command ARGS((char **wp)); int c_command(char **wp);
int c_typeset ARGS((char **wp)); int c_typeset(char **wp);
int c_alias ARGS((char **wp)); int c_alias(char **wp);
int c_unalias ARGS((char **wp)); int c_unalias(char **wp);
int c_let ARGS((char **wp)); int c_let(char **wp);
int c_jobs ARGS((char **wp)); int c_jobs(char **wp);
int c_fgbg ARGS((char **wp)); int c_fgbg(char **wp);
int c_kill ARGS((char **wp)); int c_kill(char **wp);
void getopts_reset ARGS((int val)); void getopts_reset(int val);
int c_getopts ARGS((char **wp)); int c_getopts(char **wp);
int c_bind ARGS((char **wp)); int c_bind(char **wp);
/* c_sh.c */ /* c_sh.c */
int c_label ARGS((char **wp)); int c_label(char **wp);
int c_shift ARGS((char **wp)); int c_shift(char **wp);
int c_umask ARGS((char **wp)); int c_umask(char **wp);
int c_dot ARGS((char **wp)); int c_dot(char **wp);
int c_wait ARGS((char **wp)); int c_wait(char **wp);
int c_read ARGS((char **wp)); int c_read(char **wp);
int c_eval ARGS((char **wp)); int c_eval(char **wp);
int c_trap ARGS((char **wp)); int c_trap(char **wp);
int c_brkcont ARGS((char **wp)); int c_brkcont(char **wp);
int c_exitreturn ARGS((char **wp)); int c_exitreturn(char **wp);
int c_set ARGS((char **wp)); int c_set(char **wp);
int c_unset ARGS((char **wp)); int c_unset(char **wp);
int c_ulimit ARGS((char **wp)); int c_ulimit(char **wp);
int c_times ARGS((char **wp)); int c_times(char **wp);
int timex ARGS((struct op *t, int f)); int timex(struct op *t, int f);
void timex_hook ARGS((struct op *t, char ** volatile *app)); void timex_hook(struct op *t, char ** volatile *app);
int c_exec ARGS((char **wp)); int c_exec(char **wp);
int c_builtin ARGS((char **wp)); int c_builtin(char **wp);
/* c_test.c */ /* c_test.c */
int c_test ARGS((char **wp)); int c_test(char **wp);
/* edit.c: most prototypes in edit.h */ /* edit.c: most prototypes in edit.h */
void x_init ARGS((void)); void x_init(void);
int x_read ARGS((char *buf, size_t len)); int x_read(char *buf, size_t len);
void set_editmode ARGS((const char *ed)); void set_editmode(const char *ed);
/* emacs.c: most prototypes in edit.h */ /* emacs.c: most prototypes in edit.h */
int x_bind ARGS((const char *a1, const char *a2, int macro, int x_bind(const char *a1, const char *a2, int macro,
int list)); int list);
/* eval.c */ /* eval.c */
char * substitute ARGS((const char *cp, int f)); char * substitute(const char *cp, int f);
char ** eval ARGS((char **ap, int f)); char ** eval(char **ap, int f);
char * evalstr ARGS((char *cp, int f)); char * evalstr(char *cp, int f);
char * evalonestr ARGS((char *cp, int f)); char * evalonestr(char *cp, int f);
char *debunk ARGS((char *dp, const char *sp, size_t dlen)); char *debunk(char *dp, const char *sp, size_t dlen);
void expand ARGS((char *cp, XPtrV *wp, int f)); void expand(char *cp, XPtrV *wp, int f);
int glob_str ARGS((char *cp, XPtrV *wp, int markdirs)); int glob_str(char *cp, XPtrV *wp, int markdirs);
/* exec.c */ /* exec.c */
int fd_clexec ARGS((int fd)); int fd_clexec(int fd);
int execute ARGS((struct op * volatile t, volatile int flags)); int execute(struct op * volatile t, volatile int flags);
int shcomexec ARGS((char **wp)); int shcomexec(char **wp);
struct tbl * findfunc ARGS((const char *name, unsigned int h, int create)); struct tbl * findfunc(const char *name, unsigned int h, int create);
int define ARGS((const char *name, struct op *t)); int define(const char *name, struct op *t);
void builtin ARGS((const char *name, int (*func)(char **))); void builtin(const char *name, int (*func)(char **));
struct tbl * findcom ARGS((const char *name, int flags)); struct tbl * findcom(const char *name, int flags);
void flushcom ARGS((int all)); void flushcom(int all);
char * search ARGS((const char *name, const char *path, int mode, char * search(const char *name, const char *path, int mode,
int *errnop)); int *errnop);
int search_access ARGS((const char *path, int mode, int *errnop)); int search_access(const char *path, int mode, int *errnop);
int pr_menu ARGS((char *const *ap)); int pr_menu(char *const *ap);
int pr_list ARGS((char *const *ap)); int pr_list(char *const *ap);
/* expr.c */ /* expr.c */
int evaluate ARGS((const char *expr, long *rval, int error_ok)); int evaluate(const char *expr, long *rval, int error_ok);
int v_evaluate ARGS((struct tbl *vp, const char *expr, volatile int error_ok)); int v_evaluate(struct tbl *vp, const char *expr, volatile int error_ok);
/* history.c */ /* history.c */
void init_histvec ARGS((void)); void init_histvec(void);
void hist_init ARGS((Source *s)); void hist_init(Source *s);
void hist_finish ARGS((void)); void hist_finish(void);
void histsave ARGS((int lno, const char *cmd, int dowrite)); void histsave(int lno, const char *cmd, int dowrite);
#ifdef HISTORY #ifdef HISTORY
int c_fc ARGS((char **wp)); int c_fc(char **wp);
void sethistsize ARGS((int n)); void sethistsize(int n);
void sethistfile ARGS((const char *name)); void sethistfile(const char *name);
# ifdef EASY_HISTORY # ifdef EASY_HISTORY
void histappend ARGS((const char *cmd, int nl_separate)); void histappend(const char *cmd, int nl_separate);
# endif # endif
char ** histpos ARGS((void)); char ** histpos(void);
int histN ARGS((void)); int histN(void);
int histnum ARGS((int n)); int histnum(int n);
int findhist ARGS((int start, int fwd, const char *str, int findhist(int start, int fwd, const char *str,
int anchored)); int anchored);
#endif /* HISTORY */ #endif /* HISTORY */
/* io.c */ /* io.c */
void errorf ARGS((const char *fmt, ...)) void errorf(const char *fmt, ...)
GCC_FUNC_ATTR2(noreturn, format(printf, 1, 2)); GCC_FUNC_ATTR2(noreturn, format(printf, 1, 2));
void warningf ARGS((int fileline, const char *fmt, ...)) void warningf(int fileline, const char *fmt, ...)
GCC_FUNC_ATTR(format(printf, 2, 3)); GCC_FUNC_ATTR(format(printf, 2, 3));
void bi_errorf ARGS((const char *fmt, ...)) void bi_errorf(const char *fmt, ...)
GCC_FUNC_ATTR(format(printf, 1, 2)); GCC_FUNC_ATTR(format(printf, 1, 2));
void internal_errorf ARGS((int jump, const char *fmt, ...)) void internal_errorf(int jump, const char *fmt, ...)
GCC_FUNC_ATTR(format(printf, 2, 3)); GCC_FUNC_ATTR(format(printf, 2, 3));
void error_prefix ARGS((int fileline)); void error_prefix(int fileline);
void shellf ARGS((const char *fmt, ...)) void shellf(const char *fmt, ...)
GCC_FUNC_ATTR(format(printf, 1, 2)); GCC_FUNC_ATTR(format(printf, 1, 2));
void shprintf ARGS((const char *fmt, ...)) void shprintf(const char *fmt, ...)
GCC_FUNC_ATTR(format(printf, 1, 2)); GCC_FUNC_ATTR(format(printf, 1, 2));
#ifdef KSH_DEBUG #ifdef KSH_DEBUG
void kshdebug_init_ ARGS((void)); void kshdebug_init_(void);
void kshdebug_printf_ ARGS((const char *fmt, ...)) void kshdebug_printf_(const char *fmt, ...)
GCC_FUNC_ATTR(format(printf, 1, 2)); GCC_FUNC_ATTR(format(printf, 1, 2));
void kshdebug_dump_ ARGS((const char *str, const void *mem, int nbytes)); void kshdebug_dump_(const char *str, const void *mem, int nbytes);
#endif /* KSH_DEBUG */ #endif /* KSH_DEBUG */
int can_seek ARGS((int fd)); int can_seek(int fd);
void initio ARGS((void)); void initio(void);
int ksh_dup2 ARGS((int ofd, int nfd, int errok)); int ksh_dup2(int ofd, int nfd, int errok);
int savefd ARGS((int fd, int noclose)); int savefd(int fd, int noclose);
void restfd ARGS((int fd, int ofd)); void restfd(int fd, int ofd);
void openpipe ARGS((int *pv)); void openpipe(int *pv);
void closepipe ARGS((int *pv)); void closepipe(int *pv);
int check_fd ARGS((char *name, int mode, const char **emsgp)); int check_fd(char *name, int mode, const char **emsgp);
#ifdef KSH #ifdef KSH
void coproc_init ARGS((void)); void coproc_init(void);
void coproc_read_close ARGS((int fd)); void coproc_read_close(int fd);
void coproc_readw_close ARGS((int fd)); void coproc_readw_close(int fd);
void coproc_write_close ARGS((int fd)); void coproc_write_close(int fd);
int coproc_getfd ARGS((int mode, const char **emsgp)); int coproc_getfd(int mode, const char **emsgp);
void coproc_cleanup ARGS((int reuse)); void coproc_cleanup(int reuse);
#endif /* KSH */ #endif /* KSH */
struct temp *maketemp ARGS((Area *ap, Temp_type type, struct temp **tlist)); struct temp *maketemp(Area *ap, Temp_type type, struct temp **tlist);
/* jobs.c */ /* jobs.c */
void j_init ARGS((int mflagset)); void j_init(int mflagset);
void j_exit ARGS((void)); void j_exit(void);
void j_change ARGS((void)); void j_change(void);
int exchild ARGS((struct op *t, int flags, int close_fd)); int exchild(struct op *t, int flags, int close_fd);
void startlast ARGS((void)); void startlast(void);
int waitlast ARGS((void)); int waitlast(void);
int waitfor ARGS((const char *cp, int *sigp)); int waitfor(const char *cp, int *sigp);
int j_kill ARGS((const char *cp, int sig)); int j_kill(const char *cp, int sig);
int j_resume ARGS((const char *cp, int bg)); int j_resume(const char *cp, int bg);
int j_jobs ARGS((const char *cp, int slp, int nflag)); int j_jobs(const char *cp, int slp, int nflag);
void j_notify ARGS((void)); void j_notify(void);
pid_t j_async ARGS((void)); pid_t j_async(void);
int j_stopped_running ARGS((void)); int j_stopped_running(void);
/* lex.c */ /* lex.c */
int yylex ARGS((int cf)); int yylex(int cf);
void yyerror ARGS((const char *fmt, ...)) void yyerror(const char *fmt, ...)
GCC_FUNC_ATTR2(noreturn, format(printf, 1, 2)); GCC_FUNC_ATTR2(noreturn, format(printf, 1, 2));
Source * pushs ARGS((int type, Area *areap)); Source * pushs(int type, Area *areap);
void set_prompt ARGS((int to, Source *s)); void set_prompt(int to, Source *s);
void pprompt ARGS((const char *cp, int ntruncate)); void pprompt(const char *cp, int ntruncate);
/* mail.c */ /* mail.c */
#ifdef KSH #ifdef KSH
void mcheck ARGS((void)); void mcheck(void);
void mcset ARGS((long interval)); void mcset(long interval);
void mbset ARGS((char *p)); void mbset(char *p);
void mpset ARGS((char *mptoparse)); void mpset(char *mptoparse);
#endif /* KSH */ #endif /* KSH */
/* main.c */ /* main.c */
int include ARGS((const char *name, int argc, char **argv, int include(const char *name, int argc, char **argv,
int intr_ok)); int intr_ok);
int command ARGS((const char *comm)); int command(const char *comm);
int shell ARGS((Source *volatile s, int volatile toplevel)); int shell(Source *volatile s, int volatile toplevel);
void unwind ARGS((int i)) GCC_FUNC_ATTR(noreturn); void unwind(int i) GCC_FUNC_ATTR(noreturn);
void newenv ARGS((int type)); void newenv(int type);
void quitenv ARGS((void)); void quitenv(void);
void cleanup_parents_env ARGS((void)); void cleanup_parents_env(void);
void cleanup_proc_env ARGS((void)); void cleanup_proc_env(void);
void aerror ARGS((Area *ap, const char *msg)) void aerror(Area *ap, const char *msg)
GCC_FUNC_ATTR(noreturn); GCC_FUNC_ATTR(noreturn);
/* misc.c */ /* misc.c */
void setctypes ARGS((const char *s, int t)); void setctypes(const char *s, int t);
void initctypes ARGS((void)); void initctypes(void);
char * ulton ARGS((unsigned long n, int base)); char * ulton(unsigned long n, int base);
char * str_save ARGS((const char *s, Area *ap)); char * str_save(const char *s, Area *ap);
char * str_nsave ARGS((const char *s, int n, Area *ap)); char * str_nsave(const char *s, int n, Area *ap);
int option ARGS((const char *n)); int option(const char *n);
char * getoptions ARGS((void)); char * getoptions(void);
void change_flag ARGS((enum sh_flag f, int what, int newval)); void change_flag(enum sh_flag f, int what, int newval);
int parse_args ARGS((char **argv, int what, int *setargsp)); int parse_args(char **argv, int what, int *setargsp);
int getn ARGS((const char *as, int *ai)); int getn(const char *as, int *ai);
int bi_getn ARGS((const char *as, int *ai)); int bi_getn(const char *as, int *ai);
int gmatch ARGS((const char *s, const char *p, int isfile)); int gmatch(const char *s, const char *p, int isfile);
int has_globbing ARGS((const char *xp, const char *xpe)); int has_globbing(const char *xp, const char *xpe);
const unsigned char *pat_scan ARGS((const unsigned char *p, const unsigned char *pat_scan(const unsigned char *p,
const unsigned char *pe, int match_sep)); const unsigned char *pe, int match_sep);
void qsortp ARGS((void **base, size_t n, int (*f)(void *, void *))); void qsortp(void **base, size_t n, int (*f)(void *, void *));
int xstrcmp ARGS((void *p1, void *p2)); int xstrcmp(void *p1, void *p2);
void ksh_getopt_reset ARGS((Getopt *go, int)); void ksh_getopt_reset(Getopt *go, int);
int ksh_getopt ARGS((char **argv, Getopt *go, const char *options)); int ksh_getopt(char **argv, Getopt *go, const char *options);
void print_value_quoted ARGS((const char *s)); void print_value_quoted(const char *s);
void print_columns ARGS((struct shf *shf, int n, void print_columns(struct shf *shf, int n,
char *(*func)(void *, int, char *, int), char *(*func)(void *, int, char *, int),
void *arg, int max_width, int prefcol)); void *arg, int max_width, int prefcol);
int strip_nuls ARGS((char *buf, int nbytes)); int strip_nuls(char *buf, int nbytes);
char *str_zcpy ARGS((char *dst, const char *src, int dsize)); char *str_zcpy(char *dst, const char *src, int dsize);
int blocking_read ARGS((int fd, char *buf, int nbytes)); int blocking_read(int fd, char *buf, int nbytes);
int reset_nonblock ARGS((int fd)); int reset_nonblock(int fd);
char *ksh_get_wd ARGS((char *buf, int bsize)); char *ksh_get_wd(char *buf, int bsize);
/* path.c */ /* path.c */
int make_path ARGS((const char *cwd, const char *file, int make_path(const char *cwd, const char *file,
char **pathlist, XString *xsp, int *phys_pathp)); char **pathlist, XString *xsp, int *phys_pathp);
void simplify_path ARGS((char *path)); void simplify_path(char *path);
char *get_phys_path ARGS((const char *path)); char *get_phys_path(const char *path);
void set_current_wd ARGS((char *path)); void set_current_wd(char *path);
/* rnd.c */ /* rnd.c */
long rnd_get ARGS((void)); long rnd_get(void);
void rnd_put ARGS((long)); void rnd_put(long);
void rnd_seed ARGS((long)); void rnd_seed(long);
/* syn.c */ /* syn.c */
void initkeywords ARGS((void)); void initkeywords(void);
struct op * compile ARGS((Source *s)); struct op * compile(Source *s);
/* table.c */ /* table.c */
unsigned int hash ARGS((const char *n)); unsigned int hash(const char *n);
void tinit ARGS((struct table *tp, Area *ap, int tsize)); void tinit(struct table *tp, Area *ap, int tsize);
struct tbl * tsearch ARGS((struct table *tp, const char *n, unsigned int h)); struct tbl * tsearch(struct table *tp, const char *n, unsigned int h);
struct tbl * tenter ARGS((struct table *tp, const char *n, unsigned int h)); struct tbl * tenter(struct table *tp, const char *n, unsigned int h);
void tdelete ARGS((struct tbl *p)); void tdelete(struct tbl *p);
void twalk ARGS((struct tstate *ts, struct table *tp)); void twalk(struct tstate *ts, struct table *tp);
struct tbl * tnext ARGS((struct tstate *ts)); struct tbl * tnext(struct tstate *ts);
struct tbl ** tsort ARGS((struct table *tp)); struct tbl ** tsort(struct table *tp);
/* trace.c */ /* trace.c */
/* trap.c */ /* trap.c */
void inittraps ARGS((void)); void inittraps(void);
#ifdef KSH #ifdef KSH
void alarm_init ARGS((void)); void alarm_init(void);
#endif /* KSH */ #endif /* KSH */
Trap * gettrap ARGS((const char *name, int igncase)); Trap * gettrap(const char *name, int igncase);
RETSIGTYPE trapsig ARGS((int i)); RETSIGTYPE trapsig(int i);
void intrcheck ARGS((void)); void intrcheck(void);
int fatal_trap_check ARGS((void)); int fatal_trap_check(void);
int trap_pending ARGS((void)); int trap_pending(void);
void runtraps ARGS((int intr)); void runtraps(int intr);
void runtrap ARGS((Trap *p)); void runtrap(Trap *p);
void cleartraps ARGS((void)); void cleartraps(void);
void restoresigs ARGS((void)); void restoresigs(void);
void settrap ARGS((Trap *p, char *s)); void settrap(Trap *p, char *s);
int block_pipe ARGS((void)); int block_pipe(void);
void restore_pipe ARGS((int restore_dfl)); void restore_pipe(int restore_dfl);
int setsig ARGS((Trap *p, handler_t f, int flags)); int setsig(Trap *p, handler_t f, int flags);
void setexecsig ARGS((Trap *p, int restore)); void setexecsig(Trap *p, int restore);
/* tree.c */ /* tree.c */
int fptreef ARGS((struct shf *f, int indent, const char *fmt, ...)); int fptreef(struct shf *f, int indent, const char *fmt, ...);
char * snptreef ARGS((char *s, int n, const char *fmt, ...)); char * snptreef(char *s, int n, const char *fmt, ...);
struct op * tcopy ARGS((struct op *t, Area *ap)); struct op * tcopy(struct op *t, Area *ap);
char * wdcopy ARGS((const char *wp, Area *ap)); char * wdcopy(const char *wp, Area *ap);
char * wdscan ARGS((const char *wp, int c)); char * wdscan(const char *wp, int c);
char * wdstrip ARGS((const char *wp)); char * wdstrip(const char *wp);
void tfree ARGS((struct op *t, Area *ap)); void tfree(struct op *t, Area *ap);
/* var.c */ /* var.c */
void newblock ARGS((void)); void newblock(void);
void popblock ARGS((void)); void popblock(void);
void initvar ARGS((void)); void initvar(void);
struct tbl * global ARGS((const char *n)); struct tbl * global(const char *n);
struct tbl * local ARGS((const char *n, bool_t copy)); struct tbl * local(const char *n, bool_t copy);
char * str_val ARGS((struct tbl *vp)); char * str_val(struct tbl *vp);
long intval ARGS((struct tbl *vp)); long intval(struct tbl *vp);
int setstr ARGS((struct tbl *vq, const char *s, int error_ok)); int setstr(struct tbl *vq, const char *s, int error_ok);
struct tbl *setint_v ARGS((struct tbl *vq, struct tbl *vp)); struct tbl *setint_v(struct tbl *vq, struct tbl *vp);
void setint ARGS((struct tbl *vq, long n)); void setint(struct tbl *vq, long n);
int getint ARGS((struct tbl *vp, long *nump)); int getint(struct tbl *vp, long *nump);
struct tbl * typeset ARGS((const char *var, Tflag set, Tflag clr, int field, int base)); struct tbl * typeset(const char *var, Tflag set, Tflag clr, int field, int base);
void unset ARGS((struct tbl *vp, int array_ref)); void unset(struct tbl *vp, int array_ref);
char * skip_varname ARGS((const char *s, int aok)); char * skip_varname(const char *s, int aok);
char *skip_wdvarname ARGS((const char *s, int aok)); char *skip_wdvarname(const char *s, int aok);
int is_wdvarname ARGS((const char *s, int aok)); int is_wdvarname(const char *s, int aok);
int is_wdvarassign ARGS((const char *s)); int is_wdvarassign(const char *s);
char ** makenv ARGS((void)); char ** makenv(void);
void change_random ARGS((void)); void change_random(void);
int array_ref_len ARGS((const char *cp)); int array_ref_len(const char *cp);
char * arrayname ARGS((const char *str)); char * arrayname(const char *str);
void set_array ARGS((const char *var, int reset, char **vals)); void set_array(const char *var, int reset, char **vals);
/* version.c */ /* version.c */
/* vi.c: see edit.h */ /* vi.c: see edit.h */
/* Hack to avoid billions of compile warnings on SunOS 4.1.x */ /* Hack to avoid billions of compile warnings on SunOS 4.1.x */
#if defined(MUN) && defined(sun) && !defined(__svr4__) #if defined(MUN) && defined(sun) && !defined(__svr4__)
extern void bcopy ARGS((const void *src, void *dst, size_t size)); extern void bcopy(const void *src, void *dst, size_t size);
extern int fclose ARGS((FILE *fp)); extern int fclose(FILE *fp);
extern int fprintf ARGS((FILE *fp, const char *fmt, ...)); extern int fprintf(FILE *fp, const char *fmt, ...);
extern int fread ARGS((void *buf, int size, int num, FILE *fp)); extern int fread(void *buf, int size, int num, FILE *fp);
extern int ioctl ARGS((int fd, int request, void *arg)); extern int ioctl(int fd, int request, void *arg);
extern int killpg ARGS((int pgrp, int sig)); extern int killpg(int pgrp, int sig);
extern int nice ARGS((int n)); extern int nice(int n);
extern int readlink ARGS((const char *path, char *buf, int bufsize)); extern int readlink(const char *path, char *buf, int bufsize);
extern int setpgrp ARGS((int pid, int pgrp)); extern int setpgrp(int pid, int pgrp);
extern int strcasecmp ARGS((const char *s1, const char *s2)); extern int strcasecmp(const char *s1, const char *s2);
extern int tolower ARGS((int)); extern int tolower(int);
extern int toupper ARGS((int)); extern int toupper(int);
/* Include files aren't included yet */ /* Include files aren't included yet */
extern int getrlimit ARGS(( /* int resource, struct rlimit *rpl */ )); extern int getrlimit( /* int resource, struct rlimit *rpl */ );
extern int getrusage ARGS(( /* int who, struct rusage *rusage */ )); extern int getrusage( /* int who, struct rusage *rusage */ );
extern int gettimeofday ARGS(( /* struct timeval *tv, struct timezone *tz */ )); extern int gettimeofday( /* struct timeval *tv, struct timezone *tz */ );
extern int setrlimit ARGS(( /* int resource, struct rlimit *rlp */ )); extern int setrlimit( /* int resource, struct rlimit *rlp */ );
extern int lstat ARGS(( /* const char *path, struct stat *buf */ )); extern int lstat( /* const char *path, struct stat *buf */ );
#endif #endif

88
sh.h
View File

@ -1,4 +1,4 @@
/** $MirBSD: sh.h,v 1.13 2004/09/21 11:57:13 tg Exp $ */ /** $MirBSD: sh.h,v 1.14 2004/10/28 11:11:19 tg Exp $ */
/* $OpenBSD: sh.h,v 1.18 2004/05/31 10:36:35 otto Exp $ */ /* $OpenBSD: sh.h,v 1.18 2004/05/31 10:36:35 otto Exp $ */
/* /*
@ -10,12 +10,6 @@
#include "config.h" /* system and option configuration info */ #include "config.h" /* system and option configuration info */
#ifdef HAVE_PROTOTYPES
# define ARGS(args) args /* prototype declaration */
#else
# define ARGS(args) () /* K&R declaration */
#endif
/* Start of common headers */ /* Start of common headers */
#include <stdio.h> #include <stdio.h>
@ -29,51 +23,51 @@
# include <stdlib.h> # include <stdlib.h>
#else #else
/* just a useful subset of what stdlib.h would have */ /* just a useful subset of what stdlib.h would have */
extern char * getenv ARGS((const char *)); extern char * getenv(const char *);
extern void * malloc ARGS((size_t)); extern void * malloc(size_t);
extern void * realloc ARGS((void *, size_t)); extern void * realloc(void *, size_t);
extern int free ARGS((void *)); extern int free(void *);
extern int exit ARGS((int)); extern int exit(int);
extern int atoi ARGS((const char *)); extern int atoi(const char *);
#endif /* HAVE_STDLIB_H */ #endif /* HAVE_STDLIB_H */
#ifdef HAVE_UNISTD_H #ifdef HAVE_UNISTD_H
# include <unistd.h> # include <unistd.h>
#else #else
/* just a useful subset of what unistd.h would have */ /* just a useful subset of what unistd.h would have */
extern int access ARGS((const char *, int)); extern int access(const char *, int);
extern int open ARGS((const char *, int, ...)); extern int open(const char *, int, ...);
extern int creat ARGS((const char *, mode_t)); extern int creat(const char *, mode_t);
extern int read ARGS((int, char *, unsigned)); extern int read(int, char *, unsigned);
extern int write ARGS((int, const char *, unsigned)); extern int write(int, const char *, unsigned);
extern off_t lseek ARGS((int, off_t, int)); extern off_t lseek(int, off_t, int);
extern int close ARGS((int)); extern int close(int);
extern int pipe ARGS((int [])); extern int pipe(int []);
extern int dup2 ARGS((int, int)); extern int dup2(int, int);
extern int unlink ARGS((const char *)); extern int unlink(const char *);
extern int fork ARGS((void)); extern int fork(void);
extern int execve ARGS((const char *, char * const[], char * const[])); extern int execve(const char *, char * const[], char * const[]);
extern int chdir ARGS((const char *)); extern int chdir(const char *);
extern int kill ARGS((pid_t, int)); extern int kill(pid_t, int);
extern char *getcwd(); /* no ARGS here - differs on different machines */ extern char *getcwd(); /* no ARGS here - differs on different machines */
extern int geteuid ARGS((void)); extern int geteuid(void);
extern int readlink ARGS((const char *, char *, int)); extern int readlink(const char *, char *, int);
extern int getegid ARGS((void)); extern int getegid(void);
extern int getpid ARGS((void)); extern int getpid(void);
extern int getppid ARGS((void)); extern int getppid(void);
extern unsigned int sleep ARGS((unsigned int)); extern unsigned int sleep(unsigned int);
extern int isatty ARGS((int)); extern int isatty(int);
# ifdef POSIX_PGRP # ifdef POSIX_PGRP
extern int getpgrp ARGS((void)); extern int getpgrp(void);
extern int setpgid ARGS((pid_t, pid_t)); extern int setpgid(pid_t, pid_t);
# endif /* POSIX_PGRP */ # endif /* POSIX_PGRP */
# ifdef BSD_PGRP # ifdef BSD_PGRP
extern int getpgrp ARGS((pid_t)); extern int getpgrp(pid_t);
extern int setpgrp ARGS((pid_t, pid_t)); extern int setpgrp(pid_t, pid_t);
# endif /* BSD_PGRP */ # endif /* BSD_PGRP */
# ifdef SYSV_PGRP # ifdef SYSV_PGRP
extern int getpgrp ARGS((void)); extern int getpgrp(void);
extern int setpgrp ARGS((void)); extern int setpgrp(void);
# endif /* SYSV_PGRP */ # endif /* SYSV_PGRP */
#endif /* HAVE_UNISTD_H */ #endif /* HAVE_UNISTD_H */
@ -85,11 +79,11 @@ extern int setpgrp ARGS((void));
# define strrchr rindex # define strrchr rindex
#endif /* HAVE_STRING_H */ #endif /* HAVE_STRING_H */
#ifndef HAVE_STRSTR #ifndef HAVE_STRSTR
char *strstr ARGS((const char *s, const char *p)); char *strstr(const char *s, const char *p);
#endif /* HAVE_STRSTR */ #endif /* HAVE_STRSTR */
#ifndef HAVE_STRCASECMP #ifndef HAVE_STRCASECMP
int strcasecmp ARGS((const char *s1, const char *s2)); int strcasecmp(const char *s1, const char *s2);
int strncasecmp ARGS((const char *s1, const char *s2, int n)); int strncasecmp(const char *s1, const char *s2, int n);
#endif /* HAVE_STRCASECMP */ #endif /* HAVE_STRCASECMP */
#ifdef HAVE_MEMORY_H #ifdef HAVE_MEMORY_H
@ -98,13 +92,13 @@ int strncasecmp ARGS((const char *s1, const char *s2, int n));
#ifndef HAVE_MEMSET #ifndef HAVE_MEMSET
# define memcpy(d, s, n) bcopy(s, d, n) # define memcpy(d, s, n) bcopy(s, d, n)
# define memcmp(s1, s2, n) bcmp(s1, s2, n) # define memcmp(s1, s2, n) bcmp(s1, s2, n)
void *memset ARGS((void *d, int c, size_t n)); void *memset(void *d, int c, size_t n);
#endif /* HAVE_MEMSET */ #endif /* HAVE_MEMSET */
#ifndef HAVE_MEMMOVE #ifndef HAVE_MEMMOVE
# ifdef HAVE_BCOPY # ifdef HAVE_BCOPY
# define memmove(d, s, n) bcopy(s, d, n) # define memmove(d, s, n) bcopy(s, d, n)
# else # else
void *memmove ARGS((void *d, const void *s, size_t n)); void *memmove(void *d, const void *s, size_t n);
# endif # endif
#endif /* HAVE_MEMMOVE */ #endif /* HAVE_MEMMOVE */
@ -179,7 +173,7 @@ void *memmove ARGS((void *d, const void *s, size_t n));
# define KSH_SA_FLAGS 0 # define KSH_SA_FLAGS 0
#endif /* SA_INTERRUPT */ #endif /* SA_INTERRUPT */
typedef RETSIGTYPE (*handler_t) ARGS((int)); /* signal handler */ typedef RETSIGTYPE (*handler_t)(int); /* signal handler */
#ifdef USE_FAKE_SIGACT #ifdef USE_FAKE_SIGACT
# include "sigact.h" /* use sjg's fake sigaction() */ # include "sigact.h" /* use sjg's fake sigaction() */
@ -238,7 +232,7 @@ extern int ksh_execve(char *cmd, char **args, char **env, int flags);
#endif /* HAVE_SIGSETJMP */ #endif /* HAVE_SIGSETJMP */
#ifndef HAVE_DUP2 #ifndef HAVE_DUP2
extern int dup2 ARGS((int, int)); extern int dup2(int, int);
#endif /* !HAVE_DUP2 */ #endif /* !HAVE_DUP2 */
/* Find a integer type that is at least 32 bits (or die) - SIZEOF_* defined /* Find a integer type that is at least 32 bits (or die) - SIZEOF_* defined

7
shf.c
View File

@ -1,4 +1,4 @@
/** $MirBSD: shf.c,v 1.4 2004/09/21 11:57:14 tg Exp $ */ /** $MirBSD: shf.c,v 1.5 2004/10/28 11:11:19 tg Exp $ */
/* $OpenBSD: shf.c,v 1.8 2003/02/28 09:45:09 jmc Exp $ */ /* $OpenBSD: shf.c,v 1.8 2003/02/28 09:45:09 jmc Exp $ */
/* /*
@ -9,6 +9,7 @@
#include "ksh_stat.h" #include "ksh_stat.h"
#include "ksh_limval.h" #include "ksh_limval.h"
__RCSID("$MirBSD: shf.c,v 1.5 2004/10/28 11:11:19 tg Exp $");
/* flags to shf_emptybuf() */ /* flags to shf_emptybuf() */
#define EB_READSW 0x01 /* about to switch to reading */ #define EB_READSW 0x01 /* about to switch to reading */
@ -20,8 +21,8 @@
* file descriptors. * file descriptors.
*/ */
static int shf_fillbuf ARGS((struct shf *shf)); static int shf_fillbuf(struct shf *shf);
static int shf_emptybuf ARGS((struct shf *shf, int flags)); static int shf_emptybuf(struct shf *shf, int flags);
/* Open a file. First three args are for open(), last arg is flags for /* Open a file. First three args are for open(), last arg is flags for
* this package. Returns NULL if file could not be opened, or if a dup * this package. Returns NULL if file could not be opened, or if a dup

48
shf.h
View File

@ -1,4 +1,4 @@
/** $MirBSD: shf.h,v 1.3 2004/09/21 11:57:14 tg Exp $ */ /** $MirBSD: shf.h,v 1.4 2004/10/28 11:11:19 tg Exp $ */
/* $OpenBSD: shf.h,v 1.2 1999/01/08 20:25:02 millert Exp $ */ /* $OpenBSD: shf.h,v 1.2 1999/01/08 20:25:02 millert Exp $ */
#ifndef SHF_H #ifndef SHF_H
@ -60,28 +60,28 @@ struct shf {
extern struct shf shf_iob[]; extern struct shf shf_iob[];
struct shf *shf_open ARGS((const char *name, int oflags, int mode, struct shf *shf_open(const char *name, int oflags, int mode,
int sflags)); int sflags);
struct shf *shf_fdopen ARGS((int fd, int sflags, struct shf *shf)); struct shf *shf_fdopen(int fd, int sflags, struct shf *shf);
struct shf *shf_reopen ARGS((int fd, int sflags, struct shf *shf)); struct shf *shf_reopen(int fd, int sflags, struct shf *shf);
struct shf *shf_sopen ARGS((char *buf, int bsize, int sflags, struct shf *shf_sopen(char *buf, int bsize, int sflags,
struct shf *shf)); struct shf *shf);
int shf_close ARGS((struct shf *shf)); int shf_close(struct shf *shf);
int shf_fdclose ARGS((struct shf *shf)); int shf_fdclose(struct shf *shf);
char *shf_sclose ARGS((struct shf *shf)); char *shf_sclose(struct shf *shf);
int shf_finish ARGS((struct shf *shf)); int shf_finish(struct shf *shf);
int shf_flush ARGS((struct shf *shf)); int shf_flush(struct shf *shf);
int shf_seek ARGS((struct shf *shf, off_t where, int from)); int shf_seek(struct shf *shf, off_t where, int from);
int shf_read ARGS((char *buf, int bsize, struct shf *shf)); int shf_read(char *buf, int bsize, struct shf *shf);
char *shf_getse ARGS((char *buf, int bsize, struct shf *shf)); char *shf_getse(char *buf, int bsize, struct shf *shf);
int shf_getchar ARGS((struct shf *shf)); int shf_getchar(struct shf *shf);
int shf_ungetc ARGS((int c, struct shf *shf)); int shf_ungetc(int c, struct shf *shf);
int shf_putchar ARGS((int c, struct shf *shf)); int shf_putchar(int c, struct shf *shf);
int shf_puts ARGS((const char *s, struct shf *shf)); int shf_puts(const char *s, struct shf *shf);
int shf_write ARGS((const char *buf, int nbytes, struct shf *shf)); int shf_write(const char *buf, int nbytes, struct shf *shf);
int shf_fprintf ARGS((struct shf *shf, const char *fmt, ...)); int shf_fprintf(struct shf *shf, const char *fmt, ...);
int shf_snprintf ARGS((char *buf, int bsize, const char *fmt, ...)); int shf_snprintf(char *buf, int bsize, const char *fmt, ...);
char *shf_smprintf ARGS((const char *fmt, ...)); char *shf_smprintf(const char *fmt, ...);
int shf_vfprintf ARGS((struct shf *, const char *fmt, va_list args)); int shf_vfprintf(struct shf *, const char *fmt, va_list args);
#endif /* SHF_H */ #endif /* SHF_H */

62
syn.c
View File

@ -1,4 +1,4 @@
/** $MirBSD: syn.c,v 1.5 2004/10/28 11:03:24 tg Exp $ */ /** $MirBSD: syn.c,v 1.6 2004/10/28 11:11:19 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,44 +8,44 @@
#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 $"); __RCSID("$MirBSD: syn.c,v 1.6 2004/10/28 11:11:19 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 */
}; };
static void yyparse ARGS((void)); static void yyparse(void);
static struct op *pipeline ARGS((int cf)); static struct op *pipeline(int cf);
static struct op *andor ARGS((void)); static struct op *andor(void);
static struct op *c_list ARGS((int multi)); static struct op *c_list(int multi);
static struct ioword *synio ARGS((int cf)); static struct ioword *synio(int cf);
static void musthave ARGS((int c, int cf)); static void musthave(int c, int cf);
static struct op *nested ARGS((int type, int smark, int emark)); static struct op *nested(int type, int smark, int emark);
static struct op *get_command ARGS((int cf)); static struct op *get_command(int cf);
static struct op *dogroup ARGS((void)); static struct op *dogroup(void);
static struct op *thenpart ARGS((void)); static struct op *thenpart(void);
static struct op *elsepart ARGS((void)); static struct op *elsepart(void);
static struct op *caselist ARGS((void)); static struct op *caselist(void);
static struct op *casepart ARGS((int endtok)); static struct op *casepart(int endtok);
static struct op *function_body ARGS((char *name, int ksh_func)); static struct op *function_body(char *name, int ksh_func);
static char ** wordlist ARGS((void)); static char ** wordlist(void);
static struct op *block ARGS((int type, struct op *t1, struct op *t2, static struct op *block(int type, struct op *t1, struct op *t2,
char **wp)); char **wp);
static struct op *newtp ARGS((int type)); static struct op *newtp(int type);
static void syntaxerr ARGS((const char *what)) static void syntaxerr(const char *what)
GCC_FUNC_ATTR(noreturn); GCC_FUNC_ATTR(noreturn);
static void nesting_push ARGS((struct nesting_state *save, int tok)); static void nesting_push(struct nesting_state *save, int tok);
static void nesting_pop ARGS((struct nesting_state *saved)); static void nesting_pop(struct nesting_state *saved);
static int assign_command ARGS((char *s)); static int assign_command(char *s);
static int inalias ARGS((struct source *s)); static int inalias(struct source *s);
#ifdef KSH #ifdef KSH
static int dbtestp_isa ARGS((Test_env *te, Test_meta meta)); static int dbtestp_isa(Test_env *te, Test_meta meta);
static const char *dbtestp_getopnd ARGS((Test_env *te, Test_op op, static const char *dbtestp_getopnd(Test_env *te, Test_op op,
int do_eval)); int do_eval);
static int dbtestp_eval ARGS((Test_env *te, Test_op op, const char *opnd1, static int dbtestp_eval(Test_env *te, Test_op op, const char *opnd1,
const char *opnd2, int do_eval)); const char *opnd2, int do_eval);
static void dbtestp_error ARGS((Test_env *te, int offset, const char *msg)); static void dbtestp_error(Test_env *te, int offset, const char *msg);
#endif /* KSH */ #endif /* KSH */
static struct op *outtree; /* yyparse output */ static struct op *outtree; /* yyparse output */

10
table.c
View File

@ -1,4 +1,4 @@
/** $MirBSD: table.c,v 1.4 2004/10/28 11:03:24 tg Exp $ */ /** $MirBSD: table.c,v 1.5 2004/10/28 11:11:19 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 $ */
/* /*
@ -7,10 +7,12 @@
#include "sh.h" #include "sh.h"
__RCSID("$MirBSD: table.c,v 1.5 2004/10/28 11:11:19 tg Exp $");
#define INIT_TBLS 8 /* initial table size (power of 2) */ #define INIT_TBLS 8 /* initial table size (power of 2) */
static void texpand ARGS((struct table *tp, int nsize)); static void texpand(struct table *tp, int nsize);
static int tnamecmp ARGS((void *p1, void *p2)); static int tnamecmp(void *p1, void *p2);
unsigned int unsigned int
@ -194,7 +196,7 @@ tsort(tp)
#ifdef PERF_DEBUG /* performance debugging */ #ifdef PERF_DEBUG /* performance debugging */
void tprintinfo ARGS((struct table *tp)); void tprintinfo(struct table *tp);
void void
tprintinfo(tp) tprintinfo(tp)

View File

@ -1,4 +1,4 @@
/** $MirBSD: table.h,v 1.3 2004/09/21 11:57:16 tg Exp $ */ /** $MirBSD: table.h,v 1.4 2004/10/28 11:11:19 tg Exp $ */
/* $OpenBSD: table.h,v 1.5 1999/06/15 01:18:36 millert Exp $ */ /* $OpenBSD: table.h,v 1.5 1999/06/15 01:18:36 millert Exp $ */
/* $From: table.h,v 1.3 1994/05/31 13:34:34 michael Exp $ */ /* $From: table.h,v 1.3 1994/05/31 13:34:34 michael Exp $ */
@ -20,7 +20,7 @@ struct tbl { /* table item */
union { union {
char *s; /* string */ char *s; /* string */
long i; /* integer */ long i; /* integer */
int (*f) ARGS((char **)); /* int function */ int (*f)(char **); /* int function */
struct op *t; /* "function" tree */ struct op *t; /* "function" tree */
} val; /* value */ } val; /* value */
int index; /* index for an array */ int index; /* index for an array */
@ -145,7 +145,7 @@ EXTERN struct table homedirs; /* homedir() cache */
struct builtin { struct builtin {
const char *name; const char *name;
int (*func) ARGS((char **)); int (*func)(char **);
}; };
/* these really are externs! Look in table.c for them */ /* these really are externs! Look in table.c for them */

6
trap.c
View File

@ -1,4 +1,4 @@
/** $MirBSD: trap.c,v 1.4 2004/10/28 11:03:24 tg Exp $ */ /** $MirBSD: trap.c,v 1.5 2004/10/28 11:11:19 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,7 +9,7 @@
#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 $"); __RCSID("$MirBSD: trap.c,v 1.5 2004/10/28 11:11:19 tg Exp $");
/* Table is indexed by signal number /* Table is indexed by signal number
* *
@ -59,7 +59,7 @@ inittraps()
} }
#ifdef KSH #ifdef KSH
static RETSIGTYPE alarm_catcher ARGS((int sig)); static RETSIGTYPE alarm_catcher(int sig);
void void
alarm_init() alarm_init()

18
tree.c
View File

@ -1,4 +1,4 @@
/** $MirBSD: tree.c,v 1.4 2004/10/28 11:03:24 tg Exp $ */ /** $MirBSD: tree.c,v 1.5 2004/10/28 11:11:19 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,18 +7,18 @@
#include "sh.h" #include "sh.h"
__RCSID("$MirBSD: tree.c,v 1.4 2004/10/28 11:03:24 tg Exp $"); __RCSID("$MirBSD: tree.c,v 1.5 2004/10/28 11:11:19 tg Exp $");
#define INDENT 4 #define INDENT 4
#define tputc(c, shf) shf_putchar(c, shf); #define tputc(c, shf) shf_putchar(c, shf);
static void ptree ARGS((struct op *t, int indent, struct shf *f)); static void ptree(struct op *t, int indent, struct shf *f);
static void pioact ARGS((struct shf *f, int indent, struct ioword *iop)); static void pioact(struct shf *f, int indent, struct ioword *iop);
static void tputC ARGS((int c, struct shf *shf)); static void tputC(int c, struct shf *shf);
static void tputS ARGS((char *wp, struct shf *shf)); static void tputS(char *wp, struct shf *shf);
static void vfptreef ARGS((struct shf *shf, int indent, const char *fmt, va_list va)); static void vfptreef(struct shf *shf, int indent, const char *fmt, va_list va);
static struct ioword **iocopy ARGS((struct ioword **iow, Area *ap)); static struct ioword **iocopy(struct ioword **iow, Area *ap);
static void iofree ARGS((struct ioword **iow, Area *ap)); static void iofree(struct ioword **iow, Area *ap);
/* /*
* print a command tree * print a command tree

6
tty.c
View File

@ -1,4 +1,4 @@
/** $MirBSD: tty.c,v 1.4 2004/10/28 11:03:24 tg Exp $ */ /** $MirBSD: tty.c,v 1.5 2004/10/28 11:11:19 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,7 +7,7 @@
#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 $"); __RCSID("$MirBSD: tty.c,v 1.5 2004/10/28 11:11:19 tg Exp $");
int int
get_tty(fd, ts) get_tty(fd, ts)
@ -119,7 +119,7 @@ tty_init(init_ttystate)
* so force it to be done here... * so force it to be done here...
*/ */
{ {
extern char *ttyname ARGS((int)); extern char *ttyname(int);
char *s = ttyname(isatty(2) ? 2 : 0); char *s = ttyname(isatty(2) ? 2 : 0);
int fd; int fd;

10
tty.h
View File

@ -1,4 +1,4 @@
/** $MirBSD: tty.h,v 1.3 2004/09/21 11:57:16 tg Exp $ */ /** $MirBSD: tty.h,v 1.4 2004/10/28 11:11:19 tg Exp $ */
/* $OpenBSD: tty.h,v 1.2 1996/11/21 07:59:36 downsj Exp $ */ /* $OpenBSD: tty.h,v 1.2 1996/11/21 07:59:36 downsj Exp $ */
/* /*
@ -97,10 +97,10 @@ EXTERN int tty_fd I__(-1); /* dup'd tty file descriptor */
EXTERN int tty_devtty; /* true if tty_fd is from /dev/tty */ EXTERN int tty_devtty; /* true if tty_fd is from /dev/tty */
EXTERN TTY_state tty_state; /* saved tty state */ EXTERN TTY_state tty_state; /* saved tty state */
extern int get_tty ARGS((int fd, TTY_state *ts)); extern int get_tty(int fd, TTY_state *ts);
extern int set_tty ARGS((int fd, TTY_state *ts, int flags)); extern int set_tty(int fd, TTY_state *ts, int flags);
extern void tty_init ARGS((int init_ttystate)); extern void tty_init(int init_ttystate);
extern void tty_close ARGS((void)); extern void tty_close(void);
/* be sure not to interfere with anyone else's idea about EXTERN */ /* be sure not to interfere with anyone else's idea about EXTERN */
#ifdef EXTERN_DEFINED #ifdef EXTERN_DEFINED

20
var.c
View File

@ -1,4 +1,4 @@
/** $MirBSD: var.c,v 1.9 2004/10/28 11:03:24 tg Exp $ */ /** $MirBSD: var.c,v 1.10 2004/10/28 11:11:19 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"
@ -7,6 +7,8 @@
#include "ksh_stat.h" #include "ksh_stat.h"
#include <ctype.h> #include <ctype.h>
__RCSID("$MirBSD: var.c,v 1.10 2004/10/28 11:11:19 tg Exp $");
/* /*
* Variables * Variables
* *
@ -18,14 +20,14 @@
*/ */
static struct tbl vtemp; static struct tbl vtemp;
static struct table specials; static struct table specials;
static char *formatstr ARGS((struct tbl *vp, const char *s)); static char *formatstr(struct tbl *vp, const char *s);
static void export ARGS((struct tbl *vp, const char *val)); static void export(struct tbl *vp, const char *val);
static int special ARGS((const char *name)); static int special(const char *name);
static void unspecial ARGS((const char *name)); static void unspecial(const char *name);
static void getspec ARGS((struct tbl *vp)); static void getspec(struct tbl *vp);
static void setspec ARGS((struct tbl *vp)); static void setspec(struct tbl *vp);
static void unsetspec ARGS((struct tbl *vp)); static void unsetspec(struct tbl *vp);
static struct tbl *arraysearch ARGS((struct tbl *, int)); static struct tbl *arraysearch(struct tbl *, int);
/* /*
* create a new block for function calls and simple commands * create a new block for function calls and simple commands

89
vi.c
View File

@ -1,4 +1,4 @@
/** $MirBSD: vi.c,v 1.8 2004/10/28 11:03:24 tg Exp $ */ /** $MirBSD: vi.c,v 1.9 2004/10/28 11:11:19 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,7 +15,7 @@
#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 $"); __RCSID("$MirBSD: vi.c,v 1.9 2004/10/28 11:11:19 tg Exp $");
#define Ctrl(c) (c&0x1f) #define Ctrl(c) (c&0x1f)
#define is_wordch(c) (letnum(c)) #define is_wordch(c) (letnum(c))
@ -29,45 +29,45 @@ struct edstate {
}; };
static int vi_hook ARGS((int ch)); static int vi_hook(int ch);
static void vi_reset ARGS((char *buf, size_t len)); static void vi_reset(char *buf, size_t len);
static int nextstate ARGS((int ch)); static int nextstate(int ch);
static int vi_insert ARGS((int ch)); static int vi_insert(int ch);
static int vi_cmd ARGS((int argcnt, const char *cmd)); static int vi_cmd(int argcnt, const char *cmd);
static int domove ARGS((int argcnt, const char *cmd, int sub)); static int domove(int argcnt, const char *cmd, int sub);
static int redo_insert ARGS((int count)); static int redo_insert(int count);
static void yank_range ARGS((int a, int b)); static void yank_range(int a, int b);
static int bracktype ARGS((int ch)); static int bracktype(int ch);
static void save_cbuf ARGS((void)); static void save_cbuf(void);
static void restore_cbuf ARGS((void)); static void restore_cbuf(void);
static void edit_reset ARGS((char *buf, size_t len)); static void edit_reset(char *buf, size_t len);
static int putbuf ARGS((const char *buf, int len, int repl)); static int putbuf(const char *buf, int len, int repl);
static void del_range ARGS((int a, int b)); static void del_range(int a, int b);
static int findch ARGS((int ch, int cnt, int forw, int incl)); static int findch(int ch, int cnt, int forw, int incl);
static int forwword ARGS((int argcnt)); static int forwword(int argcnt);
static int backword ARGS((int argcnt)); static int backword(int argcnt);
static int endword ARGS((int argcnt)); static int endword(int argcnt);
static int Forwword ARGS((int argcnt)); static int Forwword(int argcnt);
static int Backword ARGS((int argcnt)); static int Backword(int argcnt);
static int Endword ARGS((int argcnt)); static int Endword(int argcnt);
static int grabhist ARGS((int save, int n)); static int grabhist(int save, int n);
static int grabsearch ARGS((int save, int start, int fwd, char *pat)); static int grabsearch(int save, int start, int fwd, char *pat);
static void redraw_line ARGS((int newline)); static void redraw_line(int newline);
static void refresh ARGS((int leftside)); static void refresh(int leftside);
static int outofwin ARGS((void)); static int outofwin(void);
static void rewindow ARGS((void)); static void rewindow(void);
static int newcol ARGS((int ch, int col)); static int newcol(int ch, int col);
static void display ARGS((char *wb1, char *wb2, int leftside)); static void display(char *wb1, char *wb2, int leftside);
static void ed_mov_opt ARGS((int col, char *wb)); static void ed_mov_opt(int col, char *wb);
static int expand_word ARGS((int command)); static int expand_word(int command);
static int complete_word ARGS((int command, int count)); static int complete_word(int command, int count);
static int print_expansions ARGS((struct edstate *e, int command)); static int print_expansions(struct edstate *e, int command);
static int char_len ARGS((int c)); static int char_len(int c);
static void x_vi_zotc ARGS((int c)); static void x_vi_zotc(int c);
static void vi_pprompt ARGS((int full)); static void vi_pprompt(int full);
static void vi_error ARGS((void)); static void vi_error(void);
static void vi_macro_reset ARGS((void)); static void vi_macro_reset(void);
static int x_vi_putbuf ARGS((const char *s, size_t len)); static int x_vi_putbuf(const char *s, size_t len);
#define C_ 0x1 /* a valid command that isn't a M_, E_, U_ */ #define C_ 0x1 /* a valid command that isn't a M_, E_, U_ */
#define M_ 0x2 /* movement command (h, l, etc.) */ #define M_ 0x2 /* movement command (h, l, etc.) */
@ -143,9 +143,9 @@ const unsigned char classify[128] = {
static char undocbuf[LINE]; static char undocbuf[LINE];
static struct edstate *save_edstate ARGS((struct edstate *old)); static struct edstate *save_edstate(struct edstate *old);
static void restore_edstate ARGS((struct edstate *old, struct edstate *new)); static void restore_edstate(struct edstate *old, struct edstate *new);
static void free_edstate ARGS((struct edstate *old)); static void free_edstate(struct edstate *old);
static struct edstate ebuf; static struct edstate ebuf;
static struct edstate undobuf = { 0, undocbuf, LINE, 0, 0 }; static struct edstate undobuf = { 0, undocbuf, LINE, 0, 0 };
@ -2193,5 +2193,4 @@ vi_macro_reset()
memset((char *) &macro, 0, sizeof(macro)); memset((char *) &macro, 0, sizeof(macro));
} }
} }
#endif /* VI */ #endif /* VI */