From 024f101e97197d1001cb9dd3403eee4a2e4c35bf Mon Sep 17 00:00:00 2001 From: Kaz Kylheku Date: Sun, 2 Oct 2011 12:19:29 -0700 Subject: Compiles as C++ again. * lib.h (cons_set): New macro. * match.c (match_line, match_files): In collect clause handlers, move variable declarations above goto, and initialize with cons_set, instead of declaring and initializing with cons_bind. This eliminates the stupid C++ error that goto skips a variable initialization (which happens even when it can be trivially proven that the has no next use at the goto site!) --- ChangeLog | 13 +++++++++++++ lib.h | 8 ++++++++ match.c | 16 ++++++++++------ 3 files changed, 31 insertions(+), 6 deletions(-) diff --git a/ChangeLog b/ChangeLog index 4c267bdf..cf94b3b6 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,16 @@ +2011-10-02 Kaz Kylheku + + Compiles as C++ again. + + * lib.h (cons_set): New macro. + + * match.c (match_line, match_files): In collect clause handlers, + move variable declarations above goto, and initialize with + cons_set, instead of declaring and initializing with cons_bind. + This eliminates the stupid C++ error that goto skips a variable + initialization (which happens even when it can be trivially + proven that the has no next use at the goto site!) + 2011-10-01 Kaz Kylheku Version 038 diff --git a/lib.h b/lib.h index 329504a5..ae5bb79e 100644 --- a/lib.h +++ b/lib.h @@ -445,6 +445,14 @@ INLINE val eq(val a, val b) { return ((a) == (b) ? t : nil); } obj_t *CAR = car(c_o_n_s ## CAR ## CDR); \ obj_t *CDR = cdr(c_o_n_s ## CAR ## CDR) +#define cons_set(CAR, CDR, CONS) \ + do { \ + obj_t *c_o_n_s ## CAR ## CDR = CONS; \ + CAR = car(c_o_n_s ## CAR ## CDR); \ + CDR = cdr(c_o_n_s ## CAR ## CDR); \ + } while (0) + + #define zero num_fast(0) #define one num_fast(1) #define two num_fast(2) diff --git a/match.c b/match.c index af259cf2..673ca9e2 100644 --- a/match.c +++ b/match.c @@ -495,6 +495,8 @@ static val match_line(val bindings, val specline, val dataline, break; for (;;) { + val new_bindings = nil, new_pos = nil; + if ((gap || min) && mincounter < cmin) goto next_coll; @@ -502,9 +504,9 @@ static val match_line(val bindings, val specline, val dataline, break; { - cons_bind (new_bindings, new_pos, - match_line(bindings, coll_specline, dataline, pos, - spec_lineno, data_lineno, file)); + cons_set (new_bindings, new_pos, + match_line(bindings, coll_specline, dataline, pos, + spec_lineno, data_lineno, file)); if (until_specline) { cons_bind (until_bindings, until_pos, @@ -1499,6 +1501,8 @@ repeat_spec_same_data: result = t; while (data) { + val new_bindings = nil, success = nil; + if ((gap || min) && mincounter < cmin) goto next_collect; @@ -1506,9 +1510,9 @@ repeat_spec_same_data: break; { - cons_bind (new_bindings, success, - match_files(coll_spec, files, bindings, - data, num(data_lineno))); + cons_set (new_bindings, success, + match_files(coll_spec, files, bindings, + data, num(data_lineno))); /* Until clause sees un-collated bindings from collect. */ if (until_spec) -- cgit v1.2.3