X-Git-Url: https://jfr.im/git/irc/quakenet/newserv.git/blobdiff_plain/6b2202d0da24d4aad73f43afabb8b5d132b78bea..8855bb48b449ed06cfd3ce528b3c0a77c37cb24b:/newsearch/newsearch_ast.c diff --git a/newsearch/newsearch_ast.c b/newsearch/newsearch_ast.c index fd8e1038..63c40f1d 100644 --- a/newsearch/newsearch_ast.c +++ b/newsearch/newsearch_ast.c @@ -11,12 +11,6 @@ typedef union exprunion { 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) { @@ -242,32 +236,17 @@ static char *ast_printtree_real(StringBuf *buf, searchASTExpr *expr, searchCmd * 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, "???"); }