changeset 2952:861a7995b9fe

[xemacs-hg @ 2005-09-26 08:29:27 by ben] fix range table boundaries rangetab.c: Fix bug in handling of range endpoints when not start-closed, end-open.
author ben
date Mon, 26 Sep 2005 08:29:31 +0000
parents b694dfd2f40e
children c7d4a681eb2c
files src/ChangeLog src/rangetab.c
diffstat 2 files changed, 21 insertions(+), 3 deletions(-) [+]
line wrap: on
line diff
--- a/src/ChangeLog	Mon Sep 26 08:13:00 2005 +0000
+++ b/src/ChangeLog	Mon Sep 26 08:29:31 2005 +0000
@@ -1,3 +1,9 @@
+2005-09-26  Ben Wing  <ben@xemacs.org>
+
+	* rangetab.c:
+	* rangetab.c (Fmap_range_table):
+	Fix bug in handling of range endpoints when not start-closed, end-open.
+
 2005-09-17  Olivier Galibert  <galibert@xemacs.org>
 
 	* intl.c (Fset_current_locale): setlocale return string is valid
--- a/src/rangetab.c	Mon Sep 26 08:13:00 2005 +0000
+++ b/src/rangetab.c	Mon Sep 26 08:29:31 2005 +0000
@@ -1,6 +1,6 @@
 /* XEmacs routines to deal with range tables.
    Copyright (C) 1995 Sun Microsystems, Inc.
-   Copyright (C) 1995, 2002, 2004 Ben Wing.
+   Copyright (C) 1995, 2002, 2004, 2005 Ben Wing.
 
 This file is part of XEmacs.
 
@@ -606,8 +606,20 @@
       last = entry->last;
       oldlen = Dynarr_length (rt->entries);
       args[0] = function;
-      args[1] = make_int (first);
-      args[2] = make_int (last);
+      /* Fix up the numbers in accordance with the open/closedness of the
+	 table. */
+      {
+	EMACS_INT premier = first, dernier = last;
+	switch (rt->type)
+	  {
+	  case RANGE_START_CLOSED_END_OPEN: break;
+	  case RANGE_START_CLOSED_END_CLOSED: dernier--; break;
+	  case RANGE_START_OPEN_END_OPEN: premier--; break;
+	  case RANGE_START_OPEN_END_CLOSED: premier--, dernier--; break;
+	  }
+	args[1] = make_int (premier);
+	args[2] = make_int (dernier);
+      }
       args[3] = entry->val;
       Ffuncall (countof (args), args);
       /* Has FUNCTION removed the entry? */