summaryrefslogtreecommitdiff
path: root/src/main/smp/sys/aryu8.smp
diff options
context:
space:
mode:
Diffstat (limited to 'src/main/smp/sys/aryu8.smp')
-rw-r--r--src/main/smp/sys/aryu8.smp13
1 files changed, 5 insertions, 8 deletions
diff --git a/src/main/smp/sys/aryu8.smp b/src/main/smp/sys/aryu8.smp
index 18543f13..3f462898 100644
--- a/src/main/smp/sys/aryu8.smp
+++ b/src/main/smp/sys/aryu8.smp
@@ -27,7 +27,7 @@ struct aryu8 {
// Add all of a plain array to the aryu8
val addAry = { u8[~] xs ->
- u32 n=xs#;
+ u32 n = xs#;
_grow(n);
ary.copy(buf,len,xs,0,n);
len += n;
@@ -60,7 +60,7 @@ val atoi = { u8[~] str ->
while( x < str# && str[x] <= ' ' ) x++;
if( x == str# ) return 0;
bool neg = false;
- if( str[x]=='-' ) { neg=true; x++; }
+ if( str[x] == '-' ) { neg = true; x++; }
i64 n = 0;
while( x < str# && '0' <= str[x] <= '9' )
n = n*10 + str[x++]-'0';
@@ -69,10 +69,7 @@ val atoi = { u8[~] str ->
// Zero-terminate a string for libc, reserving one array element for the zero.
{ u8[~] -> u8[] } str0 = { u8[~] str ->
- if( str# == 4294967295 ) libc._exit(1);
- u8[] !strz = new u8[str#+1];
- u32 len=str#;
- ary.copy(strz,0,str,0,len);
- strz[str#] = '\0';
- strz;
+ if( str# == sys.integer.MAX_U32 ) libc._exit(1);
+ // Copy, terminate and return
+ return new u8[str#+1]{i64 i -> i < str# ? str[i] : '\0'; };
};