aboutsummaryrefslogtreecommitdiff
path: root/editors
diff options
context:
space:
mode:
Diffstat (limited to 'editors')
-rw-r--r--editors/awk.c27
1 files changed, 15 insertions, 12 deletions
diff --git a/editors/awk.c b/editors/awk.c
index fb3bf6b47..9646cedd6 100644
--- a/editors/awk.c
+++ b/editors/awk.c
@@ -684,8 +684,11 @@ static char nextchar(char **s)
684 pps = *s; 684 pps = *s;
685 if (c == '\\') 685 if (c == '\\')
686 c = bb_process_escape_sequence((const char**)s); 686 c = bb_process_escape_sequence((const char**)s);
687 if (c == '\\' && *s == pps) 687 if (c == '\\' && *s == pps) { /* unrecognized \z? */
688 c = *(*s)++; 688 c = *(*s); /* yes, fetch z */
689 if (c)
690 (*s)++; /* advance unless z = NUL */
691 }
689 return c; 692 return c;
690} 693}
691 694
@@ -1007,9 +1010,10 @@ static uint32_t next_token(uint32_t expected)
1007 /* it's a string */ 1010 /* it's a string */
1008 t_string = s = ++p; 1011 t_string = s = ++p;
1009 while (*p != '\"') { 1012 while (*p != '\"') {
1010 char *pp = p; 1013 char *pp;
1011 if (*p == '\0' || *p == '\n') 1014 if (*p == '\0' || *p == '\n')
1012 syntax_error(EMSG_UNEXP_EOS); 1015 syntax_error(EMSG_UNEXP_EOS);
1016 pp = p;
1013 *s++ = nextchar(&pp); 1017 *s++ = nextchar(&pp);
1014 p = pp; 1018 p = pp;
1015 } 1019 }
@@ -2926,22 +2930,21 @@ static int awk_exit(int r)
2926 * otherwise return 0 */ 2930 * otherwise return 0 */
2927static int is_assignment(const char *expr) 2931static int is_assignment(const char *expr)
2928{ 2932{
2929 char *exprc, *s, *s0, *s1; 2933 char *exprc, *val, *s, *s1;
2930 2934
2931 if (!isalnum_(*expr) || (s0 = strchr(expr, '=')) == NULL) { 2935 if (!isalnum_(*expr) || (val = strchr(expr, '=')) == NULL) {
2932 return FALSE; 2936 return FALSE;
2933 } 2937 }
2934 2938
2935 exprc = xstrdup(expr); 2939 exprc = xstrdup(expr);
2936 s0 = exprc + (s0 - expr); 2940 val = exprc + (val - expr);
2937 *s++ = '\0'; 2941 *val++ = '\0';
2938 2942
2939 s = s1 = s0; 2943 s = s1 = val;
2940 while (*s) 2944 while ((*s1 = nextchar(&s)) != '\0')
2941 *s1++ = nextchar(&s); 2945 s1++;
2942 *s1 = '\0';
2943 2946
2944 setvar_u(newvar(exprc), s0); 2947 setvar_u(newvar(exprc), val);
2945 free(exprc); 2948 free(exprc);
2946 return TRUE; 2949 return TRUE;
2947} 2950}