cvs-cvs
[Top][All Lists]
Advanced

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

[Cvs-cvs] Changes to ccvs/src/rcs.c


From: Mark D . Baushke
Subject: [Cvs-cvs] Changes to ccvs/src/rcs.c
Date: Tue, 06 Sep 2005 14:07:54 -0400

Index: ccvs/src/rcs.c
diff -u ccvs/src/rcs.c:1.349 ccvs/src/rcs.c:1.350
--- ccvs/src/rcs.c:1.349        Fri Sep  2 21:51:09 2005
+++ ccvs/src/rcs.c      Tue Sep  6 18:07:54 2005
@@ -8074,31 +8074,65 @@
     RCSVers *versp;
     Node *p, *branch;
 
+    /* Previously, this function used a recursive implementation, but
+       if the trunk has a huge number of revisions and the program
+       stack is not big, a stack overflow could occur, so this
+       nonrecursive version was developed to be more safe. */
+    Node *k, *branchlist, *onebranch;
+    List *branches;
+    List *onebranchlist;
+
     if (rev == NULL)
        return;
 
-    /* Find the delta node for this revision. */
-    p = findnode (rcs->versions, rev);
-    if (p == NULL)
+    branches = getlist();
+
+    for (; rev != NULL;)
     {
-        error (1, 0,
-               "error parsing repository file %s, file may be corrupt.", 
-               rcs->print_path);
-    }
+       /* Find the delta node for this revision. */
+       p = findnode (rcs->versions, rev);
+       if (p == NULL)
+       {
+           error (1, 0,
+                  "error parsing repository file %s, file may be corrupt.", 
+                  rcs->path);
+       }
  
-    versp = p->data;
+       versp = p->data;
+
+       /* Print the delta node and go for its `next' node.  This
+          prints the trunk. If there are any branches printed on this
+          revision, mark we have some. */
+       putdelta (versp, fp);
+       /* Store branch information into branch list so to write its
+          trunk afterwards */
+       if (versp->branches != NULL)
+       {
+           branch = getnode();
+           branch->data = versp->branches;
+
+           addnode(branches, branch);
+       }
 
-    /* Print the delta node and recurse on its `next' node.  This prints
-       the trunk.  If there are any branches printed on this revision,
+       rev = versp->next;
+    }
+
+    /* If there are any branches printed on this revision,
        print those trunks as well. */
-    putdelta (versp, fp);
-    RCS_putdtree (rcs, versp->next, fp);
-    if (versp->branches != NULL)
+    branchlist = branches->list;
+    for (branch = branchlist->next;
+        branch != branchlist;
+        branch = branch->next)
     {
-       branch = versp->branches->list;
-       for (p = branch->next; p != branch; p = p->next)
+       onebranchlist = (List *)(branch->data);
+       onebranch = onebranchlist->list;
+       for (p = onebranch->next; p != onebranch; p = p->next)
            RCS_putdtree (rcs, p->key, fp);
+
+       branch->data = NULL; /* so to prevent its freeing on dellist */
     }
+
+    dellist(&branches);
 }
 
 




reply via email to

[Prev in Thread] Current Thread [Next in Thread]