Ignore:
Timestamp:
2000-07-13T10:21:53+12:00 (24 years ago)
Author:
sjboddie
Message:

merged changes to trunk into New_Config_Format branch

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/New_Config_Format-branch/gsdl/perllib/parsargv.pm

    r537 r1279  
    6464# Returns 0 if there was an error, nonzero otherwise.
    6565#
    66 sub parse
     66
     67 
     68 sub parse
    6769{
    6870    my $arglist = shift;
     
    7072    my %option;
    7173
    72     while (($spec, $var) = splice(@_, 0, 2))
    73     {
     74    my @rest = @_;
     75
     76    # if the last argument is the string "allow_extra_options" then options
     77    # in \@rest without a corresponding SPEC will be ignored (i.e. the "$arg is
     78    # not a valid option" error won't occur)\n";
     79    my $allow_extra_options = pop @rest;
     80    if (defined ($allow_extra_options)) {
     81    if ($allow_extra_options eq "allow_extra_options") {
     82        $allow_extra_options = 1;
     83    } else {
     84        # put it back where we got it
     85        push (@rest, $allow_extra_options);
     86        $allow_extra_options = 0;
     87    }
     88    } else {
     89    $allow_extra_options = 0;
     90    }
     91
     92    while (($spec, $var) = splice(@rest, 0, 2))
     93        {
    7494    die "Variable for $spec is not a valid type."
    7595        unless ref($var) eq 'SCALAR' || ref($var) eq 'ARRAY';
     
    126146        &process_arg($option{$arg}, $arglist, \$errors);
    127147        }
    128         else
     148        elsif (!$allow_extra_options)
    129149        {
    130150        print STDERR "$arg is not a valid option.\n";
Note: See TracChangeset for help on using the changeset viewer.