summaryrefslogtreecommitdiff
path: root/editors
diff options
context:
space:
mode:
authorDenys Vlasenko2010-10-24 01:58:04 +0200
committerDenys Vlasenko2010-10-24 01:58:04 +0200
commit2b299fed6a77d3aaf7e4e768fb519f2536c2eff0 (patch)
tree1d86a176ddfbc1f853842629b758c0ab4e8ada9a /editors
parent53600591311a129717abd2e3bcaa302622a6ce67 (diff)
downloadbusybox-2b299fed6a77d3aaf7e4e768fb519f2536c2eff0.zip
busybox-2b299fed6a77d3aaf7e4e768fb519f2536c2eff0.tar.gz
awk: fix breakage in last commit
While at it, made bb_process_escape_sequence faster (same size) function old new delta nextchar 49 53 +4 bb_process_escape_sequence 138 140 +2 next_token 838 839 +1 static.charmap 20 18 -2 is_assignment 143 135 -8 ------------------------------------------------------------------------------ (add/remove: 0/0 grow/shrink: 3/2 up/down: 7/-10) Total: -3 bytes Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
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 fb3bf6b..9646ced 100644
--- a/editors/awk.c
+++ b/editors/awk.c
@@ -684,8 +684,11 @@ static char nextchar(char **s)
pps = *s;
if (c == '\\')
c = bb_process_escape_sequence((const char**)s);
- if (c == '\\' && *s == pps)
- c = *(*s)++;
+ if (c == '\\' && *s == pps) { /* unrecognized \z? */
+ c = *(*s); /* yes, fetch z */
+ if (c)
+ (*s)++; /* advance unless z = NUL */
+ }
return c;
}
@@ -1007,9 +1010,10 @@ static uint32_t next_token(uint32_t expected)
/* it's a string */
t_string = s = ++p;
while (*p != '\"') {
- char *pp = p;
+ char *pp;
if (*p == '\0' || *p == '\n')
syntax_error(EMSG_UNEXP_EOS);
+ pp = p;
*s++ = nextchar(&pp);
p = pp;
}
@@ -2926,22 +2930,21 @@ static int awk_exit(int r)
* otherwise return 0 */
static int is_assignment(const char *expr)
{
- char *exprc, *s, *s0, *s1;
+ char *exprc, *val, *s, *s1;
- if (!isalnum_(*expr) || (s0 = strchr(expr, '=')) == NULL) {
+ if (!isalnum_(*expr) || (val = strchr(expr, '=')) == NULL) {
return FALSE;
}
exprc = xstrdup(expr);
- s0 = exprc + (s0 - expr);
- *s++ = '\0';
+ val = exprc + (val - expr);
+ *val++ = '\0';
- s = s1 = s0;
- while (*s)
- *s1++ = nextchar(&s);
- *s1 = '\0';
+ s = s1 = val;
+ while ((*s1 = nextchar(&s)) != '\0')
+ s1++;
- setvar_u(newvar(exprc), s0);
+ setvar_u(newvar(exprc), val);
free(exprc);
return TRUE;
}