Update of /cvsroot/fink/fink/perlmod/Fink
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv24813

Modified Files:
        Services.pm PkgVersion.pm Engine.pm ChangeLog 
Log Message:
New param to control whether Services::expand_percent() dies, warns,
or ignores if unknown % key. Set processing of DescDetail and
DescUsage to ignore unknown % keys.


Index: Engine.pm
===================================================================
RCS file: /cvsroot/fink/fink/perlmod/Fink/Engine.pm,v
retrieving revision 1.220
retrieving revision 1.221
diff -u -d -r1.220 -r1.221
--- Engine.pm   14 Jan 2005 11:12:03 -0000      1.220
+++ Engine.pm   18 Jan 2005 07:59:13 -0000      1.221
@@ -2098,7 +2098,7 @@
                        } elsif ($_ =~ /^desc(detail|usage)$/) {
                                # multiline field, so indent 1 space always
                                # format_description does that for us
-                               print "$_:\n", 
Fink::PkgVersion::format_description($pkg->param_expanded($_)) if 
$pkg->has_param($_);
+                               print "$_:\n", 
Fink::PkgVersion::format_description($pkg->param_expanded($_, 2)) if 
$pkg->has_param($_);
                        } elsif ($_ eq 'type'       or $_ eq 'license' or
                                         $_ eq 'maintainer' or $_ eq 'homepage'
                                        ) {

Index: PkgVersion.pm
===================================================================
RCS file: /cvsroot/fink/fink/perlmod/Fink/PkgVersion.pm,v
retrieving revision 1.344
retrieving revision 1.345
diff -u -d -r1.344 -r1.345
--- PkgVersion.pm       17 Jan 2005 06:07:09 -0000      1.344
+++ PkgVersion.pm       18 Jan 2005 07:59:12 -0000      1.345
@@ -303,8 +303,10 @@
 
 sub param_expanded {
        my $self = shift;
-       return &expand_percent($self->param(@_), $self->{_expand},
-               $self->get_info_filename." \"$_[0]\"");
+       my $field = shift;
+       my $err_action = shift;
+       return &expand_percent($self->param($field), $self->{_expand},
+               $self->get_info_filename." \"$field\"", $err_action);
 }
 
 # param_default_expanded FIELD, DEFAULT
@@ -1033,13 +1035,13 @@
        $desc .= "\n";
 
        if ($self->has_param("DescDetail")) {
-               $desc .= 
&format_description($self->param_expanded("DescDetail"));
+               $desc .= 
&format_description($self->param_expanded("DescDetail", 2));
        }
 
        if ($style != 1) {
                if ($self->has_param("DescUsage")) {
                        $desc .= " .\n Usage Notes:\n";
-                       $desc .= 
&format_description($self->param_expanded("DescUsage"));
+                       $desc .= 
&format_description($self->param_expanded("DescUsage", 2));
                }
 
                if ($self->has_param("Homepage")) {

Index: Services.pm
===================================================================
RCS file: /cvsroot/fink/fink/perlmod/Fink/Services.pm,v
retrieving revision 1.142
retrieving revision 1.143
diff -u -d -r1.142 -r1.143
--- Services.pm 17 Jan 2005 05:04:42 -0000      1.142
+++ Services.pm 18 Jan 2005 07:59:11 -0000      1.143
@@ -580,6 +580,7 @@
     my $string = expand_percent $template;
     my $string = expand_percent $template, \%map;
     my $string = expand_percent $template, \%map, $err_info;
+    my $string = expand_percent $template, \%map, $err_info, $err_action;
 
 Performs percent-expansion on the given multiline $template according
 to %map (if one is defined). If a line in $template begins with #
@@ -593,9 +594,16 @@
 limitted to a single additional level (only (up to) two passes are
 made). If there are still % chars left after the recursion, that means
 $template needs more passes (beyond the recursion limit) or there are
-% patterns in $template that are not in %map. If either of these two
-cases occurs, the program will die with an error message. If given,
-$err_info will be appended to this error message.
+% patterns in $template that are not in %map. The value of $err_action
+determins what happens if either of these two cases occurs:
+
+  0 (or undef or not specified)
+         die with error message
+  1      print error message but ignore
+  2      silently ignore
+
+If given, $err_info will be appended to the error message. "Ignore" in
+this context means the unknown % is left intact in the string.
 
 To get an actual percent char in the string, protect it as %% in
 $template (similar to printf()). This occurs whether or not there is a
@@ -617,6 +625,7 @@
        my $s = shift;
        my $map = shift || {};
        my $err_info = shift;
+       my $err_action = shift || 0;
        my ($key, $value, $i, @lines, @newlines, %map, $percent_keys);
 
        return $s if (not defined $s);
@@ -662,11 +671,13 @@
                        # The presence of a sequence of an odd number
                        # of percent chars means we have unexpanded
                        # percents besides (%% => %) left. Error out.
-                       if ($s =~ /(?<!\%)(\%\%)*\%(?!\%)/) {
+                       if ($s =~ /(?<!\%)(\%\%)*\%(?!\%)/ and $err_action != 
2) {
                                my $errmsg = "Error performing percent 
expansion: unknown % expansion or nesting too deep: \"$s\"";
                                $errmsg .= " ($err_info)" if defined $err_info;
                                $errmsg .= "\n";
-                               die $errmsg;
+                               $err_action
+                                       ? print $errmsg
+                                       : die $errmsg;
                        }
                        # Now handle %% => %
                        $s =~ s/\%\%/\%/g;

Index: ChangeLog
===================================================================
RCS file: /cvsroot/fink/fink/perlmod/Fink/ChangeLog,v
retrieving revision 1.810
retrieving revision 1.811
diff -u -d -r1.810 -r1.811
--- ChangeLog   17 Jan 2005 06:14:10 -0000      1.810
+++ ChangeLog   18 Jan 2005 07:59:14 -0000      1.811
@@ -1,3 +1,11 @@
+2005-01-18  Daniel Macks  <[EMAIL PROTECTED]>
+
+       * Services.pm: add new param to expand_percent() to reduce
+       unknown-% from die to warn+ignore or silent+ignore.
+       * PkgVersion.pm: param_expanded() silently ignores unknown %-exp.
+       * Engine.pm, PkgVersion.pm: allow unknown % in DescDetail and
+       DescUsage.
+
 2005-01-17  Daniel Macks  <[EMAIL PROTECTED]>
 
        * VirtPackage.pm: Add "system-xfree86-manual-install" as a



-------------------------------------------------------
The SF.Net email is sponsored by: Beat the post-holiday blues
Get a FREE limited edition SourceForge.net t-shirt from ThinkGeek.
It's fun and FREE -- well, almost....http://www.thinkgeek.com/sfshirt
_______________________________________________
Fink-commits mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/fink-commits

Reply via email to