[hackers] [scc] Fix for condition || Roberto E. Vargas Caballero

From: <git_AT_suckless.org>
Date: Sat, 15 Aug 2015 23:27:07 +0200 (CEST)

commit 25b248b2ec25cb328aea47c140ca83f00ce2d37f
Author: Roberto E. Vargas Caballero <k0ga_AT_shike2.com>
AuthorDate: Sat Aug 15 20:37:28 2015 +0200
Commit: Roberto E. Vargas Caballero <k0ga_AT_shike2.com>
CommitDate: Sat Aug 15 20:37:28 2015 +0200

    Fix for condition
    
    Condition() expects '(' before and ')' after, so it
    was not a good idea call it in for. Exp2cond() does
    the job.

diff --git a/cc1/cc1.h b/cc1/cc1.h
index fc16aa7..ea8ad78 100644
--- a/cc1/cc1.h
+++ b/cc1/cc1.h
_AT_@ -347,6 +347,7 @@ extern void freetree(Node *np);
 extern Node *expr(void), *negate(Node *np), *constexpr(void);
 extern Node *convert(Node *np, Type *tp1, char iscast);
 extern Node *eval(Node *np), *iconstexpr(void), *condition(void);
+extern Node *exp2cond(Node *np, char neg);
 
 /* cpp.c */
 extern void icpp(void);
diff --git a/cc1/expr.c b/cc1/expr.c
index ebde5b1..f102a0c 100644
--- a/cc1/expr.c
+++ b/cc1/expr.c
_AT_@ -562,7 +562,7 @@ negate(Node *np)
         return np;
 }
 
-static Node *
+Node *
 exp2cond(Node *np, char neg)
 {
         np = decay(np);
diff --git a/cc1/stmt.c b/cc1/stmt.c
index c31fd8d..294ab5d 100644
--- a/cc1/stmt.c
+++ b/cc1/stmt.c
_AT_@ -91,7 +91,7 @@ For(Symbol *lbreak, Symbol *lcont, Caselist *lswitch)
         expect('(');
         einit = (yytoken != ';') ? expr() : NULL;
         expect(';');
- econd = (yytoken != ';') ? condition() : NULL;
+ econd = (yytoken != ';') ? exp2cond(expr(), 0) : NULL;
         expect(';');
         einc = (yytoken != ')') ? expr() : NULL;
         expect(')');
Received on Sat Aug 15 2015 - 23:27:07 CEST

This archive was generated by hypermail 2.3.0 : Sat Aug 15 2015 - 23:36:24 CEST