[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

SF.net SVN: ledger-smb: [2069] branches/1.2/LedgerSMB/Form.pm



Revision: 2069
          http://ledger-smb.svn.sourceforge.net/ledger-smb/?rev=2069&view=rev
Author:   tetragon
Date:     2008-02-10 10:11:57 -0800 (Sun, 10 Feb 2008)

Log Message:
-----------
Some substitution fixes for update_defaults

Modified Paths:
--------------
    branches/1.2/LedgerSMB/Form.pm

Modified: branches/1.2/LedgerSMB/Form.pm
===================================================================
--- branches/1.2/LedgerSMB/Form.pm	2008-02-10 16:39:47 UTC (rev 2068)
+++ branches/1.2/LedgerSMB/Form.pm	2008-02-10 18:11:57 UTC (rev 2069)
@@ -1140,7 +1140,7 @@
     my $pad;
     my $item;
 
-    while (/<\?lsmb (.+?) \?>/) {
+    TAG: while (/<\?lsmb (.+?) \?>/) {
 
         %a = ();
 
@@ -1168,12 +1168,11 @@
                 $var =~ s/if\s+not\s+//;
                 s/<\?lsmb if\s+not\s+$var \?>.*?(<\?lsmb end\s+$var \?>|$)//s;
 
-            }
-            else {
+            } else {
                 s/<\?lsmb $var \?>//;
             }
 
-            next;
+            next TAG;
         }
 
         if ( $var =~ /^if\s+/ ) {
@@ -1186,12 +1185,12 @@
                 s/<\?lsmb if\s+$var \?>.*?(<\?lsmb end\s+$var \?>|$)//s;
             }
 
-            next;
+            next TAG;
         }
 
         if ( $var =~ /^end\s+/ ) {
             s/<\?lsmb $var \?>//;
-            next;
+            next TAG;
         }
 
         if ( $a{align} || $a{width} || $a{offset} ) {
@@ -1347,10 +1346,11 @@
 
     my $key;
 
-    foreach $key ( @{ $replace{order}{$format} } ) {
-        for (@fields) { $self->{$_} =~ s/$key/$replace{$format}{$key}/g }
+    CHAR: foreach $key ( @{ $replace{order}{$format} } ) {
+        FIELD: for (@fields) {
+            $self->{$_} =~ s/$key/$replace{$format}{$key}/g;
+        }
     }
-
 }
 
 sub datetonum {
@@ -2947,6 +2947,7 @@
                         $self->{transdate}
                     )
                 )[0];
+		$param = quotemeta $param;
                 $var =~ s/$param/$str/;
             }
 
@@ -2965,21 +2966,19 @@
                 }
 
                 my $p = $param;
-                $p =~ s/(<|>|%)//g;
+                $p =~ s/(:<\?lsmb\s*|\s*\?>)//g;
                 my @p = split / /, $p;
                 my @n = split / /, uc $self->{$fld};
 
                 if ( $#p > 0 ) {
-
-                    for ( my $i = 1 ; $i <= $#p ; $i++ ) {
+                    foreach my $i (1 .. $#p) {
                         $str .= substr( $n[ $i - 1 ], 0, $p[$i] );
                     }
-
-                }
-                else {
+                } else {
                     ($str) = split /--/, $self->{$fld};
                 }
 
+                $param = quotemeta $param;
                 $var =~ s/$param/$str/;
                 $var =~ s/\W//g if $fld eq 'phone';
             }
@@ -2987,21 +2986,23 @@
             if ( $param =~ /<\?lsmb (yy|mm|dd)/i ) {
 
                 my $p = $param;
-                $p =~ s/(<|>|%)//g;
+                $p =~ s/(<\?lsmb\s*|\s*\?>)//g;
                 my $spc = $p;
-                $spc =~ s/\w//g;
+		$spc =~ s/\w//g;
                 $spc = substr( $spc, 0, 1 );
                 my %d = ( yy => 1, mm => 2, dd => 3 );
                 my @p = ();
 
-                my @a = $self->split_date( $myconfig->{dateformat},
+                my @date = $self->split_date( $myconfig->{dateformat},
                     $self->{transdate} );
-                for ( sort keys %d ) { push @p, $a[ $d{$_} ] if ( $p =~ /$_/ ) }
+                for ( sort keys %d ) { push @p, $date[ $d{$_} ] if ( $p =~ /$_/i ) }
                 $str = join $spc, @p;
+                $param = quotemeta $param;
                 $var =~ s/$param/$str/;
             }
 
             if ( $param =~ /<\?lsmb curr/i ) {
+                $param = quotemeta $param;
                 $var =~ s/$param/$self->{currency}/;
             }
         }


This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.