pike.git / src / operators.c

version» Context lines:

pike.git/src/operators.c:1:   /*   || This file is part of Pike. For copyright information see COPYRIGHT.   || Pike is distributed under GPL, LGPL and MPL. See the file COPYING   || for more information. - || $Id: operators.c,v 1.162 2002/10/11 01:39:34 nilsson Exp $ + || $Id: operators.c,v 1.163 2002/10/15 14:53:28 grubba Exp $   */      #include "global.h"   #include <math.h> - RCSID("$Id: operators.c,v 1.162 2002/10/11 01:39:34 nilsson Exp $"); + RCSID("$Id: operators.c,v 1.163 2002/10/15 14:53:28 grubba Exp $");   #include "interpret.h"   #include "svalue.h"   #include "multiset.h"   #include "mapping.h"   #include "array.h"   #include "stralloc.h"   #include "opcodes.h"   #include "operators.h"   #include "language.h"   #include "pike_memory.h"
pike.git/src/operators.c:1931:   #endif /* AUTO_BIGNUM */       if(sp[-1].type != T_INT || sp[-2].type != T_INT)    {    int args = 2;    if(call_lfun(LFUN_LSH, LFUN_RLSH))    return;       if(sp[-2].type != T_INT)    SIMPLE_BAD_ARG_ERROR("`<<", 1, "int|object"); -  SIMPLE_BAD_ARG_ERROR("`<<", 2, "int|object"); +  SIMPLE_BAD_ARG_ERROR("`<<", 2, "int(0..)|object");    }   #ifndef AUTO_BIGNUM    if (sp[-1].u.integer > 31) {    sp--;    sp[-1].u.integer = 0;    return;    }   #endif /* !AUTO_BIGNUM */ -  +  if (sp[-1].u.integer < 0) { +  SIMPLE_BAD_ARG_ERROR("`<<", 2, "int(0..)|object"); +  }    sp--;    sp[-1].u.integer = sp[-1].u.integer << sp->u.integer;   }      /*! @decl int `<<(int arg1, int arg2)    *! @decl mixed `<<(object arg1, int|object arg2)    *! @decl mixed `<<(int arg1, object arg2)    *!    *! Left shift operator.    *!
pike.git/src/operators.c:1990:      PMOD_EXPORT void o_rsh(void)   {    if(sp[-2].type != T_INT || sp[-1].type != T_INT)    {    int args = 2;    if(call_lfun(LFUN_RSH, LFUN_RRSH))    return;    if(sp[-2].type != T_INT)    SIMPLE_BAD_ARG_ERROR("`>>", 1, "int|object"); -  SIMPLE_BAD_ARG_ERROR("`>>", 2, "int|object"); +  SIMPLE_BAD_ARG_ERROR("`>>", 2, "int(0..)|object");    }    -  +  if (sp[-1].u.integer < 0) { +  SIMPLE_BAD_ARG_ERROR("`>>", 2, "int(0..)|object"); +  } +  +  if(   #ifdef AUTO_BIGNUM -  if(INT_TYPE_RSH_OVERFLOW(sp[-2].u.integer, sp[-1].u.integer)) +  (INT_TYPE_RSH_OVERFLOW(sp[-2].u.integer, sp[-1].u.integer)) + #else /* !AUTO_BIGNUM */ +  (sp[-1].u.integer > 31) + #endif /* AUTO_BIGNUM */ +  )    {    sp--; -  sp[-1].u.integer = 0; -  return; -  } - #else /* !AUTO_BIGNUM */ -  if (sp[-1].u.integer > 31) { -  sp--; +     if (sp[-1].u.integer < 0) {    sp[-1].u.integer = -1;    } else {    sp[-1].u.integer = 0;    }    return;    } - #endif /* AUTO_BIGNUM */ +        sp--;    sp[-1].u.integer = sp[-1].u.integer >> sp->u.integer;   }      /*! @decl int `>>(int arg1, int arg2)    *! @decl mixed `>>(object arg1, int|object arg2)    *! @decl mixed `>>(int arg1, object arg2)    *!    *! Right shift operator.