From 024f101e97197d1001cb9dd3403eee4a2e4c35bf Mon Sep 17 00:00:00 2001
From: Kaz Kylheku <kaz@kylheku.com>
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!)
---
 match.c | 16 ++++++++++------
 1 file changed, 10 insertions(+), 6 deletions(-)

(limited to 'match.c')

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