pike.git / src / operators.c

version» Context lines:

pike.git/src/operators.c:249:    }    Pike_error("Cast failed, wanted int, got %s\n",    get_name_of_type(TYPEOF(sp[-1])));    }    else if(SUBTYPEOF(sp[-1]) == NUMBER_UNDEFINED)    Pike_error("Cannot cast this object to int.\n");    }       break;    -  case T_FLOAT: +  case T_FLOAT: { +  FLOAT_TYPE f = sp[-1].u.float_number; +     if (   #ifdef HAVE_ISINF -  isinf(sp[-1].u.float_number) || +  isinf(f) ||   #endif   #ifdef HAVE_ISNAN -  isnan(sp[-1].u.float_number) || +  isnan(f) ||   #endif -  0) { +  0)    Pike_error("Can't cast infinites or NaN to int.\n"); -  } else { -  int i=DO_NOT_WARN((int)(sp[-1].u.float_number)); -  if((i < 0 ? -i : i) < floor(fabs(sp[-1].u.float_number))) -  { -  /* Note: This includes the case when i = 0x80000000, i.e. -  the absolute value is not computable. */ +  +  if (UNLIKELY(f > MAX_INT_TYPE || f < MIN_INT_TYPE)) {    convert_stack_top_to_bignum(); -  return; /* FIXME: OK to return? Cast tests below indicates -  we have to do this, at least for now... /Noring */ -  /* Yes, it is ok to return, it is actually an optimization :) -  * /Hubbe -  */ +  } else { +  SET_SVAL(sp[-1], T_INT, NUMBER_NUMBER, integer, f);    } -  else -  { -  SET_SVAL(sp[-1], T_INT, NUMBER_NUMBER, integer, i); -  } -  } +     break; -  +  }       case T_STRING:    /* The generic function is rather slow, so I added this    * code for benchmark purposes. :-) /per    */    if( (sp[-1].u.string->len >= 10) || sp[-1].u.string->size_shift )    convert_stack_top_string_to_inumber(10);    else    {    INT_TYPE i = strtol(sp[-1].u.string->str, 0, 10);