pike.git
/
src
/
builtin.cmod
version
»
Context lines:
10
20
40
80
file
none
3
pike.git/src/builtin.cmod:2634:
end = end_or_none->u.integer; pop_n_elems(args); if (end_or_none) { if ((end < 0) || (end < index) || (index >= numargs)) { f_aggregate(0); return; }
-
if (end >= numargs)
{
+
if (end >= numargs)
end = numargs-1; }
-
}
+
for (i = index; i <= end; i++) { switch(i) { case 0: /* Filename */ if (THIS->lineno == -1) fill_in_file_and_line();
-
if (THIS->filename)
{
+
if (THIS->filename)
ref_push_string(THIS->filename);
-
}
else
{
+
else
push_int(0);
-
}
+
break; case 1: /* Linenumber */ if (THIS->lineno == -1) fill_in_file_and_line(); push_int(THIS->lineno); break; case 2: /* Function */ push_svalue(&THIS->_fun); break; default: /* Arguments */ {
pike.git/src/builtin.cmod:2672:
bad_arg_error("`[]", Pike_sp-args, args, 1, "int(0..)", Pike_sp-args, "Bad argument 1 to backtrace_frame->`[](): " "Expected int(0..%d)\n", numargs + 2); } /* NOT_REACHED */ break; } }
-
if (end_or_none)
{
+
if (end_or_none)
f_aggregate(1 + end - index); }
-
}
+
/*! @decl mixed `[]=(int index, mixed value) */ PIKEFUN mixed `[]=(int index, mixed value) {
-
INT32 numargs =
0
;
+
INT32 numargs =
3
;
-
if (THIS->args)
{
-
numargs = THIS->args->size;
-
}
+
if (THIS->args)
+
numargs
+
= THIS->args->size;
-
numargs += 3;
-
-
if ((index < -numargs) || (index >= numargs))
{
+
if ((index < -numargs) || (index >= numargs))
index_error("pike_frame->`[]=", Pike_sp-args, args, NULL, Pike_sp-args, "Index %"PRINTPIKEINT"d is out of array range 0..%d,\n", index, numargs-1);
-
}
else if (index < 0)
{
+
else if (index < 0)
index += numargs;
-
}
+
if (args > 2) { pop_n_elems(args - 2); args = 2; } switch(index) { case 0: /* Filename */ if (THIS->lineno == -1) fill_in_file_and_line(); if (TYPEOF(*value) != PIKE_T_STRING) {
pike.git/src/builtin.cmod:2725:
if (THIS->filename) { free_string(THIS->filename); THIS->filename = NULL; } copy_shared_string(THIS->filename, value->u.string); } break; case 1: /* Linenumber */ if (THIS->lineno == -1) fill_in_file_and_line();
-
if (TYPEOF(*value) != PIKE_T_INT)
{
+
if (TYPEOF(*value) != PIKE_T_INT)
SIMPLE_BAD_ARG_ERROR("`[]=", 2, "int(1..)");
-
}
+
THIS->lineno = value->u.integer; break; case 2: /* Function */ if (THIS->lineno == -1) fill_in_file_and_line(); assign_svalue(&THIS->_fun, value); break; default: /* Arguments */ assign_svalue(THIS->args->item + index - 3, value); break;
pike.git/src/builtin.cmod:3222:
if (pos < 0) SIMPLE_BAD_ARG_ERROR("addat", 1, "int(0..)"); if (args) { int init_from_arg0 = 0, j; ptrdiff_t sum = 0; int shift = 0; for (j=1; j < args; j++) { struct pike_string *a;
-
if (TYPEOF(Pike_sp[j-args]) == PIKE_T_STRING)
{
+
if (TYPEOF(Pike_sp[j-args]) == PIKE_T_STRING)
a = Pike_sp[j-args].u.string;
-
}
else if ((TYPEOF(Pike_sp[j-args]) != PIKE_T_OBJECT) ||
-
(Pike_sp[j-args].u.object->prog != Buffer_program))
{
+
else if ((TYPEOF(Pike_sp[j-args]) != PIKE_T_OBJECT) ||
+
(Pike_sp[j-args].u.object->prog != Buffer_program))
SIMPLE_BAD_ARG_ERROR("addat", j+1, "string|String.Buffer");
-
}
else {
+
else {
a = OBJ2_BUFFER(Pike_sp[j-args].u.object)->str.s; if (!a) continue; } sum += a->len; shift |= a->size_shift; } if (!str->str.s) {
-
if ((sum + pos) <= str->initial)
{
+
if ((sum + pos) <= str->initial)
sum = str->initial;
-
}
else
{
-
sum <<= 1
;
-
sum += pos;
-
}
+
else
+
sum <<= 1
,
sum += pos;
shift = shift & ~(shift >> 1); init_string_builder_alloc(&str->str, sum, shift); } else { sum += pos; shift |= str->str.known_shift; shift = shift & ~(shift >> 1);
-
if (sum > str->str.s->len)
{
+
if (sum > str->str.s->len)
string_build_mkspace(&str->str, sum - str->str.s->len, shift);
-
}
else if (shift != str->str.known_shift)
{
+
else if (shift != str->str.known_shift)
string_build_mkspace(&str->str, 0, shift); }
-
}
+
/* We know it will be a string that really is this wide. */ str->str.known_shift = shift; if (str->str.s->len < pos) { /* Clear the padding. */ MEMSET(str->str.s->str + (str->str.s->len << str->str.s->size_shift), 0, (pos - str->str.s->len) << str->str.s->size_shift); } for(j = 1; j<args; j++) { struct pike_string *a;
-
if (TYPEOF(Pike_sp[j-args]) == PIKE_T_STRING)
{
+
if (TYPEOF(Pike_sp[j-args]) == PIKE_T_STRING)
a = Pike_sp[j-args].u.string;
-
}
else {
+
else {
a = OBJ2_BUFFER(Pike_sp[j-args].u.object)->str.s; if (!a) continue; } pike_string_cpy(MKPCHARP_STR_OFF(str->str.s, pos), a); pos += a->len; } if (str->str.s->len < pos) { str->str.s->len = pos; /* Ensure NUL-termination */ str->str.s->str[str->str.s->len << str->str.s->size_shift] = 0; } }
-
if
(
str->str.s
)
{
-
RETURN
str->str.s->len
;
-
} else {
-
RETURN
0;
+
RETURN
str->str.s
?
str->str.s->len
:
0;
}
-
}
+
/*! @decl void putchar(int c) *! Appends the character @[c] at the end of the string. */ PIKEFUN void putchar(int c) { struct Buffer_struct *str = THIS; if(!str->str.s) init_string_builder_alloc(&str->str, str->initial, 0); string_builder_putchar(&str->str, c); }
pike.git/src/builtin.cmod:3328:
*! *! Get the data from the buffer. Significantly slower than @[get], *! but does not clear the buffer. *! *! @seealso *! @[get()] */ PIKEFUN string get_copy() { struct pike_string *str = THIS->str.s;
-
if( str )
+
ptrdiff_t len;
+
if( str
&& (len = str->len
)
> 0 )
{
-
ptrdiff_t len = str->len;
-
if( len > 0 )
-
{
+
char *d = (char *)str->str; switch( str->size_shift ) { case 0: str=make_shared_binary_string0((p_wchar0 *)d,len); break; case 1: str=make_shared_binary_string1((p_wchar1 *)d,len); break;
-
case 2
:
+
default
:
str=make_shared_binary_string2((p_wchar2 *)d,len); break; } if( Pike_fp->current_object->flags & OBJECT_CLEAR_ON_EXIT ) str->flags |= STRING_CLEAR_ON_EXIT; RETURN str; }
-
}
+
push_empty_string(); return; } /*! @decl string get() *! *! Get the data from the buffer. *! *! @note *! This will clear the data in the buffer *! *! @seealso *! @[get_copy()], @[clear()] */ PIKEFUN string get( ) { struct Buffer_struct *str = THIS;
-
+
pop_n_elems(args);
if( str->str.s ) { struct pike_string *s = finish_string_builder( &str->str ); str->str.malloced = 0; str->str.s = NULL; if( Pike_fp->current_object->flags & OBJECT_CLEAR_ON_EXIT ) s->flags |= STRING_CLEAR_ON_EXIT;
-
RETURN
s;
+
push_string(
s
)
;
}
-
pop_n_elems(args);
+
else
push_empty_string();
-
return;
+
} /*! @decl void clear() *! *! Empty the buffer, and don't care about the old content. *! *! @note *! This function was not available in Pike 7.8 and earlier. *! *! @seealso