summaryrefslogtreecommitdiff
path: root/shell/ash.c
diff options
context:
space:
mode:
authorDenis Vlasenko2008-12-15 11:26:36 +0000
committerDenis Vlasenko2008-12-15 11:26:36 +0000
commit68819d123211ead5354994663776298852577c29 (patch)
tree5887801c35b833f9ae32f5cbe2b8228aeb8a9029 /shell/ash.c
parent3139ea7f1567723e200d29e46e78953ea5fe4d5b (diff)
downloadbusybox-68819d123211ead5354994663776298852577c29.zip
busybox-68819d123211ead5354994663776298852577c29.tar.gz
ash: fix CONFIG_ASH_OPTIMIZE_FOR_SIZE off + high-bit chars case
(do we even need CONFIG_ASH_OPTIMIZE_FOR_SIZE conditional?)
Diffstat (limited to 'shell/ash.c')
-rw-r--r--shell/ash.c25
1 files changed, 15 insertions, 10 deletions
diff --git a/shell/ash.c b/shell/ash.c
index 2a71a2c..2fc903b 100644
--- a/shell/ash.c
+++ b/shell/ash.c
@@ -2708,12 +2708,11 @@ SIT(int c, int syntax)
&& (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 @@ preadfd(void)
*/
//#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 @@ preadbuffer(void)
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 @@ fixredir(union node *n, const char *text, int err)
* or backquotes).
*/
static int
-noexpand(char *text)
+noexpand(const char *text)
{
- char *p;
+ const char *p;
char c;
p = text;
@@ -10304,7 +10309,7 @@ noexpand(char *text)
continue;
if (c == CTLESC)
p++;
- else if (SIT(c, BASESYNTAX) == CCTL)
+ else if (SIT((signed char)c, BASESYNTAX) == CCTL)
return 0;
}
return 1;