summaryrefslogtreecommitdiff
path: root/chapter25/src/main/smp/sys/aryi64.smp
diff options
context:
space:
mode:
authorCliff Click <cliffc@acm.org>2026-08-12 11:20:14 -0700
committerCliff Click <cliffc@acm.org>2026-08-12 11:20:14 -0700
commit1cb8279a64f4f79615ac8358927b11237df29bf2 (patch)
treed057b4ee723a9d29e16f2c71959c0ae2773cdb63 /chapter25/src/main/smp/sys/aryi64.smp
parent628452bb9f6137d433395fae5a9f5d780fb0f1e1 (diff)
downloadSimple-1cb8279a64f4f79615ac8358927b11237df29bf2.tar.gz
Simple-1cb8279a64f4f79615ac8358927b11237df29bf2.zip
Real argc/argv args
Beef up BubbleSort error handling
Diffstat (limited to 'chapter25/src/main/smp/sys/aryi64.smp')
-rw-r--r--chapter25/src/main/smp/sys/aryi64.smp13
1 files changed, 12 insertions, 1 deletions
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<len; i++ )
+ str.num(buf[i]).add(',').add(' ');
+ str.undo(2).add('\n');
+ };
+
val swap = { int i, int j ->
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;
};