summary refs log tree commit diff
diff options
context:
space:
mode:
authorherbert <herbert@gondor.apana.org.au>2005-02-25 23:16:05 +1100
committerHerbert Xu <herbert@gondor.apana.org.au>2005-09-26 18:33:03 +1000
commit155580420a6d49927a95ccae97d880f8cbceda16 (patch)
tree7dccfb482556f09da94a36f74b3fa3cad96db536
parentEliminated global exerrno. (diff)
downloaddash-155580420a6d49927a95ccae97d880f8cbceda16.tar.gz
dash-155580420a6d49927a95ccae97d880f8cbceda16.zip
Optimise away status and case statement in main().
-rw-r--r--ChangeLog2
-rw-r--r--src/main.c22
2 files changed, 6 insertions, 18 deletions
diff --git a/ChangeLog b/ChangeLog
index c51a351..70a8065 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -6,7 +6,7 @@
 
 	* Changed boolean rootshell into shlvl counter.
 	* Catch set -e exits within built-in commands.
-	* Size optimisations with state/s in main().
+	* Size optimisations with setjmp in main().
 	* Only reread exitstatus on EXEXIT in exitshell.
 	* Eliminated global exerrno.
 
diff --git a/src/main.c b/src/main.c
index c686a13..6253010 100644
--- a/src/main.c
+++ b/src/main.c
@@ -123,30 +123,18 @@ main(int argc, char **argv)
 #endif
 	state = 0;
 	if (unlikely(setjmp(jmploc.loc))) {
-		int status;
 		int e;
 		int s;
 
 		reset();
-		s = state;
 
 		e = exception;
-		switch (exception) {
-		case EXERROR:
-			status = 2;
-			break;
-
-		case EXEXIT:
-		case EXEVAL:
-			s = 0;
-			/* fall through */
-		default:
-			status = exitstatus;
-			break;
-		}
-		exitstatus = status;
+		if (e == EXERROR)
+			exitstatus = 2;
 
-		if (s == 0 || iflag == 0 || shlvl)
+		s = state;
+		if (e == EXEXIT || e == EXEVAL ||
+		    s == 0 || iflag == 0 || shlvl)
 			exitshell();
 
 		if (e == EXINT