pike.git/
src/
builtin.cmod
Branch:
Tag:
Non-build tags
All tags
No tags
2001-09-21
2001-09-21 17:57:12 by Henrik Grubbström (Grubba) <grubba@grubba.org>
b195b951cefca330e1d1521c5c5791a2702ed54f (
29
lines) (+
23
/-
6
)
[
Show
|
Annotate
]
Branch:
7.9
Fix for [bug
2314 (#2314)
].
Rev: src/builtin.cmod:1.65
1:
/* -*- c -*-
-
* $Id: builtin.cmod,v 1.
64
2001/09/
05
23
:
44
:
32
hubbe
Exp $
+
* $Id: builtin.cmod,v 1.
65
2001/09/
21
17
:
57
:
12
grubba
Exp $
*/ #include "global.h"
1382:
{ struct Buffer_struct *str = THIS; int j;
-
struct pike_string *a;
+
-
+
if (!str->str.s && args) {
+
int 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;
+
}
+
init_string_builder_alloc(&str->str, sum, shift & ~(shift>>1));
+
}
+
for( j = 0; j<args; j++ ) {
-
a = Pike_sp[-
args+j
].u.string;
-
if( !str->str.s )
-
init_string_builder_alloc( &str->str, str->initial, a->size_shift );
+
struct pike_string *
a = Pike_sp[
j
-
args
].u.string;
string_builder_shared_strcat( &str->str, a ); }
-
RETURN
str->str.s->len;
+
+
if (str->str.s) {
+
RETURN str->str.s->len;
+
} else {
+
RETURN 0;
}
-
+
}
/*! @decl string get_copy() *!