changeset 544:7fb1cf0d8a84

Replace label and gotos with a for(;;) loop, break, and continue.
author Rob Landley <rob@landley.net>
date Thu, 27 Dec 2007 00:34:59 -0600
parents f5e9e8615e47
children 11d95002dfe1
files tcc.c
diffstat 1 files changed, 35 insertions(+), 33 deletions(-) [+]
line wrap: on
line diff
--- a/tcc.c	Fri Dec 14 19:57:38 2007 -0600
+++ b/tcc.c	Thu Dec 27 00:34:59 2007 -0600
@@ -3473,41 +3473,43 @@
     TokenString str;
     struct macro_level *ml;
 
- redo:
-    next_nomacro();
-    if (!macro_ptr) {
-        /* if not reading from macro substituted string, then try
-           to substitute macros */
-        if (tok >= TOK_IDENT &&
-            (parse_flags & PARSE_FLAG_PREPROCESS)) {
-            s = define_find(tok);
-            if (s) {
-                /* we have a macro: we try to substitute */
-                tok_str_new(&str);
-                nested_list = NULL;
-                ml = NULL;
-                if (macro_subst_tok(&str, &nested_list, s, &ml) == 0) {
-                    /* substitution done, NOTE: maybe empty */
-                    tok_str_add(&str, 0, 0);
-                    macro_ptr = str.str;
-                    macro_ptr_allocated = str.str;
-                    goto redo;
+    for (;;) {
+        next_nomacro();
+        if (!macro_ptr) {
+            /* if not reading from macro substituted string, then try
+               to substitute macros */
+            if (tok >= TOK_IDENT &&
+                (parse_flags & PARSE_FLAG_PREPROCESS)) {
+                s = define_find(tok);
+                if (s) {
+                    /* we have a macro: we try to substitute */
+                    tok_str_new(&str);
+                    nested_list = NULL;
+                    ml = NULL;
+                    if (macro_subst_tok(&str, &nested_list, s, &ml) == 0) {
+                        /* substitution done, NOTE: maybe empty */
+                        tok_str_add(&str, 0, 0);
+                        macro_ptr = str.str;
+                        macro_ptr_allocated = str.str;
+                        continue;
+                    }
                 }
             }
-        }
-    } else {
-        if (tok == 0) {
-            /* end of macro or end of unget buffer */
-            if (unget_buffer_enabled) {
-                macro_ptr = unget_saved_macro_ptr;
-                unget_buffer_enabled = 0;
-            } else {
-                /* end of macro string: free it */
-                tok_str_free(macro_ptr_allocated);
-                macro_ptr = NULL;
-            }
-            goto redo;
-        }
+        } else {
+            if (tok == 0) {
+                /* end of macro or end of unget buffer */
+                if (unget_buffer_enabled) {
+                    macro_ptr = unget_saved_macro_ptr;
+                    unget_buffer_enabled = 0;
+                } else {
+                    /* end of macro string: free it */
+                    tok_str_free(macro_ptr_allocated);
+                    macro_ptr = NULL;
+                }
+                continue;
+            }
+        }
+        break;
     }
     
     /* convert preprocessor tokens into C tokens */