diff --git a/lib/MySQLConfig.pm b/lib/MySQLConfig.pm index 5cdf857f..ff6f1e1a 100644 --- a/lib/MySQLConfig.pm +++ b/lib/MySQLConfig.pm @@ -337,8 +337,9 @@ sub _parse_varvals { ITEM: foreach my $item ( @varvals ) { if ( $item ) { - # Strip leading and trailing whitespace. + # Strip leading and trailing whitespace, and trailing comments. $item =~ s/^\s+//; + $item =~ s/[#;].*$//; $item =~ s/\s+$//; } diff --git a/t/lib/MySQLConfig.t b/t/lib/MySQLConfig.t index 86cde81c..04208aa2 100644 --- a/t/lib/MySQLConfig.t +++ b/t/lib/MySQLConfig.t @@ -9,7 +9,7 @@ BEGIN { use strict; use warnings FATAL => 'all'; use English qw(-no_match_vars); -use Test::More tests => 30; +use Test::More tests => 31; use MySQLConfig; 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. # ############################################################################# diff --git a/t/lib/samples/configs/mycnf-kc-001.txt b/t/lib/samples/configs/mycnf-kc-001.txt new file mode 100644 index 00000000..5e6f2c76 --- /dev/null +++ b/t/lib/samples/configs/mycnf-kc-001.txt @@ -0,0 +1,2 @@ +[mysqld] +user=mysql ; comment