From 207febef9924c8fa5391185e75d42a7ea480bb38 Mon Sep 17 00:00:00 2001 From: Cliff Click Date: Mon, 10 Aug 2026 11:11:18 -0700 Subject: Chapter 31: Software Drawing, Time, and Graphical Games Co-authored-by: Hsiang-Ying Fu <66062782+fuhsnn@users.noreply.github.com> Co-authored-by: fuhsnn <66062782+fuhsnn@users.noreply.github.com> Co-authored-by: Symious <14933944+symious@users.noreply.github.com> Co-authored-by: Jun Kawasaki Co-authored-by: Claude Opus 5 --- src/main/smp/sys/aryu8.smp | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) (limited to 'src/main/smp/sys/aryu8.smp') 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'; }; }; -- cgit v1.2.3