pike.git/
src/
builtin.cmod
Branch:
Tag:
Non-build tags
All tags
No tags
2014-08-26
2014-08-26 23:56:50 by Stephen R. van den Berg <srb@cuci.nl>
d505c710ae9ff20c8eb1aca09f688c586b847f97 (
19
lines) (+
12
/-
7
)
[
Show
|
Annotate
]
Branch:
8.0
Fix length calculations in cut().
3406:
end = len-1; p = (char*)p+(index<<shift);
-
end -= index
-1
;
+
index =
end
-index+1;
+
end = len
-
end;
+
len
= index
<<shift
;
if (!vdiscard) {
-
+
struct pike_string *s2;
+
res = fast_clone_object( Buffer_program ); str2 = OBJ2_BUFFER( res );
-
init_string_builder_alloc(&str2->str, str2->initial =
end
, shift);
-
memcpy(str2->str.s->str, p,
shift = end<<shift
);
-
str2
->str
.s->str
[
shift
] = 0; // Ensure NUL-termination
-
str2
->
str.s->
len =
end
;
+
init_string_builder_alloc(&str2->str, str2->initial =
index
, shift);
+
memcpy(
(s2=
str2->str.s
)
->str, p,
len
);
+
s2
->str[
len
] = 0;
// Ensure NUL-termination
+
s2
->len =
index
;
}
-
memmove(p, (char*)
p+shift
,
shift+1
);
// Copy NUL-termination
-
s->len -=
end
;
+
memmove(p, (char*)
p+len
,
end<<shift
); // Copy NUL-termination
+
s->len -=
index
;
if(!vdiscard) {