pike.git / src / builtin_functions.c

version» Context lines:

pike.git/src/builtin_functions.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: builtin_functions.c,v 1.445 2002/10/11 01:39:29 nilsson Exp $ + || $Id: builtin_functions.c,v 1.446 2002/10/15 13:29:13 grubba Exp $   */      #include "global.h" - RCSID("$Id: builtin_functions.c,v 1.445 2002/10/11 01:39:29 nilsson Exp $"); + RCSID("$Id: builtin_functions.c,v 1.446 2002/10/15 13:29:13 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:4148: Inside #if defined(HAVE_MKTIME)
   *! On most systems, the supported range of dates are Dec 13, 1901    *! 20:45:52 UTC through Jan 19, 2038 03:14:07 UTC (inclusive).    *!    *! @seealso    *! @[time()], @[ctime()], @[localtime()], @[gmtime()]    */   PMOD_EXPORT void f_mktime (INT32 args)   {    INT_TYPE sec, min, hour, mday, mon, year;    struct tm date; -  int retval, raw; +  int retval;       if (args<1)    SIMPLE_TOO_FEW_ARGS_ERROR("mktime", 1);       if(args == 1)    {    MEMSET(&date, 0, sizeof(date));       push_text("sec");    push_text("min");
pike.git/src/builtin_functions.c:4217: Inside #if defined(HAVE_MKTIME)
   */    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 (retval == -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))    {    /* Post-adjust for the timezone.    *    * Note that tm_gmtoff has the opposite sign of timezone.    *    * Note also that it must be post-adjusted, since the gmtoff    * field is set by mktime(3).    */   #ifdef STRUCT_TM_HAS_GMTOFF    retval += Pike_sp[7-args].u.integer + date.tm_gmtoff;   #else    retval += Pike_sp[7-args].u.integer + date.__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;