[hackers] [sbase] insert implicit -a after primary before ! || Evan Gates

From: <git_AT_suckless.org>
Date: Sat, 21 Feb 2015 10:33:31 +0100 (CET)

commit d5f3c6e04250faa9d6f79946597524ab7f7018a1
Author: Evan Gates <evan.gates_AT_gmail.com>
Date: Fri Feb 20 17:51:04 2015 -0800

    insert implicit -a after primary before !

diff --git a/find.c b/find.c
index bb9f344..82d28d5 100644
--- a/find.c
+++ b/find.c
_AT_@ -768,6 +768,7 @@ parse(int argc, char **argv)
         char **arg;
         size_t ntok = 0;
         int print = 1;
+ Tok and = { .u.oinfo = find_op("-a"), .type = AND };
 
         /* convert argv to infix expression of Tok, inserting in *tok */
         for (arg = argv, tok = infix; *arg; arg++, tok++) {
_AT_@ -786,9 +787,7 @@ parse(int argc, char **argv)
                                 print = 0;
 
                         if (lasttype == PRIM || lasttype == RPAR) {
- tok->u.oinfo = find_op("-a"); /* ew? */
- tok->type = AND;
- tok++;
+ *tok++ = and;
                                 ntok++;
                         }
                         if (pri->getarg) {
_AT_@ -802,6 +801,10 @@ parse(int argc, char **argv)
                 } else if ((op = find_op(*arg))) { /* token is an operator */
                         if (lasttype == LPAR && op->type == RPAR)
                                 eprintf("empty parens\n");
+ if (lasttype == PRIM && op->type == NOT) { /* need another implicit -a */
+ *tok++ = and;
+ ntok++;
+ }
                         tok->type = op->type;
                         tok->u.oinfo = op;
 
_AT_@ -866,11 +869,9 @@ parse(int argc, char **argv)
                 out->type = PRIM;
                 out++;
         }
- if (print == 2) {
- out->u.oinfo = find_op("-a");
- out->type = AND;
- out++;
- }
+ if (print == 2)
+ *out++ = and;
+
         out->type = END;
 
         /* rpn now holds all operators and arguments in reverse polish notation
Received on Sat Feb 21 2015 - 10:33:31 CET

This archive was generated by hypermail 2.3.0 : Sat Feb 21 2015 - 10:36:37 CET