GNU bug report logs - #105
(split-string-and-unquote (combine-and-quote-strings STRINGS)) fails on trivial case

Previous Next

Package: emacs;

Reported by: Joe Wells <jbw <at> macs.hw.ac.uk>

Date: Tue, 1 Apr 2008 03:05:06 UTC

Severity: normal

Done: Stefan Monnier <monnier <at> iro.umontreal.ca>

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 105 in the body.
You can then email your comments to 105 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-submit-list <at> lists.donarmstrong.com, Emacs Bugs <bug-gnu-emacs <at> gnu.org>:
bug#105; Package emacs. Full text and rfc822 format available.

Acknowledgement sent to Joe Wells <jbw <at> macs.hw.ac.uk>:
New bug report received and forwarded. Copy sent to Emacs Bugs <bug-gnu-emacs <at> gnu.org>. Full text and rfc822 format available.

Message #5 received at submit <at> emacsbugs.donarmstrong.com (full text, mbox):

From: Joe Wells <jbw <at> macs.hw.ac.uk>
To: bug-gnu-emacs <at> gnu.org
Subject: (split-string-and-unquote (combine-and-quote-strings STRINGS))
	fails on trivial case
Date: Tue, 01 Apr 2008 02:17:23 +0100
The documentation strings for both split-string-and-unquote and
combine-and-quote-strings state that they attempt to achieve this
property:

  (split-string-and-unquote (combine-and-quote-strings strs)) == strs

Here is a trivial case that they fail on; the following sexp wrongly
evaluates to nil:

  (let ((l '("a b" "c")))
    (equal l
           (split-string-and-unquote (combine-and-quote-strings l))))

I hope this problem report is helpful.

Joe

======================================================================
In GNU Emacs 22.2.1 (i686-pc-linux-gnu, GTK+ Version 2.8.20)
 of 2008-04-01 on artemis
Windowing system distributor `The X.Org Foundation', version 11.0.70000000
configured using `configure  '--prefix=/home/jbw/local4' '--enable-debug' '--disable-nls' '--with-x-toolkit=gtk' 'CFLAGS=-O0 -g3 -ggdb -fno-crossjumping -DGLYPH_DEBUG=1''

Important settings:
  value of $LC_ALL: nil
  value of $LC_COLLATE: nil
  value of $LC_CTYPE: en_US.UTF-8
  value of $LC_MESSAGES: nil
  value of $LC_MONETARY: nil
  value of $LC_NUMERIC: nil
  value of $LC_TIME: jbw
  value of $LANG: nil
  locale-coding-system: utf-8
  default-enable-multibyte-characters: t


-- 
Heriot-Watt University is a Scottish charity
registered under charity number SC000278






Information forwarded to bug-submit-list <at> lists.donarmstrong.com, Emacs Bugs <bug-gnu-emacs <at> gnu.org>:
bug#105; Package emacs. Full text and rfc822 format available.

Acknowledgement sent to Chong Yidong <cyd <at> stupidchicken.com>:
Extra info received and forwarded to list. Copy sent to Emacs Bugs <bug-gnu-emacs <at> gnu.org>. Full text and rfc822 format available.

Message #10 received at 105 <at> emacsbugs.donarmstrong.com (full text, mbox):

From: Chong Yidong <cyd <at> stupidchicken.com>
To: Joe Wells <jbw <at> macs.hw.ac.uk>
Cc: 105 <at> debbugs.gnu.org, emacs-devel <at> gnu.org
Subject: Re: (split-string-and-unquote (combine-and-quote-strings STRINGS)) fails on trivial case
Date: Mon, 07 Apr 2008 01:31:34 -0400
> The documentation strings for both split-string-and-unquote and
> combine-and-quote-strings state that they attempt to achieve this
> property:
>
>   (split-string-and-unquote (combine-and-quote-strings strs)) == strs
>
> Here is a trivial case that they fail on; the following sexp wrongly
> evaluates to nil:
>
>   (let ((l '("a b" "c")))
>     (equal l
>            (split-string-and-unquote (combine-and-quote-strings l))))

I think this is a docstring mistake.  IIUC, the equation

 (split-string-and-unquote (combine-and-quote-strings strs)) == strs

only holds if STRS is a list containing a single string.  The point the
docstrings are trying to make is that combine-and-quote-strings performs
string quoting, while split-string-and-unquote performs unquoting.

If there are no objections to this interpretation, I'll check in a doc
fix shortly.




Reply sent to Stefan Monnier <monnier <at> iro.umontreal.ca>:
You have taken responsibility. Full text and rfc822 format available.

Notification sent to Joe Wells <jbw <at> macs.hw.ac.uk>:
bug acknowledged by developer. Full text and rfc822 format available.

Message #15 received at 105-done <at> emacsbugs.donarmstrong.com (full text, mbox):

From: Stefan Monnier <monnier <at> iro.umontreal.ca>
To: 105-done <at> debbugs.gnu.org
Subject: Re: (split-string-and-unquote (combine-and-quote-strings STRINGS)) fails on trivial case
Date: Mon, 07 Apr 2008 12:23:25 -0400
>> The documentation strings for both split-string-and-unquote and
>> combine-and-quote-strings state that they attempt to achieve this
>> property:
>> 
>> (split-string-and-unquote (combine-and-quote-strings strs)) == strs
>> 
>> Here is a trivial case that they fail on; the following sexp wrongly
>> evaluates to nil:
>> 
>> (let ((l '("a b" "c")))
>> (equal l
>> (split-string-and-unquote (combine-and-quote-strings l))))

> I think this is a docstring mistake.

I disagree.  This is a bug in the code.  I believe the patch below fixes it.


        Stefan


--- subr.el.~1.588.~	2008-04-07 10:23:51.000000000 -0400
+++ subr.el	2008-04-07 12:21:23.000000000 -0400
@@ -2987,10 +2987,11 @@
 This tries to quote the strings to avoid ambiguity such that
   (split-string-and-unquote (combine-and-quote-strings strs)) == strs
 Only some SEPARATORs will work properly."
-  (let ((sep (or separator " ")))
+  (let* ((sep (or separator " "))
+         (re (concat "[\\\"]" "\\|" (regexp-quote sep))))
     (mapconcat
      (lambda (str)
-       (if (string-match "[\\\"]" str)
+       (if (string-match re str)
 	   (concat "\"" (replace-regexp-in-string "[\\\"]" "\\\\\\&" str) "\"")
 	 str))
      strings sep)))




bug archived. Request was from Debbugs Internal Request <don <at> donarmstrong.com> to internal_control <at> emacsbugs.donarmstrong.com. (Tue, 06 May 2008 14:24:03 GMT) Full text and rfc822 format available.

This bug report was last modified 17 years and 104 days ago.

Previous Next


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