On 03/21/2012 04:10 PM, Vratislav Podzimek wrote:
+static gboolean key_value_ok(gchar *key, gchar *value)
+{
+ gboolean maybe = TRUE;
+ char *i;
+
+ /* check key, it has to be valid filename and will end up in the
+ * bugzilla */
+ for (i = key; *i != 0&& maybe; i++)
+ {
+ maybe = isalpha(*i) || (*i == '-') || (*i == '_') || (*i == ' ');
+ }
I think "maybe" is a bad variable name. In fact, I think that
you don't need a variable: just return false as soon as you see
something bad:
for (i = key; *i; i++)
{
if (!isalpha(*i) && (*i != '-') && (*i != '_') && (*i != ' '))
return FALSE;
}
and similarly below:
+
+ /* check value of 'basename', it has to be valid non-hidden directory
+ * name */
+ if (maybe&& (strcmp(key, "basename") == 0))
+ {
+ maybe = is_correct_filename(value);
+ if (!maybe)
+ error_msg("Value of 'basename' (%s) is not a valid directory
name.",
+ value);
+ }
+
+ return maybe;
}
--
vda