Revision: 115
Author:   matt
Date:     2006-08-24 00:03:58 +0000 (Thu, 24 Aug 2006)

Log Message:
-----------
Allow both single and double quotes in config values

Modified Paths:
--------------
    trunk/lib/AxKit2/Config.pm

Modified: trunk/lib/AxKit2/Config.pm
===================================================================
--- trunk/lib/AxKit2/Config.pm  2006-08-24 00:03:31 UTC (rev 114)
+++ trunk/lib/AxKit2/Config.pm  2006-08-24 00:03:58 UTC (rev 115)
@@ -167,17 +167,18 @@
 
 sub _get_quoted {
     my $line = shift;
+    my $quotechar = shift;
     
     my $out = '';
-    $line =~ s/^"//;
-    while ($line =~ /\G(.*?)([\\\"])/gc) {
+    $line =~ s/^$quotechar//;
+    while ($line =~ /\G(.*?)([\\$quotechar])/gc) {
         $out .= $1;
         my $token = $2;
         if ($token eq "\\") {
-            $line =~ /\G([\"\\])/gc || die "invalid escape char";
+            $line =~ /\G([$quotechar\\])/gc || die "invalid escape char";
             $out .= $1;
         }
-        elsif ($token eq '"') {
+        elsif ($token eq $quotechar) {
             $line =~ /\G\s*(.*)$/gc;
             return $out, $1;
         }
@@ -198,9 +199,9 @@
     my $str = shift;
     my @vals;
     while (length($str)) {
-        if ($str =~ /^"/) {
+        if ($str =~ /^(["'])/) {
             my $val;
-            ($val, $str) = _get_quoted($str);
+            ($val, $str) = _get_quoted($str, $1);
             push @vals, $val;
         }
         else {


Reply via email to