You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@stdcxx.apache.org by Martin Sebor <se...@roguewave.com> on 2008/03/30 20:11:46 UTC

spaces in rw_xxx_expand()

In the shell, spaces that are otherwise treated as separators can
be either escaped or quoted to have them interpreted as ordinary
characters. The rw_xxx_expand() functions let me escape spaces but
they don't seem to like quoting. For example, the shell expands
the following three strings to the same result:

     "a{b\ c,d}"    ==> "ab c ad"
     "a{b' 'c,d}"
     "a{b" "c,d}"

but rw_brace_expand() fails on the last two. It should work the
same as the shell.

In the change below I've enhanced the 0.braceexpand.cpp test to
exercise a number of (passing) test cases including plan as well
as escaped whitespace:

http://svn.apache.org/viewvc?rev=642790&view=rev

I think the same test cases should be added for quoted whitespace.

Martin

Re: spaces in rw_xxx_expand()

Posted by Martin Sebor <se...@roguewave.com>.
Travis Vitek wrote:
>  
> 
>> Martin Sebor wrote:
>>
>> PING? Should I open an issue for this or is it something you're
>> already working on or planning to?
>>
> 
> Well if we want 100% compatibility with the shell, then it should be
> implemented.

I don't expect rw_shell_expand() to necessarily behave exactly
the same way as the shell in every respect but I do think the
function should interpret escapes and quotes the same the shell
does. In my experience, quoting spaces is more common than
escaping them is so must users would find it surprising if
quoting didn't work.

> I took a look, and I think I can fix it by modifying
> _rw_brace_graph::brace_expand_write() to treat quoted blocks literally
> and failing if an unescaped quote isn't matched. That will break
> rw_brace_expand(), but that isn't too big of a deal as we've discussed
> removing that function several times.
> 
> Would you please open an issue for this? I would have done this myself,
> but I'm not sure how high a priority this is for you. I'm assuming that
> this is not to serious because you should be able to work around it by
> using escapes.

Okay, it's STDCXX-825
   http://issues.apache.org/jira/browse/STDCXX-825

I don't think it's a pressing enhancement but it would be
nice to get it implemented at some point before we start
using the function in our test suite.

Martin


RE: spaces in rw_xxx_expand()

Posted by Travis Vitek <Tr...@roguewave.com>.
 

>Martin Sebor wrote:
>
>PING? Should I open an issue for this or is it something you're
>already working on or planning to?
>

Well if we want 100% compatibility with the shell, then it should be
implemented. I took a look, and I think I can fix it by modifying
_rw_brace_graph::brace_expand_write() to treat quoted blocks literally
and failing if an unescaped quote isn't matched. That will break
rw_brace_expand(), but that isn't too big of a deal as we've discussed
removing that function several times.

Would you please open an issue for this? I would have done this myself,
but I'm not sure how high a priority this is for you. I'm assuming that
this is not to serious because you should be able to work around it by
using escapes.

>
>Martin Sebor wrote:
>> 
>> In the shell, spaces that are otherwise treated as separators can
>> be either escaped or quoted to have them interpreted as ordinary
>> characters. The rw_xxx_expand() functions let me escape spaces but
>> they don't seem to like quoting. For example, the shell expands
>> the following three strings to the same result:
>> 
>>      "a{b\ c,d}"    ==> "ab c ad"
>>      "a{b' 'c,d}"
>>      "a{b" "c,d}"
>> 
>> but rw_brace_expand() fails on the last two. It should work the
>> same as the shell.
>> 
>> In the change below I've enhanced the 0.braceexpand.cpp test to
>> exercise a number of (passing) test cases including plan as well
>> as escaped whitespace:
>> 
>> http://svn.apache.org/viewvc?rev=642790&view=rev
>> 
>> I think the same test cases should be added for quoted whitespace.
>> 
>> Martin
>> 
>> 

Re: spaces in rw_xxx_expand()

Posted by Martin Sebor <se...@roguewave.com>.
PING? Should I open an issue for this or is it something you're
already working on or planning to?


Martin Sebor wrote:
> 
> In the shell, spaces that are otherwise treated as separators can
> be either escaped or quoted to have them interpreted as ordinary
> characters. The rw_xxx_expand() functions let me escape spaces but
> they don't seem to like quoting. For example, the shell expands
> the following three strings to the same result:
> 
>      "a{b\ c,d}"    ==> "ab c ad"
>      "a{b' 'c,d}"
>      "a{b" "c,d}"
> 
> but rw_brace_expand() fails on the last two. It should work the
> same as the shell.
> 
> In the change below I've enhanced the 0.braceexpand.cpp test to
> exercise a number of (passing) test cases including plan as well
> as escaped whitespace:
> 
> http://svn.apache.org/viewvc?rev=642790&view=rev
> 
> I think the same test cases should be added for quoted whitespace.
> 
> Martin
> 
> 

-- 
View this message in context: http://www.nabble.com/spaces-in-rw_xxx_expand%28%29-tp16385194p16431767.html
Sent from the stdcxx-dev mailing list archive at Nabble.com.