[1532] in Coldmud discussion meeting

root meeting help first previous next last

patch for annoying behavior

daemon@ATHENA.MIT.EDU (Tue Dec 21 02:05:18 1999 )

From: bruce@puremagic.com
To: coldstuff@cold.org
Date: Mon, 20 Dec 1999 22:43:33 -0800 (PST)
Reply-To: coldstuff@cold.org

This will fix the annoying behavior in listidx(), bufidx() and stridx()
and properly update the credits file.

 - Bruce

diff -r -u Genesis-1.1.8-STABLE/etc/notes Genesis/etc/notes
--- Genesis-1.1.8-STABLE/etc/notes	Sat Nov 20 12:44:28 1999
+++ Genesis/etc/notes	Mon Dec 20 22:34:45 1999
@@ -10,6 +10,9 @@
       http://www.cold.org/info/lists
 
 RELEASE INFORMATION:
+1.1.9  [XX-XXX-XX] Bruce
+      * Fixed inconsistent behavior in stridx(), listidx(), and
+        bufidx() when presented with an empty first argument. (Bruce)
 1.1.8  [20-Nov-99] Brandon, Allen Noe
       * Committed the bufidx() fix to the stable branch.  Due to
         inexperience with CVS the fix did not get moved to the STABLE

diff -r -u Genesis-1.1.8-STABLE/src/ops/buffer.c Genesis/src/ops/buffer.c
--- Genesis-1.1.8-STABLE/src/ops/buffer.c	Tue Jul 13 14:07:48 1999
+++ Genesis/src/ops/buffer.c	Mon Dec 20 22:27:53 1999
@@ -194,6 +194,12 @@
     } else
         THROW((type_id, "Second argument must be a buffer or integer."))
 
+    if (!buffer_len(BUF1)) {
+        pop(argc);
+        push_int(0);
+        return;
+    }
+
     if ((r = buffer_index(BUF1, cp, clen, origin)) == F_FAILURE)
         THROW((range_id, "Origin is beyond the range of the buffer."))
 
diff -r -u Genesis-1.1.8-STABLE/src/ops/list.c Genesis/src/ops/list.c
--- Genesis-1.1.8-STABLE/src/ops/list.c	Tue Jul 13 14:07:48 1999
+++ Genesis/src/ops/list.c	Mon Dec 20 22:24:53 1999
@@ -243,6 +243,12 @@
     else
         origin = 1;
     
+    if (!LIST1->len) {
+        pop(argc);
+        push_int(0);
+        return;
+    }
+
     if ((r = list_index(LIST1, &args[1], origin)) == F_FAILURE)
         THROW((range_id, "Origin is beyond the range of the list."))
     
diff -r -u Genesis-1.1.8-STABLE/src/ops/string.c Genesis/src/ops/string.c
--- Genesis-1.1.8-STABLE/src/ops/string.c	Wed Jul 14 21:33:53 1999
+++ Genesis/src/ops/string.c	Mon Dec 20 22:21:00 1999
@@ -553,6 +553,12 @@
     if (!string_length(STR2))
         THROW((type_id, "No search string.")) 
 
+    if (!string_length(STR1)) {
+        pop(argc);
+        push_int(0);
+	return;
+    }
+
     if ((r = string_index(STR1, STR2, origin)) == F_FAILURE)
         THROW((range_id, "Origin is beyond the range of the string."))