svn commit: trunk/busybox/shell

vda at busybox.net vda at busybox.net
Thu Feb 1 01:43:39 UTC 2007


Author: vda
Date: 2007-01-31 17:43:39 -0800 (Wed, 31 Jan 2007)
New Revision: 17691

Log:
msh: cleaning up for -Wwrite-strings part #3


Modified:
   trunk/busybox/shell/msh.c


Changeset:
Modified: trunk/busybox/shell/msh.c
===================================================================
--- trunk/busybox/shell/msh.c	2007-02-01 01:43:16 UTC (rev 17690)
+++ trunk/busybox/shell/msh.c	2007-02-01 01:43:39 UTC (rev 17691)
@@ -284,7 +284,6 @@
 
 static int newenv(int f);
 static void quitenv(void);
-static void err(const char *s);
 static int anys(const char *s1, const char *s2);
 static int any(int c, const char *s);
 static void next(int f);
@@ -344,8 +343,6 @@
 /* flags to yylex */
 #define	CONTIN 01     /* skip new lines to complete command */
 
-#define	SYNTAXERR zzerr()
-
 static struct op *pipeline(int cf);
 static struct op *andor(void);
 static struct op *c_list(void);
@@ -369,8 +366,6 @@
 static void word(char *cp);
 static struct ioword **copyio(void);
 static struct ioword *io(int u, int f, char *cp);
-static void zzerr(void);
-static void yyerror(char *s);
 static int yylex(int cf);
 static int collect(int c, int c1);
 static int dual(int c);
@@ -461,17 +456,10 @@
 static int run(struct ioarg *argp, int (*f) (struct ioarg *));
 
 
-/*
- * IO functions
- */
 static int eofc(void);
 static int readc(void);
 static void unget(int c);
 static void ioecho(char c);
-static void prs(const char *s);
-static void prn(unsigned u);
-static void closef(int i);
-static void closeall(void);
 
 
 /*
@@ -734,10 +722,40 @@
 	if (head->right)
 		print_tree(head->right);
 }
-#endif							/* MSHDEBUG */
+#endif /* MSHDEBUG */
 
 
+/*
+ * IO functions
+ */
+static void prs(const char *s)
+{
+	if (*s)
+		write(2, s, strlen(s));
+}
+
+static void prn(unsigned u)
+{
+	prs(itoa(u));
+}
+
+static void closef(int i)
+{
+	if (i > 2)
+		close(i);
+}
+
+static void closeall(void)
+{
+	int u;
+
+	for (u = NUFILE; u < NOFILE;)
+		close(u++);
+}
+
+
 /* fail but return to process next command */
+static void fail(void) ATTRIBUTE_NORETURN;
 static void fail(void)
 {
 	longjmp(failpt, 1);
@@ -783,6 +801,7 @@
 	e.iop = e.iobase = iostack;
 }
 
+
 /* -------- area.c -------- */
 
 /*
@@ -967,6 +986,7 @@
 	return "";
 }
 
+
 /* -------- var.c -------- */
 
 static int eqname(const char *n1, const char *n2)
@@ -1487,6 +1507,24 @@
  * shell: syntax (C version)
  */
 
+static void yyerror(const char *s) ATTRIBUTE_NORETURN;
+static void yyerror(const char *s)
+{
+	yynerrs++;
+	if (interactive && e.iop <= iostack) {
+		multiline = 0;
+		while (eofc() == 0 && yylex(0) != '\n');
+	}
+	err(s);
+	fail();
+}
+
+static void zzerr(void) ATTRIBUTE_NORETURN;
+static void zzerr(void)
+{
+	yyerror("syntax error");
+}
+
 int yyparse(void)
 {
 	DBGPRINTF7(("YYPARSE: enter...\n"));
@@ -1515,7 +1553,7 @@
 			p = command(CONTIN);
 			if (p == NULL) {
 				DBGPRINTF8(("PIPELINE: error!\n"));
-				SYNTAXERR;
+				zzerr();
 			}
 
 			if (t->type != TPAREN && t->type != TCOM) {
@@ -1548,7 +1586,7 @@
 			p = pipeline(CONTIN);
 			if (p == NULL) {
 				DBGPRINTF8(("ANDOR: error!\n"));
-				SYNTAXERR;
+				zzerr();
 			}
 
 			t = block(c == LOGAND ? TAND : TOR, t, p, NOWORDS);
@@ -1627,7 +1665,7 @@
 	peeksym = yylex(cf);
 	if (peeksym != c) {
 		DBGPRINTF7(("MUSTHAVE: error!\n"));
-		SYNTAXERR;
+		zzerr();
 	}
 
 	peeksym = 0;
@@ -1811,7 +1849,7 @@
 	if (c == DONE && onlydone)
 		return NULL;
 	if (c != DO)
-		SYNTAXERR;
+		zzerr();
 	mylist = c_list();
 	musthave(DONE, 0);
 	return mylist;
@@ -1831,7 +1869,7 @@
 	t->type = 0;
 	t->left = c_list();
 	if (t->left == NULL)
-		SYNTAXERR;
+		zzerr();
 	t->right = elsepart();
 	return t;
 }
@@ -1845,7 +1883,7 @@
 	case ELSE:
 		t = c_list();
 		if (t == NULL)
-			SYNTAXERR;
+			zzerr();
 		return t;
 
 	case ELIF:
@@ -2058,22 +2096,6 @@
 	return iop;
 }
 
-static void zzerr(void)
-{
-	yyerror("syntax error");
-}
-
-static void yyerror(char *s)
-{
-	yynerrs++;
-	if (interactive && e.iop <= iostack) {
-		multiline = 0;
-		while (eofc() == 0 && yylex(0) != '\n');
-	}
-	err(s);
-	fail();
-}
-
 static int yylex(int cf)
 {
 	int c, c1;
@@ -4803,32 +4825,6 @@
 	return c;
 }
 
-static void prs(const char *s)
-{
-	if (*s)
-		write(2, s, strlen(s));
-}
-
-static void prn(unsigned u)
-{
-	prs(itoa(u));
-}
-
-static void closef(int i)
-{
-	if (i > 2)
-		close(i);
-}
-
-static void closeall(void)
-{
-	int u;
-
-	for (u = NUFILE; u < NOFILE;)
-		close(u++);
-}
-
-
 /*
  * remap fd into Shell's fd space
  */



More information about the busybox-cvs mailing list