Changeset 98


Ignore:
Timestamp:
05/11/07 13:49:18 (17 years ago)
Author:
kdeugau
Message:

/trunk

Further expand support for %if constructs - a == b and other
logical structures are now supported

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/debbuild

    r97 r98  
    6060my %specglobals;        # For %define's in specfile, among other things.
    6161
     62$specglobals{'_vendor'} = 'debbuild';
     63
    6264# Initialized globals
    6365my $verbosity = 0;
     
    442444      if (/^\%if/) {
    443445        s/^\%if//;
     446        chomp;
    444447        my $expr = expandmacros($_, 'g');
    445448        $iflevel++;
     449
     450        if ($expr !~ /^\s*\d+\s*$/) {
     451          # gots a logic statement we want to turn into a 1 or a 0.  most likely by eval'ing it.
     452
     453          $expr =~ s/\s+//g;
     454          $expr =~ s/^(\w+)/"$1"/ if $expr !~ /^['"]\w['"]/;
     455          $expr =~ s/(\w+)$/"$1"/ if $expr !~ /['"]\w['"]$/;
     456
     457          # Done in this order so we don't cascade incorrectly.  Yes, those spaces ARE correct in the replacements!
     458          $expr =~ s/==/ eq /;
     459          $expr =~ s/!=/ ne /;
     460          $expr =~ s/<=>/ cmp /;
     461          $expr =~ s/<=/ le /;
     462          $expr =~ s/>=/ ge /;
     463          $expr =~ s/</ lt /;
     464          $expr =~ s/>/ gt /;
     465
     466          # Turn it into something that eval's to a number.  Maybe not needed?  O_o
     467          #$expr = "( $expr ? 1 : 0 )";
     468
     469          $expr = eval $expr;
     470        }
     471
    446472        next LINE if $expr != 0;        # This appears to be the only case we call false.
    447473        while (<SPECFILE>) {
Note: See TracChangeset for help on using the changeset viewer.