Bill Pringlemeir wrote: > > If that analysis is correct, then the same thing applies to > > routing.c.
Thanks, I've removed the unnecessary newlines.
> [props.c 1.39: line 1357]
> - static const char fmt[] = "Bad line %u in config file, ignored\n";
> + static const char fmt[] = "Bad line %u in config file, ignored";
Dito.
> [props.c 1.39: line 1394]
> - while ((c = (guchar) *s) != '\0' && isascii(c) && isblank(c))
> + while ((c = (guchar) *s) != '\0' && isblank(c))
> s++;
> If c is "blank", it is also ascii? Isn't that right? I don't think
> there are UTF type blanks.
Actually, I don't know whether there are additional UTF blanks. I thought
there might be. However, the "problem" is that I'm not really sure which
locale is effective when the code is executed. There should be only two
acceptable encodings for the configuration file UTF-8 or ASCII, IMO. The
original code considered only certain ASCII blanks, I didn't want to
expand this set arbitrarily.
Anyway, the file is created automagically and anything but the value
should be pure ASCII and at this part of the code, the we're not at
the value part, considering the following scheme:
*(<blank>) <name> *(<blank>) "=" *(<blank>) <value> *(<space>)
> [props.c 1.39: line 1397]
> - if (!isascii(c) || !isalpha(c))
> + if (!isascii(c) && !isalpha(c))
> continue;
> Here, I think we keep parsing if it is alpha or ascii? So the
> condition we want to continue is "isascii(c) || isalpha(c)". Using
> demorgans law [afaik], "!(!isascii(c) && !isalpha(c))", so the
> complement would be "!isascii(c) && !isalpha(c)". I think this is
> meant to handle UTF characters?
No, it's not and that's what the isascii() is about in case the current
locale is something other than POSIX or C e.g., UTF-8 or ISO-8859-1
whereas in the latter case isalpha() returns true for characters
like ������� etc.
> Normally the isascii() would be
> redundant like the above. Maybe the condition should only be "if
> (!isalpha(c))". Hmm, maybe it is right; "we keep parsing if it is
> alpha *AND* ascii", disallowing UTF alpha characters?
Yes, this is the <name> part. If someone creates property names which
contain non-ASCII characters, I'll poke him in the eye.
> [props.c 1.39: line 1402]
> - if (c != '=' && !(isascii(c) && isblank(c))) {
> + if (!(c == '=' || isblank(c))) {
> Hmmm. I am not certain if "isascii(c)" is meant to prevent UTF (ie,
> high code page characters).
Yes, that was the intention. It might be over-protective but it shouldn't
make anything worse.
> So maybe I will just stop with this line
> of thought. Maybe a comment with a regular expression to define what
> the config lines are suppose to be like would help?
Yes, probably.
Christian
pgpWnWIZMu3IQ.pgp
Description: PGP signature
