kareila: (Default)
kareila ([personal profile] kareila) wrote in [site community profile] changelog2010-12-23 04:53 pm

[s2] more undefined warnings in s2 repo

[commit: http://hg.dwscoalition.org/s2/rev/edaae09fa13e]

http://bugs.dwscoalition.org/show_bug.cgi?id=3328

Avoid warnings for undefined variables.

Patch by [personal profile] kareila.

Files modified:
  • S2/NodeTerm.pm
  • S2/Tokenizer.pm
--------------------------------------------------------------------------------
diff -r 4fdcb0ec6110 -r edaae09fa13e S2/NodeTerm.pm
--- a/S2/NodeTerm.pm	Sat Oct 30 12:20:47 2010 +0800
+++ b/S2/NodeTerm.pm	Thu Dec 23 10:53:34 2010 -0600
@@ -465,8 +465,11 @@ sub parse {
     }
 
     # function/method call
-    if ($nt->{'type'} == $METHCALL || $t->isa('S2::TokenIdent')) {
-        $nt->{'type'} = $FUNCCALL unless $nt->{'type'} == $METHCALL;
+    my $isa_methcall = defined $nt->{type} ?
+                       $nt->{type} == $METHCALL :
+                       ! defined $METHCALL;
+    if ( $isa_methcall || $t->isa('S2::TokenIdent') ) {
+        $nt->{'type'} = $FUNCCALL unless $isa_methcall;
         $nt->{'funcIdent'} = $nt->getIdent($toker);
         $nt->{'funcArgs'} = parse S2::NodeArguments $toker;
         $nt->addNode($nt->{'funcArgs'});
diff -r 4fdcb0ec6110 -r edaae09fa13e S2/Tokenizer.pm
--- a/S2/Tokenizer.pm	Sat Oct 30 12:20:47 2010 +0800
+++ b/S2/Tokenizer.pm	Thu Dec 23 10:53:34 2010 -0600
@@ -92,7 +92,8 @@ sub moveLineCol {
 #        print STDERR "Chars: $t [$t->{'chars'}] Lines: $newlines\n";
         $this->{'line'} += $newlines;
         $t->{'chars'} =~ /\n(.+)$/m;
-        $this->{'col'} = 1 + length $1;
+        my $match = defined $1 ? $1 : '';
+        $this->{col} = 1 + length $match;
     } else {
 #        print STDERR "Chars: $t [$t->{'chars'}]\n";
         $this->{'col'} += length $t->{'chars'};
--------------------------------------------------------------------------------