[BusyBox] ash work

Aaron Lehmann aaronl at vitelus.com
Wed Oct 24 19:09:44 UTC 2001


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.
-------------- next part --------------
Index: shell/ash.c
===================================================================
RCS file: /var/cvs/busybox/shell/ash.c,v
retrieving revision 1.31
diff -u -r1.31 ash.c
--- shell/ash.c	2001/10/24 17:19:35	1.31
+++ shell/ash.c	2001/10/25 01:03:41
@@ -67,6 +67,8 @@
  * standalone shell.   Adds about 272 bytes. */
 #undef ASH_CMDCMD
 
+/* Check for new mail on interactive shells? */
+#undef ASH_MAIL
 
 /* Optimize size vs speed as size */
 #define ASH_OPTIMIZE_FOR_SIZE
@@ -1398,16 +1400,6 @@
 	INTON;
 }
 
-static struct alias *
-lookupalias(const char *name, int check)
-{
-	struct alias *ap = *__lookupalias(name);
-
-	if (check && ap && (ap->flag & ALIASINUSE))
-		return (NULL);
-	return (ap);
-}
-
 static void
 printalias(const struct alias *ap) {
 	char *p;
@@ -3097,8 +3089,10 @@
  */
 
 static void setsignal(int signo);
-static void chkmail(int silent);
 
+#ifdef ASH_MAIL
+static void chkmail(int silent);
+#endif
 
 static void
 setinteractive(int on)
@@ -3111,7 +3105,9 @@
 	setsignal(SIGINT);
 	setsignal(SIGQUIT);
 	setsignal(SIGTERM);
+#ifdef ASH_MAIL
 	chkmail(1);
+#endif
 	is_interactive = on;
 	if (do_banner==0 && is_interactive) {
 		/* Looks like they want an interactive shell */
@@ -3572,7 +3568,7 @@
 			delete_cmd_entry();
 #ifdef ASH_ALIAS
 	/* Then look at the aliases */
-		if ((ap = lookupalias(name, 0)) != NULL) {
+		if ((ap = *__lookupalias(name)) != NULL) {
 			if (verbose=='v')
 				printf("%s is an alias for %s\n", name, ap->val);
 			else
@@ -7515,8 +7511,11 @@
 	intreceived = 1;
 	return;
 }
+
+#ifdef ASH_MAIL
+
 /*
- * Routines to check for mail.  (Perhaps make part of main.c?)
+ * Routines to check for mail.
  */
 
 
@@ -7574,6 +7573,8 @@
 	popstackmark(&smark);
 }
 
+#endif /* ASH_MAIL */
+
 #define PROFILE 0
 
 #if PROFILE
@@ -7741,7 +7742,9 @@
 		if (iflag && top) {
 			inter++;
 			showjobs(1);
+#ifdef ASH_MAIL
 			chkmail(0);
+#endif
 			flushall();
 		}
 		n = parsecmd(inter);
@@ -10165,7 +10168,7 @@
 		lasttoken = t = TASSIGN;
 #ifdef ASH_ALIAS
 	} else if (checkalias) {
-		if (!quoteflag && (ap = lookupalias(wordtext, 1)) != NULL) {
+		if (!quoteflag && (ap = *__lookupalias(wordtext)) != NULL && !(ap->flag & ALIASINUSE)) {
 			if (*ap->val) {
 				pushstring(ap->val, strlen(ap->val), ap);
 			}
@@ -11431,6 +11434,9 @@
 }
 
 #ifdef DEBUG
+/*
+ * Debugging stuff.
+ */
 static void shtree (union node *, int, char *, FILE*);
 static void shcmd (union node *, FILE *);
 static void sharg (union node *, FILE *);
@@ -11555,8 +11561,6 @@
 	}
 }
 
-
-
 static void
 sharg(arg, fp)
 	union node *arg;
@@ -11658,16 +11662,8 @@
 		putc('\t', fp);
 	}
 }
-#endif
-
-
-
-/*
- * Debugging stuff.
- */
 
 
-#ifdef DEBUG
 FILE *tracefile;
 
 #if DEBUG == 2
@@ -12177,12 +12173,14 @@
 		vp->flags |= flags;
 		vp->text = s;
 
+#ifdef ASH_MAIL
 		/*
 		 * We could roll this to a function, to handle it as
 		 * a regular variable function callback, but why bother?
 		 */
 		if (iflag && (vp == &vmpath || (vp == &vmail && !mpathset())))
 			chkmail(1);
+#endif
 		INTON;
 		return;
 	}
@@ -12223,7 +12221,7 @@
 static const char *
 lookupvar(name)
 	const char *name;
-	{
+{
 	struct var *v;
 
 	if ((v = *findvar(hashvar(name), name)) && !(v->flags & VUNSET)) {


More information about the busybox mailing list