unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
From: "Mattias Engdegård" <mattiase@acm.org>
To: 39290@debbugs.gnu.org
Subject: bug#39290: [PATCH] Correct regexp for flags in 'format' doc string
Date: Sun, 26 Jan 2020 15:21:02 +0100	[thread overview]
Message-ID: <1435B249-47D1-4546-9B3F-6C67FAD16EB5@acm.org> (raw)

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

The doc string for 'format' contains

  where field is [0-9]+ followed by a literal dollar "$", flags is
  [+ #-0]+, width is [0-9]+, and precision is a literal period "."
  followed by [0-9]+.

The spec for flags isn't a correct regexp; the hyphen should be last.  This matters, because people copy it into their code without thinking (observed in the wild).

Patch acceptable for emacs-27?


[-- Attachment #2: 0001-Correct-regexp-for-flags-in-format-doc-string.patch --]
[-- Type: application/octet-stream, Size: 1010 bytes --]

From 5245a818d978a96c17c3ec7b99d93e32a07f90e6 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Mattias=20Engdeg=C3=A5rd?= <mattiase@acm.org>
Date: Sun, 26 Jan 2020 15:07:45 +0100
Subject: [PATCH] Correct regexp for flags in `format' doc string

* src/editfns.c (Fformat): Use the correct regexp for describing the
flags in a %-sequence (place the hyphen last).
---
 src/editfns.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/src/editfns.c b/src/editfns.c
index 4e35784e55..3f1b3aa4b7 100644
--- a/src/editfns.c
+++ b/src/editfns.c
@@ -3031,7 +3031,7 @@ DEFUN ("format", Fformat, Sformat, 1, MANY, 0,
   %<field><flags><width><precision>character
 
 where field is [0-9]+ followed by a literal dollar "$", flags is
-[+ #-0]+, width is [0-9]+, and precision is a literal period "."
+[+ #0-]+, width is [0-9]+, and precision is a literal period "."
 followed by [0-9]+.
 
 If a %-sequence is numbered with a field with positive value N, the
-- 
2.21.0 (Apple Git-122.2)


             reply	other threads:[~2020-01-26 14:21 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-01-26 14:21 Mattias Engdegård [this message]
2020-01-26 18:08 ` bug#39290: [PATCH] Correct regexp for flags in 'format' doc string Paul Eggert
2020-01-26 19:19   ` Eli Zaretskii
2020-01-26 19:21     ` Mattias Engdegård

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=1435B249-47D1-4546-9B3F-6C67FAD16EB5@acm.org \
    --to=mattiase@acm.org \
    --cc=39290@debbugs.gnu.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).