pike.git
/
src
/
builtin.cmod
version
»
Context lines:
10
20
40
80
file
none
3
pike.git/src/builtin.cmod:1:
/* -*- c -*- || 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.cmod,v 1.
210
2008/06/23
16
:
49
:
40
mast Exp $
+
|| $Id: builtin.cmod,v 1.
211
2008/06/23
19
:
04
:
35
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.cmod:1859:
*! @[catch()], @[throw()] */ PMOD_EXPORT PIKEFUN array(mixed) backtrace() efun; optflags OPT_EXTERNAL_DEPEND; { low_backtrace(& Pike_interpreter); }
-
#define INITIAL_BUF_LEN 4096
-
+
/*! @module String */ /*! @class Buffer *! A buffer, used for building strings. It's *! conceptually similar to a string, but you can only @[add] *! strings to it, and you can only @[get] the value from it once. *! *! There is a reason for those seemingly rather odd limitations, *! it makes it possible to do some optimizations that really speed
pike.git/src/builtin.cmod:1914:
*! know approximately how big the buffer will be, you can optimize *! the operation of @[add()] (slightly) by passing the size to this *! function. */ PIKEFUN void create( int|void size ) { struct Buffer_struct *str = THIS; if( args ) str->initial = MAXIMUM( size->u.integer, 512 ); else
-
{
+
str->initial = 256;
-
push_int(0);
+
}
-
}
+
/*! @decl string _sprintf( int flag, mapping flags ) *! It is possible to @[sprintf] a String.Buffer object *! as @tt{%s@} just as if it was a string. */ PIKEFUN string _sprintf( int flag, mapping flags ) { switch( flag ) { case 'O':
pike.git/src/builtin.cmod:2043:
int init_from_arg0 = 0, j; if (!str->str.s && args) { ptrdiff_t sum = 0; int shift = 0; for (j=0; j < args; j++) { struct pike_string *a = Pike_sp[j-args].u.string; sum += a->len; shift |= a->size_shift; }
-
if (sum < str->initial)
{
-
sum = str->initial
*
2;
-
}
+
if (sum < str->initial)
+
sum = str->initial
;
+
else if (sum > str->initial)
+
sum <<= 1;
shift = shift & ~(shift >> 1); if (shift == Pike_sp[-args].u.string->size_shift && init_string_builder_with_string (&str->str, Pike_sp[-args].u.string)) { mark_free_svalue (Pike_sp - args); if (sum > str->str.s->len) string_build_mkspace (&str->str, sum - str->str.s->len, shift); init_from_arg0 = 1; } else
pike.git/src/builtin.cmod:2131:
*! @note *! This will clear the data in the buffer */ PIKEFUN string get( ) { struct Buffer_struct *str = THIS; if( str->str.s ) { struct pike_string *s = finish_string_builder( &str->str ); str->str.malloced = 0;
-
str->str.s =
0
;
+
str->str.s =
NULL
;
RETURN s; } pop_n_elems(args); push_empty_string(); return; } /*! @decl int _sizeof() *! *! Returns the size of the buffer.