aboutsummaryrefslogtreecommitdiff
path: root/shell/ash.c
diff options
context:
space:
mode:
Diffstat (limited to 'shell/ash.c')
-rw-r--r--shell/ash.c33
1 files changed, 20 insertions, 13 deletions
diff --git a/shell/ash.c b/shell/ash.c
index b95356034..df7083370 100644
--- a/shell/ash.c
+++ b/shell/ash.c
@@ -7075,6 +7075,14 @@ varvalue(char *name, int varflags, int flags, struct strlist *var_str_list)
7075 len = strlen(p); 7075 len = strlen(p);
7076 if (!(subtype == VSPLUS || subtype == VSLENGTH)) 7076 if (!(subtype == VSPLUS || subtype == VSLENGTH))
7077 memtodest(p, len, syntax, quotes); 7077 memtodest(p, len, syntax, quotes);
7078#if ENABLE_UNICODE_SUPPORT
7079 if (subtype == VSLENGTH && len > 0) {
7080 reinit_unicode_for_ash();
7081 if (unicode_status == UNICODE_ON) {
7082 len = unicode_strlen(p);
7083 }
7084 }
7085#endif
7078 return len; 7086 return len;
7079 } 7087 }
7080 7088
@@ -7158,15 +7166,7 @@ evalvar(char *p, int flags, struct strlist *var_str_list)
7158 varunset(p, var, 0, 0); 7166 varunset(p, var, 0, 0);
7159 7167
7160 if (subtype == VSLENGTH) { 7168 if (subtype == VSLENGTH) {
7161 ssize_t n = varlen; 7169 cvtnum(varlen > 0 ? varlen : 0);
7162 if (n > 0) {
7163 reinit_unicode_for_ash();
7164 if (unicode_status == UNICODE_ON) {
7165 const char *val = lookupvar(var);
7166 n = unicode_strlen(val);
7167 }
7168 }
7169 cvtnum(n > 0 ? n : 0);
7170 goto record; 7170 goto record;
7171 } 7171 }
7172 7172
@@ -10981,7 +10981,7 @@ static union node *andor(void);
10981static union node *pipeline(void); 10981static union node *pipeline(void);
10982static union node *parse_command(void); 10982static union node *parse_command(void);
10983static void parseheredoc(void); 10983static void parseheredoc(void);
10984static char peektoken(void); 10984static char nexttoken_ends_list(void);
10985static int readtoken(void); 10985static int readtoken(void);
10986 10986
10987static union node * 10987static union node *
@@ -10991,7 +10991,7 @@ list(int nlflag)
10991 int tok; 10991 int tok;
10992 10992
10993 checkkwd = CHKNL | CHKKWD | CHKALIAS; 10993 checkkwd = CHKNL | CHKKWD | CHKALIAS;
10994 if (nlflag == 2 && peektoken()) 10994 if (nlflag == 2 && nexttoken_ends_list())
10995 return NULL; 10995 return NULL;
10996 n1 = NULL; 10996 n1 = NULL;
10997 for (;;) { 10997 for (;;) {
@@ -11033,8 +11033,15 @@ list(int nlflag)
11033 tokpushback = 1; 11033 tokpushback = 1;
11034 } 11034 }
11035 checkkwd = CHKNL | CHKKWD | CHKALIAS; 11035 checkkwd = CHKNL | CHKKWD | CHKALIAS;
11036 if (peektoken()) 11036 if (nexttoken_ends_list()) {
11037 /* Testcase: "<<EOF; then <W".
11038 * It used to segfault w/o this check:
11039 */
11040 if (heredoclist) {
11041 raise_error_unexpected_syntax(-1);
11042 }
11037 return n1; 11043 return n1;
11044 }
11038 break; 11045 break;
11039 case TEOF: 11046 case TEOF:
11040 if (heredoclist) 11047 if (heredoclist)
@@ -12471,7 +12478,7 @@ readtoken(void)
12471} 12478}
12472 12479
12473static char 12480static char
12474peektoken(void) 12481nexttoken_ends_list(void)
12475{ 12482{
12476 int t; 12483 int t;
12477 12484