pike.git / src / stuff.c

version» Context lines:

pike.git/src/stuff.c:1:   /*\   ||| This file a part of Pike, and is copyright by Fredrik Hubinette   ||| Pike is distributed as GPL (General Public License)   ||| See the files COPYING and DISCLAIMER for more information.   \*/      /* -  * $Id: stuff.c,v 1.6 1998/03/28 15:04:29 grubba Exp $ +  * $Id: stuff.c,v 1.7 1999/02/27 20:35:34 grubba Exp $    */   #include "stuff.h"      /* Not all of these are primes, but they should be adequate */   INT32 hashprimes[32] =   {    31, /* ~ 2^0 = 1 */    31, /* ~ 2^1 = 2 */    31, /* ~ 2^2 = 4 */    31, /* ~ 2^3 = 8 */
pike.git/src/stuff.c:116:   double my_strtod(char *nptr, char **endptr)   {    double tmp=STRTOD(nptr,endptr);    if(*endptr>nptr)    {    if(endptr[0][-1]=='.')    endptr[0]--;    }    return tmp;   } +  + double strtod_pcharp(PCHARP ptr, PCHARP *endptr) + { +  /* NOTE: Cuts at 63 digits */ +  +  char buff[64]; +  int i; +  double res; +  char *end_; +  +  endptr->shift = ptr.shift; +  +  if (!ptr.shift) { +  return my_strtod(ptr.ptr, &endptr->ptr); +  } +  +  for (i=0; i < 63; i++) { +  unsigned int c = INDEX_PCHARP(ptr, i); +  if (!c || (c >= 256)) { +  break; +  } +  buff[i] = c; +  } +  buff[i] = 0; +  +  res = my_strtod(buff, &end_); +  +  endptr->ptr = ptr.ptr + ((end_ - buff)<<SHIFT); +  return res; + }