Jelajahi Sumber

fix also indexing in new %options world

Ralf S. Engelschall 23 tahun lalu
induk
melakukan
e6a18dd069
1 mengubah file dengan 9 tambahan dan 11 penghapusan
  1. 9 11
      openpkg-tool/openpkg-index.pl

+ 9 - 11
openpkg-tool/openpkg-index.pl

@@ -126,15 +126,12 @@ sub upn ($) {
 #
 # deduce external variables from description
 #
-sub find_options ($) {
-    my($descr) = @_;
-    my(%evar);
-
-    %evar = map {
-        $1 => '%{'.$1.'}'
-    } $descr =~ /--define\s*'(\S+)\s*\%\{\1\}'/;
-
-    return \%evar;
+sub find_options ($$) {
+    my($spec, $descr) = @_;
+    my $evar = {};
+    $descr =~ s/--define\s*'(\S+)\s*\%\{\1\}'/$evar->{$1} = '%{'.$1.'}', ''/sge; # before openpkg-20021230
+    $spec =~ s/^%option\s*(\S+)\s+\S+/$evar->{$1} = '%{'.$1.'}', ''/mge;         # after  openpkg-20021230
+    return $evar;
 }
 
 #
@@ -292,12 +289,13 @@ sub spec2data ($) {
     my($s) = @_;
     my(%map);
     my($a,$o);
+    my $spec = $s;
 
     # remove comments
     $s =~ s/^\s*#.*?\n//mg;
 
     # map commands
-    $s =~ s/^%(ifdef|ifndef|if|define|else|endif|\{)/#$1/mg;
+    $s =~ s/^%(ifdef|ifndef|if|option|define|else|endif|\{)/#$1/mg;
 
     # split sections
     foreach (split(/^(?=%\w+\s*\n)/m, $s)) {
@@ -308,7 +306,7 @@ sub spec2data ($) {
         }
     }
 
-    $o = find_options($map{'description'});
+    $o = find_options($spec, $map{'description'});
     $a = package2data($map{'*'}, $o);
     if (exists $map{'description'}) {
         $a->{'Description'} = { '' => [ $map{'description'} ] };