]> jfr.im git - irc/quakenet/newserv.git/blobdiff - newsearch/newsearch_ast.c
Merge.
[irc/quakenet/newserv.git] / newsearch / newsearch_ast.c
index fd8e1038ff4afb47a2afd39dd0c518694b6659b2..63c40f1de5cd51860e217d3b68d713c694605b80 100644 (file)
@@ -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, "???");
   }