diff options
| -rw-r--r-- | SBO-Lib/lib/SBO/Lib/Info.pm | 7 | ||||
| -rw-r--r-- | t/32-info.t | 19 | 
2 files changed, 21 insertions, 5 deletions
diff --git a/SBO-Lib/lib/SBO/Lib/Info.pm b/SBO-Lib/lib/SBO/Lib/Info.pm index f117be6..03e740a 100644 --- a/SBO-Lib/lib/SBO/Lib/Info.pm +++ b/SBO-Lib/lib/SBO/Lib/Info.pm @@ -216,9 +216,10 @@ sub parse_info {      my $pos = 0;      my %ret; -    while ($info_str =~ /\G([A-Za-z0-9_]+)="([^"]*)"\s*\n/g) { -        my $key = $1; -        my @val = split " ", $2; +    while ($info_str =~ /\G([A-Za-z0-9_]+)="([^"]*)"\s*(?:\n|\z)/g) { +        my ($key, $val) = ($1, $2); +        $val =~ s/\\[ \t]*$/ /mg; +        my @val = split " ", $val;          @val = '' unless @val;          $ret{$key} = \@val;          $pos = pos($info_str); diff --git a/t/32-info.t b/t/32-info.t index 8b74e4b..ebada04 100644 --- a/t/32-info.t +++ b/t/32-info.t @@ -9,7 +9,7 @@ use FindBin '$RealBin';  use lib "$RealBin/../SBO-Lib/lib";  use SBO::Lib 'parse_info'; -plan tests => 16; +plan tests => 23;  my %parse = parse_info(<<"END");  FOO="bar" @@ -19,6 +19,14 @@ BAZ="barf foof   bazf"  QUUX="finf"  FLAR_f="trailing whitespace"    +FLINGLE="\ +glorg \ +glorg \  +and\ +a\ + gloob\  +blorx\ +"  END  is ($parse{FOO}[0], 'bar', 'bar value gotten from FOO key'); @@ -36,5 +44,12 @@ is ($parse{QUUX}[1], undef, 'QUUX key has correct length');  is ($parse{FLAR_f}[0], 'trailing', 'trailing value gotten from FLAR_f key');  is ($parse{FLAR_f}[1], 'whitespace', 'whitespace value gotten from FLAR_f key');  is ($parse{FLAR_f}[2], undef, 'FLAR_f key has correct length'); -delete @parse{qw/ FOO BAR BAZ QUUX FLAR_f /}; +is ($parse{FLINGLE}[0], 'glorg', 'glorg value gotten from FLINGLE key'); +is ($parse{FLINGLE}[1], 'glorg', 'glorg value gotten from FLINGLE key'); +is ($parse{FLINGLE}[2], 'and', 'and value gotten from FLINGLE key'); +is ($parse{FLINGLE}[3], 'a', 'a value gotten from FLINGLE key'); +is ($parse{FLINGLE}[4], 'gloob', 'gloob value gotten from FLINGLE key'); +is ($parse{FLINGLE}[5], 'blorx', 'blorx value gotten from FLINGLE key'); +is ($parse{FLINGLE}[6], undef, 'FLINGLE key has corect length'); +delete @parse{qw/ FOO BAR BAZ QUUX FLAR_f FLINGLE /};  is (scalar %parse, 0, 'no additional keys were parsed');  | 
