[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

bug#31727: 25.3; format-spec clobbers match data

From: Ryan Thompson
Subject: bug#31727: 25.3; format-spec clobbers match data
Date: Tue, 5 Jun 2018 10:49:33 -0700

On Tue, Jun 5, 2018 at 10:39 AM Noam Postavsky <address@hidden> wrote:
On 5 June 2018 at 13:30, Ryan Thompson <address@hidden> wrote:
> The following code throws an error:
> (progn
>    (string-match "h.*o" "hello")
>    (format-spec "This sets the %s" (format-spec-make ?s "match data"))
>    (match-string 0 "hello"))
> This is because the implementation of "format-spec" uses regular
> expressions internally, and does not save the match data and restore it
> afterward.

(elisp) Match Data:

Notice that all functions are allowed to overwrite the match data
unless they’re explicitly documented not to do so.

Wow, I was not aware of that. This seems... really fragile. In any case, I suppose the behavior is as documented, so you can close this bug.

reply via email to

[Prev in Thread] Current Thread [Next in Thread]