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

SF.net SVN: ledger-smb: [465] trunk/utils/cli



Revision: 465
          http://svn.sourceforge.net/ledger-smb/?rev=465&view=rev
Author:   einhverfr
Date:     2006-11-02 09:07:56 -0800 (Thu, 02 Nov 2006)

Log Message:
-----------
Nested IF support for the CLI script host

Modified Paths:
--------------
    trunk/utils/cli/ledgersmb_cli.pl
    trunk/utils/cli/sample.lsmb

Modified: trunk/utils/cli/ledgersmb_cli.pl
===================================================================
--- trunk/utils/cli/ledgersmb_cli.pl	2006-11-02 06:58:01 UTC (rev 464)
+++ trunk/utils/cli/ledgersmb_cli.pl	2006-11-02 17:07:56 UTC (rev 465)
@@ -134,9 +134,7 @@
 sub if_handler {
 	my $key = shift;
 	if (!$stackref->{$key}){
-		while ($line !~ /^(\s*FI\s*|\s*END\s+IF\s*)$/ ){
-			$line = <>;
-		}
+		$if_count = 1;
 	}
 }
 
@@ -155,6 +153,15 @@
 my $scriptparse = new Parse::RecDescent($syntax);
 
 while ($line = <>){
+	if ($if_count){
+		if ($line =~ /^\s*IF\s/){
+			++$if_count;
+		}
+		if ($line =~ /^(\s*FI\s*|\s*END\s+IF\s*)$/){
+			--$if_count;
+		}
+	}
+	next if ($if_count);
 	$line =~ s/#.*$//; # strip comments
 	$scriptparse->startrule($line);
 }

Modified: trunk/utils/cli/sample.lsmb
===================================================================
--- trunk/utils/cli/sample.lsmb	2006-11-02 06:58:01 UTC (rev 464)
+++ trunk/utils/cli/sample.lsmb	2006-11-02 17:07:56 UTC (rev 465)
@@ -1,3 +1,4 @@
+# Comments start with a pund sign
 ENV:PGUSER = postgres # how to set an environment variable
 login = demo  # How to set a form variable
 password = demo  
@@ -7,3 +8,7 @@
 vc = customer
 db = customer
 CALL CT->create_links(user, form) # call a function
+IF bcc4 # Conditional IF's can be nested
+testing = hi
+FI
+


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