diff options
author | Eric Andersen <andersen@codepoet.org> | 2001-10-31 11:05:49 +0000 |
---|---|---|
committer | Eric Andersen <andersen@codepoet.org> | 2001-10-31 11:05:49 +0000 |
commit | ec07469a3eff7f9ac7be886390592c31163ddf59 (patch) | |
tree | c657a40dfcd9b4e247f632d718809909b9fb1f5f | |
parent | 31a0ece3a711dd24cdb49c3a0a83ad4838f27e6e (diff) | |
download | busybox-w32-ec07469a3eff7f9ac7be886390592c31163ddf59.tar.gz busybox-w32-ec07469a3eff7f9ac7be886390592c31163ddf59.tar.bz2 busybox-w32-ec07469a3eff7f9ac7be886390592c31163ddf59.zip |
Patch from Aaron Lehmann <aaronl@vitelus.com>;
This diff does 2 things:
1) removes an unnecessary function. saves 64 bytes on i386
2) allows you to disable checking of mail (actually, it's now disabled
by default). this would be a nice CML1 option, but for now it's a
#(define|undef) in the C file like the other internal ash options.
this saves an additional 352 bytes if you leave mail disabled.
-rw-r--r-- | shell/ash.c | 50 |
1 files changed, 24 insertions, 26 deletions
diff --git a/shell/ash.c b/shell/ash.c index a1029fa05..feee31dee 100644 --- a/shell/ash.c +++ b/shell/ash.c | |||
@@ -67,6 +67,8 @@ | |||
67 | * standalone shell. Adds about 272 bytes. */ | 67 | * standalone shell. Adds about 272 bytes. */ |
68 | #undef ASH_CMDCMD | 68 | #undef ASH_CMDCMD |
69 | 69 | ||
70 | /* Check for new mail on interactive shells? */ | ||
71 | #undef ASH_MAIL | ||
70 | 72 | ||
71 | /* Optimize size vs speed as size */ | 73 | /* Optimize size vs speed as size */ |
72 | #define ASH_OPTIMIZE_FOR_SIZE | 74 | #define ASH_OPTIMIZE_FOR_SIZE |
@@ -1399,16 +1401,6 @@ rmaliases(void) | |||
1399 | INTON; | 1401 | INTON; |
1400 | } | 1402 | } |
1401 | 1403 | ||
1402 | static struct alias * | ||
1403 | lookupalias(const char *name, int check) | ||
1404 | { | ||
1405 | struct alias *ap = *__lookupalias(name); | ||
1406 | |||
1407 | if (check && ap && (ap->flag & ALIASINUSE)) | ||
1408 | return (NULL); | ||
1409 | return (ap); | ||
1410 | } | ||
1411 | |||
1412 | static void | 1404 | static void |
1413 | printalias(const struct alias *ap) { | 1405 | printalias(const struct alias *ap) { |
1414 | char *p; | 1406 | char *p; |
@@ -3101,8 +3093,10 @@ true_main(argc, argv) | |||
3101 | */ | 3093 | */ |
3102 | 3094 | ||
3103 | static void setsignal(int signo); | 3095 | static void setsignal(int signo); |
3104 | static void chkmail(int silent); | ||
3105 | 3096 | ||
3097 | #ifdef ASH_MAIL | ||
3098 | static void chkmail(int silent); | ||
3099 | #endif | ||
3106 | 3100 | ||
3107 | static void | 3101 | static void |
3108 | setinteractive(int on) | 3102 | setinteractive(int on) |
@@ -3115,7 +3109,9 @@ setinteractive(int on) | |||
3115 | setsignal(SIGINT); | 3109 | setsignal(SIGINT); |
3116 | setsignal(SIGQUIT); | 3110 | setsignal(SIGQUIT); |
3117 | setsignal(SIGTERM); | 3111 | setsignal(SIGTERM); |
3112 | #ifdef ASH_MAIL | ||
3118 | chkmail(1); | 3113 | chkmail(1); |
3114 | #endif | ||
3119 | is_interactive = on; | 3115 | is_interactive = on; |
3120 | if (do_banner==0 && is_interactive) { | 3116 | if (do_banner==0 && is_interactive) { |
3121 | /* Looks like they want an interactive shell */ | 3117 | /* Looks like they want an interactive shell */ |
@@ -3576,7 +3572,7 @@ hashcmd(argc, argv) | |||
3576 | delete_cmd_entry(); | 3572 | delete_cmd_entry(); |
3577 | #ifdef ASH_ALIAS | 3573 | #ifdef ASH_ALIAS |
3578 | /* Then look at the aliases */ | 3574 | /* Then look at the aliases */ |
3579 | if ((ap = lookupalias(name, 0)) != NULL) { | 3575 | if ((ap = *__lookupalias(name)) != NULL) { |
3580 | if (verbose=='v') | 3576 | if (verbose=='v') |
3581 | printf("%s is an alias for %s\n", name, ap->val); | 3577 | printf("%s is an alias for %s\n", name, ap->val); |
3582 | else | 3578 | else |
@@ -7523,8 +7519,11 @@ static void waitonint(int sig) { | |||
7523 | intreceived = 1; | 7519 | intreceived = 1; |
7524 | return; | 7520 | return; |
7525 | } | 7521 | } |
7522 | |||
7523 | #ifdef ASH_MAIL | ||
7524 | |||
7526 | /* | 7525 | /* |
7527 | * Routines to check for mail. (Perhaps make part of main.c?) | 7526 | * Routines to check for mail. |
7528 | */ | 7527 | */ |
7529 | 7528 | ||
7530 | 7529 | ||
@@ -7582,6 +7581,8 @@ chkmail(int silent) | |||
7582 | popstackmark(&smark); | 7581 | popstackmark(&smark); |
7583 | } | 7582 | } |
7584 | 7583 | ||
7584 | #endif /* ASH_MAIL */ | ||
7585 | |||
7585 | #define PROFILE 0 | 7586 | #define PROFILE 0 |
7586 | 7587 | ||
7587 | #if PROFILE | 7588 | #if PROFILE |
@@ -7749,7 +7750,9 @@ cmdloop(int top) | |||
7749 | if (iflag && top) { | 7750 | if (iflag && top) { |
7750 | inter++; | 7751 | inter++; |
7751 | showjobs(1); | 7752 | showjobs(1); |
7753 | #ifdef ASH_MAIL | ||
7752 | chkmail(0); | 7754 | chkmail(0); |
7755 | #endif | ||
7753 | flushall(); | 7756 | flushall(); |
7754 | } | 7757 | } |
7755 | n = parsecmd(inter); | 7758 | n = parsecmd(inter); |
@@ -10188,7 +10191,7 @@ top: | |||
10188 | lasttoken = t = TASSIGN; | 10191 | lasttoken = t = TASSIGN; |
10189 | #ifdef ASH_ALIAS | 10192 | #ifdef ASH_ALIAS |
10190 | } else if (checkalias) { | 10193 | } else if (checkalias) { |
10191 | if (!quoteflag && (ap = lookupalias(wordtext, 1)) != NULL) { | 10194 | if (!quoteflag && (ap = *__lookupalias(wordtext)) != NULL && !(ap->flag & ALIASINUSE)) { |
10192 | if (*ap->val) { | 10195 | if (*ap->val) { |
10193 | pushstring(ap->val, strlen(ap->val), ap); | 10196 | pushstring(ap->val, strlen(ap->val), ap); |
10194 | } | 10197 | } |
@@ -11454,6 +11457,9 @@ dup_as_newfd(from, to) | |||
11454 | } | 11457 | } |
11455 | 11458 | ||
11456 | #ifdef DEBUG | 11459 | #ifdef DEBUG |
11460 | /* | ||
11461 | * Debugging stuff. | ||
11462 | */ | ||
11457 | static void shtree (union node *, int, char *, FILE*); | 11463 | static void shtree (union node *, int, char *, FILE*); |
11458 | static void shcmd (union node *, FILE *); | 11464 | static void shcmd (union node *, FILE *); |
11459 | static void sharg (union node *, FILE *); | 11465 | static void sharg (union node *, FILE *); |
@@ -11578,8 +11584,6 @@ shcmd(cmd, fp) | |||
11578 | } | 11584 | } |
11579 | } | 11585 | } |
11580 | 11586 | ||
11581 | |||
11582 | |||
11583 | static void | 11587 | static void |
11584 | sharg(arg, fp) | 11588 | sharg(arg, fp) |
11585 | union node *arg; | 11589 | union node *arg; |
@@ -11681,16 +11685,8 @@ indent(amount, pfx, fp) | |||
11681 | putc('\t', fp); | 11685 | putc('\t', fp); |
11682 | } | 11686 | } |
11683 | } | 11687 | } |
11684 | #endif | ||
11685 | |||
11686 | |||
11687 | |||
11688 | /* | ||
11689 | * Debugging stuff. | ||
11690 | */ | ||
11691 | 11688 | ||
11692 | 11689 | ||
11693 | #ifdef DEBUG | ||
11694 | FILE *tracefile; | 11690 | FILE *tracefile; |
11695 | 11691 | ||
11696 | #if DEBUG == 2 | 11692 | #if DEBUG == 2 |
@@ -12200,12 +12196,14 @@ setvareq(s, flags) | |||
12200 | vp->flags |= flags; | 12196 | vp->flags |= flags; |
12201 | vp->text = s; | 12197 | vp->text = s; |
12202 | 12198 | ||
12199 | #ifdef ASH_MAIL | ||
12203 | /* | 12200 | /* |
12204 | * We could roll this to a function, to handle it as | 12201 | * We could roll this to a function, to handle it as |
12205 | * a regular variable function callback, but why bother? | 12202 | * a regular variable function callback, but why bother? |
12206 | */ | 12203 | */ |
12207 | if (iflag && (vp == &vmpath || (vp == &vmail && !mpathset()))) | 12204 | if (iflag && (vp == &vmpath || (vp == &vmail && !mpathset()))) |
12208 | chkmail(1); | 12205 | chkmail(1); |
12206 | #endif | ||
12209 | INTON; | 12207 | INTON; |
12210 | return; | 12208 | return; |
12211 | } | 12209 | } |
@@ -12246,7 +12244,7 @@ listsetvar(mylist) | |||
12246 | static const char * | 12244 | static const char * |
12247 | lookupvar(name) | 12245 | lookupvar(name) |
12248 | const char *name; | 12246 | const char *name; |
12249 | { | 12247 | { |
12250 | struct var *v; | 12248 | struct var *v; |
12251 | 12249 | ||
12252 | if ((v = *findvar(hashvar(name), name)) && !(v->flags & VUNSET)) { | 12250 | if ((v = *findvar(hashvar(name), name)) && !(v->flags & VUNSET)) { |
@@ -12650,7 +12648,7 @@ findvar(struct var **vpp, const char *name) | |||
12650 | /* | 12648 | /* |
12651 | * Copyright (c) 1999 Herbert Xu <herbert@debian.org> | 12649 | * Copyright (c) 1999 Herbert Xu <herbert@debian.org> |
12652 | * This file contains code for the times builtin. | 12650 | * This file contains code for the times builtin. |
12653 | * $Id: ash.c,v 1.33 2001/10/31 10:40:37 andersen Exp $ | 12651 | * $Id: ash.c,v 1.34 2001/10/31 11:05:49 andersen Exp $ |
12654 | */ | 12652 | */ |
12655 | static int timescmd (int argc, char **argv) | 12653 | static int timescmd (int argc, char **argv) |
12656 | { | 12654 | { |