Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/bin/csh Keep track of the while level, when popping loops be...



details:   https://anonhg.NetBSD.org/src/rev/9579c6cd79be
branches:  trunk
changeset: 566594:9579c6cd79be
user:      christos <christos%NetBSD.org@localhost>
date:      Thu May 13 15:25:58 2004 +0000

description:
Keep track of the while level, when popping loops because of a breaksw.
This is nasty...

diffstat:

 bin/csh/func.c |  13 +++++++++----
 1 files changed, 9 insertions(+), 4 deletions(-)

diffs (54 lines):

diff -r 0740905b9c67 -r 9579c6cd79be bin/csh/func.c
--- a/bin/csh/func.c    Thu May 13 15:20:18 2004 +0000
+++ b/bin/csh/func.c    Thu May 13 15:25:58 2004 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: func.c,v 1.28 2004/04/17 15:40:52 christos Exp $ */
+/* $NetBSD: func.c,v 1.29 2004/05/13 15:25:58 christos Exp $ */
 
 /*-
  * Copyright (c) 1980, 1991, 1993
@@ -34,7 +34,7 @@
 #if 0
 static char sccsid[] = "@(#)func.c     8.1 (Berkeley) 5/31/93";
 #else
-__RCSID("$NetBSD: func.c,v 1.28 2004/04/17 15:40:52 christos Exp $");
+__RCSID("$NetBSD: func.c,v 1.29 2004/05/13 15:25:58 christos Exp $");
 #endif
 #endif /* not lint */
 
@@ -593,6 +593,7 @@
     Char wordbuf[BUFSIZE];
     Char *aword, *cp;
     struct whyle *wp;
+    int wlevel = 0;
 
     aword = wordbuf;
     Stype = type;
@@ -630,14 +631,17 @@
            break;
        case T_END:
            if (type == T_BRKSW) {
-               wp = whyles;
-               if (wp) {
+               if (wlevel == 0) {
+                   wp = whyles;
+                   if (wp) {
                        whyles = wp->w_next;
                        wpfree(wp);
+                   }
                }
            }
            if (type == T_BREAK)
                level--;
+           wlevel--;
            break;
        case T_ENDIF:
            if (type == T_IF || type == T_ELSE)
@@ -664,6 +668,7 @@
            break;
        case T_FOREACH: 
        case T_WHILE:
+           wlevel++;
            if (type == T_BREAK)
                level++;
            break;          



Home | Main Index | Thread Index | Old Index