all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* RE_TRANSLATE_P
@ 2004-11-26 11:30 Eli Zaretskii
  2004-11-29  6:12 ` RE_TRANSLATE_P Richard Stallman
  0 siblings, 1 reply; 4+ messages in thread
From: Eli Zaretskii @ 2004-11-26 11:30 UTC (permalink / raw)


A recent change to src/config.in changed the definition of
RE_TRANSLATE_P to this:

    #define RE_TRANSLATE_P(TBL) (!EQ (TBL, make_number (0)))

whereas before the change it simply called XFASTINT.

This causes RE_TRANSLATE_P to invoke a function, at least if compilers
other than GCC are used.  I wonder why replacing XFASTINT with XINT
was not enough to fix the original problem?

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

* Re: RE_TRANSLATE_P
  2004-11-26 11:30 RE_TRANSLATE_P Eli Zaretskii
@ 2004-11-29  6:12 ` Richard Stallman
  2004-11-29  9:12   ` RE_TRANSLATE_P Kim F. Storm
  0 siblings, 1 reply; 4+ messages in thread
From: Richard Stallman @ 2004-11-29  6:12 UTC (permalink / raw)
  Cc: emacs-devel

    This causes RE_TRANSLATE_P to invoke a function, at least if compilers
    other than GCC are used.  I wonder why replacing XFASTINT with XINT
    was not enough to fix the original problem?

Would this make it right?

*** config.in	23 Nov 2004 11:44:45 -0500	1.203
--- config.in	29 Nov 2004 00:30:17 -0500	
***************
*** 969,975 ****
--- 969,979 ----
  /* Tell regex.c to use a type compatible with Emacs.  */
  #define RE_TRANSLATE_TYPE Lisp_Object
  #define RE_TRANSLATE(TBL, C) CHAR_TABLE_TRANSLATE (TBL, C)
+ #ifdef __GCC__
  #define RE_TRANSLATE_P(TBL) (!EQ (TBL, make_number (0)))
+ #else
+ #define RE_TRANSLATE_P(TBL) (!(INTEGERP (TBL) && XINT (TBL) == 0))
+ #endif
  #endif
  
  /* Avoid link-time collision with system mktime if we will use our own.  */

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

* Re: RE_TRANSLATE_P
  2004-11-29  6:12 ` RE_TRANSLATE_P Richard Stallman
@ 2004-11-29  9:12   ` Kim F. Storm
  2004-11-30  7:02     ` RE_TRANSLATE_P Richard Stallman
  0 siblings, 1 reply; 4+ messages in thread
From: Kim F. Storm @ 2004-11-29  9:12 UTC (permalink / raw)
  Cc: Eli Zaretskii, emacs-devel

Richard Stallman <rms@gnu.org> writes:

>     This causes RE_TRANSLATE_P to invoke a function, at least if compilers
>     other than GCC are used.  I wonder why replacing XFASTINT with XINT
>     was not enough to fix the original problem?
>
> Would this make it right?

It seems like that change was made in several places, so perhaps
we should have a ZEROP macro to test such cases in a portable
manner.  

It would also make the code cleaner:

ZEROP (obj)

is much easier to understand at a glance than

EQ (obj, make_number (0))


A possible definition would be:

#ifdef __GCC__
#define ZEROP(obj) (!EQ ((obj), make_number (0)))
#else
#define ZEROP(obj) (!(INTEGERP ((obj)) && XINT ((obj)) == 0))
#endif

But the second form evals 'obj' twice, so we need a BIG FAT WARNING
when using ZEROP, or find some other portable way to implement it.


I could make that change.

>
> *** config.in	23 Nov 2004 11:44:45 -0500	1.203
> --- config.in	29 Nov 2004 00:30:17 -0500	
> ***************
> *** 969,975 ****
> --- 969,979 ----
>   /* Tell regex.c to use a type compatible with Emacs.  */
>   #define RE_TRANSLATE_TYPE Lisp_Object
>   #define RE_TRANSLATE(TBL, C) CHAR_TABLE_TRANSLATE (TBL, C)
> + #ifdef __GCC__
>   #define RE_TRANSLATE_P(TBL) (!EQ (TBL, make_number (0)))
> + #else
> + #define RE_TRANSLATE_P(TBL) (!(INTEGERP (TBL) && XINT (TBL) == 0))
> + #endif
>   #endif
>   
>   /* Avoid link-time collision with system mktime if we will use our own.  */
>
>
> _______________________________________________
> Emacs-devel mailing list
> Emacs-devel@gnu.org
> http://lists.gnu.org/mailman/listinfo/emacs-devel
>
>

-- 
Kim F. Storm <storm@cua.dk> http://www.cua.dk

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

* Re: RE_TRANSLATE_P
  2004-11-29  9:12   ` RE_TRANSLATE_P Kim F. Storm
@ 2004-11-30  7:02     ` Richard Stallman
  0 siblings, 0 replies; 4+ messages in thread
From: Richard Stallman @ 2004-11-30  7:02 UTC (permalink / raw)
  Cc: eliz, emacs-devel

    It seems like that change was made in several places, so perhaps
    we should have a ZEROP macro to test such cases in a portable
    manner.  

That would be a natural extension if it had no problems.
But as you pointed out, it has a problem:

    But the second form evals 'obj' twice, so we need a BIG FAT WARNING
    when using ZEROP, or find some other portable way to implement it.

So let's not replace an easy change with a hard one.  The specific
change I suggested has no problem, because RE_TRANSLATE_P is used only
with variables as arguments.

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

end of thread, other threads:[~2004-11-30  7:02 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2004-11-26 11:30 RE_TRANSLATE_P Eli Zaretskii
2004-11-29  6:12 ` RE_TRANSLATE_P Richard Stallman
2004-11-29  9:12   ` RE_TRANSLATE_P Kim F. Storm
2004-11-30  7:02     ` RE_TRANSLATE_P Richard Stallman

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.