Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
P
Pyston
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Boxiang Sun
Pyston
Commits
2748c606
Commit
2748c606
authored
Apr 03, 2015
by
Chris Toshok
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix bug introduced on colocation branch for empty string/list passed to strJoin
parent
e871f4ef
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
14 additions
and
0 deletions
+14
-0
src/runtime/str.cpp
src/runtime/str.cpp
+10
-0
test/tests/str_functions.py
test/tests/str_functions.py
+4
-0
No files found.
src/runtime/str.cpp
View file @
2748c606
...
...
@@ -47,6 +47,7 @@ extern "C" PyObject* string_splitlines(PyStringObject* self, PyObject* args) noe
namespace
pyston
{
BoxedString
::
BoxedString
(
const
char
*
s
,
size_t
n
)
:
s
(
storage
(),
n
)
{
RELEASE_ASSERT
(
n
!=
llvm
::
StringRef
::
npos
,
""
);
if
(
s
)
{
memmove
(
data
(),
s
,
n
);
data
()[
n
]
=
0
;
...
...
@@ -56,17 +57,20 @@ BoxedString::BoxedString(const char* s, size_t n) : s(storage(), n) {
}
BoxedString
::
BoxedString
(
llvm
::
StringRef
lhs
,
llvm
::
StringRef
rhs
)
:
s
(
storage
(),
lhs
.
size
()
+
rhs
.
size
())
{
RELEASE_ASSERT
(
lhs
.
size
()
+
rhs
.
size
()
!=
llvm
::
StringRef
::
npos
,
""
);
memmove
(
data
(),
lhs
.
data
(),
lhs
.
size
());
memmove
(
data
()
+
lhs
.
size
(),
rhs
.
data
(),
rhs
.
size
());
data
()[
lhs
.
size
()
+
rhs
.
size
()]
=
0
;
}
BoxedString
::
BoxedString
(
llvm
::
StringRef
s
)
:
s
(
storage
(),
s
.
size
())
{
RELEASE_ASSERT
(
s
.
size
()
!=
llvm
::
StringRef
::
npos
,
""
);
memmove
(
data
(),
s
.
data
(),
s
.
size
());
data
()[
s
.
size
()]
=
0
;
}
BoxedString
::
BoxedString
(
size_t
n
,
char
c
)
:
s
(
storage
(),
n
)
{
RELEASE_ASSERT
(
n
!=
llvm
::
StringRef
::
npos
,
""
);
memset
(
data
(),
c
,
n
);
data
()[
n
]
=
0
;
}
...
...
@@ -1694,6 +1698,9 @@ Box* strJoin(BoxedString* self, Box* rhs) {
int
i
=
0
;
if
(
rhs
->
cls
==
str_cls
)
{
BoxedString
*
srhs
=
static_cast
<
BoxedString
*>
(
rhs
);
if
(
srhs
->
size
()
==
0
)
return
EmptyString
;
size_t
rtn_len
=
self
->
size
()
*
(
srhs
->
size
()
-
1
)
+
srhs
->
size
();
BoxedString
*
rtn
=
new
(
rtn_len
)
BoxedString
(
nullptr
,
rtn_len
);
char
*
p
=
rtn
->
data
();
...
...
@@ -1708,6 +1715,9 @@ Box* strJoin(BoxedString* self, Box* rhs) {
return
rtn
;
}
else
if
(
rhs
->
cls
==
list_cls
)
{
BoxedList
*
lrhs
=
static_cast
<
BoxedList
*>
(
rhs
);
if
(
lrhs
->
size
==
0
)
return
EmptyString
;
size_t
rtn_len
=
self
->
size
()
*
(
lrhs
->
size
-
1
);
for
(
int
l
=
0
;
l
<
lrhs
->
size
;
l
++
)
{
...
...
test/tests/str_functions.py
View file @
2748c606
print
"-"
.
join
([
"hello"
,
"world"
])
print
"-"
.
join
((
"hello"
,
"world"
))
print
"hi"
.
join
(
""
)
print
"hi"
.
join
([])
print
"hi"
.
join
(())
print
repr
(
chr
(
0
)
+
chr
(
180
))
print
repr
(
'"'
)
# print repr("'") // don't feel like handling this right now; this should print out (verbatim) "'", ie realize it can use double quotes
...
...
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