summaryrefslogtreecommitdiffstats
path: root/tools
diff options
context:
space:
mode:
authorMarc-André Lureau <marcandre.lureau@gmail.com>2013-02-13 12:46:03 +0100
committerMarc-André Lureau <marcandre.lureau@gmail.com>2013-02-13 12:46:03 +0100
commit6bc9aaeca4327cae4109e9664a7a70897f3c41e8 (patch)
treea12622063319e8f362e78dc7c5c3adf2fee8f4a1 /tools
parentc6d54cef256653dc6dd2e35f8e67557e44e8f929 (diff)
downloadmsitools-6bc9aaeca4327cae4109e9664a7a70897f3c41e8.zip
msitools-6bc9aaeca4327cae4109e9664a7a70897f3c41e8.tar.gz
msitools-6bc9aaeca4327cae4109e9664a7a70897f3c41e8.tar.xz
wixl: make environment variable mandatory
Make environment variable mandatory if used inside XML content. Preprocessor conditions are still optionnal.
Diffstat (limited to 'tools')
-rw-r--r--tools/wixl/preprocessor.vala16
1 files changed, 8 insertions, 8 deletions
diff --git a/tools/wixl/preprocessor.vala b/tools/wixl/preprocessor.vala
index 98c95c9..16f30a0 100644
--- a/tools/wixl/preprocessor.vala
+++ b/tools/wixl/preprocessor.vala
@@ -29,17 +29,14 @@ namespace Wixl {
return variables.lookup (name);
}
- public string eval_variable (string str, File? file, bool needed = true) throws GLib.Error {
+ public string? eval_variable (string str, File? file) throws GLib.Error {
var var = str.split (".", 2);
if (var.length != 2)
throw new Wixl.Error.FAILED ("invalid variable %s", str);
switch (var[0]) {
case "var":
- var val = lookup_variable (var[1]);
- if (val == null && needed)
- throw new Wixl.Error.FAILED ("Undefined variable %s", var[1]);
- return val;
+ return lookup_variable (var[1]);
case "env":
return Environment.get_variable (var[1]);
case "sys":
@@ -76,7 +73,10 @@ namespace Wixl {
var substring = remainder[1:closing];
if (substring.index_of ("(") != -1)
throw new Wixl.Error.FIXME ("unsupported function");
- result += eval_variable (substring, file);
+ var val = eval_variable (substring, file);
+ if (val == null)
+ throw new Wixl.Error.FAILED ("Undefined variable %s", substring);
+ result += val;
end += closing + 1;
}
}
@@ -153,12 +153,12 @@ namespace Wixl {
case "ifdef":
ifstack.push_head (context);
var value = reader.const_value ().strip ();
- context = new IfContext (context.enabled && context.is_true, eval_variable (value, file, false) != null, IfContext.State.IF);
+ context = new IfContext (context.enabled && context.is_true, eval_variable (value, file) != null, IfContext.State.IF);
break;
case "ifndef":
ifstack.push_head (context);
var value = reader.const_value ().strip ();
- context = new IfContext (context.enabled && context.is_true, eval_variable (value, file, false) == null, IfContext.State.IF);
+ context = new IfContext (context.enabled && context.is_true, eval_variable (value, file) == null, IfContext.State.IF);
break;
case "else":
if (ifstack.is_empty ())