From 1cb8279a64f4f79615ac8358927b11237df29bf2 Mon Sep 17 00:00:00 2001 From: Cliff Click Date: Wed, 12 Aug 2026 11:20:14 -0700 Subject: Real argc/argv args Beef up BubbleSort error handling --- chapter25/src/main/smp/sys/aryi64.smp | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) (limited to 'chapter25/src/main/smp/sys/aryi64.smp') diff --git a/chapter25/src/main/smp/sys/aryi64.smp b/chapter25/src/main/smp/sys/aryi64.smp index 8a154f34..c2bc394f 100644 --- a/chapter25/src/main/smp/sys/aryi64.smp +++ b/chapter25/src/main/smp/sys/aryi64.smp @@ -36,6 +36,14 @@ struct aryi64 { str.undo(2).add(']'); }; + // Comma-separated form used by command-line examples. + val csv = { -> + var str = new aryu8(new u8[1]); + for( int i=0; i i64 tmp = buf[i]; buf[i] = buf[j]; @@ -62,9 +70,12 @@ val parseAryI64 = { u8[~] str -> // Parse number commas "123, " until something else while( s.x < s.buf# ) { nums.add(s.number()); + if( s.bad ) return null; if( !s.match(',') ) break; }; // Close the list - return s.match(']') ? nums : null; + if( !s.match(']') ) return null; + s.skip(); + return s.x == s.buf# ? nums : null; }; -- cgit v1.2.3