Changeset 26466

Show
Ignore:
Timestamp:
15.11.2012 14:02:26 (7 years ago)
Author:
ak19
Message:

Need to handle on/off flags which take optional values. If these flags are present, their 'value' defaults to true

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • main/trunk/greenstone2/perllib/collConfigxml.pm

    r26452 r26466  
    316316    # these get stored in-memory at the top level as (n, v) pairs, just as in GS2 
    317317    elsif ($currentLevel =~ /$generalOptions/ and $element eq "option") { 
    318     if (defined $name and $name =~ /\w/ and defined $value and $value =~ /\w/) { 
    319         #$data->{$currentLevel}->{$name} = $value; 
    320         $data->{$name} = $value; 
     318    if (defined $name and $name =~ /\w/) { 
     319 
     320        # if a flag's value is on or 1, set it to true. If the value is off or 0, set it to false. (GS2 expects true/false) 
     321        # But such on/off flags (like -gli) need not be given a value, in which case the value defaults to 'true' again. 
     322 
     323        if(defined $value and $value =~ /\w/) {      
     324 
     325        if ($value =~ m/^(on|1)$/) { 
     326            $value = "true"; 
     327        } elsif ($value =~ m/^(off|0)$/) { 
     328            $value = "false"; 
     329        } # else, use whatever value is provided 
     330 
     331        }  
     332        else { 
     333        $value = "true"; 
     334        } 
     335        $data->{$name} = $value; #$data->{$currentLevel}->{$name} = $value; 
    321336        #print "@@@@ Added $currentLevel option: $name=$value\n"; 
    322337    }