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.480 2007/03/29 15:38:20 mast Exp $ + || $Id: builtin_functions.c,v 1.481 2008/04/22 18:17:55 mast Exp $   */      #include "global.h" - RCSID("$Id: builtin_functions.c,v 1.480 2007/03/29 15:38:20 mast Exp $"); + RCSID("$Id: builtin_functions.c,v 1.481 2008/04/22 18:17:55 mast 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:4161: Inside #if defined(HAVE_GMTIME)
   *!    *! This function works like @[localtime()] but the result is    *! not adjusted for the local time zone.    *!    *! @seealso    *! @[localtime()], @[time()], @[ctime()], @[mktime()]    */   PMOD_EXPORT void f_gmtime(INT32 args)   {    struct tm *tm; -  INT_TYPE tt; +  LONGEST tt;    time_t t;    -  get_all_args("gmtime", args, "%i", &tt); +  get_all_args("gmtime", args, "%l", &tt);    -  t = tt; + #if SIZEOF_TIME_T < SIZEOF_LONGEST +  if ((time_t) tt != tt) +  SIMPLE_ARG_ERROR ("gmtime", 1, "Timestamp outside valid range."); + #endif +  t = (time_t) tt; +     tm = gmtime(&t);    if (!tm) Pike_error ("gmtime() on this system cannot handle "    "the timestamp %ld.\n", (long) t);    pop_n_elems(args);    encode_struct_tm(tm);       push_string(make_shared_string("timezone"));    push_int(0);    f_aggregate_mapping(20);   }
pike.git/src/builtin_functions.c:4222: Inside #if defined(HAVE_LOCALTIME)
   *!    *! @note    *! The field @tt{"timezone"@} may not be available on all platforms.    *!    *! @seealso    *! @[Calendar], @[gmtime()], @[time()], @[ctime()], @[mktime()]    */   PMOD_EXPORT void f_localtime(INT32 args)   {    struct tm *tm; -  INT_TYPE tt; +  LONGEST tt;    time_t t;    -  get_all_args("localtime", args, "%i", &tt); +  get_all_args("localtime", args, "%l", &tt);    -  t = tt; + #if SIZEOF_TIME_T < SIZEOF_LONGEST +  if ((time_t) tt != tt) +  SIMPLE_ARG_ERROR ("gmtime", 1, "Timestamp outside valid range."); + #endif +  t = (time_t) tt; +     tm = localtime(&t);    if (!tm) Pike_error ("localtime() on this system cannot handle "    "the timestamp %ld.\n", (long) t);    pop_n_elems(args);    encode_struct_tm(tm);       push_string(make_shared_string("timezone"));   #ifdef STRUCT_TM_HAS_GMTOFF    push_int(-tm->tm_gmtoff);   #elif defined(STRUCT_TM_HAS___TM_GMTOFF)
pike.git/src/builtin_functions.c:4645: Inside #if 0
   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);    }   #endif /* 0 */    }       pop_n_elems(args); + #if SIZEOF_TIME_T > SIZEOF_INT_TYPE +  push_int64 (retval); + #else    push_int(retval); -  + #endif   }   #define GOT_F_MKTIME   #endif /* HAVE_MKTIME || HAVE_LOCALTIME */      /* Parse a sprintf/sscanf-style format string */   static ptrdiff_t low_parse_format(p_wchar0 *s, ptrdiff_t slen)   {    ptrdiff_t i;    ptrdiff_t offset = 0;    int num_percent_percent = 0;