[Geany-Devel] Placeholder replacement in (build) commands
Dimitar Zhekov
dimitar.zhekov at xxxxx
Fri Apr 3 16:16:45 UTC 2015
On 03.4.2015 г. 03:52, Lex Trotman wrote:
>> To find proper quoting for Windows, you'll need to look no further than
>> spawn_append_argument() in the new spawn. :)
>
> Well, thats obviously the name of a quoting function, perhaps it
> should be spawn_append_argument_win_quoted() so I might have noticed
> it :)
>
> Its fine for appending an argument, but when replacing a placeholder
> you can't be certain it isn't inside quotes already. [...]
Sure.
> But it doesn't put arguments containing tabs inside " either.
If you mean spawn_append_argument, it checks for at least one " or
g_ascii_isspace(), and if so, quotes the entire argument. There's no way
it'll miss a tab.
>> The only thing I'm not sure about are \n \v ... - the official VS 2013 msdn
>> says "arguments are delimited by white space, which is either a space or
>> a tab", [...]
>
> It puts arguments containing \n and \v inside " which sounds
> reasonable but yeah unexplained why.
Actually, I confused the blanks which *may* cause quoting with the ones
should delimit the program name. The former set must be permissive to
cope with stupid RTL-s, while the latter must be restrictive to avoid
Win~1 to avoid running unexpected things.
So the actual blog error is that '\f' and especially '\r' are not
included. But I'm not much better: after checking g_ascii_isspace(), it
turns out that '\v' is not a spacing character for glib, despite both C
and C++ standards saying it is. *facepalm*
"Everyone quotes command line arguments the wrong way" - truer words
have never been said. I'll switch to isspace(), and even if it considers
some non-ascii characters to be spaces, that'll do no harm.
(I can even quote unconditionally - the resulting CL will be a bit ugly,
but it's internal to spawn anyway.)
--
E-gards: Jimmy
More information about the Devel
mailing list