Discussion:
[PATCH] improve string handling for short filter expressions
Johannes Weißl
2011-01-18 03:24:54 UTC
Permalink
allow "~a rolling stones ~l banquet"
---
expr.c | 8 ++++----
1 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/expr.c b/expr.c
index 1a7f8e4..cea5ae7 100644
--- a/expr.c
+++ b/expr.c
@@ -636,7 +636,6 @@ static char *expand_short_expr(const char *expr_short)
if (c == '"') {
stack4_replace_top(&state_stack, ST_IN_QUOTE_STR);
out[k++] = c;
- /* out[k++] = '*'; */
} else {
stack4_replace_top(&state_stack, ST_IN_STR);
out[k++] = '"';
@@ -647,16 +646,17 @@ static char *expand_short_expr(const char *expr_short)
case ST_IN_QUOTE_STR:
if (c == '"' && expr_short[i-1] != '\\') {
stack4_pop(&state_stack);
- /* out[k++] = '*'; */
}
out[k++] = c;
break;
case ST_IN_STR:
/* isalnum() doesn't work for multi-byte characters */
- if (c != ' ' && c != ')' && c != '~' && c != '|' &&
- c != '(' && c != '!' && c != '\0') {
+ if (c != '~' && c != '!' && c != '|' &&
+ c != '(' && c != ')' && c != '\0') {
out[k++] = c;
} else {
+ while (k > 0 && out[k-1] == ' ')
+ k--;
out[k++] = '*';
out[k++] = '"';
i--;
--
1.7.2.3
Johannes Weißl
2011-01-19 04:40:48 UTC
Permalink
---
expr.c | 2 +-
1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/expr.c b/expr.c
index 1a7f8e4..5642727 100644
--- a/expr.c
+++ b/expr.c
@@ -553,7 +553,7 @@ static char *expand_short_expr(const char *expr_short)
out[k++] = '(';
} else if (etype == EXPR_STR) {
stack4_push(&state_stack, ST_EXPECT_STR);
- } else {
+ } else if (etype != EXPR_BOOL) {
BUG("wrong etype: %d\n", etype);
}
strcpy(out+k, key);
--
1.7.2.3
Gregory Petrosyan
2011-01-19 17:03:03 UTC
Permalink
Gregory Petrosyan
2011-01-19 17:03:29 UTC
Permalink
Post by Johannes Weißl
allow "~a rolling stones ~l banquet"
---
 expr.c |    8 ++++----
 1 files changed, 4 insertions(+), 4 deletions(-)
Thanks, applied!

                Gregory

Loading...