char *literal;
} exprunion;
-typedef struct searchASTCache {
- searchASTExpr *tree;
- searchASTExpr *cache[AST_RECENT];
- int nextpos;
-} searchASTCache;
-
/* comares either a string and a string or an expression and an expression */
static searchASTExpr *compareloc(searchASTExpr *expr, exprunion *loc) {
if(expr->type == AST_NODE_LITERAL) {
sbaddchar(buf, ')');
} else if(expr->type == AST_NODE_LITERAL) {
- int quotesrequired, escrequired;
char *p;
- for(quotesrequired=escrequired=0,p=expr->u.literal;*p;p++) {
- if(*p == '(' || *p == ')' || *p == ' ')
- quotesrequired = 1;
- if(*p == '\\' || *p == '"') {
- escrequired = 1;
- if(quotesrequired)
- break;
- }
- }
- if(quotesrequired)
- sbaddchar(buf, '"');
-
- if(escrequired) {
- for(p=expr->u.literal;*p;p++) {
- if(*p == '\\' || *p == '"')
- sbaddchar(buf, '\\');
- sbaddchar(buf, *p);
- }
- } else {
- sbaddstr(buf, expr->u.literal);
+
+ sbaddchar(buf, '"');
+
+ for(p=expr->u.literal;*p;p++) {
+ if(*p == '\\' || *p == '"')
+ sbaddchar(buf, '\\');
+ sbaddchar(buf, *p);
}
- if(quotesrequired)
- sbaddchar(buf, '"');
+ sbaddchar(buf, '"');
} else {
sbaddstr(buf, "???");
}