Subject: | Inserting random value into text when numbers end a line in C |
In ANSI_C89 mode (and others - Java, and C both seem to show this) it's
possible to insert some text from earlier expressions into the output.
This was found on the expression:
Blah = 1 << 2
Note the lack of comma at the end. This means that the expression in
ANSI_C89 which reads:
if ($self->testInt($text, 0, undef, 0, '#stay', 'Decimal')) {
captures the entire remaining text. Subsequently, in Template.pm, sub
highlight() we have the section :
$text =~ s/^(.)//;
my $attr = $plug->attributes->{$plug->contextInfo($context, 'attribute')};
$self->snippetParse($1, $attr);
which causes $1 from an earlier operation to be inserted into the output
document. This is because the regular expression does NOT match, so $1
is not assigned.
This should possibly read:
if ($text =~ s/^(.)//)
{
my $c = $1;
my $attr = $plug->attributes->{$plug->contextInfo($context,
'attribute')};
$self->snippetParse($c, $attr);
}
to ensure that the value captured is used correctly and not affected by
anything else, and only processed when it matches in the first place.