[Lxr-dev] [ lxr-Bugs-3204197 ] Incorrect identifier recognition
Brought to you by:
ajlittoz
From: SourceForge.net <no...@so...> - 2011-03-09 13:53:11
|
Bugs item #3204197, was opened at 2011-03-09 14:47 Message generated for change (Settings changed) made by ajlittoz You can respond by visiting: https://sourceforge.net/tracker/?func=detail&atid=390117&aid=3204197&group_id=27350 Please note that this message will contain a full copy of the comment thread, including the initial issue submission, for this request, not just the latest update. >Category: Lang support Group: None Status: Open Resolution: None Priority: 5 Private: No Submitted By: Andre-Littoz (ajlittoz) Assigned to: Nobody/Anonymous (nobody) Summary: Incorrect identifier recognition Initial Comment: LXR v0.9.8 Generic.pm::processcode uses a pattern for identifier recognition that encompasses all forms of identifiers in all languages. In Perl, identifiers may begin with a hyphen -. When this pattern is used for C, Pascal, Fortran, ... it may erroneously capture a variable preceded by the operator - (or part of --) and this string cannot be matched against the variable. It is preferable to customize the pattern per language. Thus, 'spec' in generic.conf is extended with a new key 'identdef' with the syntax: 'identdef' => pattern_string pattern_string is not surrounded by pattern delimiters. It will be used by processcode to tag identifiers AND reserved words. It MUST then encompass these 2 classes of symbols. Do not add \b at the end, it will be done for you. Since it becomes a critical part of the process, a sensible default is always created (with the pattern used in version 0.9.8). Proposed patch for Generic.pm in sub new !-51 110304 (after line 51, insert:) ! $$self{'langmap'}{$lang}{'identdef'} = '[-\w~\#][\w]*' ! unless defined $self->langinfo('identdef'); ! -------------------------------- end of patch -------------------------------------- in sub processcode NOTE: this part of the patch is the same as the second part of patch for bug 3204171 !155,155 110303 remove processreserved ! my $source = $$code; ! my $answer = ''; ! my $identdef = $self->langinfo('identdef'); !-158,165 110303 replace regexp substitution ! while ( $source =~ s/^(.*?)($identdef)\b//s){ ! $answer .= "$1" . ! ( $self->isreserved($2) ! ? "<span class='reserved'>$2</span>" ! : ! ( $index->issymbol($2, $$self{'releaseid'}) ! ? join($2, @{$$self{'itag'}}) ! : $2 ! ) ! ); ! } ! $$code = $answer . $source; --------------------------- end of patch ------------------------- ---------------------------------------------------------------------- You can respond by visiting: https://sourceforge.net/tracker/?func=detail&atid=390117&aid=3204197&group_id=27350 |