[project @ 2000-03-14 09:55:05 by simonmar]
[ghc-hetmet.git] / ghc / interpreter / scc.c
index 809d54a..837fd17 100644 (file)
@@ -2,14 +2,15 @@
 /* --------------------------------------------------------------------------
  * Strongly connected components algorithm for static.c.
  *
- * Hugs 98 is Copyright (c) Mark P Jones, Alastair Reid and the Yale
- * Haskell Group 1994-99, and is distributed as Open Source software
- * under the Artistic License; see the file "Artistic" that is included
- * in the distribution for details.
+ * The Hugs 98 system is Copyright (c) Mark P Jones, Alastair Reid, the
+ * Yale Haskell Group, and the Oregon Graduate Institute of Science and
+ * Technology, 1994-1999, All rights reserved.  It is distributed as
+ * free software under the license in the file "License", which is
+ * included in the distribution.
  *
  * $RCSfile: scc.c,v $
- * $Revision: 1.3 $
- * $Date: 1999/02/03 17:08:36 $
+ * $Revision: 1.6 $
+ * $Date: 2000/03/13 11:37:16 $
  * ------------------------------------------------------------------------*/
 
 #ifndef SCC_C
 static Cell daSccs = NIL;
 static Int  daCount;
 
-static Int local sccMin Args((Int,Int));
-
-static Int local sccMin(x,y)            /* calculate minimum of x,y        */
-Int x, y; {                             /* (unless y is zero)              */
+static Int local sccMin ( Int x, Int y) /* calculate minimum of x,y        */
+{                                       /* (unless y is zero)              */
     return (x<=y || y==0) ? x : y;
 }
 #endif
@@ -43,9 +42,8 @@ Int x, y; {                             /* (unless y is zero)              */
  * This would probably have been a good application for C++ templates ...
  * ------------------------------------------------------------------------*/
 
-static Int local LOWLINK Args((Cell));  /* local function                  */
-static Int local LOWLINK(v)             /* calculate `lowlink' of v        */
-Cell v; {
+static Int local LOWLINK( Cell v )      /* calculate `lowlink' of v        */
+{
     Int  low = daCount;
     Int  dfn = daCount;                 /* depth first search no. of v     */
     List ws  = DEPENDS(v);              /* adjacency list for v            */
@@ -74,20 +72,23 @@ Cell v; {
 #ifdef SCC
 static List local SCC(bs)               /* sort list with added dependency */
 List bs; {                              /* info into SCCs                  */
+    List tmp = NIL;
     clearStack();
     daSccs = NIL;                       /* clear current list of SCCs      */
 
     for (daCount=1; nonNull(bs); bs=tl(bs))      /* visit each binding     */
         if (!visited(hd(bs)))
             LOWLINK(hd(bs));
-
-    return rev(daSccs);                 /* reverse to obtain correct order */
+    tmp = rev(daSccs);
+    daSccs = NIL;
+    return tmp;                         /* reverse to obtain correct order */
 }
 #endif
 
 #ifdef SCC2                             /* Two argument version            */
 static List local SCC2(bs,cs)           /* sort lists with added dependency*/
 List bs, cs; {                          /* info into SCCs                  */
+    List tmp = NIL;
     clearStack();
     daSccs = NIL;                       /* clear current list of SCCs      */
 
@@ -97,8 +98,9 @@ List bs, cs; {                          /* info into SCCs                  */
     for (; nonNull(cs); cs=tl(cs))
         if (!visited(hd(cs)))
             LOWLINK(hd(cs));
-
-    return rev(daSccs);                 /* reverse to obtain correct order */
+    tmp = rev(daSccs);
+    daSccs = NIL;
+    return tmp;                         /* reverse to obtain correct order */
 }
 #endif