>  function integer_range_info(range_option, init, option)
    >  {
    >      if (range_option != "") {
    > -       start = nth_arg(0, range_option);
    > -       end = nth_arg(1, range_option);
    > +       init = init + 0;
    > +       start = nth_arg(0, range_option) + 0;
    > +       end = nth_arg(1, range_option) + 0;
    >         if (init != "" && init != "-1" && (init < start || init > end))
    
    
    In this case the test for init != "" is at least unnecessary.

Right! Thanks for noticing.

    Maybe something else has to be used.  I didn't trace the uses but if init
    is deliberately set to "" then the test would have to be replaced with init
    != 0.

Hm, in principle Init() can specify any non-negative number, including
0... what about a conservative approach that fixes the ordering problem
but leaves the "special cases" -1 and "" with exactly the same semantics
than before:

function integer_range_info(range_option, init, option)
{
    if (range_option != "") {
        ival = init + 0;
        start = nth_arg(0, range_option) + 0;
        end = nth_arg(1, range_option) + 0;
        if (init != "" && init != "-1" && (ival < start || ival > end))
          print "#error initial value " init " of '" option "' must be in range 
[" start "," end "]"
        return start ", " end
    }
    else
        return "-1, -1"
}

Reply via email to