On 2014-02-11 23:03, Ben Boeckel wrote:
On Tue, Feb 11, 2014 at 19:16:49 -0500, Matthew Woehlke wrote:
On 2014-02-11 17:54, Ben Boeckel wrote:
Parsing in CMake is split into separate sections: the part which parses
the lines into CMake's command calls and the part which expands
variables (which is why "${cmd}(${args})" isn't allowed).

Right; I'd figured that much out on my own, and my own parser AFAICT
operates in a similar manner to CMake itself... it doesn't try to
tokenize variable substitutions (I didn't need that, and it would
have made the API non-trivially more complex), although it does choke
if it seems things like '${foo\n'. From what I can tell, the CMake
command parsing pass does also?

Probably worth a test. The new parser will see:

     ${foo
     }

and happily lookup the "foo\n" variable. The old parser may have choked.

Hmm... that's an interesting and perhaps undesirable behavior change.

AFAICT, the old parser, on encountering a substitution ('${', '@', '$ENV{', '$CACHE{'), would consume '[[:alnum:]+-._/]' until it found a matching '}' or '@'. If it found '@' or '$' it would try to consume the substitution according to the same rules. So yes, the old parser does reject '${foo\n}' (also '${foo~}', etc.). (Did you check that it isn't the first stage parser that rejects these?)

As an exception to the above, spaces are allowed inside '$ENV{}' (and maybe '$CACHE{}'?)... (Interestingly, bash won't let you set such an environment variable... though /usr/bin/env will...)

FWIW, variables named as such can still come in through CMakeCache.txt
and probably the command line as well, so maybe there's some value here.
If it's wanted, I can tighten up the new implementation (it's also the
perfect release version to start rejecting junk like ';' or ' ' in
variable names, but it is probably too late in the release cycle at this
point).

Yeah... I have definitely wanted that (rejecting setting variables that don't match the above rules) before :-).

I think I even mentioned that at some point as 'things I'd like to see in 3.0'.

--
Matthew

--

Powered by www.kitware.com

Visit other Kitware open-source projects at 
http://www.kitware.com/opensource/opensource.html

Please keep messages on-topic and check the CMake FAQ at: 
http://www.cmake.org/Wiki/CMake_FAQ

Follow this link to subscribe/unsubscribe:
http://public.kitware.com/cgi-bin/mailman/listinfo/cmake-developers

Reply via email to