Author: spadkins
Date: Thu Apr  2 11:20:31 2009
New Revision: 12670

Modified:
   p5ee/trunk/App-Options/CHANGES
   p5ee/trunk/App-Options/lib/App/Options.pm
   p5ee/trunk/App-Options/t/app.conf
   p5ee/trunk/App-Options/t/main.t

Log:
1.07 - allow dashes in variable names

Modified: p5ee/trunk/App-Options/CHANGES
==============================================================================
--- p5ee/trunk/App-Options/CHANGES      (original)
+++ p5ee/trunk/App-Options/CHANGES      Thu Apr  2 11:20:31 2009
@@ -2,6 +2,12 @@
 # CHANGE LOG
 #############################################################################
 
+VERSION 1.07
+ x Allow dashes ("-") as a variable name (i.e. foo-bar = 1).
+   In doing this, I actually allow that any characters other than 
spaces/tabs/= can make up the variable name
+ x Trim leading and trailing tabs (as well as spaces) from the line
+
+VERSION 1.05
 VERSION 1.06
  x Remove trailing \r from option files (for Windows-edited .conf files)
 

Modified: p5ee/trunk/App-Options/lib/App/Options.pm
==============================================================================
--- p5ee/trunk/App-Options/lib/App/Options.pm   (original)
+++ p5ee/trunk/App-Options/lib/App/Options.pm   Thu Apr  2 11:20:31 2009
@@ -14,7 +14,7 @@
 use File::Spec;
 use Config;
 
-$VERSION = "1.06";
+$VERSION = "1.07";
 
 =head1 NAME
 
@@ -1099,12 +1099,12 @@
                 next if ($exclude_section);
 
                 s/#.*$//;        # delete comments
-                s/^ +//;         # delete leading spaces
-                s/ +$//;         # delete trailing spaces
+                s/^\s+//;         # delete leading spaces
+                s/\s+$//;         # delete trailing spaces
                 next if (/^$/);  # skip blank lines
 
                 # look for "var = value" (ignore other lines)
-                if (/^([a-zA-Z0-9_.-{}]+)\s*=\s*(.*)/) {  # untainting also 
happens
+                if (/^([^\s=]+)\s*=\s*(.*)/) {  # untainting also happens
                     $var = $1;
                     $value = $2;
 

Modified: p5ee/trunk/App-Options/t/app.conf
==============================================================================
--- p5ee/trunk/App-Options/t/app.conf   (original)
+++ p5ee/trunk/App-Options/t/app.conf   Thu Apr  2 11:20:31 2009
@@ -52,5 +52,6 @@
 var25 = This is text \
 and more text
 var26 = normal
+foo-bar = 1
 
 flush_imports = 1

Modified: p5ee/trunk/App-Options/t/main.t
==============================================================================
--- p5ee/trunk/App-Options/t/main.t     (original)
+++ p5ee/trunk/App-Options/t/main.t     Thu Apr  2 11:20:31 2009
@@ -123,6 +123,7 @@
 # $ENV{X} variable substitution tests
 ok($App::options{envtest} eq "xyzzy", "\$ENV{X} variable substitution worked");
 ok($App::options{plugh} eq "twisty passages", "auto-import of APP_ env vars 
worked");
+ok(defined $App::options{"foo-bar"} && $App::options{"foo-bar"} eq "1", 
"foo-bar = 1 (dash in option key)");
 
 exit 0;
 

Reply via email to