ObjFW  Diff

Differences From Artifact [f919bded41]:

To Artifact [43f4209e77]:


81
82
83
84
85
86
87
88

89

90
91
92
93
94
95
96
97
98
99
100
101
102

103
104

105
106

107
108
109
110
111
112
113
81
82
83
84
85
86
87

88
89
90
91
92
93
94
95
96
97
98
99
100
101


102


103


104
105
106
107
108
109
110
111







-
+

+











-
-
+
-
-
+
-
-
+







	} @finally {
		free(locale);
	}
}
#endif

static bool
evaluateCondition(OFString *condition, OFDictionary *variables)
evaluateCondition(OFString *condition_, OFDictionary *variables)
{
	OFMutableString *condition = [[condition_ mutableCopy] autorelease];
	OFMutableArray *tokens, *operators, *stack;

	/* Empty condition is the fallback that's always true */
	if (condition.length == 0)
		return true;

	/*
	 * Dirty hack to allow not needing spaces after "!" or "(" and spaces
	 * before ")".
	 * TODO: Replace with a proper tokenizer.
	 */
	condition = [condition stringByReplacingOccurrencesOfString: @"!"
							 withString: @"! "];
	[condition replaceOccurrencesOfString: @"!" withString: @"! "];
	condition = [condition stringByReplacingOccurrencesOfString: @"("
							 withString: @"( "];
	[condition replaceOccurrencesOfString: @"(" withString: @"( "];
	condition = [condition stringByReplacingOccurrencesOfString: @")"
							 withString: @" )"];
	[condition replaceOccurrencesOfString: @")" withString: @" )"];

	/* Substitute variables and convert to RPN first */
	tokens = [OFMutableArray array];
	operators = [OFMutableArray array];
	for (OFString *token in [condition
	    componentsSeparatedByString: @" "
				options: OF_STRING_SKIP_EMPTY]) {