|
From: Chris K <gnu...@li...> - 2006-04-05 08:23:16
|
(moving back onto the list)
Ethan A Merritt wrote:
> On Tuesday 04 April 2006 12:24 pm, you wrote:
>> I strongly propose that '}' should also be excluded from the valid font name
>> characters, and therefore '{' as well. The new code would be:
>>
>>> localfontname = p;
>>> while ((ch = *p) > ' ' && ch != '=' && ch != '*'
>>> && ch != '{' && ch != '}')
>>> ++p;
>>> save = *(savepos=p);
>
> I just tried that, and it doesn't quite work.
> See for example the output of
>
> set title "aaa{/Symbol{bbb}}ccc"
>
> Your intent, I think, was to forgive the missing ' ' and
> proceed to process the next chunk of text. But it seems to
> need additional checks and/or case statements in order to
> avoid spurious error messages about mismatched curly braces.
>
> Anyhow, if you can prepare a patch with a bit more
> error checking and testing, I'll apply it.
>
I see what the problem is now. You need a sacrificial character, a space, after
the font name in order to use the parsing optimization where you overwrite the
space with '\0'. So in the above "aaa{/Symbol{bbb}}ccc\0 "you get
"aaa{/Symbol\0bbb}ccc\0" for localfontname "Symbol\0" and recurse with "bbb}ccc\0".
If the next character is '=' or '*' then it has to recognize this before
overwriting it with '\0'.
The overwritten character is always stored and replaced after the recursion.
If the parser would just copy the localfontname to separate storage, this would
not be an issue, and the parser would not need to mutate input string this way.
So long as the number of font changes in a plot is less than a few thousand, the
performance loss will be negligible.
I will contribute a patch for this.
--
Chris
|