summaryrefslogtreecommitdiff
path: root/src/cmds.c
diff options
context:
space:
mode:
authorJim Blandy <jimb@redhat.com>1993-05-14 14:37:53 +0000
committerJim Blandy <jimb@redhat.com>1993-05-14 14:37:53 +0000
commiteba01c49808bb0e8ee36afb6a802bc3e20635c0b (patch)
treef7a5b7b1bc82f6787f020349ee48bb9f2527c304 /src/cmds.c
parentb88d846dbb0f02f38ca7fc560dd6fa63dffa3c9c (diff)
downloademacs-eba01c49808bb0e8ee36afb6a802bc3e20635c0b.tar.gz
* cmds.c (Fforward_char): Check proposed new position, and then
set point, instead of setting point to a potentially invalid position.
Diffstat (limited to 'src/cmds.c')
-rw-r--r--src/cmds.c33
1 files changed, 22 insertions, 11 deletions
diff --git a/src/cmds.c b/src/cmds.c
index e81d7c61e59..ed150f7d5d3 100644
--- a/src/cmds.c
+++ b/src/cmds.c
@@ -41,17 +41,28 @@ On reaching end of buffer, stop and signal error.")
else
CHECK_NUMBER (n, 0);
- SET_PT (point + XINT (n));
- if (point < BEGV)
- {
- SET_PT (BEGV);
- Fsignal (Qbeginning_of_buffer, Qnil);
- }
- if (point > ZV)
- {
- SET_PT (ZV);
- Fsignal (Qend_of_buffer, Qnil);
- }
+ /* This used to just set point to point + XINT (n), and then check
+ to see if it was within boundaries. But now that SET_PT can
+ potentially do a lot of stuff (calling entering and exiting
+ hooks, etcetera), that's not a good approach. So we validate the
+ proposed position, then set point. */
+ {
+ int new_point = point + XINT (n);
+
+ if (new_point < BEGV)
+ {
+ SET_PT (BEGV);
+ Fsignal (Qbeginning_of_buffer, Qnil);
+ }
+ if (new_point > ZV)
+ {
+ SET_PT (ZV);
+ Fsignal (Qend_of_buffer, Qnil);
+ }
+
+ SET_PT (new_point);
+ }
+
return Qnil;
}