all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* [mange@freemail.hu: next-single-property-change and narrowed buffers]
@ 2006-09-08 20:29 Richard Stallman
  2006-09-08 21:29 ` Fwd: next-single-property-change and narrowed buffers Stefan Monnier
  0 siblings, 1 reply; 3+ messages in thread
From: Richard Stallman @ 2006-09-08 20:29 UTC (permalink / raw)


Would someone please fix this and DTRT?

------- Start of forwarded message -------
From: Magnus Henoch <mange@freemail.hu>
To: emacs-pretest-bug@gnu.org
Jabber-Id: legoscia@jabber.cd.chalmers.se
Date: Fri, 08 Sep 2006 15:04:00 +0200
MIME-Version: 1.0
Content-Type: text/plain; charset=us-ascii
Subject: next-single-property-change and narrowed buffers
X-Spam-Status: No, score=0.1 required=5.0 tests=FORGED_RCVD_HELO 
	autolearn=failed version=3.0.4

Please describe exactly what actions triggered the bug
and the precise symptoms of the bug:

The docsting of next-single-property-change promises that it will
never return a value equal to the position given, but it does if the
buffer is narrowed and the next property change occurs after the
narrowed region.  Test case:

(defun test-nspc ()
  (interactive)
  (with-current-buffer (get-buffer-create "*test-nspc*")
    (fundamental-mode)
    (erase-buffer)
    (insert (make-string 100 ?\ ))
    (add-text-properties 25 50 '(test-nspc t))
    (narrow-to-region 1 49)
    (let ((pos (point-min)))
      (while pos
	(message "pos is %s" pos)
	(let ((old-pos pos))
	  (setq pos (next-single-property-change pos 'test-nspc))
	  (when (and pos (<= pos old-pos))
	    (error "%s is <= %s" pos old-pos)))))))

If emacs crashed, and you have the emacs process in the gdb debugger,
please include the output from the following gdb commands:
    `bt full' and `xbacktrace'.
If you would like to further debug the crash, please read the file
/usr/local/share/emacs/22.0.50/etc/DEBUG for instructions.


In GNU Emacs 22.0.50.4 (powerpc-unknown-netbsd3.99.23, X toolkit, Xaw3d scroll bars)
 of 2006-08-21 on zemdatav
X server distributor `The XFree86 Project, Inc', version 11.0.40500000
Important settings:
  value of $LC_ALL: nil
  value of $LC_COLLATE: nil
  value of $LC_CTYPE: en_US.UTF-8
  value of $LC_MESSAGES: nil
  value of $LC_MONETARY: nil
  value of $LC_NUMERIC: nil
  value of $LC_TIME: nil
  value of $LANG: nil
  locale-coding-system: utf-8
  default-enable-multibyte-characters: t

Major mode: Custom

Minor modes in effect:
  shell-dirtrack-mode: t
  display-time-mode: t
  jabber-activity-mode: t
  jabber-mode-line-mode: t
  iswitchb-mode: t
  icomplete-mode: t
  tooltip-mode: t
  mouse-wheel-mode: t
  file-name-shadow-mode: t
  global-font-lock-mode: t
  font-lock-mode: t
  blink-cursor-mode: t
  unify-8859-on-encoding-mode: t
  utf-translate-cjk-mode: t
  auto-compression-mode: t
  line-number-mode: t
  transient-mark-mode: t

Recent input:
<tab> <return> <down> <down> <down> <down> <down> <down> 
<down> <down> <down> <down> <down> <down> <down> <down> 
<down> <down> <down> <down> <down> <down> <down> <down> 
<down> <down> <down> <down> <down> <down> <down> <down> 
<down> <down> <down> <down> <down> <down> <down> <down> 
<down> <down> <up> <up> <up> <up> <up> <up> <up> <up> 
C-e C-h v <return> <C-s-down> <tab> <tab> <return> 
<down> <down> <down> <down> <down> <down> <down> <down> 
<down> <down> <down> <down> <down> <tab> <tab> <return> 
<tab> <return> 1 C-x b C-s <return> C-x k <return> 
y e s <return> M-x r e p o r t SPC e m SPC <return
>

Recent messages:
mouse-2, RET: customize variable
Creating customization items...
Creating customization items ...done
Resetting customization items...done
Creating customization setup...done
Message from spenatmannen in Iccarus
Hide the value of this option.
To install your edits, invoke [State] and choose the Set operation
Change the state of this item.
Wrote /home/magnus/emacs-custom.el


_______________________________________________
emacs-pretest-bug mailing list
emacs-pretest-bug@gnu.org
http://lists.gnu.org/mailman/listinfo/emacs-pretest-bug
------- End of forwarded message -------

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: Fwd: next-single-property-change and narrowed  buffers
  2006-09-08 20:29 [mange@freemail.hu: next-single-property-change and narrowed buffers] Richard Stallman
@ 2006-09-08 21:29 ` Stefan Monnier
  2006-09-09 16:40   ` Magnus Henoch
  0 siblings, 1 reply; 3+ messages in thread
From: Stefan Monnier @ 2006-09-08 21:29 UTC (permalink / raw)
  Cc: emacs-devel

> Would someone please fix this and DTRT?

> The docsting of next-single-property-change promises that it will
> never return a value equal to the position given, but it does if the
> buffer is narrowed and the next property change occurs after the
> narrowed region.  Test case:

I believe the patch below corrects this problem (for related functions as
well).  Can you confirm?


        Stefan


--- orig/src/textprop.c
+++ mod/src/textprop.c
@@ -1001,17 +1001,16 @@
 	 && (NILP (limit) || next->position < XFASTINT (limit)))
     next = next_interval (next);
 
-  if (NULL_INTERVAL_P (next))
-    return limit;
-  if (NILP (limit))
-    XSETFASTINT (limit, (STRINGP (object)
-			 ? SCHARS (object)
-			 : BUF_ZV (XBUFFER (object))));
-  if (!(next->position < XFASTINT (limit)))
+  if (NULL_INTERVAL_P (next)
+      || (next->position
+	  >= (INTEGERP (limit)
+	      ? XFASTINT (limit)
+	      : (STRINGP (object)
+		 ? SCHARS (object)
+		 : BUF_ZV (XBUFFER (object))))))
     return limit;
-
-  XSETFASTINT (position, next->position);
-  return position;
+  else
+    return make_number (next->position);
 }
 
 /* Return 1 if there's a change in some property between BEG and END.  */
@@ -1083,16 +1082,16 @@
 	 && (NILP (limit) || next->position < XFASTINT (limit)))
     next = next_interval (next);
 
-  if (NULL_INTERVAL_P (next))
-    return limit;
-  if (NILP (limit))
-    XSETFASTINT (limit, (STRINGP (object)
-			 ? SCHARS (object)
-			 : BUF_ZV (XBUFFER (object))));
-  if (!(next->position < XFASTINT (limit)))
+  if (NULL_INTERVAL_P (next)
+      || (next->position
+	  >= (INTEGERP (limit)
+	      ? XFASTINT (limit)
+	      : (STRINGP (object)
+		 ? SCHARS (object)
+		 : BUF_ZV (XBUFFER (object))))))
     return limit;
-
-  return make_number (next->position);
+  else
+    return make_number (next->position);
 }
 
 DEFUN ("previous-property-change", Fprevious_property_change,
@@ -1132,14 +1131,15 @@
 	 && (NILP (limit)
 	     || (previous->position + LENGTH (previous) > XFASTINT (limit))))
     previous = previous_interval (previous);
-  if (NULL_INTERVAL_P (previous))
-    return limit;
-  if (NILP (limit))
-    XSETFASTINT (limit, (STRINGP (object) ? 0 : BUF_BEGV (XBUFFER (object))));
-  if (!(previous->position + LENGTH (previous) > XFASTINT (limit)))
-    return limit;
 
-  return make_number (previous->position + LENGTH (previous));
+  if (NULL_INTERVAL_P (previous)
+      || (previous->position + LENGTH (previous)
+	  <= (INTEGERP (limit)
+	      ? XFASTINT (limit)
+	      : (STRINGP (object) ? 0 : BUF_BEGV (XBUFFER (object))))))
+    return limit;
+  else
+    return make_number (previous->position + LENGTH (previous));
 }
 
 DEFUN ("previous-single-property-change", Fprevious_single_property_change,
@@ -1184,14 +1184,15 @@
 	 && (NILP (limit)
 	     || (previous->position + LENGTH (previous) > XFASTINT (limit))))
     previous = previous_interval (previous);
-  if (NULL_INTERVAL_P (previous))
-    return limit;
-  if (NILP (limit))
-    XSETFASTINT (limit, (STRINGP (object) ? 0 : BUF_BEGV (XBUFFER (object))));
-  if (!(previous->position + LENGTH (previous) > XFASTINT (limit)))
-    return limit;
 
-  return make_number (previous->position + LENGTH (previous));
+  if (NULL_INTERVAL_P (previous)
+      || (previous->position + LENGTH (previous)
+	  <= (INTEGERP (limit)
+	      ? XFASTINT (limit)
+	      : (STRINGP (object) ? 0 : BUF_BEGV (XBUFFER (object))))))
+    return limit;
+  else
+    return make_number (previous->position + LENGTH (previous));
 }
 \f
 /* Callers note, this can GC when OBJECT is a buffer (or nil).  */

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: Fwd: next-single-property-change and narrowed  buffers
  2006-09-08 21:29 ` Fwd: next-single-property-change and narrowed buffers Stefan Monnier
@ 2006-09-09 16:40   ` Magnus Henoch
  0 siblings, 0 replies; 3+ messages in thread
From: Magnus Henoch @ 2006-09-09 16:40 UTC (permalink / raw)


Stefan Monnier <monnier@iro.umontreal.ca> writes:

> I believe the patch below corrects this problem (for related functions as
> well).  Can you confirm?

Yes, this fixes the problem for me.  Thanks!

Magnus

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2006-09-09 16:40 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2006-09-08 20:29 [mange@freemail.hu: next-single-property-change and narrowed buffers] Richard Stallman
2006-09-08 21:29 ` Fwd: next-single-property-change and narrowed buffers Stefan Monnier
2006-09-09 16:40   ` Magnus Henoch

Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.