From 978c1ccb7e4ca347e8097fc8c0d035dd2775a7d5 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Henrik=20Grubbstr=C3=B6m=20=28Grubba=29?=
 <grubba@grubba.org>
Date: Wed, 18 Mar 1998 00:03:34 +0100
Subject: [PATCH] Added some DEBUG code for diff_longest_sequence.

Rev: src/builtin_functions.c:1.83
---
 src/builtin_functions.c | 16 +++++++++++++++-
 1 file changed, 15 insertions(+), 1 deletion(-)

diff --git a/src/builtin_functions.c b/src/builtin_functions.c
index 168aeafbab..ef04b6fc3d 100644
--- a/src/builtin_functions.c
+++ b/src/builtin_functions.c
@@ -4,7 +4,7 @@
 ||| See the files COPYING and DISCLAIMER for more information.
 \*/
 #include "global.h"
-RCSID("$Id: builtin_functions.c,v 1.82 1998/03/16 22:11:48 grubba Exp $");
+RCSID("$Id: builtin_functions.c,v 1.83 1998/03/17 23:03:34 grubba Exp $");
 #include "interpret.h"
 #include "svalue.h"
 #include "pike_macros.h"
@@ -1919,6 +1919,13 @@ static struct array* diff_longest_sequence(struct array *cmptbl, int blen)
 #ifdef DIFF_DEBUG
 	 fprintf(stderr, "DIFF:  j=%d, x=%d\n", j, x);
 #endif /* DIFF_DEBUG */
+#ifdef DEBUG
+	 if (x >= blen) {
+	   fatal("diff_longest_sequence(): x:%d >= blen:%d\n", x, blen);
+	 } else if (x < 0) {
+	   fatal("diff_longest_sequence(): x:%d < 0\n", x);
+	 }
+#endif /* DEBUG */
 	 if (!marks[x]) {
 	   int pos;
 
@@ -1955,6 +1962,13 @@ static struct array* diff_longest_sequence(struct array *cmptbl, int blen)
 #ifdef DIFF_DEBUG
 	   fprintf(stderr, "DIFF: New j=%d, x=%d\n", j, x);
 #endif /* DIFF_DEBUG */
+#ifdef DEBUG
+	   if (x >= blen) {
+	     fatal("diff_longest_sequence(): x:%d >= blen:%d\n", x, blen);
+	   } else if (x < 0) {
+	     fatal("diff_longest_sequence(): x:%d < 0\n", x);
+	   }
+#endif /* DEBUG */
 
 	   /* Put x on the stack. */
 	   marks[x] = 1;
-- 
GitLab