unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
* safe_call1 considered harmful
@ 2006-07-21  9:36 Eli Zaretskii
  2006-07-21 11:34 ` Kenichi Handa
  0 siblings, 1 reply; 14+ messages in thread
From: Eli Zaretskii @ 2006-07-21  9:36 UTC (permalink / raw)
  Cc: handa

The change below was presumably made to avoid errors in functions that
are put on the various *-coding-system-alist variables.  Those errors
might have been caused by the recent changes in several modes that now
use a cons cell `(FILENAME . BUFFER)' instead of just the file name as
the argument to find-operation-coding-system (when the operation is
insert-file-contents), because some packages put functions on the
file-coding-system-alist that are not ready for the cons cell.

I think the change in coding.c is for the worse: it masks such
problems from us, so instead of seeing bug reports, we sweep the
problems under the carpet, where they run risk to be left undetected
until after the release.

A case in point is the function find-buffer-file-type-coding-system
that dos-w32.el adds to file-coding-system-alist: it was not modified
to support the change in the find-operation-coding-system's interface,
and caused files with DOS EOLs uncompressed from archives to be shown
with the ^M characters.  This happened because
find-buffer-file-type-coding-system throws an error, but safe_call1
silently ignores it.

So how about if we undo the change below?


2006-05-29  Kenichi Handa  <handa@m17n.org>

	* coding.c (Ffind_operation_coding_system): Call a function by
	safe_call1 instead of call1.

Index: src/coding.c
===================================================================
RCS file: /cvsroot/emacs/emacs/src/coding.c,v
retrieving revision 1.338
retrieving revision 1.339
diff -u -r1.338 -r1.339
--- src/coding.c	26 May 2006 04:48:21 -0000	1.338
+++ src/coding.c	29 May 2006 00:54:27 -0000	1.339
@@ -7539,7 +7539,7 @@
 	    return Fcons (val, val);
 	  if (! NILP (Ffboundp (val)))
 	    {
-	      val = call1 (val, Flist (nargs, args));
+	      val = safe_call1 (val, Flist (nargs, args));
 	      if (CONSP (val))
 		return val;
 	      if (SYMBOLP (val) && ! NILP (Fcoding_system_p (val)))

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

* Re: safe_call1 considered harmful
  2006-07-21  9:36 safe_call1 considered harmful Eli Zaretskii
@ 2006-07-21 11:34 ` Kenichi Handa
  2006-07-21 15:49   ` Eli Zaretskii
  2006-07-21 19:37   ` Richard Stallman
  0 siblings, 2 replies; 14+ messages in thread
From: Kenichi Handa @ 2006-07-21 11:34 UTC (permalink / raw)
  Cc: emacs-devel

In article <uirlrguz3.fsf@gnu.org>, Eli Zaretskii <eliz@gnu.org> writes:

> The change below was presumably made to avoid errors in functions that
> are put on the various *-coding-system-alist variables.  Those errors
> might have been caused by the recent changes in several modes that now
> use a cons cell `(FILENAME . BUFFER)' instead of just the file name as
> the argument to find-operation-coding-system (when the operation is
> insert-file-contents), because some packages put functions on the
> file-coding-system-alist that are not ready for the cons cell.

> I think the change in coding.c is for the worse: it masks such
> problems from us, so instead of seeing bug reports, we sweep the
> problems under the carpet, where they run risk to be left undetected
> until after the release.

> A case in point is the function find-buffer-file-type-coding-system
> that dos-w32.el adds to file-coding-system-alist: it was not modified
> to support the change in the find-operation-coding-system's interface,
> and caused files with DOS EOLs uncompressed from archives to be shown
> with the ^M characters.  This happened because
> find-buffer-file-type-coding-system throws an error, but safe_call1
> silently ignores it.

> So how about if we undo the change below?

Ah, hmmm, I didn't think about such a situation.  The change
was to avoid the backward incompatiblity reported by the
attached mail.

But, by considering this problem again, I found another
solution than calling find-operation-coding-system with
(FILENAME . BUFFER).  That is to provide an extra argument
BUFFER.  Then, we can keep backward compatibility and
find-buffer-file-type-coding-system works as before, and, by
modifying po-find-file-coding-system to check that extra
argument instead of checking if FILENAME is cons or not, we
can make it work well too.

Do I still miss something?  If not, I'll try to change the
current code along that line.

---
Kenichi Handa
handa@m17n.org

Date: Sun, 28 May 2006 10:23:16 +0200
From: Sven Joachim <svenjoac@gmx.de>
MIME-Version: 1.0
To: Kenichi Handa <handa@m17n.org>
In-Reply-To: <E1FkDtH-0002qI-00@etlken>
Content-Type: text/plain; charset=ISO-8859-1; format=flowed
Cc: emacs-pretest-bug@gnu.org
Subject: Re: Coding system of compressed PO files is not recognized
X-Spam-Status: No, score=-2.5 required=5.0 tests=AWL,BAYES_00 autolearn=ham 	version=3.0.3

Kenichi Handa wrote:
> Do you mean that, po-compat.el was able to detect a coding
> system of compressed PO file correctly before my change?

No, it wasn't.  But at least it was able to visit the file
without getting an error. ;-)



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

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

* Re: safe_call1 considered harmful
  2006-07-21 11:34 ` Kenichi Handa
@ 2006-07-21 15:49   ` Eli Zaretskii
  2006-07-24  1:36     ` Kenichi Handa
  2006-07-21 19:37   ` Richard Stallman
  1 sibling, 1 reply; 14+ messages in thread
From: Eli Zaretskii @ 2006-07-21 15:49 UTC (permalink / raw)
  Cc: emacs-devel

> From: Kenichi Handa <handa@m17n.org>
> CC: emacs-devel@gnu.org
> Date: Fri, 21 Jul 2006 20:34:16 +0900
> 
> But, by considering this problem again, I found another
> solution than calling find-operation-coding-system with
> (FILENAME . BUFFER).  That is to provide an extra argument
> BUFFER.  Then, we can keep backward compatibility and
> find-buffer-file-type-coding-system works as before, and, by
> modifying po-find-file-coding-system to check that extra
> argument instead of checking if FILENAME is cons or not, we
> can make it work well too.

This will work if no function on file-coding-system-alist currently
looks at arguments beyond the 1st one, the file name.  If there are
functions which look beyond that, such a change will break them.
While the chance of having such functions is very small, I don't see
how any significant change in the API could avoid breaking some
function that wasn't written to support the new API.

In any case, I think we should revert the change you made to use
safe_call1.  Then we will quickly find any remaining functions that
need to be modified.

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

* Re: safe_call1 considered harmful
  2006-07-21 11:34 ` Kenichi Handa
  2006-07-21 15:49   ` Eli Zaretskii
@ 2006-07-21 19:37   ` Richard Stallman
  2006-07-24  1:44     ` Kenichi Handa
  1 sibling, 1 reply; 14+ messages in thread
From: Richard Stallman @ 2006-07-21 19:37 UTC (permalink / raw)
  Cc: eliz, emacs-devel

    But, by considering this problem again, I found another
    solution than calling find-operation-coding-system with
    (FILENAME . BUFFER).  That is to provide an extra argument
    BUFFER.

Would you please be more concrete?  Passing an extra argument to a set
of functions is very incompatible.

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

* Re: safe_call1 considered harmful
  2006-07-21 15:49   ` Eli Zaretskii
@ 2006-07-24  1:36     ` Kenichi Handa
  2006-07-29 11:00       ` Eli Zaretskii
  0 siblings, 1 reply; 14+ messages in thread
From: Kenichi Handa @ 2006-07-24  1:36 UTC (permalink / raw)
  Cc: emacs-devel

In article <uac73gdpy.fsf@gnu.org>, Eli Zaretskii <eliz@gnu.org> writes:

>> But, by considering this problem again, I found another
>> solution than calling find-operation-coding-system with
>> (FILENAME . BUFFER).  That is to provide an extra argument
>> BUFFER.  Then, we can keep backward compatibility and
>> find-buffer-file-type-coding-system works as before, and, by
>> modifying po-find-file-coding-system to check that extra
>> argument instead of checking if FILENAME is cons or not, we
>> can make it work well too.

> This will work if no function on file-coding-system-alist currently
> looks at arguments beyond the 1st one, the file name.  If there are
> functions which look beyond that, such a change will break them.

No, what I meant is to give the extra argument BUFFER at the
END of the normal arguments to insert-file-contents.  So,
for instance, tar-extract will call
find-operation-coding-system as this:

			     (car (find-operation-coding-system
				   'insert-file-contents
				   name t nil nil nil (current-buffer)))

The new docstring (only the last paragraph) for
find-operation-coding-system will be:

----------------------------------------------------------------------
[...]
If OPERATION is `insert-file-contents', there may be an extra argument
BUFFER at the end.  In that case, FILENAME is a file name to look up,
and BUFFER is a buffer that contains the file's contents (not yet
decoded).  If `file-coding-system-alist' specifies a function to call
for FILENAME, that function should examine the contents of BUFFER
instead of reading the file.
----------------------------------------------------------------------

This change breaks only such a function that checks that the
number of given arguments is not greater than 5 (the maximum
arguments to insert-file-contents).  I believe such a
function is very very rare.

> In any case, I think we should revert the change you made to use
> safe_call1.

Yes.

---
Kenichi Handa
handa@m17n.org

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

* Re: safe_call1 considered harmful
  2006-07-21 19:37   ` Richard Stallman
@ 2006-07-24  1:44     ` Kenichi Handa
  2006-07-24 18:22       ` Richard Stallman
  0 siblings, 1 reply; 14+ messages in thread
From: Kenichi Handa @ 2006-07-24  1:44 UTC (permalink / raw)
  Cc: eliz, emacs-devel

In article <E1G40o4-0007uN-FH@fencepost.gnu.org>, Richard Stallman <rms@gnu.org> writes:

>     But, by considering this problem again, I found another
>     solution than calling find-operation-coding-system with
>     (FILENAME . BUFFER).  That is to provide an extra argument
>     BUFFER.

> Would you please be more concrete?  Passing an extra argument to a set
> of functions is very incompatible.

find-operation-coding-system calls a registered function
with a single argument; a list of arguments given to
find-operation-coding-system.  So, appending an extra
argument at the tail of the list is fairly safe.

---
Kenichi Handa
handa@m17n.org

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

* Re: safe_call1 considered harmful
  2006-07-24  1:44     ` Kenichi Handa
@ 2006-07-24 18:22       ` Richard Stallman
  2006-07-30  9:18         ` Kenichi Handa
  0 siblings, 1 reply; 14+ messages in thread
From: Richard Stallman @ 2006-07-24 18:22 UTC (permalink / raw)
  Cc: eliz, emacs-devel

    find-operation-coding-system calls a registered function
    with a single argument; a list of arguments given to
    find-operation-coding-system.  So, appending an extra
    argument at the tail of the list is fairly safe.

It might seem that way; but what happens if we change the calling
convention of one of the operations, giving it an additional argument?
That may be necessary some day.  I prefer the current convention.

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

* Re: safe_call1 considered harmful
  2006-07-24  1:36     ` Kenichi Handa
@ 2006-07-29 11:00       ` Eli Zaretskii
  2006-07-31  3:04         ` Kenichi Handa
  0 siblings, 1 reply; 14+ messages in thread
From: Eli Zaretskii @ 2006-07-29 11:00 UTC (permalink / raw)
  Cc: emacs-devel

> From: Kenichi Handa <handa@m17n.org>
> CC: emacs-devel@gnu.org
> Date: Mon, 24 Jul 2006 10:36:12 +0900
> 
> > In any case, I think we should revert the change you made to use
> > safe_call1.
> 
> Yes.

Done.

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

* Re: safe_call1 considered harmful
  2006-07-24 18:22       ` Richard Stallman
@ 2006-07-30  9:18         ` Kenichi Handa
  2006-07-31  4:38           ` Richard Stallman
  0 siblings, 1 reply; 14+ messages in thread
From: Kenichi Handa @ 2006-07-30  9:18 UTC (permalink / raw)
  Cc: eliz, emacs-devel

In article <E1G5548-0002HD-8x@fencepost.gnu.org>, Richard Stallman <rms@gnu.org> writes:

>     find-operation-coding-system calls a registered function
>     with a single argument; a list of arguments given to
>     find-operation-coding-system.  So, appending an extra
>     argument at the tail of the list is fairly safe.

> It might seem that way; but what happens if we change the calling
> convention of one of the operations, giving it an additional argument?
> That may be necessary some day.  I prefer the current convention.

We can change tar-mode/arc-mode/jka-compr to call
find-operation-coding-system with full number of arguments
plus the extra argument BUFFER.  Then, a function called
from find-operation-coding-system can check if the number of
arguments is greater than the normal number (which can be
checked by subr-arity).  If it is greater, the function can
know that the last argument is BUFFER.  By that way, the
function doesn't break even if we add a new argument to
find-operation-coding-system.

---
Kenichi Handa
handa@m17n.org

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

* Re: safe_call1 considered harmful
  2006-07-29 11:00       ` Eli Zaretskii
@ 2006-07-31  3:04         ` Kenichi Handa
  0 siblings, 0 replies; 14+ messages in thread
From: Kenichi Handa @ 2006-07-31  3:04 UTC (permalink / raw)
  Cc: emacs-devel

In article <u1ws4d6b1.fsf@gnu.org>, Eli Zaretskii <eliz@gnu.org> writes:

>> > In any case, I think we should revert the change you made to use
>> > safe_call1.
>> 
>> Yes.

> Done.

Thank you.

---
Kenichi Handa
handa@m17n.org

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

* Re: safe_call1 considered harmful
  2006-07-30  9:18         ` Kenichi Handa
@ 2006-07-31  4:38           ` Richard Stallman
  2006-07-31  5:14             ` Kenichi Handa
  0 siblings, 1 reply; 14+ messages in thread
From: Richard Stallman @ 2006-07-31  4:38 UTC (permalink / raw)
  Cc: eliz, emacs-devel

    We can change tar-mode/arc-mode/jka-compr to call
    find-operation-coding-system with full number of arguments
    plus the extra argument BUFFER.

I'd rather leave it alone.

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

* Re: safe_call1 considered harmful
  2006-07-31  4:38           ` Richard Stallman
@ 2006-07-31  5:14             ` Kenichi Handa
  2006-07-31 22:16               ` Richard Stallman
  0 siblings, 1 reply; 14+ messages in thread
From: Kenichi Handa @ 2006-07-31  5:14 UTC (permalink / raw)
  Cc: eliz, emacs-devel

In article <E1G7PXw-0000FA-Js@fencepost.gnu.org>, Richard Stallman <rms@gnu.org> writes:

>     We can change tar-mode/arc-mode/jka-compr to call
>     find-operation-coding-system with full number of arguments
>     plus the extra argument BUFFER.

> I'd rather leave it alone.

If you think the backward incompatible problem raised by the
current code is not that a big problem, I don't argue
anymore.  Shall I install this change in etc/NEWS?

*** NEWS	31 Jul 2006 09:41:07 +0900	1.1382
--- NEWS	31 Jul 2006 14:08:58 +0900	
***************
*** 3661,3668 ****
  \f
  * Incompatible Lisp Changes in Emacs 22.1
  
! ** The function find-operation-coding-system accepts a cons (FILENAME
! . BUFFER) in an argument correponding to the target.
  
  ---
  ** The variables post-command-idle-hook and post-command-idle-delay have
--- 3661,3670 ----
  \f
  * Incompatible Lisp Changes in Emacs 22.1
  
! ** The function find-operation-coding-system may be called with a cons
! (FILENAME . BUFFER) in the second argument if the first argument
! OPERATION is `insert-file-contents', and thus a function registered in
! `file-coding-system-alist' is also called with such an argument.
  
  ---
  ** The variables post-command-idle-hook and post-command-idle-delay have

---
Kenichi Handa
handa@m17n.org

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

* Re: safe_call1 considered harmful
  2006-07-31  5:14             ` Kenichi Handa
@ 2006-07-31 22:16               ` Richard Stallman
  2006-08-01  0:50                 ` Kenichi Handa
  0 siblings, 1 reply; 14+ messages in thread
From: Richard Stallman @ 2006-07-31 22:16 UTC (permalink / raw)
  Cc: eliz, emacs-devel

    If you think the backward incompatible problem raised by the
    current code is not that a big problem, I don't argue
    anymore.  Shall I install this change in etc/NEWS?

Please do.

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

* Re: safe_call1 considered harmful
  2006-07-31 22:16               ` Richard Stallman
@ 2006-08-01  0:50                 ` Kenichi Handa
  0 siblings, 0 replies; 14+ messages in thread
From: Kenichi Handa @ 2006-08-01  0:50 UTC (permalink / raw)
  Cc: eliz, emacs-devel

Richard Stallman <rms@gnu.org> writes:

>     If you think the backward incompatible problem raised by the
>     current code is not that a big problem, I don't argue
>     anymore.  Shall I install this change in etc/NEWS?

> Please do.

Done.

---
Kenichi Handa
handa@m17n.org

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

end of thread, other threads:[~2006-08-01  0:50 UTC | newest]

Thread overview: 14+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2006-07-21  9:36 safe_call1 considered harmful Eli Zaretskii
2006-07-21 11:34 ` Kenichi Handa
2006-07-21 15:49   ` Eli Zaretskii
2006-07-24  1:36     ` Kenichi Handa
2006-07-29 11:00       ` Eli Zaretskii
2006-07-31  3:04         ` Kenichi Handa
2006-07-21 19:37   ` Richard Stallman
2006-07-24  1:44     ` Kenichi Handa
2006-07-24 18:22       ` Richard Stallman
2006-07-30  9:18         ` Kenichi Handa
2006-07-31  4:38           ` Richard Stallman
2006-07-31  5:14             ` Kenichi Handa
2006-07-31 22:16               ` Richard Stallman
2006-08-01  0:50                 ` Kenichi Handa

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).