nitlanguage
/
nit.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
| inline |
side by side
(parent:
c76035c
)
lib/socket: support reading string with null bytes
author
Alexis Laferrière
<alexis.laf@xymus.net>
Fri, 29 May 2015 14:48:42 +0000
(10:48 -0400)
committer
Alexis Laferrière
<alexis.laf@xymus.net>
Fri, 29 May 2015 17:08:16 +0000
(13:08 -0400)
Signed-off-by: Alexis Laferrière <alexis.laf@xymus.net>
lib/socket/socket_c.nit
patch
|
blob
|
history
diff --git
a/lib/socket/socket_c.nit
b/lib/socket/socket_c.nit
index
ee6173e
..
d9056d6
100644
(file)
--- a/
lib/socket/socket_c.nit
+++ b/
lib/socket/socket_c.nit
@@
-138,14
+138,14
@@
extern class NativeSocket `{ int* `}
return write(*self, &byt, 1);
`}
- fun read: String import NativeString.to_s_with_length, NativeString.to_s_with_copy `{
- static char c[1024];
+ fun read: String import NativeString.to_s_with_length, NativeString `{
+ char *c = new_NativeString(1024);
int n = read(*self, c, 1023);
if(n < 0) {
return NativeString_to_s_with_length("",0);
}
c[n] = 0;
- return NativeString_to_s_with_copy(c);
+ return NativeString_to_s_with_length(c, n);
`}
# Sets an option for the socket