Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
clean-and-itasks
sapl-interpreter
Commits
79abd78a
Commit
79abd78a
authored
Jan 25, 2016
by
Laszlo Domoszlai
Browse files
real fix for string_slice
parent
3721aaf8
Changes
1
Hide whitespace changes
Inline
Side-by-side
interpreter/prim.c
View file @
79abd78a
...
...
@@ -234,17 +234,21 @@ void __string_slice(int dst_idx)
Thunk
*
idx2
=
arg
(
1
);
char
*
chars
;
int
full_length
;
if
(
str
->
desc
==
(
Desc
*
)
__STRING_PTR__
)
{
chars
=
str
->
_string_ptr
->
chars
;
full_length
=
str
->
_string_ptr
->
length
;
}
else
{
chars
=
str
->
_array
.
_chars
;
full_length
=
str
->
_array
.
length
;
}
int
length
=
idx2
->
_int
-
idx1
->
_int
;
int
length
=
idx2
->
_int
-
idx1
->
_int
+
1
;
if
(
idx1
->
_int
+
length
>
full_length
)
length
=
full_length
-
idx1
->
_int
;
target
=
string_create
(
target
,
length
);
memcpy
(
target
->
_array
.
_chars
,
chars
+
idx1
->
_int
,
length
);
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment