unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
* (message (format "File %s" file))
@ 2005-08-31 20:33 D Goel
  2005-08-31 22:10 ` Stefan Monnier
                   ` (2 more replies)
  0 siblings, 3 replies; 8+ messages in thread
From: D Goel @ 2005-08-31 20:33 UTC (permalink / raw)



A *lot* of source code contains easy-to-miss bugs like this: 

	(message (format "File: %s" file))

which will lead to erers like these: 

Debugger entered--Lisp error: (error "Not enough arguments for format string")

if the filename contains %.


I plan to go through the entire source code, and only in cases I am
sure, fix these bugs (which mostly involves adding a "%s% after
`message', or getting rid of the unnecessary format call following
(message).

(I will be spotting these bugs with the aid of a regexp search tool).

I have committ access, but this is the first time I am planning to
make any real changes (which happen te be large-scale too), so I
thought I should ask for permission as well as any suggestions before
doing so.  For each fix, I would add a proper changlog entry saying
something like:  message format spec fix.



Here are a few examples:

iswitchb:
      (message (format "no buffer matching `%s'" buf)))))


printing.el:
     (message (error-message-string data)))))


flyspell:
	(message (format "duplicate `%s'" word)))




gud:
   (message (format "Error parsing file %s." file))



I will leave any code alone unless I am absolutely sure of what I am
doing.  



Here's an example of when I am not sure: 

  (message (substitute-command-keys "Press \\[wdired-finish-edit] when
  finished \
	or \\[wdired-abort-changes] to abort changes")))

Can the above code ever lead to errors? 

Either way, isn't it safe to insert a "%s" after message anyways?


====================================================

All this almost makes one wonder if it would make sense to provide a
msg:

(defun msg (arg)
	(message "%s" arg))

A lot of times, an author accidentally writes the code with msg in
mind rather than message.  This error is pervasive, especially if you
look at all the add-on code (not part of emacs).  I bet there is aon
average, at least one bug per file.

 


Sincerely,

DG                                 http://gnufans.net/
--

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

end of thread, other threads:[~2005-09-21  6:43 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2005-08-31 20:33 (message (format "File %s" file)) D Goel
2005-08-31 22:10 ` Stefan Monnier
2005-08-31 22:46   ` D Goel
2005-09-05 14:07   ` Kim F. Storm
2005-09-06  5:29     ` Richard M. Stallman
2005-09-01 15:53 ` Richard M. Stallman
2005-09-20  5:11 ` Juri Linkov
2005-09-21  6:43   ` Richard M. Stallman

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