Bug 1007938: MySQLConfig doesn't support end-of-line comments

Patch provided by Kaiwang CHEN (~kaiwang-chen) on Launchpad.
This commit is contained in:
Brian Fraser fraserb@gmail.com
2012-06-11 12:33:45 -03:00
parent 87f32cc857
commit d387b22c07
3 changed files with 15 additions and 2 deletions

View File

@@ -337,8 +337,9 @@ sub _parse_varvals {
ITEM: ITEM:
foreach my $item ( @varvals ) { foreach my $item ( @varvals ) {
if ( $item ) { if ( $item ) {
# Strip leading and trailing whitespace. # Strip leading and trailing whitespace, and trailing comments.
$item =~ s/^\s+//; $item =~ s/^\s+//;
$item =~ s/[#;].*$//;
$item =~ s/\s+$//; $item =~ s/\s+$//;
} }

View File

@@ -9,7 +9,7 @@ BEGIN {
use strict; use strict;
use warnings FATAL => 'all'; use warnings FATAL => 'all';
use English qw(-no_match_vars); use English qw(-no_match_vars);
use Test::More tests => 30; use Test::More tests => 31;
use MySQLConfig; use MySQLConfig;
use DSNParser; use DSNParser;
@@ -827,6 +827,16 @@ SKIP: {
); );
} }
$config = new MySQLConfig(
file => "$trunk/t/lib/samples/configs/mycnf-kc-001.txt",
TextResultSetParser => $trp,
);
is(
$config->value_of('user'),
'mysql',
'end of line comment in option file'
);
# ############################################################################# # #############################################################################
# Done. # Done.
# ############################################################################# # #############################################################################

View File

@@ -0,0 +1,2 @@
[mysqld]
user=mysql ; comment