GNU bug report logs - #14207
24.2; insert-file-contents clobbers match data

Previous Next

Package: emacs;

Reported by: Aidan Gauland <aidalgol <at> no8wireless.co.nz>

Date: Mon, 15 Apr 2013 01:02:01 UTC

Severity: minor

Tags: notabug

Found in version 24.2

Done: Glenn Morris <rgm <at> gnu.org>

Bug is archived. No further changes may be made.

To add a comment to this bug, you must first unarchive it, by sending
a message to control AT debbugs.gnu.org, with unarchive 14207 in the body.
You can then email your comments to 14207 AT debbugs.gnu.org in the normal way.

Toggle the display of automated, internal messages from the tracker.

View this report as an mbox folder, status mbox, maintainer mbox


Report forwarded to bug-gnu-emacs <at> gnu.org:
bug#14207; Package emacs. (Mon, 15 Apr 2013 01:02:01 GMT) Full text and rfc822 format available.

Acknowledgement sent to Aidan Gauland <aidalgol <at> no8wireless.co.nz>:
New bug report received and forwarded. Copy sent to bug-gnu-emacs <at> gnu.org. (Mon, 15 Apr 2013 01:02:02 GMT) Full text and rfc822 format available.

Message #5 received at submit <at> debbugs.gnu.org (full text, mbox):

From: Aidan Gauland <aidalgol <at> no8wireless.co.nz>
To: bug-gnu-emacs <at> gnu.org
Subject: 24.2; insert-file-contents clobbers match data
Date: Mon, 15 Apr 2013 12:56:26 +1200
If (and only if) the match data is non-nil when `insert-file-contents'
is called, it clobbers the match-data.

To demonstrate:
*** Welcome to IELM ***  Type (describe-mode) for help.
ELISP> (match-data)
nil
ELISP> (equal 
        (match-data)
        (progn 
          (write-region "foo bar baz wiz" nil "/tmp/foo-file")
          (with-temp-buffer (insert-file-contents "/tmp/foo-file"))
          (match-data)))
t
ELISP> (match-data)
nil
ELISP> (search-backward "elisp" nil t)
340
ELISP> (match-data)
(#<marker at 340 in *ielm*> #<marker at 345 in *ielm*>)

ELISP> (equal 
        (match-data)
        (progn 
          (write-region "foo bar baz wiz" nil "/tmp/foo-file")
          (with-temp-buffer (insert-file-contents "/tmp/foo-file"))
          (match-data)))
nil
ELISP> (match-data)
(0 0)

ELISP> 


In GNU Emacs 24.2.1 (x86_64-pc-linux-gnu, GTK+ Version 2.20.1)
 of 2013-04-03 on dimension8, modified by Debian
Windowing system distributor `The X.Org Foundation', version 11.0.10707000
Configured using:
 `configure '--build' 'x86_64-linux-gnu' '--build' 'x86_64-linux-gnu'
 '--prefix=/usr' '--sharedstatedir=/var/lib' '--libexecdir=/usr/lib'
 '--localstatedir=/var/lib' '--infodir=/usr/share/info'
 '--mandir=/usr/share/man' '--with-pop=yes'
 '--enable-locallisppath=/etc/emacs24:/etc/emacs:/usr/local/share/emacs/24.2/site-lisp:/usr/local/share/emacs/site-lisp:/usr/share/emacs/24.2/site-lisp:/usr/share/emacs/site-lisp'
 '--without-gconf' '--with-crt-dir=/usr/lib/' '--with-x=yes'
 '--with-x-toolkit=gtk' '--with-toolkit-scroll-bars'
 'build_alias=x86_64-linux-gnu' 'CFLAGS=-g -O2 -fstack-protector
 --param=ssp-buffer-size=4 -Wformat -Werror=format-security -Wall'
 'LDFLAGS=-Wl,-z,relro' 'CPPFLAGS=-D_FORTIFY_SOURCE=2''

Important settings:
  value of $LC_ALL: nil
  value of $LC_COLLATE: nil
  value of $LC_CTYPE: nil
  value of $LC_MESSAGES: nil
  value of $LC_MONETARY: nil
  value of $LC_NUMERIC: nil
  value of $LC_TIME: nil
  value of $LANG: en_NZ.utf8
  value of $XMODIFIERS: nil
  locale-coding-system: utf-8-unix
  default enable-multibyte-characters: t

Major mode: IELM

Minor modes in effect:
  tooltip-mode: t
  mouse-wheel-mode: t
  tool-bar-mode: t
  menu-bar-mode: t
  file-name-shadow-mode: t
  global-font-lock-mode: t
  font-lock-mode: t
  blink-cursor-mode: t
  auto-composition-mode: t
  auto-encryption-mode: t
  auto-compression-mode: t
  line-number-mode: t
  transient-mark-mode: t

Recent input:
M-x i e l m <return> C-y <return> C-y <return> ( m 
a t c h - d a t a ) <return> C-y <return> M-p M-p <return> 
M-p M-p M-p M-p <return> M-p M-p <return> M-< C-n C-p 
C-SPC M-> M-w M-x r e p o r <tab> <return>

Recent messages:
History item: 1
History item: 2
History item: 1
History item: 2
History item: 3
History item: 4
Wrote /tmp/foo-file
History item: 1
History item: 2
Mark set [2 times]

Load-path shadows:
/usr/share/emacs/24.2/site-lisp/debian-startup hides /usr/share/emacs/site-lisp/debian-startup
/usr/share/emacs/24.2/site-lisp/dictionaries-common/flyspell hides /usr/share/emacs/24.2/lisp/textmodes/flyspell
/usr/share/emacs/24.2/site-lisp/dictionaries-common/ispell hides /usr/share/emacs/24.2/lisp/textmodes/ispell

Features:
(shadow sort gnus-util mail-extr emacsbug message format-spec rfc822 mml
easymenu mml-sec mm-decode mm-bodies mm-encode mail-parse rfc2231
mailabbrev gmm-utils mailheader sendmail rfc2047 rfc2045 ietf-drums
mm-util mail-prsvr mail-utils ielm pp comint regexp-opt ansi-color ring
time-date tooltip ediff-hook vc-hooks lisp-float-type mwheel x-win x-dnd
tool-bar dnd fontset image fringe lisp-mode register page menu-bar
rfn-eshadow timer select scroll-bar mouse jit-lock font-lock syntax
facemenu font-core frame cham georgian utf-8-lang misc-lang vietnamese
tibetan thai tai-viet lao korean japanese hebrew greek romanian slovak
czech european ethiopic indian cyrillic chinese case-table epa-hook
jka-cmpr-hook help simple abbrev minibuffer loaddefs button faces
cus-face files text-properties overlay sha1 md5 base64 format env
code-pages mule custom widget hashtable-print-readable backquote
make-network-process dbusbind dynamic-setting font-render-setting
move-toolbar gtk x-toolkit x multi-tty emacs)




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#14207; Package emacs. (Mon, 15 Apr 2013 05:22:02 GMT) Full text and rfc822 format available.

Message #8 received at 14207 <at> debbugs.gnu.org (full text, mbox):

From: Eli Zaretskii <eliz <at> gnu.org>
To: Aidan Gauland <aidalgol <at> no8wireless.co.nz>
Cc: 14207 <at> debbugs.gnu.org
Subject: Re: bug#14207: 24.2; insert-file-contents clobbers match data
Date: Mon, 15 Apr 2013 08:16:35 +0300
> From: Aidan Gauland <aidalgol <at> no8wireless.co.nz>
> Date: Mon, 15 Apr 2013 12:56:26 +1200
> 
> If (and only if) the match data is non-nil when `insert-file-contents'
> is called, it clobbers the match-data.

And why is that a bug?

From the ELisp manual (node "Match Data"):

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

'insert-file-contents' is not documented to preserve match data.




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#14207; Package emacs. (Tue, 16 Apr 2013 01:27:02 GMT) Full text and rfc822 format available.

Message #11 received at 14207 <at> debbugs.gnu.org (full text, mbox):

From: Aidan Gauland <aidalgol <at> no8wireless.co.nz>
To: Eli Zaretskii <eliz <at> gnu.org>
Cc: 14207 <at> debbugs.gnu.org
Subject: Re: bug#14207: 24.2; insert-file-contents clobbers match data
Date: Tue, 16 Apr 2013 13:22:12 +1200
Eli Zaretskii <eliz <at> gnu.org> writes:

>> From: Aidan Gauland <aidalgol <at> no8wireless.co.nz>
>> Date: Mon, 15 Apr 2013 12:56:26 +1200
>> 
>> If (and only if) the match data is non-nil when `insert-file-contents'
>> is called, it clobbers the match-data.
>
> And why is that a bug?
>
> From the ELisp manual (node "Match Data"):
>
>      Notice that all functions are allowed to overwrite the match data
>   unless they're explicitly documented not to do so.
>
> 'insert-file-contents' is not documented to preserve match data.

Oh, OK.  I thought it was the other way around: functions are supposed
to explicitly be documented as modifying the match data.




Added tag(s) notabug. Request was from Glenn Morris <rgm <at> gnu.org> to control <at> debbugs.gnu.org. (Tue, 16 Apr 2013 17:15:02 GMT) Full text and rfc822 format available.

bug closed, send any further explanations to 14207 <at> debbugs.gnu.org and Aidan Gauland <aidalgol <at> no8wireless.co.nz> Request was from Glenn Morris <rgm <at> gnu.org> to control <at> debbugs.gnu.org. (Tue, 16 Apr 2013 17:15:02 GMT) Full text and rfc822 format available.

bug archived. Request was from Debbugs Internal Request <help-debbugs <at> gnu.org> to internal_control <at> debbugs.gnu.org. (Wed, 15 May 2013 11:24:03 GMT) Full text and rfc822 format available.

This bug report was last modified 12 years and 91 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.