svn commit: trunk/busybox/shell

vda at busybox.net vda at busybox.net
Mon Dec 15 11:26:36 UTC 2008


Author: vda
Date: 2008-12-15 03:26:36 -0800 (Mon, 15 Dec 2008)
New Revision: 24417

Log:
ash: fix CONFIG_ASH_OPTIMIZE_FOR_SIZE off + high-bit chars case
(do we even need CONFIG_ASH_OPTIMIZE_FOR_SIZE conditional?)



Modified:
   trunk/busybox/shell/ash.c


Changeset:
Modified: trunk/busybox/shell/ash.c
===================================================================
--- trunk/busybox/shell/ash.c	2008-12-15 09:49:15 UTC (rev 24416)
+++ trunk/busybox/shell/ash.c	2008-12-15 11:26:36 UTC (rev 24417)
@@ -2708,12 +2708,11 @@
 	 && (unsigned char)c <= (unsigned char)(CTLQUOTEMARK)
 	) {
 		return CCTL;
-	} else {
-		s = strchrnul(spec_symbls, c);
-		if (*s == '\0')
-			return CWORD;
-		indx = syntax_index_table[s - spec_symbls];
 	}
+	s = strchrnul(spec_symbls, c);
+	if (*s == '\0')
+		return CWORD;
+	indx = syntax_index_table[s - spec_symbls];
 	return S_I_T[indx][syntax];
 }
 
@@ -9290,6 +9289,12 @@
  */
 //#define pgetc_debug(...) bb_error_msg(__VA_ARGS__)
 #define pgetc_debug(...) ((void)0)
+/*
+ * NB: due to SIT(c) internals (syntax_index_table[] vector),
+ * pgetc() and related functions must return chars SIGN-EXTENDED into ints,
+ * not zero-extended. Seems fragile to me. Affects only !USE_SIT_FUNCTION case,
+ * so we can fix it by ditching !USE_SIT_FUNCTION if Unicode requires that.
+ */
 static int
 preadbuffer(void)
 {
@@ -9390,12 +9395,12 @@
 			g_parsefile->left_in_line,
 			g_parsefile->next_to_pgetc,
 			g_parsefile->next_to_pgetc);
-	return (unsigned char)(*g_parsefile->next_to_pgetc++);
+	return signed_char2int(*g_parsefile->next_to_pgetc++);
 }
 
 #define pgetc_as_macro() \
 	(--g_parsefile->left_in_line >= 0 \
-	? (unsigned char)(*g_parsefile->next_to_pgetc++) \
+	? signed_char2int(*g_parsefile->next_to_pgetc++) \
 	: preadbuffer() \
 	)
 
@@ -10293,9 +10298,9 @@
  * or backquotes).
  */
 static int
-noexpand(char *text)
+noexpand(const char *text)
 {
-	char *p;
+	const char *p;
 	char c;
 
 	p = text;
@@ -10304,7 +10309,7 @@
 			continue;
 		if (c == CTLESC)
 			p++;
-		else if (SIT(c, BASESYNTAX) == CCTL)
+		else if (SIT((signed char)c, BASESYNTAX) == CCTL)
 			return 0;
 	}
 	return 1;




More information about the busybox-cvs mailing list