pike.git / src / builtin.cmod

version» Context lines:

pike.git/src/builtin.cmod:26:   #include "operators.h"   #include "builtin_functions.h"   #include "fsort.h"   #include "pike_cpulib.h"   #include "gc.h"   #include "block_allocator.h"   #include "pikecode.h"   #include "opcodes.h"   #include "whitespace.h"   #include "sprintf.h" + #include "pike_search.h"      #include <errno.h>   #include <math.h>   #include <fcntl.h>      #ifdef HAVE_ARPA_INET_H   #include <arpa/inet.h>   #endif /* HAVE_ARPA_INET_H */      #define DEFAULT_CMOD_STORAGE
pike.git/src/builtin.cmod:101:    int is_utc_zone = tm_zone && !strcmp(tm_zone, "UTC");    if (is_utc_zone)    this->t.tm_isdst = 0;    this->unix_time = mktime_zone(&this->t, is_utc_zone, 0);    this->modified = 0;    }      #ifdef HAVE_STRPTIME    /*! @decl int(0..1) strptime( string(1..255) format, string(1..255) data )    *! -  *! Parse the given @[data] using the format in @[format] as a date. +  *! @note +  *! The @expr{format@} and @expr{data@} are reversed.    *! -  *! @dl -  *! @item %% -  *! The % character. -  *! -  *! @item %a or %A -  *! The weekday name according to the C locale, in abbreviated -  *! form or the full name. -  *! -  *! @item %b or %B or %h -  *! The month name according to the C locale, in abbreviated form -  *! or the full name. -  *! -  *! @item %c -  *! The date and time representation for the C locale. -  *! -  *! @item %C -  *! The century number (0-99). -  *! -  *! @item %d or %e -  *! The day of month (1-31). -  *! -  *! @item %D -  *! Equivalent to %m/%d/%y. -  *! -  *! @item %H -  *! The hour (0-23). -  *! -  *! @item %I -  *! The hour on a 12-hour clock (1-12). -  *! -  *! @item %j -  *! The day number in the year (1-366). -  *! -  *! @item %m -  *! The month number (1-12). -  *! -  *! @item %M -  *! The minute (0-59). -  *! -  *! @item %n -  *! Arbitrary whitespace. -  *! -  *! @item %p -  *! The C locale's equivalent of AM or PM. -  *! -  *! @item %R -  *! Equivalent to %H:%M. -  *! -  *! @item %S -  *! The second (0-60; 60 may occur for leap seconds; -  *! earlier also 61 was allowed). -  *! -  *! @item %t -  *! Arbitrary whitespace. -  *! -  *! @item %T -  *! Equivalent to %H:%M:%S. -  *! -  *! @item %U -  *! The week number with Sunday the first day of the week (0-53). -  *! -  *! @item %w -  *! The weekday number (0-6) with Sunday = 0. -  *! -  *! @item %W -  *! The week number with Monday the first day of the week (0-53). -  *! -  *! @item %x -  *! The date, using the C locale's date format. -  *! -  *! @item %X -  *! The time, using the C locale's time format. -  *! -  *! @item %y -  *! The year within century (0-99). When a century is not -  *! otherwise specified, values in the range 69-99 refer to years -  *! in the twentieth century (1969-1999); values in the range -  *! 00-68 refer to years in the twenty-first century (2000-2068). -  *! -  *! @item %Y -  *! The year, including century (for example, 1991). -  *! @enddl -  *! +  *! @seealso +  *! @[strptime]    */    PIKEFUN int(0..1) strptime( string(1..255) format, string(1..255) data )    {    if( format->size_shift || data->size_shift )    Pike_error("Only 8bit strings are supported\n");    THIS->modified = 1;    if( strptime_zone( data->str, format->str, &THIS->t ) == NULL )    RETURN 0;    RETURN 1;    }   #endif /* HAVE_STRPTIME */    /*! @decl string(1..255) strftime( string(1..255) format )    *! See also @[Gettext.setlocale]    *! -  *! Convert the structure to a string. -  *! -  *! @dl -  *! @item %a -  *! The abbreviated weekday name according to the current locale -  *! -  *! @item %A -  *! The full weekday name according to the current locale. -  *! -  *! @item %b -  *! The abbreviated month name according to the current locale. -  *! -  *! @item %B -  *! The full month name according to the current locale. -  *! -  *! @item %c -  *! The preferred date and time representation for the current locale. -  *! -  *! @item %C -  *! The century number (year/100) as a 2-digit integer. -  *! -  *! @item %d -  *! The day of the month as a decimal number (range 01 to 31). -  *! -  *! @item %D -  *! Equivalent to @expr{%m/%d/%y@}. (for Americans only. -  *! Americans should note that in other countries @expr{%d/%m/%y@} -  *! is rather common. This means that in international context -  *! this format is ambiguous and should not be used.) -  *! -  *! @item %e -  *! Like @expr{%d@}, the day of the month as a decimal number, -  *! but a leading zero is replaced by a space. -  *! -  *! @item %E -  *! Modifier: use alternative format, see below. -  *! -  *! @item %F -  *! Equivalent to %Y-%m-%d (the ISO 8601 date format). (C99) -  *! -  *! @item %G -  *! The ISO 8601 week-based year (see NOTES) with century as a -  *! decimal number. The 4-digit year corresponding to the ISO -  *! week number (see @expr{%V@}). This has the same format and -  *! value as @expr{%Y@}, except that if the ISO week number -  *! belongs to the previous or next year, that year is used instead. -  *! -  *! @item %g -  *! Like @expr{%G@}, but without century, that is, -  *! with a 2-digit year (00-99). (TZ) -  *! -  *! @item %h -  *! Equivalent to %b. -  *! -  *! @item %H -  *! The hour as a decimal number using a 24-hour clock (range 00 to 23). -  *! -  *! @item %I -  *! The hour as a decimal number using a 12-hour clock (range 01 to 12). -  *! -  *! @item %j -  *! The day of the year as a decimal number (range 001 to 366). -  *! -  *! @item %k -  *! The hour (24-hour clock) as a decimal number (range 0 to 23); -  *! single digits are preceded by a blank. (See also @expr{%H@}.) -  *! -  *! @item %l -  *! The hour (12-hour clock) as a decimal number (range 1 to 12); -  *! single digits are preceded by a blank. (See also @expr{%I@}.) -  *! -  *! @item %m -  *! The month as a decimal number (range 01 to 12). -  *! -  *! @item %M -  *! The minute as a decimal number (range 00 to 59). -  *! -  *! @item %n -  *! A newline character. (SU) -  *! -  *! @item %O -  *! Modifier: use alternative format, see below. (SU) -  *! -  *! @item %p -  *! Either @expr{"AM"@} or @expr{"PM"@} according to the given time -  *! value, or the corresponding strings for the current locale. -  *! Noon is treated as @expr{"PM"@} and midnight as @expr{"AM"@}. -  *! -  *! @item %P -  *! Like @expr{%p@} but in lowercase: @expr{"am"@} or @expr{"pm"@} -  *! or a corresponding string for the current locale. -  *! -  *! @item %r -  *! The time in a.m. or p.m. notation. In the POSIX locale this is -  *! equivalent to @expr{%I:%M:%S %p@}. -  *! -  *! @item %R -  *! The time in 24-hour notation (@expr{%H:%M@}). (SU) -  *! For a version including the seconds, see @expr{%T@} below. -  *! -  *! @item %s -  *! The number of seconds since the Epoch, -  *! 1970-01-01 00:00:00 +0000 (UTC). (TZ) -  *! -  *! @item %S -  *! The second as a decimal number (range 00 to 60). -  *! (The range is up to 60 to allow for occasional leap seconds.) -  *! -  *! @item %t -  *! A tab character. (SU) -  *! -  *! @item %T -  *! The time in 24-hour notation (@expr{%H:%M:%S@}). (SU) -  *! -  *! @item %u -  *! The day of the week as a decimal, range 1 to 7, Monday being 1. -  *! See also @expr{%w@}. (SU) -  *! -  *! @item %U -  *! The week number of the current year as a decimal number, -  *! range 00 to 53, starting with the first Sunday as the first -  *! day of week 01. See also @expr{%V@} and @expr{%W@}. -  *! -  *! @item %V -  *! The ISO 8601 week number of the current year as a decimal number, -  *! range 01 to 53, where week 1 is the first week that has at least -  *! 4 days in the new year. See also @expr{%U@} and @expr{%W@}. -  *! -  *! @item %w -  *! The day of the week as a decimal, range 0 to 6, Sunday being 0. -  *! See also @expr{%u@}. -  *! @enddl +  *! @seealso +  *! @[strftime]    */ -  PIKEFUN string strftime(string(1..255) format) +  PIKEFUN string(1..255) strftime(string(1..255) format)    { -  char *buffer = xalloc( 8192 ); +  char buffer[8192];    buffer[0] = 0; -  strftime_zone( buffer, 8192, format->str, &THIS->t ); -  push_text( buffer ); +  strftime_zone(buffer, sizeof(buffer), format->str, &THIS->t); +  push_text(buffer);    }       /*! @decl int(0..60) sec;    *! @decl int(0..59) min;    *! @decl int(0..59) hour;    *! @decl int(1..31) mday;    *! @decl int(0..11) mon;    *! @decl int year;    *!    *! The various fields in the structure. Note that setting these
pike.git/src/builtin.cmod:2986:    struct object *o = fast_clone_object(backtrace_frame_program);    struct backtrace_frame_struct *bf;    struct identifier *function = NULL;       size--;       SET_SVAL(res->item[size], PIKE_T_OBJECT, 0, object, o);       bf = OBJ2_BACKTRACE_FRAME(o);    +  SET_SVAL(bf->_fun, PIKE_T_INT, NUMBER_DESTRUCTED, integer, 0); +  +  if (!f->context) { +  if (f->pc == (void *)do_gc) { +  SET_SVAL(bf->_fun, PIKE_T_STRING, 0, string, make_shared_string("gc")); +  } +  continue; +  } +     if ((bf->prog = f->context->prog)) {    add_ref(bf->prog);    bf->pc = f->pc;    }    -  SET_SVAL(bf->_fun, PIKE_T_INT, NUMBER_DESTRUCTED, integer, 0); -  +     if (f->current_object && f->current_object->prog) {    if (f->fun == FUNCTION_BUILTIN) {    /* Unusual case. The frame is from call_c_initializers(), gc()    * or similar. cf [bug 6156]. /grubba    *    * Masquerade as the program.    *    * FIXME: Ought to keep parent-pointers.    */    SET_SVAL(bf->_fun, PIKE_T_PROGRAM, 0,
pike.git/src/builtin.cmod:3582:    memset( str, 0, sizeof( *str ) );    }       EXIT    gc_trivial;    {    struct Buffer_struct *str = THIS;    if( str->str.s )    {    if( Pike_fp->flags & OBJECT_CLEAR_ON_EXIT ) -  guaranteed_memset( str->str.s->str, 0, str->str.s->len ); +  secure_zero( str->str.s->str, str->str.s->len );    free_string_builder( &str->str );    }    }       GC_RECURSE    {    if (mc_count_bytes (Pike_fp->current_object) && THIS->str.s)    mc_counted_bytes += THIS->str.malloced;    }   }