A recent addition of a message field to Cygwin's setup.hint broke
genini. The introduction of a new unquoted token between the key and
the value confused the get subroutine. The attached patch adds a
special case for message fields, allowing correct parsing in this
particular case.
I'm not sure this is really the best solution. It would perhaps be
better to treat double quotes as the start and end of a word regardless
of when the quotes begin and end on the line.
2010-02-26 Brendan Conoboy <b...@redhat.com>
* genini (get): Handle special 'message' format case.
--
Brendan Conoboy / Red Hat, Inc. / b...@redhat.com
*** genini.old 2010-02-26 22:46:43.250406000 -0500
--- genini 2010-02-26 22:41:06.680957000 -0500
***************
*** 49,55 ****
undef $main::curfile;
for my $p (sort keys %pkg) {
print "\n@ $p\n";
! for my $key ('sdesc', 'ldesc', 'category', 'requires') {
my $val = $pkg{$p}{''}{$key};
if (!defined($val) && $pkg{$p}{''}{'install'} !~ /_obsolete/o) {
mywarn "package $p is missing a $key field"
--- 49,55 ----
undef $main::curfile;
for my $p (sort keys %pkg) {
print "\n@ $p\n";
! for my $key ('sdesc', 'ldesc', 'category', 'requires', 'message') {
my $val = $pkg{$p}{''}{$key};
if (!defined($val) && $pkg{$p}{''}{'install'} !~ /_obsolete/o) {
mywarn "package $p is missing a $key field"
***************
*** 84,92 ****
my $key = shift;
my $val = shift;
! if (substr($val, 0, 1) ne '"') {
! $val = '"'. $val . '"' if $key eq 'ldesc' || $key eq 'sdesc';
! } else {
while (length($val) == 1 || $val !~ /"$/os) {
$_ = <$FH>;
length or last;
--- 84,90 ----
my $key = shift;
my $val = shift;
! if ( (substr($val, 0, 1) eq '"') or ($key eq "message" and $val =~
/\w\s+"/) ) {
while (length($val) == 1 || $val !~ /"$/os) {
$_ = <$FH>;
length or last;
***************
*** 94,101 ****
s/(\S)\s+$/$1/;
$val .= "\n" . $_;
}
}
! $val =~ s/(.)"(.)/$1'$2/mog;
return $val;
}
--- 92,105 ----
s/(\S)\s+$/$1/;
$val .= "\n" . $_;
}
+ } else {
+ $val = '"'. $val . '"' if $key eq 'ldesc' || $key eq 'sdesc';
}
! if ( $key eq "message" ) {
! $val =~ s/(\w\s+".*)"(.)/$1'$2/mog;
! } else {
! $val =~ s/(.)"(.)/$1'$2/mog;
! }
return $val;
}