pike.git / src / builtin_functions.c

version» Context lines:

pike.git/src/builtin_functions.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.   \*/   /**/   #include "global.h" - RCSID("$Id: builtin_functions.c,v 1.363 2002/10/03 17:23:29 mast Exp $"); + RCSID("$Id: builtin_functions.c,v 1.364 2002/10/15 13:51:39 grubba Exp $");   #include "interpret.h"   #include "svalue.h"   #include "pike_macros.h"   #include "object.h"   #include "program.h"   #include "array.h"   #include "pike_error.h"   #include "constants.h"   #include "mapping.h"   #include "stralloc.h"
pike.git/src/builtin_functions.c:4150: Inside #if defined(HAVE_MKTIME)
   &sec, &min, &hour, &mday, &mon, &year);       MEMSET(&date, 0, sizeof(date));    date.tm_sec=sec;    date.tm_min=min;    date.tm_hour=hour;    date.tm_mday=mday;    date.tm_mon=mon;    date.tm_year=year;    +  if (args > 6) { +  if (Pike_sp[6-args].type != T_INT) { +  PIKE_ERROR("mktime", "Bad argument 6 (expected int).\n", Pike_sp, args); +  } +  if (args > 7) { +  if (Pike_sp[7-args].type != T_INT) { +  PIKE_ERROR("mktime", "Bad argument 7 (expected int).\n", +  Pike_sp, args); +  } +  } +  } +     if ((args > 6) && (Pike_sp[6-args].subtype == NUMBER_NUMBER))    {    date.tm_isdst = Pike_sp[6-args].u.integer;    } else {    date.tm_isdst = -1;    }      #ifdef STRUCT_TM_HAS_GMTOFF    /* BSD-style */    date.tm_gmtoff = 0;   #else   #ifdef STRUCT_TM_HAS___TM_GMTOFF    /* Linux-style */    date.__tm_gmtoff = 0; -  + #else +  if((args > 7) && (Pike_sp[7-args].subtype == NUMBER_NUMBER)) +  { +  /* Pre-adjust for the timezone. +  * +  * Note that pre-adjustment must be done on AIX for dates +  * near Jan 1, 1970, sine AIX mktime(3) doesn't support +  * negative time. +  */ +  date.tm_sec += Pike_sp[7-args].u.integer + #ifdef HAVE_EXTERNAL_TIMEZONE +  - timezone + #endif /* HAVE_EXTERNAL_TIMEZONE */ +  ; +  }   #endif /* STRUCT_TM_HAS___TM_GMTOFF */   #endif /* STRUCT_TM_HAS_GMTOFF */    -  raw = retval = mktime(&date); +  retval = mktime(&date);    -  +  if (raw == -1) +  PIKE_ERROR("mktime", "Cannot convert.\n", Pike_sp, args); +  + #if defined(STRUCT_TM_HAS_GMTOFF) || defined(STRUCT_TM_HAS___TM_GMTOFF)    if((args > 7) && (Pike_sp[7-args].subtype == NUMBER_NUMBER))    {    /* Adjust for the timezone. */   #ifdef STRUCT_TM_HAS_GMTOFF    retval += Pike_sp[7-args].u.integer + date.tm_gmtoff;   #else   #ifdef STRUCT_TM_HAS___TM_GMTOFF    retval += Pike_sp[7-args].u.integer + date.__tm_gmtoff;   #else   #ifdef HAVE_EXTERNAL_TIMEZONE    retval += Pike_sp[7-args].u.integer - timezone;   #endif /* HAVE_EXTERNAL_TIMEZONE */   #endif /* STRUCT_TM_HAS___TM_GMTOFF */   #endif /* STRUCT_TM_HAS_GMTOFF */    } -  + #endif /* STRUCT_TM_HAS_GMTOFF || STRUCT_TM_HAS___TM_GMTOFF */    -  if (raw == -1) -  PIKE_ERROR("mktime", "Cannot convert.\n", Pike_sp, args); +  if ((args > 6) && (Pike_sp[6-args].subtype == NUMBER_NUMBER) && +  (Pike_sp[6-args].u.integer != -1) && +  (Pike_sp[6-args].u.integer != date.tm_isdst)) { +  /* Some stupid libc's (Hi Linux!) don't accept that we've set isdst... */ +  retval += 3600 * (Pike_sp[6-args].u.integer - date.tm_isdst); +  } +     pop_n_elems(args);    push_int(retval);   }      #endif      /* Parse a sprintf/sscanf-style format string */   static ptrdiff_t low_parse_format(p_wchar0 *s, ptrdiff_t slen)   {    ptrdiff_t i;