From 3dc0c5b1bf519557ed570d726d3b9a832ea16528 Mon Sep 17 00:00:00 2001 From: jca Date: Mon, 15 Jan 2018 14:58:05 +0000 Subject: [PATCH] Stop pretending we support building ksh without EDIT/HISTORY support ok anton@ --- bin/ksh/c_ksh.c | 4 +--- bin/ksh/config.h | 16 +++------------- bin/ksh/edit.c | 4 +--- bin/ksh/exec.c | 4 +--- bin/ksh/history.c | 26 +------------------------- bin/ksh/lex.c | 18 ++++++------------ bin/ksh/lex.h | 7 ++----- bin/ksh/main.c | 16 +++++----------- bin/ksh/misc.c | 20 +++++++++----------- bin/ksh/sh.h | 12 +++--------- bin/ksh/var.c | 14 +------------- 11 files changed, 33 insertions(+), 108 deletions(-) diff --git a/bin/ksh/c_ksh.c b/bin/ksh/c_ksh.c index 0e071809d55..f939114c9a5 100644 --- a/bin/ksh/c_ksh.c +++ b/bin/ksh/c_ksh.c @@ -1,4 +1,4 @@ -/* $OpenBSD: c_ksh.c,v 1.56 2018/01/06 16:28:58 millert Exp $ */ +/* $OpenBSD: c_ksh.c,v 1.57 2018/01/15 14:58:05 jca Exp $ */ /* * built-in Korn commands: c_* @@ -1384,9 +1384,7 @@ const struct builtin kshbuiltins [] = { {"+command", c_command}, {"echo", c_print}, {"*=export", c_typeset}, -#ifdef HISTORY {"+fc", c_fc}, -#endif /* HISTORY */ {"+getopts", c_getopts}, {"+jobs", c_jobs}, {"+kill", c_kill}, diff --git a/bin/ksh/config.h b/bin/ksh/config.h index 9c9e35f3ac5..2bdffb9ac0d 100644 --- a/bin/ksh/config.h +++ b/bin/ksh/config.h @@ -1,4 +1,4 @@ -/* $OpenBSD: config.h,v 1.18 2018/01/14 16:04:21 anton Exp $ */ +/* $OpenBSD: config.h,v 1.19 2018/01/15 14:58:05 jca Exp $ */ /* config.h. NOT generated automatically. */ @@ -11,9 +11,6 @@ #ifndef CONFIG_H #define CONFIG_H -/* Include any history? */ -#define HISTORY 1 - /* Strict POSIX behaviour? */ /* #undef POSIXLY_CORRECT */ @@ -24,15 +21,8 @@ * End of configuration stuff for PD ksh. */ -#if defined(EMACS) || defined(VI) -# define EDIT -#else -# undef EDIT +#if !defined(EMACS) && !defined(VI) +# error "Define either EMACS or VI." #endif -/* Editing implies history */ -#if defined(EDIT) && !defined(HISTORY) -# define HISTORY -#endif /* EDIT */ - #endif /* CONFIG_H */ diff --git a/bin/ksh/edit.c b/bin/ksh/edit.c index ffff9845eca..d7f2c03bc83 100644 --- a/bin/ksh/edit.c +++ b/bin/ksh/edit.c @@ -1,4 +1,4 @@ -/* $OpenBSD: edit.c,v 1.61 2018/01/06 16:28:58 millert Exp $ */ +/* $OpenBSD: edit.c,v 1.62 2018/01/15 14:58:05 jca Exp $ */ /* * Command line editing - common code @@ -6,7 +6,6 @@ */ #include "config.h" -#ifdef EDIT #include #include @@ -910,4 +909,3 @@ x_escape(const char *s, size_t len, int (*putbuf_func) (const char *, size_t)) return (rval); } -#endif /* EDIT */ diff --git a/bin/ksh/exec.c b/bin/ksh/exec.c index 09484b8cf75..ad25879ed6b 100644 --- a/bin/ksh/exec.c +++ b/bin/ksh/exec.c @@ -1,4 +1,4 @@ -/* $OpenBSD: exec.c,v 1.70 2017/12/27 13:02:57 millert Exp $ */ +/* $OpenBSD: exec.c,v 1.71 2018/01/15 14:58:05 jca Exp $ */ /* * execute command tree @@ -1239,7 +1239,6 @@ herein(const char *content, int sub) return fd; } -#ifdef EDIT /* * ksh special - the select command processing section * print the args in column form - assuming that we can @@ -1365,7 +1364,6 @@ pr_list(char *const *ap) return n; } -#endif /* EDIT */ /* * [[ ... ]] evaluation routines diff --git a/bin/ksh/history.c b/bin/ksh/history.c index 3812e92f895..84ea5fdf263 100644 --- a/bin/ksh/history.c +++ b/bin/ksh/history.c @@ -1,4 +1,4 @@ -/* $OpenBSD: history.c,v 1.78 2018/01/06 16:28:58 millert Exp $ */ +/* $OpenBSD: history.c,v 1.79 2018/01/15 14:58:05 jca Exp $ */ /* * command history @@ -25,8 +25,6 @@ #include "sh.h" -#ifdef HISTORY - static void history_write(void); static FILE *history_open(void); static void history_load(Source *); @@ -856,25 +854,3 @@ hist_finish(void) { history_close(); } - -#else /* HISTORY */ - -/* No history to be compiled in: dummy routines to avoid lots more ifdefs */ -void -init_histvec(void) -{ -} -void -hist_init(Source *s) -{ -} -void -hist_finish(void) -{ -} -void -histsave(int lno, const char *cmd, int dowrite) -{ - errorf("history not enabled"); -} -#endif /* HISTORY */ diff --git a/bin/ksh/lex.c b/bin/ksh/lex.c index 4ed8557d016..9e94e34ef5a 100644 --- a/bin/ksh/lex.c +++ b/bin/ksh/lex.c @@ -1,4 +1,4 @@ -/* $OpenBSD: lex.c,v 1.77 2018/01/06 16:28:58 millert Exp $ */ +/* $OpenBSD: lex.c,v 1.78 2018/01/15 14:58:05 jca Exp $ */ /* * lexical analysis and source input @@ -1086,14 +1086,13 @@ getsc_line(Source *s) ksh_tmout_state = TMOUT_READING; alarm(ksh_tmout); } -#ifdef EDIT if (have_tty && (0 -# ifdef VI +#ifdef VI || Flag(FVI) -# endif /* VI */ -# ifdef EMACS +#endif /* VI */ +#ifdef EMACS || Flag(FEMACS) || Flag(FGMACS) -# endif /* EMACS */ +#endif /* EMACS */ )) { int nread; @@ -1102,10 +1101,7 @@ getsc_line(Source *s) nread = 0; xp[nread] = '\0'; xp += nread; - } - else -#endif /* EDIT */ - { + } else { if (interactive) { pprompt(prompt, 0); } else @@ -1153,7 +1149,6 @@ getsc_line(Source *s) shf_fdclose(s->u.shf); s->str = NULL; } else if (interactive) { -#ifdef HISTORY char *p = Xstring(s->xs, xp); if (cur_prompt == PS1) while (*p && ctype(*p, C_IFS) && ctype(*p, C_IFSWS)) @@ -1162,7 +1157,6 @@ getsc_line(Source *s) s->line++; histsave(s->line, s->str, 1); } -#endif /* HISTORY */ } if (interactive) set_prompt(PS2); diff --git a/bin/ksh/lex.h b/bin/ksh/lex.h index 70771c9c0f0..bf9072cdf89 100644 --- a/bin/ksh/lex.h +++ b/bin/ksh/lex.h @@ -1,4 +1,4 @@ -/* $OpenBSD: lex.h,v 1.20 2018/01/06 16:28:58 millert Exp $ */ +/* $OpenBSD: lex.h,v 1.21 2018/01/15 14:58:05 jca Exp $ */ /* * Source input, lexer and parser @@ -105,15 +105,12 @@ extern YYSTYPE yylval; /* result from yylex */ extern struct ioword *heres[HERES], **herep; extern char ident[IDENT+1]; -#ifdef HISTORY -# define HISTORYSIZE 500 /* size of saved history */ +#define HISTORYSIZE 500 /* size of saved history */ extern char **history; /* saved commands */ extern char **histptr; /* last history item */ extern uint32_t histsize; /* history size */ -#endif /* HISTORY */ - int yylex(int); void yyerror(const char *, ...) __attribute__((__noreturn__, __format__ (printf, 1, 2))); diff --git a/bin/ksh/main.c b/bin/ksh/main.c index 044099605fe..ae2220ea1ea 100644 --- a/bin/ksh/main.c +++ b/bin/ksh/main.c @@ -1,4 +1,4 @@ -/* $OpenBSD: main.c,v 1.87 2018/01/14 16:04:21 anton Exp $ */ +/* $OpenBSD: main.c,v 1.88 2018/01/15 14:58:05 jca Exp $ */ /* * startup, main loop, environments and error handling @@ -69,9 +69,7 @@ int builtin_flag; char *current_wd; int current_wd_size; -#ifdef EDIT int x_cols = 80; -#endif /* EDIT */ /* * shell initialization @@ -94,9 +92,7 @@ static const char *initcoms [] = { "stop=kill -STOP", "autoload=typeset -fu", "functions=typeset -f", -#ifdef HISTORY "history=fc -l", -#endif /* HISTORY */ "integer=typeset -i", "nohup=nohup ", "local=typeset", @@ -249,12 +245,12 @@ main(int argc, char *argv[]) /* Set edit mode to emacs by default, may be overridden * by the environment or the user. Also, we want tab completion * on in vi by default. */ -#if defined(EDIT) && defined(EMACS) +#if defined(EMACS) change_flag(FEMACS, OF_SPECIAL, 1); -#endif /* EDIT && EMACS */ -#if defined(EDIT) && defined(VI) +#endif /* EMACS */ +#if defined(VI) Flag(FVITABCOMPLETE) = 1; -#endif /* EDIT && VI */ +#endif /* VI */ /* import environment */ if (environ != NULL) @@ -367,11 +363,9 @@ main(int argc, char *argv[]) i = Flag(FMONITOR) != 127; Flag(FMONITOR) = 0; j_init(i); -#ifdef EDIT /* Do this after j_init(), as tty_fd is not initialized 'til then */ if (Flag(FTALKING)) x_init(); -#endif l = genv->loc; l->argv = make_argv(argc - (argi - 1), &argv[argi - 1]); diff --git a/bin/ksh/misc.c b/bin/ksh/misc.c index 37124c3f022..4d2bb22499c 100644 --- a/bin/ksh/misc.c +++ b/bin/ksh/misc.c @@ -1,4 +1,4 @@ -/* $OpenBSD: misc.c,v 1.66 2018/01/14 16:04:21 anton Exp $ */ +/* $OpenBSD: misc.c,v 1.67 2018/01/15 14:58:05 jca Exp $ */ /* * Miscellaneous functions @@ -270,27 +270,25 @@ change_flag(enum sh_flag f, if (what != OF_CMDLINE && newval != oldval) j_change(); } else -#ifdef EDIT if (0 -# ifdef VI +#ifdef VI || f == FVI -# endif /* VI */ -# ifdef EMACS +#endif /* VI */ +#ifdef EMACS || f == FEMACS || f == FGMACS -# endif /* EMACS */ +#endif /* EMACS */ ) { if (newval) { -# ifdef VI +#ifdef VI Flag(FVI) = 0; -# endif /* VI */ -# ifdef EMACS +#endif /* VI */ +#ifdef EMACS Flag(FEMACS) = Flag(FGMACS) = 0; -# endif /* EMACS */ +#endif /* EMACS */ Flag(f) = newval; } } else -#endif /* EDIT */ /* Turning off -p? */ if (f == FPRIVILEGED && oldval && !newval) { gid_t gid = getgid(); diff --git a/bin/ksh/sh.h b/bin/ksh/sh.h index d2fab9ebb14..2203578aeda 100644 --- a/bin/ksh/sh.h +++ b/bin/ksh/sh.h @@ -1,4 +1,4 @@ -/* $OpenBSD: sh.h,v 1.69 2018/01/14 16:04:21 anton Exp $ */ +/* $OpenBSD: sh.h,v 1.70 2018/01/15 14:58:05 jca Exp $ */ /* * Public Domain Bourne/Korn shell @@ -338,18 +338,14 @@ extern int builtin_flag; /* flags of called builtin (SPEC_BI, etc.) */ extern char *current_wd; extern int current_wd_size; -#ifdef EDIT /* Minimum required space to work with on a line - if the prompt leaves less * space than this on a line, the prompt is truncated. */ -# define MIN_EDIT_SPACE 7 +#define MIN_EDIT_SPACE 7 /* Minimum allowed value for x_cols: 2 for prompt, 3 for " < " at end of line */ -# define MIN_COLS (2 + MIN_EDIT_SPACE + 3) +#define MIN_COLS (2 + MIN_EDIT_SPACE + 3) extern int x_cols; /* tty columns */ -#else -# define x_cols 80 /* for pr_menu(exec.c) */ -#endif /* These to avoid bracket matching problems */ #define OPAREN '(' @@ -451,7 +447,6 @@ void init_histvec(void); void hist_init(Source *); void hist_finish(void); void histsave(int, const char *, int); -#ifdef HISTORY int c_fc(char **); void sethistcontrol(const char *); void sethistsize(int); @@ -462,7 +457,6 @@ int findhist(int, int, const char *, int); int findhistrel(const char *); char **hist_get_newest(int); -#endif /* HISTORY */ /* io.c */ void errorf(const char *, ...) __attribute__((__noreturn__, __format__ (printf, 1, 2))); diff --git a/bin/ksh/var.c b/bin/ksh/var.c index 31f97e6baf4..a3a9b7cd960 100644 --- a/bin/ksh/var.c +++ b/bin/ksh/var.c @@ -1,4 +1,4 @@ -/* $OpenBSD: var.c,v 1.63 2018/01/06 16:28:58 millert Exp $ */ +/* $OpenBSD: var.c,v 1.64 2018/01/15 14:58:05 jca Exp $ */ #include @@ -97,15 +97,11 @@ initvar(void) { "PATH", V_PATH }, { "POSIXLY_CORRECT", V_POSIXLY_CORRECT }, { "TMPDIR", V_TMPDIR }, -#ifdef HISTORY { "HISTCONTROL", V_HISTCONTROL }, { "HISTFILE", V_HISTFILE }, { "HISTSIZE", V_HISTSIZE }, -#endif /* HISTORY */ -#ifdef EDIT { "EDITOR", V_EDITOR }, { "VISUAL", V_VISUAL }, -#endif /* EDIT */ { "MAIL", V_MAIL }, { "MAILCHECK", V_MAILCHECK }, { "MAILPATH", V_MAILPATH }, @@ -933,13 +929,11 @@ getspec(struct tbl *vp) setint(vp, (long) (rand() & 0x7fff)); vp->flag |= SPECIAL; break; -#ifdef HISTORY case V_HISTSIZE: vp->flag &= ~SPECIAL; setint(vp, (long) histsize); vp->flag |= SPECIAL; break; -#endif /* HISTORY */ case V_OPTIND: vp->flag &= ~SPECIAL; setint(vp, (long) user_opt.uoptind); @@ -991,7 +985,6 @@ setspec(struct tbl *vp) tmpdir = str_save(s, APERM); } break; -#ifdef HISTORY case V_HISTCONTROL: sethistcontrol(str_val(vp)); break; @@ -1003,8 +996,6 @@ setspec(struct tbl *vp) case V_HISTFILE: sethistfile(str_val(vp)); break; -#endif /* HISTORY */ -#ifdef EDIT case V_VISUAL: set_editmode(str_val(vp)); break; @@ -1026,7 +1017,6 @@ setspec(struct tbl *vp) x_cols = l; } break; -#endif /* EDIT */ case V_MAIL: mbset(str_val(vp)); break; @@ -1086,11 +1076,9 @@ unsetspec(struct tbl *vp) case V_MAILPATH: mpset(NULL); break; -#ifdef HISTORY case V_HISTCONTROL: sethistcontrol(NULL); break; -#endif case V_LINENO: case V_MAILCHECK: /* at&t ksh leaves previous value in place */ case V_RANDOM: -- 2.20.1