comparison lwlib/lw_expr.c @ 2:7317fbe024af

Clean up insane number of compiler warnings under -Wall
author lost@l-w.ca
date Thu, 20 Jan 2011 22:39:46 -0700
parents 2c24602be78f
children 6b9991fb39b6
comparison
equal deleted inserted replaced
1:96c4dc89016e 2:7317fbe024af
20 */ 20 */
21 21
22 #include <stdarg.h> 22 #include <stdarg.h>
23 #include <stdio.h> 23 #include <stdio.h>
24 #include <string.h> 24 #include <string.h>
25 #include <ctype.h>
25 26
26 #define ___lw_expr_c_seen___ 27 #define ___lw_expr_c_seen___
27 #include "lw_alloc.h" 28 #include "lw_alloc.h"
28 #include "lw_expr.h" 29 #include "lw_expr.h"
29 #include "lw_error.h" 30 #include "lw_error.h"
109 110
110 /* actually duplicates the entire expression */ 111 /* actually duplicates the entire expression */
111 void lw_expr_add_operand(lw_expr_t E, lw_expr_t O); 112 void lw_expr_add_operand(lw_expr_t E, lw_expr_t O);
112 lw_expr_t lw_expr_copy(lw_expr_t E) 113 lw_expr_t lw_expr_copy(lw_expr_t E)
113 { 114 {
114 lw_expr_t r, t; 115 lw_expr_t r;
115 struct lw_expr_opers *o; 116 struct lw_expr_opers *o;
116 117
117 r = lw_alloc(sizeof(struct lw_expr_priv)); 118 r = lw_alloc(sizeof(struct lw_expr_priv));
118 *r = *E; 119 *r = *E;
119 r -> operands = NULL; 120 r -> operands = NULL;
608 return; 609 return;
609 610
610 // merge plus operations 611 // merge plus operations
611 if (E -> value == lw_expr_oper_plus) 612 if (E -> value == lw_expr_oper_plus)
612 { 613 {
613 lw_expr_t e2;
614
615 tryagainplus: 614 tryagainplus:
616 for (o = E -> operands; o; o = o -> next) 615 for (o = E -> operands; o; o = o -> next)
617 { 616 {
618 if (o -> p -> type == lw_expr_type_oper && o -> p -> value == lw_expr_oper_plus) 617 if (o -> p -> type == lw_expr_type_oper && o -> p -> value == lw_expr_oper_plus)
619 { 618 {
620 struct lw_expr_opers *o2, *o3; 619 struct lw_expr_opers *o2;
621 // we have a + operation - bring operands up 620 // we have a + operation - bring operands up
622 621
623 for (o2 = E -> operands; o2 && o2 -> next != o; o2 = o2 -> next) 622 for (o2 = E -> operands; o2 && o2 -> next != o; o2 = o2 -> next)
624 /* do nothing */ ; 623 /* do nothing */ ;
625 if (o2) 624 if (o2)
638 } 637 }
639 638
640 // merge times operations 639 // merge times operations
641 if (E -> value == lw_expr_oper_times) 640 if (E -> value == lw_expr_oper_times)
642 { 641 {
643 lw_expr_t e2;
644
645 tryagaintimes: 642 tryagaintimes:
646 for (o = E -> operands; o; o = o -> next) 643 for (o = E -> operands; o; o = o -> next)
647 { 644 {
648 if (o -> p -> type == lw_expr_type_oper && o -> p -> value == lw_expr_oper_times) 645 if (o -> p -> type == lw_expr_type_oper && o -> p -> value == lw_expr_oper_times)
649 { 646 {
650 struct lw_expr_opers *o2, *o3; 647 struct lw_expr_opers *o2;
651 // we have a + operation - bring operands up 648 // we have a + operation - bring operands up
652 649
653 for (o2 = E -> operands; o2 && o2 -> next != o; o2 = o2 -> next) 650 for (o2 = E -> operands; o2 && o2 -> next != o; o2 = o2 -> next)
654 /* do nothing */ ; 651 /* do nothing */ ;
655 if (o2) 652 if (o2)