OpenPKG CVS Repository
  http://cvs.openpkg.org/
  ____________________________________________________________________________

  Server: cvs.openpkg.org                  Name:   Michael van Elst
  Root:   /e/openpkg/cvs                   Email:  [EMAIL PROTECTED]
  Module: openpkg-re                       Date:   12-Nov-2002 14:47:33
  Branch: HEAD                             Handle: 2002111213473200

  Modified files:
    openpkg-re              openpkg-index

  Log:
    no more condition sorting to match upn code with static #if structure
    include module description in RDF

  Summary:
    Revision    Changes     Path
    1.4         +42 -20     openpkg-re/openpkg-index
  ____________________________________________________________________________

  Index: openpkg-re/openpkg-index
  ============================================================
  $ cvs diff -u -r1.3 -r1.4 openpkg-index
  --- openpkg-re/openpkg-index  12 Nov 2002 11:23:27 -0000      1.3
  +++ openpkg-re/openpkg-index  12 Nov 2002 13:47:32 -0000      1.4
  @@ -100,8 +100,6 @@
   #
   # translate default section from spec-file
   # into a hash
  -# extended lines have already been concatenated
  -# comment lines have already been removed
   # %if/%ifdef/%define... are translated to #if/#ifdef/#define
   #
   # #defines are interpolated (correct ?)
  @@ -120,6 +118,12 @@
       my($l, $v, $cond, $d, $p);
       my($re,@defs);
   
  +    # combine multilines
  +    $s =~ s/\\\n/ /sg;
  +
  +    # remove comments
  +    $s =~ s/^\s*#.*?\n//mg;
  +
       #
       # map conditional variable macros
       #
  @@ -161,7 +165,7 @@
                   if (defined $1) {
                       $term .= " $1 ";
                   } elsif (exists $evar{$2}) {
  -                    $term .= ($3 eq 'no' ? '! ' : '').vsub(\%evar,$evar{$2});
  +                    $term .= ($3 eq 'no' ? '! ' : '').vsub(\%evar,'%{'.$2.'}');
                   } else {
                       die "ERROR: unknown conditional: $l\n== $v\n";
                   }
  @@ -172,14 +176,14 @@
               #
               if ($term ne '') {
                   push @term, "( $term )";
  -                $cond = join(' && ',sort @term).'';
  +                $cond = join(' && ', @term).'';
               }
           } elsif ($v =~ /^\#endif\s*$/) {
               #
               # unwind last #if expression
               #
               pop @term;
  -            $cond = join(' + ',sort @term).'';
  +            $cond = join(' + ', @term).'';
   
           } elsif ($v =~ /^\#(?:define)\s*(\S+)\s*(.*?)\s*$/) {
   
  @@ -226,12 +230,7 @@
   sub spec2data ($) {
       my($s) = @_;
       my(%map);
  -
  -    # combine multilines
  -    $s =~ s/\\\n/ /sg;
  -
  -    # remove comments
  -    $s =~ s/^\s*#.*?\n//mg;
  +    my($a);
   
       # map commands
       $s =~ s/^%(ifdef|ifndef|if|define|endif|\{)/#$1/mg;
  @@ -245,7 +244,12 @@
           }
       }
   
  -    return package2data($map{'*'});
  +    $a = package2data($map{'*'});
  +    if (exists $map{'description'}) {
  +        $a->{'Description'} = $map{'description'};
  +    }
  +
  +    return $a;
   }
   
   ##########################################################################
  @@ -282,6 +286,22 @@
   }
   
   #
  +# send out $a->{$k} as text-style tag
  +#
  +sub xml_text ($$$;$) {
  +    my($i,$a,$k,$tag) = @_;
  +    my($out);
  +    return "" unless exists $a->{$k};
  +    $tag = $k unless defined $tag;
  +    $i = ' ' x $i;
  +
  +    $out = e($a->{$k});
  +    $out .= "\n" unless $out =~ /\n$/s;
  +
  +    return "$i<$tag>\n$out$i</$tag>\n";
  +}
  +
  +#
   # send out @{$a->{$k}} as body of an XML tag
   # $k is the name of the tag unless overridden by $tag
   # $i denotes the depth of indentation to form nicely
  @@ -296,10 +316,11 @@
       return "" unless exists $a->{$k};
       $tag = $k unless defined $tag;
       $out = '';
  +    $i = ' ' x $i;
   
       foreach $cond (sort keys %{$a->{$k}}) {
           $upn = e(upn($cond));
  -        $out .= (' ' x $i).
  +        $out .= $i.
               ($cond ne '' ?  "<$tag cond=\"$upn\">" : "<$tag>").
               join("\n", map { e($_) } @{$a->{$k}->{$cond}}).
               "</$tag>\n";
  @@ -320,17 +341,18 @@
       return "" unless exists $a->{$k};
       $tag = $k unless defined $tag;
       $out = '';
  +    $i = ' ' x $i;
   
       foreach $cond (sort keys %{$a->{$k}}) {
           $upn = e(upn($cond));
  -        $out .= (' ' x $i).
  +        $out .= $i.
                   ($cond ne '' ? "<$tag cond=\"$upn\">\n" : "<$tag>\n").
  -                (' ' x ($i+2))."<rdf:bag>\n".
  +                "$i  <rdf:bag>\n".
                   join("",
  -                     map { (' ' x ($i+4))."<rdf:li>".e($_)."</rdf:li>\n" }
  +                     map { "$i    <rdf:li>".e($_)."</rdf:li>\n" }
                        @{$a->{$k}->{$cond}}).
  -                (' ' x ($i+2))."</rdf:bag>\n".
  -                (' ' x $i)."</$tag>\n";
  +                "$i  </rdf:bag>\n".
  +                "$i</$tag>\n";
       }
   
       return $out;
  @@ -391,7 +413,8 @@
           xml_bag(6, $a, 'PreReq'),
           xml_bag(6, $a, 'Provides'),
           xml_bag(6, $a, 'Conflicts'),
  -        xml_bag(6, $a, 'Source');
  +        xml_bag(6, $a, 'Source'),
  +        xml_text(6, $a, 'Description');
   
       print $fh <<EOFEOF;
       </rdf:Description>
  @@ -417,7 +440,6 @@
   while ($d = $dh->read) {
       next if $d =~ /^\./;
       $specpath = "$prefix/$d/$d.spec";
  -    warn "$specpath\n";
       if (-f $specpath) {
           $s = `cat $specpath`;
           $a = spec2data($s)
______________________________________________________________________
The OpenPKG Project                                    www.openpkg.org
CVS Repository Commit List                     [EMAIL PROTECTED]

Reply via email to