* unifdef EDIT, VI, EMACS, HISTORY

* optimise away 0 ||
no binary changes
This commit is contained in:
tg 2004-12-18 19:17:10 +00:00
parent 245d3ed291
commit cbeac44097
14 changed files with 49 additions and 198 deletions

10
c_ksh.c
View File

@ -1,4 +1,4 @@
/** $MirBSD: src/bin/ksh/c_ksh.c,v 2.3 2004/12/18 18:58:30 tg Exp $ */ /** $MirBSD: src/bin/ksh/c_ksh.c,v 2.4 2004/12/18 19:17:10 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: src/bin/ksh/c_ksh.c,v 2.3 2004/12/18 18:58:30 tg Exp $"); __RCSID("$MirBSD: src/bin/ksh/c_ksh.c,v 2.4 2004/12/18 19:17:10 tg Exp $");
int int
c_cd(char **wp) c_cd(char **wp)
@ -1341,7 +1341,6 @@ c_getopts(char **wp)
return optc < 0 ? 1 : ret; return optc < 0 ? 1 : ret;
} }
#ifdef EMACS
int int
c_bind(char **wp) c_bind(char **wp)
{ {
@ -1375,7 +1374,6 @@ c_bind(char **wp)
return rv; return rv;
} }
#endif
/* 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;
@ -1388,9 +1386,7 @@ const struct builtin kshbuiltins [] = {
{"+command", c_command}, {"+command", c_command},
{"echo", c_print}, {"echo", c_print},
{"*=export", c_typeset}, {"*=export", c_typeset},
#ifdef HISTORY
{"+fc", c_fc}, {"+fc", c_fc},
#endif /* HISTORY */
{"+getopts", c_getopts}, {"+getopts", c_getopts},
{"+jobs", c_jobs}, {"+jobs", c_jobs},
{"+kill", c_kill}, {"+kill", c_kill},
@ -1405,8 +1401,6 @@ const struct builtin kshbuiltins [] = {
{"+bg", c_fgbg}, {"+bg", c_fgbg},
{"+fg", c_fgbg}, {"+fg", c_fgbg},
#endif #endif
#ifdef EMACS
{"bind", c_bind}, {"bind", c_bind},
#endif
{NULL, NULL} {NULL, NULL}
}; };

View File

@ -1,24 +1,15 @@
/** $MirBSD: src/bin/ksh/conf-end.h,v 2.4 2004/12/18 19:02:29 tg Exp $ */ /** $MirBSD: src/bin/ksh/conf-end.h,v 2.5 2004/12/18 19:17:10 tg Exp $ */
/* $OpenBSD: conf-end.h,v 1.2 1996/08/25 12:37:58 downsj Exp $ */ /* $OpenBSD: conf-end.h,v 1.2 1996/08/25 12:37:58 downsj Exp $ */
#ifndef CONF_END_H #ifndef CONF_END_H
#define CONF_END_H #define CONF_END_H
/* Include emacs editing? */
#define EMACS 1
/* Include vi editing? */
#define VI 1
/* Include job control? */ /* Include job control? */
#define JOBS 1 #define JOBS 1
/* Include brace-expansion? */ /* Include brace-expansion? */
#define BRACE_EXPAND 1 #define BRACE_EXPAND 1
/* Include any history? */
#define HISTORY 1
/* Include complex history? */ /* Include complex history? */
#define COMPLEX_HISTORY #define COMPLEX_HISTORY
@ -35,29 +26,11 @@
# error "int cannot hold 32 bit" # error "int cannot hold 32 bit"
#endif #endif
#if defined(EMACS) || defined(VI)
# define EDIT
#else
# undef EDIT
#endif
/* Super small configuration-- no editing. */
#if defined(EDIT) && defined(NOEDIT)
# undef EDIT
# undef EMACS
# undef VI
#endif
/* Editing implies history */
#if defined(EDIT) && !defined(HISTORY)
# define HISTORY
#endif /* EDIT */
/* /*
* if you don't have mmap() you can't use Peter Collinson's history * if you don't have mmap() you can't use Peter Collinson's history
* mechanism. If that is the case, then define EASY_HISTORY * mechanism. If that is the case, then define EASY_HISTORY
*/ */
#if defined(HISTORY) && (!defined(COMPLEX_HISTORY) || !defined(HAVE_MMAP) || !defined(HAVE_FLOCK)) #if !defined(COMPLEX_HISTORY) || !defined(HAVE_MMAP) || !defined(HAVE_FLOCK)
# undef COMPLEX_HISTORY # undef COMPLEX_HISTORY
# define EASY_HISTORY /* sjg's trivial history file */ # define EASY_HISTORY /* sjg's trivial history file */
#endif #endif

24
edit.c
View File

@ -1,4 +1,4 @@
/** $MirBSD: src/bin/ksh/edit.c,v 2.2 2004/12/13 19:05:08 tg Exp $ */ /** $MirBSD: src/bin/ksh/edit.c,v 2.3 2004/12/18 19:17:10 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 $ */
/* /*
@ -7,7 +7,6 @@
*/ */
#include "config.h" #include "config.h"
#ifdef EDIT
#include "sh.h" #include "sh.h"
#include "tty.h" #include "tty.h"
@ -22,7 +21,7 @@
#include <ctype.h> #include <ctype.h>
#include "ksh_stat.h" #include "ksh_stat.h"
__RCSID("$MirBSD: src/bin/ksh/edit.c,v 2.2 2004/12/13 19:05:08 tg Exp $"); __RCSID("$MirBSD: src/bin/ksh/edit.c,v 2.3 2004/12/18 19:17:10 tg Exp $");
#if defined(TIOCGWINSZ) #if defined(TIOCGWINSZ)
static RETSIGTYPE x_sigwinch(int sig); static RETSIGTYPE x_sigwinch(int sig);
@ -59,9 +58,7 @@ x_init(void)
check_sigwinch(); check_sigwinch();
#endif /* TIOCGWINSZ */ #endif /* TIOCGWINSZ */
#ifdef EMACS
x_init_emacs(); x_init_emacs();
#endif /* EMACS */
/* Bizarreness to figure out how to disable /* Bizarreness to figure out how to disable
* a struct termios.c_cc[] char * a struct termios.c_cc[] char
@ -134,16 +131,11 @@ x_read(char *buf, size_t len)
#endif /* TIOCGWINSZ */ #endif /* TIOCGWINSZ */
x_mode(TRUE); x_mode(TRUE);
#ifdef EMACS
if (Flag(FEMACS) || Flag(FGMACS)) if (Flag(FEMACS) || Flag(FGMACS))
i = x_emacs(buf, len); i = x_emacs(buf, len);
else else if (Flag(FVI))
#endif
#ifdef VI
if (Flag(FVI))
i = x_vi(buf, len); i = x_vi(buf, len);
else else
#endif
i = -1; /* internal error */ i = -1; /* internal error */
x_mode(FALSE); x_mode(FALSE);
return i; return i;
@ -289,11 +281,8 @@ x_mode(bool_t onoff)
edchars.eof = -1; edchars.eof = -1;
if (edchars.werase == vdisable_c) if (edchars.werase == vdisable_c)
edchars.werase = -1; edchars.werase = -1;
if (memcmp(&edchars, &oldchars, sizeof(edchars)) != 0) { if (memcmp(&edchars, &oldchars, sizeof(edchars)) != 0)
#ifdef EMACS
x_emacs_keys(&edchars); x_emacs_keys(&edchars);
#endif
}
} else { } else {
/* TF_WAIT doesn't seem to be necessary when leaving xmode */ /* TF_WAIT doesn't seem to be necessary when leaving xmode */
set_tty(tty_fd, &tty_state, TF_NONE); set_tty(tty_fd, &tty_state, TF_NONE);
@ -357,12 +346,8 @@ void
set_editmode(const char *ed) set_editmode(const char *ed)
{ {
static const enum sh_flag edit_flags[] = { static const enum sh_flag edit_flags[] = {
#ifdef EMACS
FEMACS, FGMACS, FEMACS, FGMACS,
#endif
#ifdef VI
FVI, FVI,
#endif
}; };
char *rcp; char *rcp;
unsigned i; unsigned i;
@ -985,4 +970,3 @@ x_escape(const char *s, size_t len, int (*putbuf_func) (const char *, size_t))
return (rval); return (rval);
} }
#endif /* EDIT */

View File

@ -1,4 +1,4 @@
/** $MirBSD: src/bin/ksh/emacs.c,v 2.3 2004/12/13 19:09:06 tg Exp $ */ /** $MirBSD: src/bin/ksh/emacs.c,v 2.4 2004/12/18 19:17:10 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 $ */
/* /*
@ -10,7 +10,6 @@
*/ */
#include "config.h" #include "config.h"
#ifdef EMACS
#include "sh.h" #include "sh.h"
#include "ksh_stat.h" #include "ksh_stat.h"
@ -19,7 +18,7 @@
#include <locale.h> #include <locale.h>
#include "edit.h" #include "edit.h"
__RCSID("$MirBSD: src/bin/ksh/emacs.c,v 2.3 2004/12/13 19:09:06 tg Exp $"); __RCSID("$MirBSD: src/bin/ksh/emacs.c,v 2.4 2004/12/18 19:17:10 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 */
@ -2028,4 +2027,3 @@ x_lastcp(void)
xlp_valid = TRUE; xlp_valid = TRUE;
return (xlp); return (xlp);
} }
#endif /* EDIT */

9
exec.c
View File

@ -1,4 +1,4 @@
/** $MirBSD: src/bin/ksh/exec.c,v 2.4 2004/12/18 18:58:30 tg Exp $ */ /** $MirBSD: src/bin/ksh/exec.c,v 2.5 2004/12/18 19:17:10 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,7 +10,7 @@
#include <ctype.h> #include <ctype.h>
#include "ksh_stat.h" #include "ksh_stat.h"
__RCSID("$MirBSD: src/bin/ksh/exec.c,v 2.4 2004/12/18 18:58:30 tg Exp $"); __RCSID("$MirBSD: src/bin/ksh/exec.c,v 2.5 2004/12/18 19:17:10 tg Exp $");
static int comexec(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);
@ -1315,9 +1315,8 @@ herein(const char *content, int sub)
static char * static char *
do_selectargs(char **ap, bool_t print_menu) do_selectargs(char **ap, bool_t print_menu)
{ {
static const char *const read_args[] = { static const char *const read_args[] =
"read", "-r", "REPLY", (char *) 0 {"read", "-r", "REPLY", NULL};
};
char *s; char *s;
int i, argct; int i, argct;

View File

@ -1,4 +1,4 @@
/** $MirBSD: src/bin/ksh/history.c,v 2.4 2004/12/13 19:18:01 tg Exp $ */ /** $MirBSD: src/bin/ksh/history.c,v 2.5 2004/12/18 19:17:10 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,10 +21,9 @@
#include "sh.h" #include "sh.h"
#include "ksh_stat.h" #include "ksh_stat.h"
__RCSID("$MirBSD: src/bin/ksh/history.c,v 2.4 2004/12/13 19:18:01 tg Exp $"); __RCSID("$MirBSD: src/bin/ksh/history.c,v 2.5 2004/12/18 19:17:10 tg Exp $");
#ifdef HISTORY #ifndef EASY_HISTORY
# ifndef EASY_HISTORY
/* Defines and includes for the complicated case */ /* Defines and includes for the complicated case */
# include <sys/file.h> # include <sys/file.h>
@ -50,7 +49,7 @@ static int sprinkle(int);
# define MAP_FLAGS MAP_PRIVATE # define MAP_FLAGS MAP_PRIVATE
# endif # endif
# endif /* of EASY_HISTORY */ #endif /* of EASY_HISTORY */
static int hist_execute(char *cmd); static int hist_execute(char *cmd);
static int hist_replace(char **hp, const char *pat, const char *rep, static int hist_replace(char **hp, const char *pat, const char *rep,
@ -547,12 +546,12 @@ sethistfile(const char *name)
/* /*
* its a new name - possibly * its a new name - possibly
*/ */
# ifdef EASY_HISTORY #ifdef EASY_HISTORY
if (hname) { if (hname) {
afree(hname, APERM); afree(hname, APERM);
hname = NULL; hname = NULL;
} }
# else #else
if (histfd) { if (histfd) {
/* yes the file is open */ /* yes the file is open */
(void) close(histfd); (void) close(histfd);
@ -564,7 +563,7 @@ sethistfile(const char *name)
histptr = history - 1; histptr = history - 1;
hist_source->line = 0; hist_source->line = 0;
} }
# endif #endif
hist_init(hist_source); hist_init(hist_source);
} }
@ -582,7 +581,7 @@ init_histvec(void)
} }
} }
# ifdef EASY_HISTORY #ifdef EASY_HISTORY
/* /*
* save command in history * save command in history
*/ */
@ -717,7 +716,7 @@ hist_finish(void)
} }
} }
# else /* EASY_HISTORY */ #else /* EASY_HISTORY */
/* /*
* Routines added by Peter Collinson BSDI(Europe)/Hillside Systems to * Routines added by Peter Collinson BSDI(Europe)/Hillside Systems to
@ -775,9 +774,9 @@ histsave(int lno, const char *cmd, int dowrite)
* Each command is * Each command is
* <command byte><command number(4 bytes)><bytes><null> * <command byte><command number(4 bytes)><bytes><null>
*/ */
# define HMAGIC1 0xab #define HMAGIC1 0xab
# define HMAGIC2 0xcd #define HMAGIC2 0xcd
# define COMMAND 0xff #define COMMAND 0xff
void void
hist_init(Source *s) hist_init(Source *s)
@ -1111,30 +1110,4 @@ sprinkle(int fd)
return(write(fd, mag, 2) != 2); return(write(fd, mag, 2) != 2);
} }
#endif
# endif
#else /* HISTORY */
/* No history to be compiled in: dummy routines to avoid lots more ifdefs */
void
init_histvec()
{
}
void
hist_init(s)
Source *s;
{
}
void
hist_finish()
{
}
void
histsave(lno, cmd, dowrite)
int lno;
const char *cmd;
int dowrite;
{
errorf("history not enabled");
}
#endif /* HISTORY */

26
lex.c
View File

@ -1,4 +1,4 @@
/** $MirBSD: src/bin/ksh/lex.c,v 2.4 2004/12/18 18:58:30 tg Exp $ */ /** $MirBSD: src/bin/ksh/lex.c,v 2.5 2004/12/18 19:17:10 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,7 +8,7 @@
#include "sh.h" #include "sh.h"
#include <ctype.h> #include <ctype.h>
__RCSID("$MirBSD: src/bin/ksh/lex.c,v 2.4 2004/12/18 18:58:30 tg Exp $"); __RCSID("$MirBSD: src/bin/ksh/lex.c,v 2.5 2004/12/18 19:17:10 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.
@ -982,16 +982,7 @@ getsc_line(Source *s)
ksh_tmout_state = TMOUT_READING; ksh_tmout_state = TMOUT_READING;
alarm(ksh_tmout); alarm(ksh_tmout);
} }
#ifdef EDIT if (have_tty && (Flag(FVI) || Flag(FEMACS) || Flag(FGMACS))) {
if (have_tty && (0
# ifdef VI
|| Flag(FVI)
# endif /* VI */
# ifdef EMACS
|| Flag(FEMACS) || Flag(FGMACS)
# endif /* EMACS */
))
{
int nread; int nread;
nread = x_read(xp, LINE); nread = x_read(xp, LINE);
@ -999,10 +990,7 @@ getsc_line(Source *s)
nread = 0; nread = 0;
xp[nread] = '\0'; xp[nread] = '\0';
xp += nread; xp += nread;
} } else {
else
#endif /* EDIT */
{
if (interactive) { if (interactive) {
pprompt(prompt, 0); pprompt(prompt, 0);
} else } else
@ -1052,23 +1040,21 @@ getsc_line(Source *s)
shf_fdclose(s->u.shf); shf_fdclose(s->u.shf);
s->str = NULL; s->str = NULL;
} else if (interactive) { } else if (interactive) {
#ifdef HISTORY
char *p = Xstring(s->xs, xp); char *p = Xstring(s->xs, xp);
if (cur_prompt == PS1) if (cur_prompt == PS1)
while (*p && ctype(*p, C_IFS) && ctype(*p, C_IFSWS)) while (*p && ctype(*p, C_IFS) && ctype(*p, C_IFSWS))
p++; p++;
if (*p) { if (*p) {
# ifdef EASY_HISTORY #ifdef EASY_HISTORY
if (cur_prompt == PS2) if (cur_prompt == PS2)
histappend(Xstring(s->xs, xp), 1); histappend(Xstring(s->xs, xp), 1);
else else
# endif /* EASY_HISTORY */ #endif /* EASY_HISTORY */
{ {
s->line++; s->line++;
histsave(s->line, s->str, 1); histsave(s->line, s->str, 1);
} }
} }
#endif /* HISTORY */
} }
if (interactive) if (interactive)
set_prompt(PS2, (Source *) 0); set_prompt(PS2, (Source *) 0);

6
lex.h
View File

@ -1,4 +1,4 @@
/** $MirBSD: src/bin/ksh/lex.h,v 2.2 2004/12/18 18:58:30 tg Exp $ */ /** $MirBSD: src/bin/ksh/lex.h,v 2.3 2004/12/18 19:17:10 tg Exp $ */
/* $OpenBSD: lex.h,v 1.8 2004/11/02 22:09:24 deraadt Exp $ */ /* $OpenBSD: lex.h,v 1.8 2004/11/02 22:09:24 deraadt Exp $ */
/* $From: lex.h,v 1.4 1994/05/31 13:34:34 michael Exp $ */ /* $From: lex.h,v 1.4 1994/05/31 13:34:34 michael Exp $ */
@ -122,12 +122,10 @@ EXTERN YYSTYPE yylval; /* result from yylex */
EXTERN struct ioword *heres [HERES], **herep; EXTERN struct ioword *heres [HERES], **herep;
EXTERN char ident [IDENT+1]; EXTERN char ident [IDENT+1];
#ifdef HISTORY #define HISTORYSIZE 511 /* size of saved history */
# define HISTORYSIZE 511 /* size of saved history */
EXTERN char **history; /* saved commands */ EXTERN char **history; /* saved commands */
EXTERN char **histptr; /* last history item */ EXTERN char **histptr; /* last history item */
EXTERN int histsize; /* history size */ EXTERN int histsize; /* history size */
#endif /* HISTORY */
#endif /* ndef LEX_H */ #endif /* ndef LEX_H */

16
main.c
View File

@ -1,4 +1,4 @@
/** $MirBSD: src/bin/ksh/main.c,v 2.8 2004/12/18 19:02:29 tg Exp $ */ /** $MirBSD: src/bin/ksh/main.c,v 2.9 2004/12/18 19:17:10 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 $ */
/* /*
@ -15,7 +15,7 @@
* shell version * shell version
*/ */
__RCSID("$MirBSD: src/bin/ksh/main.c,v 2.8 2004/12/18 19:02:29 tg Exp $"); __RCSID("$MirBSD: src/bin/ksh/main.c,v 2.9 2004/12/18 19:17:10 tg Exp $");
const char ksh_version[] = const char ksh_version[] =
"@(#)PD KSH v5.2.14 MirOS R20 in " "@(#)PD KSH v5.2.14 MirOS R20 in "
@ -62,9 +62,7 @@ static const char *const initcoms [] = {
#endif #endif
"autoload=typeset -fu", "autoload=typeset -fu",
"functions=typeset -f", "functions=typeset -f",
# ifdef HISTORY
"history=fc -l", "history=fc -l",
# endif /* HISTORY */
"integer=typeset -i", "integer=typeset -i",
"nohup=nohup ", "nohup=nohup ",
"local=typeset", "local=typeset",
@ -102,9 +100,7 @@ main(int argc, char *argv[])
/* make sure argv[] is sane */ /* make sure argv[] is sane */
if (!*argv) { if (!*argv) {
static const char *empty_argv[] = { static const char *empty_argv[] = {"mksh", NULL};
"mksh", (char *) 0
};
argv = (char **) empty_argv; argv = (char **) empty_argv;
argc = 1; argc = 1;
@ -199,12 +195,8 @@ main(int argc, char *argv[])
/* Set edit mode to emacs by default, may be overridden /* Set edit mode to emacs by default, may be overridden
* by the environment or the user. Also, we want tab completion * by the environment or the user. Also, we want tab completion
* on in vi by default. */ * on in vi by default. */
#if defined(EDIT) && defined(EMACS)
change_flag(FEMACS, OF_SPECIAL, 1); change_flag(FEMACS, OF_SPECIAL, 1);
#endif /* EDIT && EMACS */
#if defined(EDIT) && defined(VI)
Flag(FVITABCOMPLETE) = 1; Flag(FVITABCOMPLETE) = 1;
#endif /* EDIT && VI */
/* import environment */ /* import environment */
if (environ != NULL) if (environ != NULL)
@ -322,11 +314,9 @@ main(int argc, char *argv[])
i = Flag(FMONITOR) != 127; i = Flag(FMONITOR) != 127;
Flag(FMONITOR) = 0; Flag(FMONITOR) = 0;
j_init(i); j_init(i);
#ifdef EDIT
/* Do this after j_init(), as tty_fd is not initialized 'til then */ /* Do this after j_init(), as tty_fd is not initialized 'til then */
if (Flag(FTALKING)) if (Flag(FTALKING))
x_init(); x_init();
#endif
l = e->loc; l = e->loc;
l->argv = &argv[argi - 1]; l->argv = &argv[argi - 1];

26
misc.c
View File

@ -1,4 +1,4 @@
/** $MirBSD: src/bin/ksh/misc.c,v 2.4 2004/12/18 18:58:30 tg Exp $ */ /** $MirBSD: src/bin/ksh/misc.c,v 2.5 2004/12/18 19:17:10 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 $ */
/* /*
@ -13,7 +13,7 @@
#include <sys/ioctl.h> #include <sys/ioctl.h>
#include "ksh_stat.h" #include "ksh_stat.h"
__RCSID("$MirBSD: src/bin/ksh/misc.c,v 2.4 2004/12/18 18:58:30 tg Exp $"); __RCSID("$MirBSD: src/bin/ksh/misc.c,v 2.5 2004/12/18 19:17:10 tg Exp $");
#ifndef UCHAR_MAX #ifndef UCHAR_MAX
# define UCHAR_MAX 0xFF # define UCHAR_MAX 0xFF
@ -133,14 +133,10 @@ const struct option options[] = {
#endif #endif
{ "bgnice", 0, OF_ANY }, { "bgnice", 0, OF_ANY },
{ (char *) 0, 'c', OF_CMDLINE }, { (char *) 0, 'c', OF_CMDLINE },
#ifdef EMACS
{ "emacs", 0, OF_ANY }, { "emacs", 0, OF_ANY },
{ "emacs-usemeta", 0, OF_ANY }, /* non-standard */ { "emacs-usemeta", 0, OF_ANY }, /* non-standard */
#endif
{ "errexit", 'e', OF_ANY }, { "errexit", 'e', OF_ANY },
#ifdef EMACS
{ "gmacs", 0, OF_ANY }, { "gmacs", 0, OF_ANY },
#endif
{ "ignoreeof", 0, OF_ANY }, { "ignoreeof", 0, OF_ANY },
{ "interactive",'i', OF_CMDLINE }, { "interactive",'i', OF_CMDLINE },
{ "keyword", 'k', OF_ANY }, { "keyword", 'k', OF_ANY },
@ -168,13 +164,11 @@ const struct option options[] = {
{ "stdin", 's', OF_CMDLINE }, /* pseudo non-standard */ { "stdin", 's', OF_CMDLINE }, /* pseudo non-standard */
{ "trackall", 'h', OF_ANY }, { "trackall", 'h', OF_ANY },
{ "verbose", 'v', OF_ANY }, { "verbose", 'v', OF_ANY },
#ifdef VI
{ "vi", 0, OF_ANY }, { "vi", 0, OF_ANY },
{ "viraw", 0, OF_ANY }, /* no effect */ { "viraw", 0, OF_ANY }, /* no effect */
{ "vi-show8", 0, OF_ANY }, /* non-standard */ { "vi-show8", 0, OF_ANY }, /* non-standard */
{ "vi-tabcomplete", 0, OF_ANY }, /* non-standard */ { "vi-tabcomplete", 0, OF_ANY }, /* non-standard */
{ "vi-esccomplete", 0, OF_ANY }, /* non-standard */ { "vi-esccomplete", 0, OF_ANY }, /* non-standard */
#endif
{ "xtrace", 'x', OF_ANY }, { "xtrace", 'x', OF_ANY },
/* Anonymous flags: used internally by shell only /* Anonymous flags: used internally by shell only
* (not visible to user) * (not visible to user)
@ -283,27 +277,13 @@ change_flag(enum sh_flag f, int what, int newval)
j_change(); j_change();
} else } else
#endif /* JOBS */ #endif /* JOBS */
#ifdef EDIT if (f == FVI || f == FEMACS || f == FGMACS) {
if (0
# ifdef VI
|| f == FVI
# endif /* VI */
# ifdef EMACS
|| f == FEMACS || f == FGMACS
# endif /* EMACS */
)
{
if (newval) { if (newval) {
# ifdef VI
Flag(FVI) = 0; Flag(FVI) = 0;
# endif /* VI */
# ifdef EMACS
Flag(FEMACS) = Flag(FGMACS) = 0; Flag(FEMACS) = Flag(FGMACS) = 0;
# endif /* EMACS */
Flag(f) = newval; Flag(f) = newval;
} }
} else } else
#endif /* EDIT */
/* Turning off -p? */ /* Turning off -p? */
if (f == FPRIVILEGED && oldval && !newval) { if (f == FPRIVILEGED && oldval && !newval) {
seteuid(ksheuid = getuid()); seteuid(ksheuid = getuid());

View File

@ -1,4 +1,4 @@
/** $MirBSD: src/bin/ksh/proto.h,v 2.4 2004/12/18 18:58:30 tg Exp $ */ /** $MirBSD: src/bin/ksh/proto.h,v 2.5 2004/12/18 19:17:10 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 $ */
@ -91,19 +91,17 @@ void init_histvec(void);
void hist_init(Source *s); void hist_init(Source *s);
void hist_finish(void); void hist_finish(void);
void histsave(int lno, const char *cmd, int dowrite); void histsave(int lno, const char *cmd, int dowrite);
#ifdef HISTORY
int c_fc(char **wp); int c_fc(char **wp);
void sethistsize(int n); void sethistsize(int n);
void sethistfile(const char *name); void sethistfile(const char *name);
# ifdef EASY_HISTORY #ifdef EASY_HISTORY
void histappend(const char *cmd, int nl_separate); void histappend(const char *cmd, int nl_separate);
# endif #endif
char ** histpos(void); char ** histpos(void);
int histN(void); int histN(void);
int histnum(int n); int histnum(int n);
int findhist(int start, int fwd, const char *str, int findhist(int start, int fwd, const char *str,
int anchored); int anchored);
#endif /* HISTORY */
/* io.c */ /* io.c */
void errorf(const char *fmt, ...) void errorf(const char *fmt, ...)
GCC_FUNC_ATTR2(noreturn, format(printf, 1, 2)); GCC_FUNC_ATTR2(noreturn, format(printf, 1, 2));

12
sh.h
View File

@ -1,4 +1,4 @@
/** $MirBSD: src/bin/ksh/sh.h,v 2.4 2004/12/18 18:58:30 tg Exp $ */ /** $MirBSD: src/bin/ksh/sh.h,v 2.5 2004/12/18 19:17:10 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 $ */
#ifndef SH_H #ifndef SH_H
@ -427,14 +427,10 @@ enum sh_flag {
#endif #endif
FBGNICE, /* bgnice */ FBGNICE, /* bgnice */
FCOMMAND, /* -c: (invocation) execute specified command */ FCOMMAND, /* -c: (invocation) execute specified command */
#ifdef EMACS
FEMACS, /* emacs command editing */ FEMACS, /* emacs command editing */
FEMACSUSEMETA, /* use 8th bit as meta */ FEMACSUSEMETA, /* use 8th bit as meta */
#endif
FERREXIT, /* -e: quit on error */ FERREXIT, /* -e: quit on error */
#ifdef EMACS
FGMACS, /* gmacs command editing */ FGMACS, /* gmacs command editing */
#endif
FIGNOREEOF, /* eof does not exit */ FIGNOREEOF, /* eof does not exit */
FTALKING, /* -i: interactive */ FTALKING, /* -i: interactive */
FKEYWORD, /* -k: name=value anywhere */ FKEYWORD, /* -k: name=value anywhere */
@ -458,13 +454,11 @@ enum sh_flag {
FSTDIN, /* -s: (invocation) parse stdin */ FSTDIN, /* -s: (invocation) parse stdin */
FTRACKALL, /* -h: create tracked aliases for all commands */ FTRACKALL, /* -h: create tracked aliases for all commands */
FVERBOSE, /* -v: echo input */ FVERBOSE, /* -v: echo input */
#ifdef VI
FVI, /* vi command editing */ FVI, /* vi command editing */
FVIRAW, /* always read in raw mode (ignored) */ FVIRAW, /* always read in raw mode (ignored) */
FVISHOW8, /* display chars with 8th bit set as is (versus M-) */ FVISHOW8, /* display chars with 8th bit set as is (versus M-) */
FVITABCOMPLETE, /* enable tab as file name completion char */ FVITABCOMPLETE, /* enable tab as file name completion char */
FVIESCCOMPLETE, /* enable ESC as file name completion in command mode */ FVIESCCOMPLETE, /* enable ESC as file name completion in command mode */
#endif
FXTRACE, /* -x: execution trace */ FXTRACE, /* -x: execution trace */
FTALKING_I, /* (internal): initial shell was interactive */ FTALKING_I, /* (internal): initial shell was interactive */
FNFLAGS /* (place holder: how many flags are there) */ FNFLAGS /* (place holder: how many flags are there) */
@ -639,7 +633,6 @@ EXTERN Tflag builtin_flag; /* flags of called builtin (SPEC_BI, etc.) */
EXTERN char *current_wd; EXTERN char *current_wd;
EXTERN int current_wd_size; EXTERN int current_wd_size;
#ifdef EDIT
/* Minimum required space to work with on a line - if the prompt leaves less /* Minimum required space to work with on a line - if the prompt leaves less
* space than this on a line, the prompt is truncated. * space than this on a line, the prompt is truncated.
*/ */
@ -648,9 +641,6 @@ EXTERN int current_wd_size;
*/ */
# define MIN_COLS (2 + MIN_EDIT_SPACE + 3) # define MIN_COLS (2 + MIN_EDIT_SPACE + 3)
EXTERN int x_cols I__(80); /* tty columns */ EXTERN int x_cols I__(80); /* tty columns */
#else
# define x_cols 80 /* for pr_menu(exec.c) */
#endif
/* These to avoid bracket matching problems */ /* These to avoid bracket matching problems */
#define OPAREN '(' #define OPAREN '('

14
var.c
View File

@ -1,4 +1,4 @@
/** $MirBSD: src/bin/ksh/var.c,v 2.3 2004/12/18 18:58:32 tg Exp $ */ /** $MirBSD: src/bin/ksh/var.c,v 2.4 2004/12/18 19:17:10 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,7 +7,7 @@
#include "ksh_stat.h" #include "ksh_stat.h"
#include <ctype.h> #include <ctype.h>
__RCSID("$MirBSD: src/bin/ksh/var.c,v 2.3 2004/12/18 18:58:32 tg Exp $"); __RCSID("$MirBSD: src/bin/ksh/var.c,v 2.4 2004/12/18 19:17:10 tg Exp $");
/* /*
* Variables * Variables
@ -94,14 +94,10 @@ initvar(void)
{ "PATH", V_PATH }, { "PATH", V_PATH },
{ "POSIXLY_CORRECT", V_POSIXLY_CORRECT }, { "POSIXLY_CORRECT", V_POSIXLY_CORRECT },
{ "TMPDIR", V_TMPDIR }, { "TMPDIR", V_TMPDIR },
#ifdef HISTORY
{ "HISTFILE", V_HISTFILE }, { "HISTFILE", V_HISTFILE },
{ "HISTSIZE", V_HISTSIZE }, { "HISTSIZE", V_HISTSIZE },
#endif /* HISTORY */
#ifdef EDIT
{ "EDITOR", V_EDITOR }, { "EDITOR", V_EDITOR },
{ "VISUAL", V_VISUAL }, { "VISUAL", V_VISUAL },
#endif /* EDIT */
{ "RANDOM", V_RANDOM }, { "RANDOM", V_RANDOM },
{ "SECONDS", V_SECONDS }, { "SECONDS", V_SECONDS },
{ "TMOUT", V_TMOUT }, { "TMOUT", V_TMOUT },
@ -906,13 +902,11 @@ getspec(struct tbl *vp)
setint(vp, rnd_get()); setint(vp, rnd_get());
vp->flag |= SPECIAL; vp->flag |= SPECIAL;
break; break;
#ifdef HISTORY
case V_HISTSIZE: case V_HISTSIZE:
vp->flag &= ~SPECIAL; vp->flag &= ~SPECIAL;
setint(vp, (long) histsize); setint(vp, (long) histsize);
vp->flag |= SPECIAL; vp->flag |= SPECIAL;
break; break;
#endif /* HISTORY */
case V_OPTIND: case V_OPTIND:
vp->flag &= ~SPECIAL; vp->flag &= ~SPECIAL;
setint(vp, (long) user_opt.uoptind); setint(vp, (long) user_opt.uoptind);
@ -966,7 +960,6 @@ setspec(struct tbl *vp)
tmpdir = str_save(s, APERM); tmpdir = str_save(s, APERM);
} }
break; break;
#ifdef HISTORY
case V_HISTSIZE: case V_HISTSIZE:
vp->flag &= ~SPECIAL; vp->flag &= ~SPECIAL;
sethistsize((int) intval(vp)); sethistsize((int) intval(vp));
@ -975,8 +968,6 @@ setspec(struct tbl *vp)
case V_HISTFILE: case V_HISTFILE:
sethistfile(str_val(vp)); sethistfile(str_val(vp));
break; break;
#endif /* HISTORY */
#ifdef EDIT
case V_VISUAL: case V_VISUAL:
set_editmode(str_val(vp)); set_editmode(str_val(vp));
break; break;
@ -988,7 +979,6 @@ setspec(struct tbl *vp)
if ((x_cols = intval(vp)) <= MIN_COLS) if ((x_cols = intval(vp)) <= MIN_COLS)
x_cols = MIN_COLS; x_cols = MIN_COLS;
break; break;
#endif /* EDIT */
case V_RANDOM: case V_RANDOM:
vp->flag &= ~SPECIAL; vp->flag &= ~SPECIAL;
rnd_put(intval(vp)); rnd_put(intval(vp));

6
vi.c
View File

@ -1,4 +1,4 @@
/** $MirBSD: src/bin/ksh/vi.c,v 2.2 2004/12/13 19:05:09 tg Exp $ */ /** $MirBSD: src/bin/ksh/vi.c,v 2.3 2004/12/18 19:17:10 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 $ */
/* /*
@ -8,14 +8,13 @@
*/ */
#include "config.h" #include "config.h"
#ifdef VI
#include "sh.h" #include "sh.h"
#include <ctype.h> #include <ctype.h>
#include "ksh_stat.h" /* completion */ #include "ksh_stat.h" /* completion */
#include "edit.h" #include "edit.h"
__RCSID("$MirBSD: src/bin/ksh/vi.c,v 2.2 2004/12/13 19:05:09 tg Exp $"); __RCSID("$MirBSD: src/bin/ksh/vi.c,v 2.3 2004/12/18 19:17:10 tg Exp $");
#define Ctrl(c) (c&0x1f) #define Ctrl(c) (c&0x1f)
#define is_wordch(c) (letnum(c)) #define is_wordch(c) (letnum(c))
@ -2113,4 +2112,3 @@ vi_macro_reset(void)
memset((char *) &macro, 0, sizeof(macro)); memset((char *) &macro, 0, sizeof(macro));
} }
} }
#endif /* VI */