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.653 2008/04/18 19:56:01 grubba Exp $ + || $Id: builtin_functions.c,v 1.654 2008/04/22 18:32:53 mast Exp $   */      #include "global.h"   #include "interpret.h"   #include "svalue.h"   #include "pike_macros.h"   #include "object.h"   #include "program.h"   #include "array.h"   #include "pike_error.h"
pike.git/src/builtin_functions.c:5040: Inside #if defined (HAVE_GMTIME) || defined (HAVE_GMTIME_R) || defined (HAVE_GMTIME_S)
   *!    *! @seealso    *! @[localtime()], @[time()], @[ctime()], @[mktime()]    */   PMOD_EXPORT void f_gmtime(INT32 args)   {   #if defined (HAVE_GMTIME_R) || defined (HAVE_GMTIME_S)    struct tm tm_s;   #endif    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 (tt > MAX_TIME_T || tt < MIN_TIME_T) +  SIMPLE_ARG_ERROR ("gmtime", 1, "Timestamp outside valid range."); + #endif +  t = (time_t) tt; +    #ifdef HAVE_GMTIME_R    tm = gmtime_r (&t, &tm_s);   #elif defined (HAVE_GMTIME_S)    if (!gmtime_s (&tm_s, &t)) tm = &tm_s;   #else    tm = gmtime(&t);   #endif    if (!tm) Pike_error ("gmtime() on this system cannot handle "    "the timestamp %ld.\n", (long) t);    pop_n_elems(args);
pike.git/src/builtin_functions.c:5108: Inside #if defined(HAVE_LOCALTIME)
   *! @note    *! Prior to Pike 7.5 the field @expr{"timezone"@} was sometimes not    *! present, and was sometimes not adjusted for daylight savings time.    *!    *! @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 (tt > MAX_TIME_T || tt < MIN_TIME_T) +  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_text("timezone");   #ifdef STRUCT_TM_HAS_GMTOFF    push_int(-tm->tm_gmtoff);   #elif defined(STRUCT_TM_HAS___TM_GMTOFF)