sh: Remove mkinit's initialization routine.

Instead, call the only init function left directly from main().
This commit is contained in:
Jilles Tjoelker 2013-01-20 12:44:50 +00:00
parent cd64c5881d
commit 59e0cc8e4a
5 changed files with 12 additions and 35 deletions

View File

@ -33,10 +33,6 @@ programs is:
There are undoubtedly too many of these. Mkinit searches all the
C source files for entries looking like:
INIT {
x = 1; /* executed during initialization */
}
RESET {
x = 2; /* executed when the shell does a longjmp
back to the main command loop */

View File

@ -33,5 +33,4 @@
* $FreeBSD$
*/
void init(void);
void reset(void);

View File

@ -139,7 +139,7 @@ main(int argc, char *argv[])
#endif
rootpid = getpid();
rootshell = 1;
init();
initvar();
setstackmark(&smark);
setstackmark(&smark2);
procargs(argc, argv);

View File

@ -101,7 +101,7 @@ struct block {
*/
struct event {
const char *name; /* name of event (e.g. INIT) */
const char *name; /* name of event (e.g. RESET) */
const char *routine; /* name of routine called on event */
const char *comment; /* comment describing routine */
struct text code; /* code for handling event */
@ -114,11 +114,6 @@ char writer[] = "\
*/\n\
\n";
char init[] = "\
/*\n\
* Initialization code.\n\
*/\n";
char reset[] = "\
/*\n\
* This routine is called when an error or an interrupt occurs in an\n\
@ -127,7 +122,6 @@ char reset[] = "\
struct event event[] = {
{ "INIT", "init", init, { NULL, 0, NULL, NULL } },
{ "RESET", "reset", reset, { NULL, 0, NULL, NULL } },
{ NULL, NULL, NULL, { NULL, 0, NULL, NULL } }
};

View File

@ -146,29 +146,11 @@ static int varequal(const char *, const char *);
static struct var *find_var(const char *, struct var ***, int *);
static int localevar(const char *);
/*
* Initialize the variable symbol tables and import the environment.
*/
#ifdef mkinit
INCLUDE "var.h"
MKINIT char **environ;
INIT {
char **envp;
initvar();
for (envp = environ ; *envp ; envp++) {
if (strchr(*envp, '=')) {
setvareq(*envp, VEXPORT|VTEXTFIXED);
}
}
}
#endif
extern char **environ;
/*
* This routine initializes the builtin variables. It is called when the
* shell is initialized.
* This routine initializes the builtin variables and imports the environment.
* It is called when the shell is initialized.
*/
void
@ -178,6 +160,7 @@ initvar(void)
const struct varinit *ip;
struct var *vp;
struct var **vpp;
char **envp;
for (ip = varinit ; (vp = ip->var) != NULL ; ip++) {
if (find_var(ip->text, &vpp, &vp->name_len) != NULL)
@ -201,6 +184,11 @@ initvar(void)
fmtstr(ppid, sizeof(ppid), "%d", (int)getppid());
setvarsafe("PPID", ppid, 0);
}
for (envp = environ ; *envp ; envp++) {
if (strchr(*envp, '=')) {
setvareq(*envp, VEXPORT|VTEXTFIXED);
}
}
}
/*
@ -356,7 +344,7 @@ setvareq(char *s, int flags)
* a regular variable function callback, but why bother?
*
* Note: this assumes iflag is not set to 1 initially.
* As part of init(), this is called before arguments
* As part of initvar(), this is called before arguments
* are looked at.
*/
if ((vp == &vmpath || (vp == &vmail && ! mpathset())) &&