NthArgument with 0x8800 and the single quote

#1
When I use

Code:
NthArgument(psz, i | 0x8800, ...);
with a string containing one single quote (') it fails and I get, for example,

Code:
v:\> plugin_command don't forget to
TCC: No closing quote
What's up with that and how do I stop it?
 
#2
Here's a simple, concrete example:

Code:
INT WINAPI TEST ( WCHAR *psz )
{
    Printf(L"OK\r\n%s\r\n", NthArgument(psz, 0 | 0x8800, NULL, NULL));
    return 0;
}
Code:
v:\> test don't
OK
TCC: No closing quote
 
#3
Funny, I'm working on an OSD-like plugin and I see a similar problem with the built-in OSD:

Code:
v:\> osd /pos=0,0 don't forget to ...
TCC: No closing quote
Usage : OSD ...

v:\> osd /pos=0,0 `don't forget to ...`
TCC: No closing quote
Usage : OSD ...
Double quoting "text" works around it but I don't want to see the double quotes.
 

rconn

Administrator
Staff member
May 14, 2008
10,495
94
#4
When I use

Code:
NthArgument(psz, i | 0x8800, ...);
with a string containing one single quote (') it fails and I get, for example,

Code:
v:\> plugin_command don't forget to
TCC: No closing quote
What's up with that and how do I stop it?
WAD -- the 0x8000 arg tells NthArgument that you want to use single quotes as quote characters. Then you only pass it one single quote, and NthArgument quite correctly complains.
 
#5
On Sat, 11 Jun 2011 15:58:00 -0400, you wrote:

|WAD -- the 0x8000 arg tells NthArgument that you want to use single quotes as quote characters. Then you only pass it one single quote, and NthArgument quite correctly complains.

TakeCMd.h says

Code:
0x8000 - don't interpret a commas as a delimiter
and does indeed do that. There's no mention of the single quote (anywhere). Are
the flags documented correctly? Here's all of them.

Code:
0x8000 - don't interpret a commas as a delimiter
0x4000 - interpret ( and ) as quoting characters
0x2000 - interpret [ and ] as quoting characters
0x1000 - disable the back quote quoting character
0x800 - don't interpret a switch character as a delimiter
 

rconn

Administrator
Staff member
May 14, 2008
10,495
94
#6
On Sat, 11 Jun 2011 15:58:00 -0400, you wrote:

|WAD -- the 0x8000 arg tells NthArgument that you want to use single quotes as quote characters. Then you only pass it one single quote, and NthArgument quite correctly complains.

TakeCMd.h says

Code:
0x8000 - don't interpret a commas as a delimiter
and does indeed do that. There's no mention of the single quote (anywhere). Are the flags documented correctly? Here's all of them.

Code:
0x8000 - don't interpret a commas as a delimiter
0x4000 - interpret ( and ) as quoting characters
0x2000 - interpret [ and ] as quoting characters
0x1000 - disable the back quote quoting character
0x800 - don't interpret a switch character as a delimiter
0x8000 does both things (don't interpret commas as a delimiter, and use ' as a quote character).

But I don't see any reason for you to be using 0x8000 for either meaning.
 
#7
On Sat, 11 Jun 2011 17:07:40 -0400, you wrote:

|0x8000 does both things (don't interpret commas as a delimiter, and use ' as a quote character).

That doesn't make much sense to me. Is there some place where that combined
function is useful?

|But I don't see any reason for you to be using 0x8000 for either meaning.

Well I want to parse args like

Code:
 ... /COLOR=R[,G,B] ... plain text
where the plain text may include commas and single quotes. What would you
recommend?

Could NextArgument() help me here, or will that "look ahead" and complain about
an unmatched single quote?

OSD chokes on single quotes and escaping them doesn't help (though EscapeLine()
before using the string as window text allows (for me) ^^^' to work). I figured
you were using NthArgument() with 0x8000 there, like me.
 

rconn

Administrator
Staff member
May 14, 2008
10,495
94
#8
> That doesn't make much sense to me. Is there some place where
> that combined function is useful?
Yes, it's essential for me in several places. There is no chance of it
changing.

For places where I have to parse commas, I don't use NthArgument.


> Could NextArgument() help me here, or will that "look ahead" and complain
> about an unmatched single quote?
NextArgument is irrelevant; it simply removes the specified argument &
replaces it with the next one. You'd get the same error.
 
#10
On Sat, 11 Jun 2011 21:14:40 -0400, you wrote:

|---Quote (Originally by rconn)---
|0x8000 does both things (don't interpret commas as a delimiter, and use ' as a quote character).
|---End Quote---
|I'm curious. When does TCC use the apostrophe / single quote for quoting?

I'm curious too. I can't think of anywhere the user can use them for grouping
words into one argument. Correct me if I'm wrong ... the only place the user
sees ' as anything but an ordinary character is in "FOR ... IN ('command') ...".