svn commit: r245689 - head/bin/sh
Jilles Tjoelker
jilles at FreeBSD.org
Sun Jan 20 12:44:52 UTC 2013
Author: jilles
Date: Sun Jan 20 12:44:50 2013
New Revision: 245689
URL: http://svnweb.freebsd.org/changeset/base/245689
Log:
sh: Remove mkinit's initialization routine.
Instead, call the only init function left directly from main().
Modified:
head/bin/sh/TOUR
head/bin/sh/init.h
head/bin/sh/main.c
head/bin/sh/mkinit.c
head/bin/sh/var.c
Modified: head/bin/sh/TOUR
==============================================================================
--- head/bin/sh/TOUR Sun Jan 20 11:58:49 2013 (r245688)
+++ head/bin/sh/TOUR Sun Jan 20 12:44:50 2013 (r245689)
@@ -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 */
Modified: head/bin/sh/init.h
==============================================================================
--- head/bin/sh/init.h Sun Jan 20 11:58:49 2013 (r245688)
+++ head/bin/sh/init.h Sun Jan 20 12:44:50 2013 (r245689)
@@ -33,5 +33,4 @@
* $FreeBSD$
*/
-void init(void);
void reset(void);
Modified: head/bin/sh/main.c
==============================================================================
--- head/bin/sh/main.c Sun Jan 20 11:58:49 2013 (r245688)
+++ head/bin/sh/main.c Sun Jan 20 12:44:50 2013 (r245689)
@@ -139,7 +139,7 @@ main(int argc, char *argv[])
#endif
rootpid = getpid();
rootshell = 1;
- init();
+ initvar();
setstackmark(&smark);
setstackmark(&smark2);
procargs(argc, argv);
Modified: head/bin/sh/mkinit.c
==============================================================================
--- head/bin/sh/mkinit.c Sun Jan 20 11:58:49 2013 (r245688)
+++ head/bin/sh/mkinit.c Sun Jan 20 12:44:50 2013 (r245689)
@@ -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 } }
};
Modified: head/bin/sh/var.c
==============================================================================
--- head/bin/sh/var.c Sun Jan 20 11:58:49 2013 (r245688)
+++ head/bin/sh/var.c Sun Jan 20 12:44:50 2013 (r245689)
@@ -146,29 +146,11 @@ static int varequal(const char *, const
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())) &&
More information about the svn-src-all
mailing list