From 589cf7f7ff31c7ca52d035d9587657b8e0b7d2e2 Mon Sep 17 00:00:00 2001
From: "Mirar (Pontus Hagland)" <pike@sort.mirar.org>
Date: Thu, 26 Oct 2000 17:05:30 +0200
Subject: [PATCH] fixed bignum bug and autoconversion in enumerate

Rev: src/builtin_functions.c:1.316
---
 src/builtin_functions.c | 18 ++++++++++++++++--
 1 file changed, 16 insertions(+), 2 deletions(-)

diff --git a/src/builtin_functions.c b/src/builtin_functions.c
index 8c596dde78..4c1daac45f 100644
--- a/src/builtin_functions.c
+++ b/src/builtin_functions.c
@@ -5,7 +5,7 @@
 \*/
 /**/
 #include "global.h"
-RCSID("$Id: builtin_functions.c,v 1.315 2000/10/13 19:39:37 hubbe Exp $");
+RCSID("$Id: builtin_functions.c,v 1.316 2000/10/26 15:05:30 mirar Exp $");
 #include "interpret.h"
 #include "svalue.h"
 #include "pike_macros.h"
@@ -5495,6 +5495,20 @@ void f_enumerate(INT32 args)
 	 d->item[i].u.integer=start;
 	 d->item[i].type=T_INT;
 	 d->item[i].subtype=NUMBER_NUMBER;
+#ifdef AUTO_BIGNUM
+	 if ((step>0 && start+step<start) ||
+	     (step<0 && start+step>start)) /* overflow */
+	 {
+	    pop_stack();
+	    push_int(n);
+	    push_int(step);
+	    convert_stack_top_to_bignum();
+	    push_int(start);
+	    convert_stack_top_to_bignum();
+	    f_enumerate(3);
+	    return;
+	 }
+#endif
 	 start+=step;
       }
    }
@@ -5556,7 +5570,7 @@ void f_enumerate(INT32 args)
 	 }
       }
       pop_stack();
-      stack_pop_n_elems_keep_top(4);
+      stack_pop_n_elems_keep_top(args);
    }
 }
 
-- 
GitLab