unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
* [PATCH] * src/editfns.c (Fchar_after): Small optimization.
@ 2017-09-30 18:41 Philipp Stephani
  2017-09-30 19:05 ` Eli Zaretskii
  0 siblings, 1 reply; 5+ messages in thread
From: Philipp Stephani @ 2017-09-30 18:41 UTC (permalink / raw)
  To: emacs-devel; +Cc: Philipp Stephani

---
 src/editfns.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/src/editfns.c b/src/editfns.c
index b03eb947de..e87c682f97 100644
--- a/src/editfns.c
+++ b/src/editfns.c
@@ -1256,10 +1256,10 @@ If POS is out of range, the value is nil.  */)
   if (NILP (pos))
     {
       pos_byte = PT_BYTE;
-      XSETFASTINT (pos, PT);
+      if (pos_byte == ZV_BYTE)
+        return Qnil;
     }
-
-  if (MARKERP (pos))
+  else if (MARKERP (pos))
     {
       pos_byte = marker_byte_position (pos);
       if (pos_byte < BEGV_BYTE || pos_byte >= ZV_BYTE)
-- 
2.14.1




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

* Re: [PATCH] * src/editfns.c (Fchar_after): Small optimization.
  2017-09-30 18:41 [PATCH] * src/editfns.c (Fchar_after): Small optimization Philipp Stephani
@ 2017-09-30 19:05 ` Eli Zaretskii
  2017-10-01 10:56   ` Philipp Stephani
  0 siblings, 1 reply; 5+ messages in thread
From: Eli Zaretskii @ 2017-09-30 19:05 UTC (permalink / raw)
  To: Philipp Stephani; +Cc: phst, emacs-devel

> From: Philipp Stephani <p.stephani2@gmail.com>
> Date: Sat, 30 Sep 2017 20:41:11 +0200
> Cc: Philipp Stephani <phst@google.com>
> 
> ---
>  src/editfns.c | 6 +++---
>  1 file changed, 3 insertions(+), 3 deletions(-)
> 
> diff --git a/src/editfns.c b/src/editfns.c
> index b03eb947de..e87c682f97 100644
> --- a/src/editfns.c
> +++ b/src/editfns.c
> @@ -1256,10 +1256,10 @@ If POS is out of range, the value is nil.  */)
>    if (NILP (pos))
>      {
>        pos_byte = PT_BYTE;
> -      XSETFASTINT (pos, PT);
> +      if (pos_byte == ZV_BYTE)  <<<<<<<<<<<<<<<<<<<<<<
> +        return Qnil;

The comparison should use >=, not just ==, because PT could be
temporarily out of bounds.  I've seen Lisp hooks which cause such
calamities.  For the same reason, we should also check that PT_BYTE is
not smaller than BEGV_BYTE.

Thanks.



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

* [PATCH] * src/editfns.c (Fchar_after): Small optimization.
  2017-09-30 19:05 ` Eli Zaretskii
@ 2017-10-01 10:56   ` Philipp Stephani
  2017-10-01 15:04     ` Eli Zaretskii
  0 siblings, 1 reply; 5+ messages in thread
From: Philipp Stephani @ 2017-10-01 10:56 UTC (permalink / raw)
  To: emacs-devel; +Cc: Philipp Stephani

---
 src/editfns.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/src/editfns.c b/src/editfns.c
index e326604467..4dcf7cbe6e 100644
--- a/src/editfns.c
+++ b/src/editfns.c
@@ -1256,10 +1256,10 @@ If POS is out of range, the value is nil.  */)
   if (NILP (pos))
     {
       pos_byte = PT_BYTE;
-      XSETFASTINT (pos, PT);
+      if (pos_byte < BEGV_BYTE || pos_byte >= ZV_BYTE)
+        return Qnil;
     }
-
-  if (MARKERP (pos))
+  else if (MARKERP (pos))
     {
       pos_byte = marker_byte_position (pos);
       if (pos_byte < BEGV_BYTE || pos_byte >= ZV_BYTE)
-- 
2.14.2




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

* Re: [PATCH] * src/editfns.c (Fchar_after): Small optimization.
  2017-10-01 10:56   ` Philipp Stephani
@ 2017-10-01 15:04     ` Eli Zaretskii
  2017-10-01 16:30       ` Philipp Stephani
  0 siblings, 1 reply; 5+ messages in thread
From: Eli Zaretskii @ 2017-10-01 15:04 UTC (permalink / raw)
  To: Philipp Stephani; +Cc: phst, emacs-devel

> From: Philipp Stephani <p.stephani2@gmail.com>
> Date: Sun,  1 Oct 2017 12:56:47 +0200
> Cc: Philipp Stephani <phst@google.com>
> 
> diff --git a/src/editfns.c b/src/editfns.c
> index e326604467..4dcf7cbe6e 100644
> --- a/src/editfns.c
> +++ b/src/editfns.c
> @@ -1256,10 +1256,10 @@ If POS is out of range, the value is nil.  */)
>    if (NILP (pos))
>      {
>        pos_byte = PT_BYTE;
> -      XSETFASTINT (pos, PT);
> +      if (pos_byte < BEGV_BYTE || pos_byte >= ZV_BYTE)
> +        return Qnil;
>      }
> -
> -  if (MARKERP (pos))
> +  else if (MARKERP (pos))
>      {
>        pos_byte = marker_byte_position (pos);
>        if (pos_byte < BEGV_BYTE || pos_byte >= ZV_BYTE)

LGTM, thanks.



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

* Re: [PATCH] * src/editfns.c (Fchar_after): Small optimization.
  2017-10-01 15:04     ` Eli Zaretskii
@ 2017-10-01 16:30       ` Philipp Stephani
  0 siblings, 0 replies; 5+ messages in thread
From: Philipp Stephani @ 2017-10-01 16:30 UTC (permalink / raw)
  To: Eli Zaretskii; +Cc: phst, emacs-devel

[-- Attachment #1: Type: text/plain, Size: 856 bytes --]

Eli Zaretskii <eliz@gnu.org> schrieb am So., 1. Okt. 2017 um 17:04 Uhr:

> > From: Philipp Stephani <p.stephani2@gmail.com>
> > Date: Sun,  1 Oct 2017 12:56:47 +0200
> > Cc: Philipp Stephani <phst@google.com>
> >
> > diff --git a/src/editfns.c b/src/editfns.c
> > index e326604467..4dcf7cbe6e 100644
> > --- a/src/editfns.c
> > +++ b/src/editfns.c
> > @@ -1256,10 +1256,10 @@ If POS is out of range, the value is nil.  */)
> >    if (NILP (pos))
> >      {
> >        pos_byte = PT_BYTE;
> > -      XSETFASTINT (pos, PT);
> > +      if (pos_byte < BEGV_BYTE || pos_byte >= ZV_BYTE)
> > +        return Qnil;
> >      }
> > -
> > -  if (MARKERP (pos))
> > +  else if (MARKERP (pos))
> >      {
> >        pos_byte = marker_byte_position (pos);
> >        if (pos_byte < BEGV_BYTE || pos_byte >= ZV_BYTE)
>
> LGTM, thanks.
>

Pushed as 66d37175ec to master.

[-- Attachment #2: Type: text/html, Size: 1443 bytes --]

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

end of thread, other threads:[~2017-10-01 16:30 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2017-09-30 18:41 [PATCH] * src/editfns.c (Fchar_after): Small optimization Philipp Stephani
2017-09-30 19:05 ` Eli Zaretskii
2017-10-01 10:56   ` Philipp Stephani
2017-10-01 15:04     ` Eli Zaretskii
2017-10-01 16:30       ` Philipp Stephani

Code repositories for project(s) associated with this public inbox

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

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).