From: "D Goel" <deego@gnufans.org>
Subject: (message (format "File %s" file))
Date: Wed, 31 Aug 2005 16:33:26 -0400 [thread overview]
Message-ID: <873bop978p.fsf@gnufans.net> (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/
--
next reply other threads:[~2005-08-31 20:33 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2005-08-31 20:33 D Goel [this message]
2005-08-31 22:10 ` (message (format "File %s" file)) 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
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: https://www.gnu.org/software/emacs/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=873bop978p.fsf@gnufans.net \
--to=deego@gnufans.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).