This is the mail archive of the
cygwin-apps
mailing list for the Cygwin project.
Re: genini: message field always emitted
Christopher Faylor wrote:
> genini shouldn't assume that message is required and setup.exe shouldn't
> have to care about blank messages.
>
> Btw, the syntax is (or should be):
>
> message keyword "something"
>
> That's why you're seeing a syntax error.
Thx. So, the attached works for me...OK?
2010-03-11 Charles Wilson <...>
* genini: Add new array variables to hold and categorize
keywords. Add the optional keywords to okmissing. Use the
keyword arrays when iterating.
(get): For message keyword, only attempt to process $val
if non-empty. Also, explicitly parse $val, not $_.
--
Chuck
Index: genini
===================================================================
RCS file: /cvs/cygwin-apps/genini/genini,v
retrieving revision 1.10
diff -u -p -r1.10 genini
--- genini 11 Mar 2010 23:50:29 -0000 1.10
+++ genini 12 Mar 2010 02:19:15 -0000
@@ -18,11 +18,17 @@ sub usage();
my @okmissing;
my ($outfile, $help, $recursive);
my @cmp_fmts = qw(gz bz2 lzma xz);
+my @required_pkgkeys = qw(sdesc ldesc category requires);
+my @optional_pkgkeys = qw(message);
+my @pkgkeys = (@required_pkgkeys, @optional_pkgkeys);
+my @verkeys = qw(version install source);
+
GetOptions('okmissing=s'=>\@okmissing, 'output=s'=>\$outfile, 'help'=>\$help, 'recursive'=>\$recursive) or usage;
$help and usage;
@main::okmissing{@okmissing} = @okmissing;
+@main::okmissing{@optional_pkgkeys} = @optional_pkgkeys;
if (defined($outfile)) {
open(STDOUT, '>', $outfile) or die "$0: can't open $outfile - $!\n";
@@ -51,7 +57,7 @@ print "$main::setup_version\n" if $main:
undef $main::curfile;
for my $p (sort keys %pkg) {
print "\n@ $p\n";
- for my $key ('sdesc', 'ldesc', 'category', 'requires', 'message') {
+ for my $key (@pkgkeys) {
my $val = $pkg{$p}{''}{$key};
if (!defined($val) && $pkg{$p}{''}{'install'} !~ /_obsolete/o) {
mywarn "package $p is missing a $key field"
@@ -74,7 +80,7 @@ for my $p (sort keys %pkg) {
for my $what ('', "[prev]\n", "[test]\n") {
$pkg{$p}{$what} or next;
print "$what";
- for my $key ('version', 'install', 'source') {
+ for my $key (@verkeys) {
my $val = $pkg{$p}{$what}{$key} or next;
print "$key: ", $val, "\n";
}
@@ -87,8 +93,10 @@ sub get {
my $val = shift;
if ($keyhint eq 'message') {
- my ($kw, $rest) = /^(\S+)\s+(.*)$/;
- return $kw . ' ' . get($FH, 'ldesc', $rest);
+ if ($val) {
+ my ($kw, $rest) = $val =~ /^(\S+)\s+(.*)$/;
+ return $kw . ' ' . get($FH, 'ldesc', $rest);
+ }
} elsif (substr($val, 0, 1) ne '"') {
$val = '"'. $val . '"' if $keyhint eq 'ldesc' || $keyhint eq 'sdesc';
} else {
@@ -99,7 +107,7 @@ sub get {
s/(\S)\s+$/$1/;
$val .= "\n" . $_;
}
- }
+ }
$val =~ s/(.)"(.)/$1'$2/mog;
return $val;
}