* unifdef EDIT, VI, EMACS, HISTORY
* optimise away 0 || no binary changes
This commit is contained in:
		
							
								
								
									
										10
									
								
								c_ksh.c
									
									
									
									
									
								
							
							
						
						
									
										10
									
								
								c_ksh.c
									
									
									
									
									
								
							| @@ -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 $	*/ | ||||
|  | ||||
| /* | ||||
| @@ -13,7 +13,7 @@ | ||||
| #include <sys/cygwin.h> | ||||
| #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 | ||||
| c_cd(char **wp) | ||||
| @@ -1341,7 +1341,6 @@ c_getopts(char **wp) | ||||
| 	return optc < 0 ? 1 : ret; | ||||
| } | ||||
|  | ||||
| #ifdef EMACS | ||||
| int | ||||
| c_bind(char **wp) | ||||
| { | ||||
| @@ -1375,7 +1374,6 @@ c_bind(char **wp) | ||||
|  | ||||
| 	return rv; | ||||
| } | ||||
| #endif | ||||
|  | ||||
| /* A leading = means assignments before command are kept; | ||||
|  * a leading * means a POSIX special builtin; | ||||
| @@ -1388,9 +1386,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}, | ||||
| @@ -1405,8 +1401,6 @@ const struct builtin kshbuiltins [] = { | ||||
| 	{"+bg", c_fgbg}, | ||||
| 	{"+fg", c_fgbg}, | ||||
| #endif | ||||
| #ifdef EMACS | ||||
| 	{"bind", c_bind}, | ||||
| #endif | ||||
| 	{NULL, NULL} | ||||
| }; | ||||
|   | ||||
							
								
								
									
										31
									
								
								conf-end.h
									
									
									
									
									
								
							
							
						
						
									
										31
									
								
								conf-end.h
									
									
									
									
									
								
							| @@ -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 $	*/ | ||||
|  | ||||
| #ifndef CONF_END_H | ||||
| #define CONF_END_H | ||||
|  | ||||
| /* Include emacs editing? */ | ||||
| #define EMACS 1 | ||||
|  | ||||
| /* Include vi editing? */ | ||||
| #define VI 1 | ||||
|  | ||||
| /* Include job control? */ | ||||
| #define JOBS 1 | ||||
|  | ||||
| /* Include brace-expansion? */ | ||||
| #define BRACE_EXPAND 1 | ||||
|  | ||||
| /* Include any history? */ | ||||
| #define HISTORY 1 | ||||
|  | ||||
| /* Include complex history? */ | ||||
| #define COMPLEX_HISTORY | ||||
|  | ||||
| @@ -35,29 +26,11 @@ | ||||
| # error "int cannot hold 32 bit" | ||||
| #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 | ||||
|  * 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 | ||||
| # define EASY_HISTORY			/* sjg's trivial history file */ | ||||
| #endif | ||||
|   | ||||
							
								
								
									
										24
									
								
								edit.c
									
									
									
									
									
								
							
							
						
						
									
										24
									
								
								edit.c
									
									
									
									
									
								
							| @@ -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 $	*/ | ||||
|  | ||||
| /* | ||||
| @@ -7,7 +7,6 @@ | ||||
|  */ | ||||
|  | ||||
| #include "config.h" | ||||
| #ifdef EDIT | ||||
|  | ||||
| #include "sh.h" | ||||
| #include "tty.h" | ||||
| @@ -22,7 +21,7 @@ | ||||
| #include <ctype.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) | ||||
| static RETSIGTYPE x_sigwinch(int sig); | ||||
| @@ -59,9 +58,7 @@ x_init(void) | ||||
| 	check_sigwinch(); | ||||
| #endif /* TIOCGWINSZ */ | ||||
|  | ||||
| #ifdef EMACS | ||||
| 	x_init_emacs(); | ||||
| #endif /* EMACS */ | ||||
|  | ||||
| 	/* Bizarreness to figure out how to disable | ||||
| 	 * a struct termios.c_cc[] char | ||||
| @@ -134,16 +131,11 @@ x_read(char *buf, size_t len) | ||||
| #endif /* TIOCGWINSZ */ | ||||
|  | ||||
| 	x_mode(TRUE); | ||||
| #ifdef EMACS | ||||
| 	if (Flag(FEMACS) || Flag(FGMACS)) | ||||
| 		i = x_emacs(buf, len); | ||||
| 	else | ||||
| #endif | ||||
| #ifdef VI | ||||
| 	if (Flag(FVI)) | ||||
| 	else if (Flag(FVI)) | ||||
| 		i = x_vi(buf, len); | ||||
| 	else | ||||
| #endif | ||||
| 		i = -1;		/* internal error */ | ||||
| 	x_mode(FALSE); | ||||
| 	return i; | ||||
| @@ -289,11 +281,8 @@ x_mode(bool_t onoff) | ||||
| 			edchars.eof = -1; | ||||
| 		if (edchars.werase == vdisable_c) | ||||
| 			edchars.werase = -1; | ||||
| 		if (memcmp(&edchars, &oldchars, sizeof(edchars)) != 0) { | ||||
| #ifdef EMACS | ||||
| 		if (memcmp(&edchars, &oldchars, sizeof(edchars)) != 0) | ||||
| 			x_emacs_keys(&edchars); | ||||
| #endif | ||||
| 		} | ||||
| 	} else { | ||||
| 		/* TF_WAIT doesn't seem to be necessary when leaving xmode */ | ||||
| 		set_tty(tty_fd, &tty_state, TF_NONE); | ||||
| @@ -357,12 +346,8 @@ void | ||||
| set_editmode(const char *ed) | ||||
| { | ||||
| 	static const enum sh_flag edit_flags[] = { | ||||
| #ifdef EMACS | ||||
| 			FEMACS, FGMACS, | ||||
| #endif | ||||
| #ifdef VI | ||||
| 			FVI, | ||||
| #endif | ||||
| 		    }; | ||||
| 	char *rcp; | ||||
| 	unsigned i; | ||||
| @@ -985,4 +970,3 @@ x_escape(const char *s, size_t len, int (*putbuf_func) (const char *, size_t)) | ||||
|  | ||||
| 	return (rval); | ||||
| } | ||||
| #endif /* EDIT */ | ||||
|   | ||||
							
								
								
									
										6
									
								
								emacs.c
									
									
									
									
									
								
							
							
						
						
									
										6
									
								
								emacs.c
									
									
									
									
									
								
							| @@ -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 $	*/ | ||||
|  | ||||
| /* | ||||
| @@ -10,7 +10,6 @@ | ||||
|  */ | ||||
|  | ||||
| #include "config.h" | ||||
| #ifdef EMACS | ||||
|  | ||||
| #include "sh.h" | ||||
| #include "ksh_stat.h" | ||||
| @@ -19,7 +18,7 @@ | ||||
| #include <locale.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; | ||||
| #define	AEDIT	&aedit		/* area for kill ring and macro defns */ | ||||
| @@ -2028,4 +2027,3 @@ x_lastcp(void) | ||||
|   xlp_valid = TRUE; | ||||
|   return (xlp); | ||||
| } | ||||
| #endif /* EDIT */ | ||||
|   | ||||
							
								
								
									
										9
									
								
								exec.c
									
									
									
									
									
								
							
							
						
						
									
										9
									
								
								exec.c
									
									
									
									
									
								
							| @@ -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 $	*/ | ||||
|  | ||||
| /* | ||||
| @@ -10,7 +10,7 @@ | ||||
| #include <ctype.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, | ||||
| 			      int volatile flags); | ||||
| @@ -1315,9 +1315,8 @@ herein(const char *content, int sub) | ||||
| static char * | ||||
| do_selectargs(char **ap, bool_t print_menu) | ||||
| { | ||||
| 	static const char *const read_args[] = { | ||||
| 					"read", "-r", "REPLY", (char *) 0 | ||||
| 				    }; | ||||
| 	static const char *const read_args[] = | ||||
| 	   {"read", "-r", "REPLY", NULL}; | ||||
| 	char *s; | ||||
| 	int i, argct; | ||||
|  | ||||
|   | ||||
							
								
								
									
										53
									
								
								history.c
									
									
									
									
									
								
							
							
						
						
									
										53
									
								
								history.c
									
									
									
									
									
								
							| @@ -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 $	*/ | ||||
|  | ||||
| /* | ||||
| @@ -21,10 +21,9 @@ | ||||
| #include "sh.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 */ | ||||
|  | ||||
| #  include <sys/file.h> | ||||
| @@ -50,7 +49,7 @@ static int sprinkle(int); | ||||
| #   define MAP_FLAGS	MAP_PRIVATE | ||||
| #  endif | ||||
|  | ||||
| # endif	/* of EASY_HISTORY */ | ||||
| #endif	/* of EASY_HISTORY */ | ||||
|  | ||||
| static int	hist_execute(char *cmd); | ||||
| 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 | ||||
| 	 */ | ||||
| # ifdef EASY_HISTORY | ||||
| #ifdef EASY_HISTORY | ||||
| 	if (hname) { | ||||
| 		afree(hname, APERM); | ||||
| 		hname = NULL; | ||||
| 	} | ||||
| # else | ||||
| #else | ||||
| 	if (histfd) { | ||||
| 		/* yes the file is open */ | ||||
| 		(void) close(histfd); | ||||
| @@ -564,7 +563,7 @@ sethistfile(const char *name) | ||||
| 		histptr = history - 1; | ||||
| 		hist_source->line = 0; | ||||
| 	} | ||||
| # endif | ||||
| #endif | ||||
|  | ||||
| 	hist_init(hist_source); | ||||
| } | ||||
| @@ -582,7 +581,7 @@ init_histvec(void) | ||||
| 	} | ||||
| } | ||||
|  | ||||
| # ifdef EASY_HISTORY | ||||
| #ifdef EASY_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 | ||||
| @@ -775,9 +774,9 @@ histsave(int lno, const char *cmd, int dowrite) | ||||
|  *	Each command is | ||||
|  *	<command byte><command number(4 bytes)><bytes><null> | ||||
|  */ | ||||
| # define HMAGIC1		0xab | ||||
| # define HMAGIC2		0xcd | ||||
| # define COMMAND		0xff | ||||
| #define HMAGIC1		0xab | ||||
| #define HMAGIC2		0xcd | ||||
| #define COMMAND		0xff | ||||
|  | ||||
| void | ||||
| hist_init(Source *s) | ||||
| @@ -1111,30 +1110,4 @@ sprinkle(int fd) | ||||
|  | ||||
| 	return(write(fd, mag, 2) != 2); | ||||
| } | ||||
|  | ||||
| # 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 */ | ||||
| #endif | ||||
|   | ||||
							
								
								
									
										26
									
								
								lex.c
									
									
									
									
									
								
							
							
						
						
									
										26
									
								
								lex.c
									
									
									
									
									
								
							| @@ -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 $	*/ | ||||
|  | ||||
| /* | ||||
| @@ -8,7 +8,7 @@ | ||||
| #include "sh.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 | ||||
|  * needed for each particular state. | ||||
| @@ -982,16 +982,7 @@ getsc_line(Source *s) | ||||
| 		ksh_tmout_state = TMOUT_READING; | ||||
| 		alarm(ksh_tmout); | ||||
| 	} | ||||
| #ifdef EDIT | ||||
| 	if (have_tty && (0 | ||||
| # ifdef VI | ||||
| 			 || Flag(FVI) | ||||
| # endif /* VI */ | ||||
| # ifdef EMACS | ||||
| 			 || Flag(FEMACS) || Flag(FGMACS) | ||||
| # endif /* EMACS */ | ||||
| 		)) | ||||
| 	{ | ||||
| 	if (have_tty && (Flag(FVI) || Flag(FEMACS) || Flag(FGMACS))) { | ||||
| 		int nread; | ||||
|  | ||||
| 		nread = x_read(xp, LINE); | ||||
| @@ -999,10 +990,7 @@ getsc_line(Source *s) | ||||
| 			nread = 0; | ||||
| 		xp[nread] = '\0'; | ||||
| 		xp += nread; | ||||
| 	} | ||||
| 	else | ||||
| #endif /* EDIT */ | ||||
| 	{ | ||||
| 	} else { | ||||
| 		if (interactive) { | ||||
| 			pprompt(prompt, 0); | ||||
| 		} else | ||||
| @@ -1052,23 +1040,21 @@ 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)) | ||||
| 				p++; | ||||
| 		if (*p) { | ||||
| # ifdef EASY_HISTORY | ||||
| #ifdef EASY_HISTORY | ||||
| 			if (cur_prompt == PS2) | ||||
| 				histappend(Xstring(s->xs, xp), 1); | ||||
| 			else | ||||
| # endif /* EASY_HISTORY */ | ||||
| #endif /* EASY_HISTORY */ | ||||
| 			{ | ||||
| 				s->line++; | ||||
| 				histsave(s->line, s->str, 1); | ||||
| 			} | ||||
| 		} | ||||
| #endif /* HISTORY */ | ||||
| 	} | ||||
| 	if (interactive) | ||||
| 		set_prompt(PS2, (Source *) 0); | ||||
|   | ||||
							
								
								
									
										6
									
								
								lex.h
									
									
									
									
									
								
							
							
						
						
									
										6
									
								
								lex.h
									
									
									
									
									
								
							| @@ -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 $	*/ | ||||
| /*	$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	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  **histptr;	/* last history item */ | ||||
| EXTERN	int	histsize;	/* history size */ | ||||
| #endif /* HISTORY */ | ||||
|  | ||||
| #endif	/* ndef LEX_H */ | ||||
|   | ||||
							
								
								
									
										16
									
								
								main.c
									
									
									
									
									
								
							
							
						
						
									
										16
									
								
								main.c
									
									
									
									
									
								
							| @@ -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 $	*/ | ||||
|  | ||||
| /* | ||||
| @@ -15,7 +15,7 @@ | ||||
|  * 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[] = | ||||
| 	"@(#)PD KSH v5.2.14 MirOS R20 in " | ||||
| @@ -62,9 +62,7 @@ static const char *const initcoms [] = { | ||||
| #endif | ||||
| 	  "autoload=typeset -fu", | ||||
| 	  "functions=typeset -f", | ||||
| # ifdef HISTORY | ||||
| 	  "history=fc -l", | ||||
| # endif /* HISTORY */ | ||||
| 	  "integer=typeset -i", | ||||
| 	  "nohup=nohup ", | ||||
| 	  "local=typeset", | ||||
| @@ -102,9 +100,7 @@ main(int argc, char *argv[]) | ||||
|  | ||||
| 	/* make sure argv[] is sane */ | ||||
| 	if (!*argv) { | ||||
| 		static const char	*empty_argv[] = { | ||||
| 					    "mksh", (char *) 0 | ||||
| 					}; | ||||
| 		static const char *empty_argv[] = {"mksh", NULL}; | ||||
|  | ||||
| 		argv = (char **) empty_argv; | ||||
| 		argc = 1; | ||||
| @@ -199,12 +195,8 @@ 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) | ||||
| 	change_flag(FEMACS, OF_SPECIAL, 1); | ||||
| #endif /* EDIT && EMACS */ | ||||
| #if defined(EDIT) && defined(VI) | ||||
| 	Flag(FVITABCOMPLETE) = 1; | ||||
| #endif /* EDIT && VI */ | ||||
|  | ||||
| 	/* import environment */ | ||||
| 	if (environ != NULL) | ||||
| @@ -322,11 +314,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 = e->loc; | ||||
| 	l->argv = &argv[argi - 1]; | ||||
|   | ||||
							
								
								
									
										26
									
								
								misc.c
									
									
									
									
									
								
							
							
						
						
									
										26
									
								
								misc.c
									
									
									
									
									
								
							| @@ -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 $	*/ | ||||
|  | ||||
| /* | ||||
| @@ -13,7 +13,7 @@ | ||||
| #include <sys/ioctl.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 | ||||
| # define UCHAR_MAX	0xFF | ||||
| @@ -133,14 +133,10 @@ const struct option options[] = { | ||||
| #endif | ||||
| 	{ "bgnice",	  0,		OF_ANY }, | ||||
| 	{ (char *) 0, 	'c',	    OF_CMDLINE }, | ||||
| #ifdef EMACS | ||||
| 	{ "emacs",	  0,		OF_ANY }, | ||||
| 	{ "emacs-usemeta",  0,		OF_ANY }, /* non-standard */ | ||||
| #endif | ||||
| 	{ "errexit",	'e',		OF_ANY }, | ||||
| #ifdef EMACS | ||||
| 	{ "gmacs",	  0,		OF_ANY }, | ||||
| #endif | ||||
| 	{ "ignoreeof",	  0,		OF_ANY }, | ||||
| 	{ "interactive",'i',	    OF_CMDLINE }, | ||||
| 	{ "keyword",	'k',		OF_ANY }, | ||||
| @@ -168,13 +164,11 @@ const struct option options[] = { | ||||
| 	{ "stdin",	's',	    OF_CMDLINE }, /* pseudo non-standard */ | ||||
| 	{ "trackall",	'h',		OF_ANY }, | ||||
| 	{ "verbose",	'v',		OF_ANY }, | ||||
| #ifdef VI | ||||
| 	{ "vi",		  0,		OF_ANY }, | ||||
| 	{ "viraw",	  0,		OF_ANY }, /* no effect */ | ||||
| 	{ "vi-show8",	  0,		OF_ANY }, /* non-standard */ | ||||
| 	{ "vi-tabcomplete",  0, 	OF_ANY }, /* non-standard */ | ||||
| 	{ "vi-esccomplete",  0, 	OF_ANY }, /* non-standard */ | ||||
| #endif | ||||
| 	{ "xtrace",	'x',		OF_ANY }, | ||||
| 	/* Anonymous flags: used internally by shell only | ||||
| 	 * (not visible to user) | ||||
| @@ -283,27 +277,13 @@ change_flag(enum sh_flag f, int what, int newval) | ||||
| 			j_change(); | ||||
| 	} else | ||||
| #endif /* JOBS */ | ||||
| #ifdef EDIT | ||||
| 	if (0 | ||||
| # ifdef VI | ||||
| 	    || f == FVI | ||||
| # endif /* VI */ | ||||
| # ifdef EMACS | ||||
| 	    || f == FEMACS || f == FGMACS | ||||
| # endif /* EMACS */ | ||||
| 	   ) | ||||
| 	{ | ||||
| 	if (f == FVI || f == FEMACS || f == FGMACS) { | ||||
| 		if (newval) { | ||||
| # ifdef VI | ||||
| 			Flag(FVI) = 0; | ||||
| # endif /* VI */ | ||||
| # ifdef EMACS | ||||
| 			Flag(FEMACS) = Flag(FGMACS) = 0; | ||||
| # endif /* EMACS */ | ||||
| 			Flag(f) = newval; | ||||
| 		} | ||||
| 	} else | ||||
| #endif /* EDIT */ | ||||
| 	/* Turning off -p? */ | ||||
| 	if (f == FPRIVILEGED && oldval && !newval) { | ||||
| 		seteuid(ksheuid = getuid()); | ||||
|   | ||||
							
								
								
									
										8
									
								
								proto.h
									
									
									
									
									
								
							
							
						
						
									
										8
									
								
								proto.h
									
									
									
									
									
								
							| @@ -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 $	*/ | ||||
| /*	$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_finish(void); | ||||
| void	histsave(int lno, const char *cmd, int dowrite); | ||||
| #ifdef HISTORY | ||||
| int 	c_fc(char **wp); | ||||
| void	sethistsize(int n); | ||||
| void	sethistfile(const char *name); | ||||
| # ifdef EASY_HISTORY | ||||
| #ifdef EASY_HISTORY | ||||
| void 	histappend(const char *cmd, int nl_separate); | ||||
| # endif | ||||
| #endif | ||||
| char **	histpos(void); | ||||
| int 	histN(void); | ||||
| int 	histnum(int n); | ||||
| int	findhist(int start, int fwd, const char *str, | ||||
| 			      int anchored); | ||||
| #endif /* HISTORY */ | ||||
| /* io.c */ | ||||
| void 	errorf(const char *fmt, ...) | ||||
| 				GCC_FUNC_ATTR2(noreturn, format(printf, 1, 2)); | ||||
|   | ||||
							
								
								
									
										12
									
								
								sh.h
									
									
									
									
									
								
							
							
						
						
									
										12
									
								
								sh.h
									
									
									
									
									
								
							| @@ -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 $	*/ | ||||
|  | ||||
| #ifndef SH_H | ||||
| @@ -427,14 +427,10 @@ enum sh_flag { | ||||
| #endif | ||||
| 	FBGNICE,	/* bgnice */ | ||||
| 	FCOMMAND,	/* -c: (invocation) execute specified command */ | ||||
| #ifdef EMACS | ||||
| 	FEMACS,		/* emacs command editing */ | ||||
| 	FEMACSUSEMETA,	/* use 8th bit as meta */ | ||||
| #endif | ||||
| 	FERREXIT,	/* -e: quit on error */ | ||||
| #ifdef EMACS | ||||
| 	FGMACS,		/* gmacs command editing */ | ||||
| #endif | ||||
| 	FIGNOREEOF,	/* eof does not exit */ | ||||
| 	FTALKING,	/* -i: interactive */ | ||||
| 	FKEYWORD,	/* -k: name=value anywhere */ | ||||
| @@ -458,13 +454,11 @@ enum sh_flag { | ||||
| 	FSTDIN,		/* -s: (invocation) parse stdin */ | ||||
| 	FTRACKALL,	/* -h: create tracked aliases for all commands */ | ||||
| 	FVERBOSE,	/* -v: echo input */ | ||||
| #ifdef VI | ||||
| 	FVI,		/* vi command editing */ | ||||
| 	FVIRAW,		/* always read in raw mode (ignored) */ | ||||
| 	FVISHOW8,	/* display chars with 8th bit set as is (versus M-) */ | ||||
| 	FVITABCOMPLETE,	/* enable tab as file name completion char */ | ||||
| 	FVIESCCOMPLETE,	/* enable ESC as file name completion in command mode */ | ||||
| #endif | ||||
| 	FXTRACE,	/* -x: execution trace */ | ||||
| 	FTALKING_I,	/* (internal): initial shell was interactive */ | ||||
| 	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 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. | ||||
|  */ | ||||
| @@ -648,9 +641,6 @@ EXTERN int	current_wd_size; | ||||
|  */ | ||||
| # define MIN_COLS	(2 + MIN_EDIT_SPACE + 3) | ||||
| 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 */ | ||||
| #define OPAREN	'(' | ||||
|   | ||||
							
								
								
									
										14
									
								
								var.c
									
									
									
									
									
								
							
							
						
						
									
										14
									
								
								var.c
									
									
									
									
									
								
							| @@ -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 $	*/ | ||||
|  | ||||
| #include "sh.h" | ||||
| @@ -7,7 +7,7 @@ | ||||
| #include "ksh_stat.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 | ||||
| @@ -94,14 +94,10 @@ initvar(void) | ||||
| 			{ "PATH",		V_PATH }, | ||||
| 			{ "POSIXLY_CORRECT",	V_POSIXLY_CORRECT }, | ||||
| 			{ "TMPDIR",		V_TMPDIR }, | ||||
| #ifdef HISTORY | ||||
| 			{ "HISTFILE",		V_HISTFILE }, | ||||
| 			{ "HISTSIZE",		V_HISTSIZE }, | ||||
| #endif /* HISTORY */ | ||||
| #ifdef EDIT | ||||
| 			{ "EDITOR",		V_EDITOR }, | ||||
| 			{ "VISUAL",		V_VISUAL }, | ||||
| #endif /* EDIT */ | ||||
| 			{ "RANDOM",		V_RANDOM }, | ||||
| 			{ "SECONDS",		V_SECONDS }, | ||||
| 			{ "TMOUT",		V_TMOUT }, | ||||
| @@ -906,13 +902,11 @@ getspec(struct tbl *vp) | ||||
| 		setint(vp, rnd_get()); | ||||
| 		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); | ||||
| @@ -966,7 +960,6 @@ setspec(struct tbl *vp) | ||||
| 				tmpdir = str_save(s, APERM); | ||||
| 		} | ||||
| 		break; | ||||
| #ifdef HISTORY | ||||
| 	  case V_HISTSIZE: | ||||
| 		vp->flag &= ~SPECIAL; | ||||
| 		sethistsize((int) intval(vp)); | ||||
| @@ -975,8 +968,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; | ||||
| @@ -988,7 +979,6 @@ setspec(struct tbl *vp) | ||||
| 		if ((x_cols = intval(vp)) <= MIN_COLS) | ||||
| 			x_cols = MIN_COLS; | ||||
| 		break; | ||||
| #endif /* EDIT */ | ||||
| 	  case V_RANDOM: | ||||
| 		vp->flag &= ~SPECIAL; | ||||
| 		rnd_put(intval(vp)); | ||||
|   | ||||
							
								
								
									
										6
									
								
								vi.c
									
									
									
									
									
								
							
							
						
						
									
										6
									
								
								vi.c
									
									
									
									
									
								
							| @@ -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 $	*/ | ||||
|  | ||||
| /* | ||||
| @@ -8,14 +8,13 @@ | ||||
|  */ | ||||
|  | ||||
| #include "config.h" | ||||
| #ifdef VI | ||||
|  | ||||
| #include "sh.h" | ||||
| #include <ctype.h> | ||||
| #include "ksh_stat.h"		/* completion */ | ||||
| #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	is_wordch(c)	(letnum(c)) | ||||
| @@ -2113,4 +2112,3 @@ vi_macro_reset(void) | ||||
| 		memset((char *) ¯o, 0, sizeof(macro)); | ||||
| 	} | ||||
| } | ||||
| #endif	/* VI */ | ||||
|   | ||||
		Reference in New Issue
	
	Block a user