This is the mail archive of the cygwin-apps mailing list for the Cygwin project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: genini patch to support the new message field


On Fri, Feb 26, 2010 at 09:03:46PM -0700, Brendan Conoboy wrote:
>2010-02-26  Brendan Conoboy  <blc@redhat.com>
>
>         * genini (get): Handle special 'message' format case.
>
>***************
>*** 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+"/) ) {

(Please adhere to the rest of the file and use '||' and '&&' in if
expressions.)

I think it makes more sense to test for message initially and, if found skip
over the keyword and parse the rest of the line as normal:

Does this work?

cgf

Index: genini
===================================================================
RCS file: /cvs/cygwin-apps/genini/genini,v
retrieving revision 1.7
diff -d -u -r1.7 genini
--- genini	23 Feb 2007 16:24:17 -0000	1.7
+++ genini	28 Feb 2010 23:50:08 -0000
@@ -49,7 +49,7 @@
 undef $main::curfile;
 for my $p (sort keys %pkg) {
     print "\n@ $p\n";
-    for my $key ('sdesc', 'ldesc', 'category', 'requires') {
+    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"
@@ -81,11 +81,14 @@
 
 sub get {
     my $FH = shift;
-    my $key = shift;
+    my $keyhint = shift;
     my $val = shift;
 
-    if (substr($val, 0, 1) ne '"') {
-	$val = '"'. $val . '"' if $key eq 'ldesc' || $key eq 'sdesc';
+    if ($keyhint eq 'message') {
+	my ($kw, $rest) = /^(\S+)\s+(.*)$/;
+	return $kw . ' ' . get($FH, 'ldesc', $rest);
+    } elsif (substr($val, 0, 1) ne '"') {
+	$val = '"'. $val . '"' if $keyhint eq 'ldesc' || $keyhint eq 'sdesc';
     } else {
 	while (length($val) == 1 || $val !~ /"$/os) {
 	    $_ = <$FH>;


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]