omega-mv
Omega: a language for verified programs, semantic identity and machine realization. Seed-born work and existing implementations have distinct provenance.
Brought by drakestapleton
omega-mv / train / omega-llm / tools / wsplit / wsplit.om
| 1 | note SPDX-License-Identifier: AGPL-3.0-only |
| 2 | note Built after omega-mv e5b32567 om/sha256/sha256-om2.om by tools/omegallm/wdrive/wbuild (README.md). |
| 3 | note Reproduces make_splits.py and make_d.py using CPython 3.12.3 random algorithms. |
| 4 | note MT19937 attribution and license are in README.md. All source inputs are read-only. |
| 5 | note Bounded string arena, JSON input, row set, and exclusion table; exhaustion refuses. |
| 6 | text wsroot "/home/drakestapleton/handoffs/tool-omega-20261104/" |
| 7 | text wsgrid "round40/data/copy-grid.json" |
| 8 | text wsdiag "round41/c2/diag/d-item.json" |
| 9 | text wslocal "round40/data/localization-screen.json" |
| 10 | text wstarg "round40/data/target-jobs.json" |
| 11 | text wssel "round40/grid-selected.json" |
| 12 | text wsdata "round40/data" |
| 13 | text wsr41 "round41" |
| 14 | text wsitem "item" |
| 15 | text wshello "hello" |
| 16 | text wsprompt "prompt" |
| 17 | text wsanswer "answer" |
| 18 | text wspath "path" |
| 19 | text wslength "length" |
| 20 | text wspatt "pattern" |
| 21 | text wsstem "stem" |
| 22 | text wsstate "state" |
| 23 | text wsjobs "jobs/item" |
| 24 | text wsunread "unread" |
| 25 | text wstask "Task: " |
| 26 | text wsgoal "Goal: " |
| 27 | text wsloop "times in a for loop" |
| 28 | text wsrandom "random" |
| 29 | text wsrunpat "run" |
| 30 | text wspair "pair" |
| 31 | text wssrc40 "round40-grid" |
| 32 | text wssrc41 "round41-d-item" |
| 33 | text wssplits "splits" |
| 34 | text wsd "d" |
| 35 | text wsjson ".json" |
| 36 | text wsrec ".rec" |
| 37 | text wsmeta ".meta" |
| 38 | text wssp " " |
| 39 | text wsnl "\n" |
| 40 | text wstarget "target" |
| 41 | text wsctrl "control" |
| 42 | text wsword "word" |
| 43 | text wsfile "path" |
| 44 | text wshex "0123456789abcdef" |
| 45 | text wshead "[\n" |
| 46 | text wsrow " {\n" |
| 47 | text wssep ",\n" |
| 48 | text wsend "\n }" |
| 49 | text wsclose "\n]" |
| 50 | text wsfld " \"" |
| 51 | text wscolon "\": " |
| 52 | text wssplit "split" |
| 53 | text wssrc "src" |
| 54 | text wsrole "role" |
| 55 | text wsidx "idx" |
| 56 | text wsext ".om" |
| 57 | text wsfileln "\nFile: " |
| 58 | text wsstatex "\nState: unread\nAnswer:\n" |
| 59 | text wsans1 "{\"tool\":\"read_file\",\"path\":\"" |
| 60 | text wsans2 "\"}" |
| 61 | text wsg1 "Task: Write Omega that prints hello" |
| 62 | text wsg2 " followed by a newline.\nAnswer:\n" |
| 63 | text wsg3 "text msg \"hello" |
| 64 | text wsg4 "\\n\"" |
| 65 | text wstempl "templates " |
| 66 | text wsforms " goal forms " |
| 67 | text wsexcl " excluded ids " |
| 68 | text wsusage "usage: wsplit splits|d OUTDIR [seed-offset]\n" |
| 69 | |
| 70 | global wsout uchar 524288 |
| 71 | global wson ulong 1 |
| 72 | global wsarena uchar 4194304 |
| 73 | global wsaoff ulong 32768 |
| 74 | global wsalen ulong 32768 |
| 75 | global wsan ulong 2 |
| 76 | note wsan[0] string count; wsan[1] arena byte count. String zero is empty. |
| 77 | global wsin uchar 524288 |
| 78 | global wsinp ulong 2 |
| 79 | note wsinp[0] cursor; wsinp[1] length. |
| 80 | global wstpls ulong 512 |
| 81 | global wstn ulong 2 |
| 82 | note task ids at 0..255; goal forms at 256..511. |
| 83 | global wsrows ulong 8192 |
| 84 | global wsorder ulong 1024 |
| 85 | global wsrn ulong 1 |
| 86 | note Each row: source or split id, length, pattern, path/word, prompt, answer. |
| 87 | global wsobj ulong 8 |
| 88 | global wsused ulong 32768 |
| 89 | global wsulen ulong 32768 |
| 90 | global wsunc ulong 1 |
| 91 | global wsmt ulong 624 |
| 92 | global wsmti ulong 1 |
| 93 | global wsname uchar 4096 |
| 94 | global wsnamn ulong 1 |
| 95 | global wsodir uchar 4096 |
| 96 | global wsodn ulong 1 |
| 97 | global wsbuf uchar 65536 |
| 98 | global wsraw ulong 4 |
| 99 | note raw prefix position, digit value, digit count, collecting flag. |
| 100 | global wsopts ulong 2 |
| 101 | note command 1 splits / 2 d; seed offset. |
| 102 | global wsdig uchar 16 |
| 103 | global wsids ulong 1 |
| 104 | note Actual pattern for latest ident: 0 random, 1 run, 2 pair. |
| 105 | |
| 106 | fn wsreset to void |
| 107 | put wson 0 0 |
| 108 | end |
| 109 | fn wsbyte c ulong to void |
| 110 | n = get wson 0 |
| 111 | if ge n len wsout |
| 112 | exit 61 |
| 113 | end |
| 114 | put wsout n uchar c |
| 115 | put wson 0 add n 1 |
| 116 | end |
| 117 | fn wsapp s view uchar * to void |
| 118 | for i ulong len s |
| 119 | wsbyte ulong get s i |
| 120 | end |
| 121 | end |
| 122 | fn wsnum v ulong to void |
| 123 | b = new uchar 32 0 |
| 124 | n = ulong 0 |
| 125 | x = v |
| 126 | while true bound 32 |
| 127 | put b n uchar add rem x 10 48 |
| 128 | n = add n 1 |
| 129 | x = div x 10 |
| 130 | if eq x 0 |
| 131 | break |
| 132 | end |
| 133 | end |
| 134 | while gt n 0 bound 32 |
| 135 | n = sub n 1 |
| 136 | wsbyte ulong get b n |
| 137 | end |
| 138 | end |
| 139 | fn wsstore to ulong |
| 140 | id = add get wsan 0 1 |
| 141 | n = get wson 0 |
| 142 | o = get wsan 1 |
| 143 | if or ge id len wsaoff gt add o n len wsarena |
| 144 | exit 61 |
| 145 | end |
| 146 | put wsaoff id o |
| 147 | put wsalen id n |
| 148 | for i ulong n |
| 149 | put wsarena add o i get wsout i |
| 150 | end |
| 151 | put wsan 0 id |
| 152 | put wsan 1 add o n |
| 153 | ret id |
| 154 | end |
| 155 | fn wsstr s view uchar * to ulong |
| 156 | wsreset |
| 157 | wsapp s |
| 158 | ret wsstore |
| 159 | end |
| 160 | fn wsch id ulong i ulong to ulong |
| 161 | if ge i get wsalen id |
| 162 | exit 62 |
| 163 | end |
| 164 | ret ulong get wsarena add get wsaoff id i |
| 165 | end |
| 166 | fn wsadds id ulong to void |
| 167 | for i ulong get wsalen id |
| 168 | wsbyte wsch id i |
| 169 | end |
| 170 | end |
| 171 | fn wseq id ulong s view uchar * to bool |
| 172 | if ne get wsalen id len s |
| 173 | ret false |
| 174 | end |
| 175 | for i ulong len s |
| 176 | if ne wsch id i ulong get s i |
| 177 | ret false |
| 178 | end |
| 179 | end |
| 180 | ret true |
| 181 | end |
| 182 | fn wscmp a ulong b ulong to long |
| 183 | n = get wsalen a |
| 184 | if lt get wsalen b n |
| 185 | n = get wsalen b |
| 186 | end |
| 187 | for i ulong n |
| 188 | x = wsch a i |
| 189 | y = wsch b i |
| 190 | if lt x y |
| 191 | ret -1 |
| 192 | end |
| 193 | if gt x y |
| 194 | ret 1 |
| 195 | end |
| 196 | end |
| 197 | ret sub long get wsalen a long get wsalen b |
| 198 | end |
| 199 | fn wsprefix id ulong pos ulong s view uchar * to bool |
| 200 | if gt add pos len s get wsalen id |
| 201 | ret false |
| 202 | end |
| 203 | for i ulong len s |
| 204 | if ne wsch id add pos i ulong get s i |
| 205 | ret false |
| 206 | end |
| 207 | end |
| 208 | ret true |
| 209 | end |
| 210 | fn wscontains id ulong s view uchar * to bool |
| 211 | for i ulong get wsalen id |
| 212 | if wsprefix id i s |
| 213 | ret true |
| 214 | end |
| 215 | end |
| 216 | ret false |
| 217 | end |
| 218 | fn wsdigit c ulong to bool |
| 219 | ret and ge c 48 le c 57 |
| 220 | end |
| 221 | |
| 222 | note CPython-compatible helpers copied from wprobe.om at 72d3377, symbols renamed. |
| 223 | fn wsinit s ulong to void |
| 224 | put wsmt 0 s |
| 225 | for i ulong 623 |
| 226 | p = get wsmt i |
| 227 | put wsmt add i 1 and add mul 1812433253 xor p shr p 30 add i 1 4294967295 |
| 228 | end |
| 229 | end |
| 230 | note init_by_array with the key [s]; exit 2 when s needs more than 32 bits. |
| 231 | fn wsseed s ulong to void |
| 232 | if gt s 4294967295 |
| 233 | exit 2 |
| 234 | end |
| 235 | wsinit 19650218 |
| 236 | i = ulong 1 |
| 237 | for k ulong 624 |
| 238 | p = get wsmt sub i 1 |
| 239 | put wsmt i and add xor get wsmt i mul xor p shr p 30 1664525 s 4294967295 |
| 240 | i = wswrap add i 1 |
| 241 | end |
| 242 | for k2 ulong 623 |
| 243 | p2 = get wsmt sub i 1 |
| 244 | put wsmt i and sub xor get wsmt i mul xor p2 shr p2 30 1566083941 i 4294967295 |
| 245 | i = wswrap add i 1 |
| 246 | end |
| 247 | put wsmt 0 2147483648 |
| 248 | put wsmti 0 624 |
| 249 | end |
| 250 | fn wswrap i ulong to ulong |
| 251 | if lt i 624 |
| 252 | ret i |
| 253 | end |
| 254 | put wsmt 0 get wsmt 623 |
| 255 | ret 1 |
| 256 | end |
| 257 | fn wsrand to ulong |
| 258 | if ge get wsmti 0 624 |
| 259 | wstwist |
| 260 | end |
| 261 | i = get wsmti 0 |
| 262 | put wsmti 0 add i 1 |
| 263 | y = get wsmt i |
| 264 | y = xor y shr y 11 |
| 265 | y = xor y and shl y 7 2636928640 |
| 266 | y = xor y and shl y 15 4022730752 |
| 267 | ret xor y shr y 18 |
| 268 | end |
| 269 | fn wstwist to void |
| 270 | for k ulong 624 |
| 271 | y = or and get wsmt k 2147483648 and get wsmt rem add k 1 624 2147483647 |
| 272 | v = xor get wsmt rem add k 397 624 shr y 1 |
| 273 | if eq and y 1 1 |
| 274 | v = xor v 2567483615 |
| 275 | end |
| 276 | put wsmt k v |
| 277 | end |
| 278 | put wsmti 0 0 |
| 279 | end |
| 280 | note CPython _randbelow: high k bits of a uint32 output, with rejection. |
| 281 | fn wsbelow m ulong to ulong |
| 282 | k = ulong 0 |
| 283 | while gt shr m k 0 bound 64 |
| 284 | k = add k 1 |
| 285 | end |
| 286 | for i ulong 100000 |
| 287 | x = shr wsrand sub 32 k |
| 288 | if lt x m |
| 289 | ret x |
| 290 | end |
| 291 | end |
| 292 | exit 63 |
| 293 | end |
| 294 | |
| 295 | note Numeric key plus digit length preserves leading zero strings; open-addressed exact set. |
| 296 | fn wsinsert v ulong n ulong to bool |
| 297 | if eq n 0 |
| 298 | ret false |
| 299 | end |
| 300 | i = and xor v shl n 16 32767 |
| 301 | while true bound 32768 |
| 302 | if eq get wsulen i 0 |
| 303 | put wsused i v |
| 304 | put wsulen i n |
| 305 | put wsunc 0 add get wsunc 0 1 |
| 306 | ret true |
| 307 | end |
| 308 | if and eq get wsulen i n eq get wsused i v |
| 309 | ret false |
| 310 | end |
| 311 | i = and add i 1 32767 |
| 312 | end |
| 313 | exit 61 |
| 314 | end |
| 315 | fn wsrawend to void |
| 316 | if gt get wsraw 2 0 |
| 317 | ok = wsinsert get wsraw 1 get wsraw 2 |
| 318 | end |
| 319 | put wsraw 1 0 |
| 320 | put wsraw 2 0 |
| 321 | put wsraw 3 0 |
| 322 | end |
| 323 | fn wsrawbyte c ulong pref view uchar * to void |
| 324 | if eq get wsraw 3 1 |
| 325 | if wsdigit c |
| 326 | n = add get wsraw 2 1 |
| 327 | if gt n 18 |
| 328 | exit 61 |
| 329 | end |
| 330 | put wsraw 2 n |
| 331 | put wsraw 1 add mul get wsraw 1 10 sub c 48 |
| 332 | ret |
| 333 | end |
| 334 | wsrawend |
| 335 | end |
| 336 | p = get wsraw 0 |
| 337 | if eq c ulong get pref p |
| 338 | p = add p 1 |
| 339 | else |
| 340 | p = 0 |
| 341 | if eq c ulong get pref 0 |
| 342 | p = 1 |
| 343 | end |
| 344 | end |
| 345 | if eq p len pref |
| 346 | put wsraw 3 1 |
| 347 | p = 0 |
| 348 | end |
| 349 | put wsraw 0 p |
| 350 | end |
| 351 | fn wsle b view uchar * o ulong n ulong to ulong |
| 352 | v = ulong 0 |
| 353 | for i ulong n |
| 354 | v = or v shl ulong get b add o i mul i 8 |
| 355 | end |
| 356 | ret v |
| 357 | end |
| 358 | fn wsclosefd fd int to void |
| 359 | r = fclose fd |
| 360 | if lt r 0 |
| 361 | exit 70 |
| 362 | end |
| 363 | end |
| 364 | fn wsscan mode ulong to void |
| 365 | st = new uchar 128 0 |
| 366 | fd = int fopen wsname 0 get wsnamn 0 0 0 |
| 367 | if lt fd 0 |
| 368 | exit 70 |
| 369 | end |
| 370 | r = fstat fd st 0 128 |
| 371 | if lt r 0 |
| 372 | exit 70 |
| 373 | end |
| 374 | if ge wsle st 48 8 52428800 |
| 375 | wsclosefd fd |
| 376 | ret |
| 377 | end |
| 378 | for i ulong 4 |
| 379 | put wsraw i 0 |
| 380 | end |
| 381 | while true bound 999999 |
| 382 | r = read fd wsbuf 0 len wsbuf |
| 383 | if lt r 0 |
| 384 | exit 70 |
| 385 | end |
| 386 | if eq r 0 |
| 387 | break |
| 388 | end |
| 389 | for i ulong ulong r |
| 390 | if eq mode 0 |
| 391 | wsrawbyte ulong get wsbuf i wsitem |
| 392 | else |
| 393 | wsrawbyte ulong get wsbuf i wshello |
| 394 | end |
| 395 | end |
| 396 | end |
| 397 | wsrawend |
| 398 | wsclosefd fd |
| 399 | end |
| 400 | fn wssetname rel view uchar * to void |
| 401 | n = len wsroot |
| 402 | for i ulong n |
| 403 | put wsname i get wsroot i |
| 404 | end |
| 405 | for i ulong len rel |
| 406 | put wsname add n i get rel i |
| 407 | end |
| 408 | put wsnamn 0 add n len rel |
| 409 | end |
| 410 | note Linux getdents64 record: reclen at 16, type at 18, name at 19. |
| 411 | fn wswalk recur bool mode ulong depth ulong to void |
| 412 | buf = new uchar 8192 0 |
| 413 | if gt depth 32 |
| 414 | exit 61 |
| 415 | end |
| 416 | base = get wsnamn 0 |
| 417 | note O_DIRECTORY on Linux AArch64, as seed/host/tests/directories.om. |
| 418 | fd = int fopen wsname 0 base 16384 0 |
| 419 | if lt fd 0 |
| 420 | exit 70 |
| 421 | end |
| 422 | while true bound 999999 |
| 423 | r = getdnts fd buf 0 len buf |
| 424 | if lt r 0 |
| 425 | exit 70 |
| 426 | end |
| 427 | if eq r 0 |
| 428 | break |
| 429 | end |
| 430 | o = ulong 0 |
| 431 | while lt o ulong r bound 8192 |
| 432 | sz = wsle buf add o 16 2 |
| 433 | if or lt sz 20 gt add o sz ulong r |
| 434 | exit 62 |
| 435 | end |
| 436 | if ne get buf add o 19 46 |
| 437 | wsentry buf o base recur mode depth |
| 438 | end |
| 439 | o = add o sz |
| 440 | end |
| 441 | end |
| 442 | put wsnamn 0 base |
| 443 | wsclosefd fd |
| 444 | end |
| 445 | fn wsentry buf view uchar 8192 o ulong base ulong recur bool mode ulong depth ulong to void |
| 446 | n = ulong 0 |
| 447 | p = add o 19 |
| 448 | while ne get buf add p n 0 bound 4096 |
| 449 | if ge add base add n 1 4095 |
| 450 | exit 61 |
| 451 | end |
| 452 | put wsname add base add n 1 get buf add p n |
| 453 | n = add n 1 |
| 454 | end |
| 455 | put wsname base 47 |
| 456 | put wsnamn 0 add base add n 1 |
| 457 | kind = get buf add o 18 |
| 458 | if eq kind 4 |
| 459 | if recur |
| 460 | wswalk true mode add depth 1 |
| 461 | end |
| 462 | else |
| 463 | if eq kind 8 |
| 464 | if wssuffix |
| 465 | wsscan mode |
| 466 | end |
| 467 | else |
| 468 | note The frozen inputs contain no symlinks or DT_UNKNOWN entries. Refuse rather than omit. |
| 469 | exit 62 |
| 470 | end |
| 471 | end |
| 472 | put wsnamn 0 base |
| 473 | end |
| 474 | fn wssuffix to bool |
| 475 | n = get wsnamn 0 |
| 476 | if lt n 5 |
| 477 | ret false |
| 478 | end |
| 479 | for j ulong 5 |
| 480 | if ne get wsname add sub n 5 j get wsjson j |
| 481 | ret false |
| 482 | end |
| 483 | end |
| 484 | ret true |
| 485 | end |
| 486 | |
| 487 | note JSON tokenizer for the frozen top-level arrays of objects. Strings decode to UTF-8. |
| 488 | global wstok ulong 2 |
| 489 | fn wspeek to ulong |
| 490 | if ge get wsinp 0 get wsinp 1 |
| 491 | exit 62 |
| 492 | end |
| 493 | ret ulong get wsin get wsinp 0 |
| 494 | end |
| 495 | fn wstake to ulong |
| 496 | c = wspeek |
| 497 | put wsinp 0 add get wsinp 0 1 |
| 498 | ret c |
| 499 | end |
| 500 | fn wshexval c ulong to ulong |
| 501 | if wsdigit c |
| 502 | ret sub c 48 |
| 503 | end |
| 504 | if and ge c 97 le c 102 |
| 505 | ret sub c 87 |
| 506 | end |
| 507 | if and ge c 65 le c 70 |
| 508 | ret sub c 55 |
| 509 | end |
| 510 | exit 62 |
| 511 | end |
| 512 | fn wshex4 to ulong |
| 513 | v = ulong 0 |
| 514 | for i ulong 4 |
| 515 | v = add mul v 16 wshexval wstake |
| 516 | end |
| 517 | ret v |
| 518 | end |
| 519 | fn wsutf v ulong to void |
| 520 | if lt v 128 |
| 521 | wsbyte v |
| 522 | ret |
| 523 | end |
| 524 | if lt v 2048 |
| 525 | wsbyte or 192 shr v 6 |
| 526 | else |
| 527 | if lt v 65536 |
| 528 | wsbyte or 224 shr v 12 |
| 529 | else |
| 530 | wsbyte or 240 shr v 18 |
| 531 | wsbyte or 128 and shr v 12 63 |
| 532 | end |
| 533 | wsbyte or 128 and shr v 6 63 |
| 534 | end |
| 535 | wsbyte or 128 and v 63 |
| 536 | end |
| 537 | fn wsescape to void |
| 538 | c = wstake |
| 539 | if or or eq c 34 eq c 92 eq c 47 |
| 540 | wsbyte c |
| 541 | ret |
| 542 | end |
| 543 | if eq c 98 |
| 544 | wsbyte 8 |
| 545 | ret |
| 546 | end |
| 547 | if eq c 102 |
| 548 | wsbyte 12 |
| 549 | ret |
| 550 | end |
| 551 | if eq c 110 |
| 552 | wsbyte 10 |
| 553 | ret |
| 554 | end |
| 555 | if eq c 114 |
| 556 | wsbyte 13 |
| 557 | ret |
| 558 | end |
| 559 | if eq c 116 |
| 560 | wsbyte 9 |
| 561 | ret |
| 562 | end |
| 563 | if eq c 117 |
| 564 | v = wshex4 |
| 565 | if and ge v 55296 le v 56319 |
| 566 | if ne wstake 92 |
| 567 | exit 62 |
| 568 | end |
| 569 | if ne wstake 117 |
| 570 | exit 62 |
| 571 | end |
| 572 | w = wshex4 |
| 573 | if or lt w 56320 gt w 57343 |
| 574 | exit 62 |
| 575 | end |
| 576 | v = add 65536 add shl sub v 55296 10 sub w 56320 |
| 577 | end |
| 578 | wsutf v |
| 579 | ret |
| 580 | end |
| 581 | exit 62 |
| 582 | end |
| 583 | fn wsnext to void |
| 584 | while le wspeek 32 bound 524288 |
| 585 | c = wstake |
| 586 | end |
| 587 | c = wstake |
| 588 | put wstok 0 c |
| 589 | put wstok 1 0 |
| 590 | if eq c 34 |
| 591 | wsreset |
| 592 | while true bound 524288 |
| 593 | c = wstake |
| 594 | if eq c 34 |
| 595 | break |
| 596 | end |
| 597 | if eq c 92 |
| 598 | wsescape |
| 599 | else |
| 600 | if lt c 32 |
| 601 | exit 62 |
| 602 | end |
| 603 | wsbyte c |
| 604 | end |
| 605 | end |
| 606 | put wstok 1 wsstore |
| 607 | ret |
| 608 | end |
| 609 | if or wsdigit c eq c 45 |
| 610 | v = ulong 0 |
| 611 | if ne c 45 |
| 612 | v = sub c 48 |
| 613 | end |
| 614 | while wsdigit wspeek bound 20 |
| 615 | v = add mul v 10 sub wstake 48 |
| 616 | end |
| 617 | put wstok 0 48 |
| 618 | put wstok 1 v |
| 619 | ret |
| 620 | end |
| 621 | if or or eq c 116 eq c 102 eq c 110 |
| 622 | while and ge wspeek 97 le wspeek 122 bound 8 |
| 623 | c = wstake |
| 624 | end |
| 625 | put wstok 0 1 |
| 626 | end |
| 627 | end |
| 628 | fn wsexpect c ulong to void |
| 629 | wsnext |
| 630 | if ne get wstok 0 c |
| 631 | exit 62 |
| 632 | end |
| 633 | end |
| 634 | fn wsskip to void |
| 635 | if or eq get wstok 0 123 eq get wstok 0 91 |
| 636 | depth = ulong 1 |
| 637 | while gt depth 0 bound 524288 |
| 638 | wsnext |
| 639 | c = get wstok 0 |
| 640 | if or eq c 123 eq c 91 |
| 641 | depth = add depth 1 |
| 642 | end |
| 643 | if or eq c 125 eq c 93 |
| 644 | depth = sub depth 1 |
| 645 | end |
| 646 | end |
| 647 | end |
| 648 | end |
| 649 | fn wsfield key ulong to ulong |
| 650 | if wseq key wsprompt |
| 651 | ret 0 |
| 652 | end |
| 653 | if wseq key wsanswer |
| 654 | ret 1 |
| 655 | end |
| 656 | if wseq key wspath |
| 657 | ret 2 |
| 658 | end |
| 659 | if wseq key wspatt |
| 660 | ret 3 |
| 661 | end |
| 662 | if wseq key wslength |
| 663 | ret 4 |
| 664 | end |
| 665 | if or wseq key wsstem wseq key wsstate |
| 666 | ret 5 |
| 667 | end |
| 668 | ret 6 |
| 669 | end |
| 670 | fn wsobject to void |
| 671 | for i ulong 8 |
| 672 | put wsobj i 0 |
| 673 | end |
| 674 | while true bound 4096 |
| 675 | wsnext |
| 676 | if eq get wstok 0 125 |
| 677 | ret |
| 678 | end |
| 679 | if ne get wstok 0 34 |
| 680 | exit 62 |
| 681 | end |
| 682 | key = wsfield get wstok 1 |
| 683 | wsexpect 58 |
| 684 | wsnext |
| 685 | if lt key 6 |
| 686 | if eq key 4 |
| 687 | if ne get wstok 0 48 |
| 688 | exit 62 |
| 689 | end |
| 690 | else |
| 691 | if ne get wstok 0 34 |
| 692 | exit 62 |
| 693 | end |
| 694 | end |
| 695 | put wsobj key get wstok 1 |
| 696 | end |
| 697 | wsskip |
| 698 | wsnext |
| 699 | if eq get wstok 0 125 |
| 700 | ret |
| 701 | end |
| 702 | if ne get wstok 0 44 |
| 703 | exit 62 |
| 704 | end |
| 705 | end |
| 706 | exit 61 |
| 707 | end |
| 708 | fn wstinsert id ulong kind ulong to void |
| 709 | n = get wstn kind |
| 710 | base = mul kind 256 |
| 711 | p = ulong 0 |
| 712 | while lt p n bound 256 |
| 713 | c = wscmp id get wstpls add base p |
| 714 | if eq c 0 |
| 715 | ret |
| 716 | end |
| 717 | if lt c 0 |
| 718 | break |
| 719 | end |
| 720 | p = add p 1 |
| 721 | end |
| 722 | if ge n 256 |
| 723 | exit 61 |
| 724 | end |
| 725 | j = n |
| 726 | while gt j p bound 256 |
| 727 | put wstpls add base j get wstpls add base sub j 1 |
| 728 | j = sub j 1 |
| 729 | end |
| 730 | put wstpls add base p id |
| 731 | put wstn kind add n 1 |
| 732 | end |
| 733 | fn wsline id ulong a ulong e ulong to void |
| 734 | kind = ulong 2 |
| 735 | if wsprefix id a wstask |
| 736 | kind = 0 |
| 737 | end |
| 738 | if wsprefix id a wsgoal |
| 739 | kind = 1 |
| 740 | end |
| 741 | if eq kind 2 |
| 742 | ret |
| 743 | end |
| 744 | wsreset |
| 745 | i = a |
| 746 | while lt i e bound 524288 |
| 747 | c = wsch id i |
| 748 | if and eq kind 1 wsdigit c |
| 749 | wsbyte 123 |
| 750 | wsbyte 125 |
| 751 | while lt i e bound 524288 |
| 752 | if not wsdigit wsch id i |
| 753 | break |
| 754 | end |
| 755 | i = add i 1 |
| 756 | end |
| 757 | else |
| 758 | wsbyte c |
| 759 | i = add i 1 |
| 760 | end |
| 761 | end |
| 762 | wstinsert wsstore kind |
| 763 | end |
| 764 | fn wstemplate id ulong to void |
| 765 | a = ulong 0 |
| 766 | n = get wsalen id |
| 767 | for i ulong n |
| 768 | if eq wsch id i 10 |
| 769 | wsline id a i |
| 770 | a = add i 1 |
| 771 | end |
| 772 | end |
| 773 | wsline id a n |
| 774 | end |
| 775 | fn wsrowput r ulong col ulong v ulong to void |
| 776 | if ge r 1024 |
| 777 | exit 61 |
| 778 | end |
| 779 | put wsrows add mul r 8 col v |
| 780 | end |
| 781 | fn wsrowget r ulong col ulong to ulong |
| 782 | ret get wsrows add mul r 8 col |
| 783 | end |
| 784 | fn wsdiagnose mode ulong to void |
| 785 | if eq mode 1 |
| 786 | if not wseq get wsobj 5 wsjobs |
| 787 | ret |
| 788 | end |
| 789 | else |
| 790 | if not wseq get wsobj 5 wsunread |
| 791 | ret |
| 792 | end |
| 793 | end |
| 794 | r = get wsrn 0 |
| 795 | s = ulong 0 |
| 796 | if eq mode 1 |
| 797 | s = wsstr wssrc40 |
| 798 | else |
| 799 | s = wsstr wssrc41 |
| 800 | end |
| 801 | wsrowput r 0 s |
| 802 | wsrowput r 1 get wsobj 4 |
| 803 | wsrowput r 2 get wsobj 3 |
| 804 | wsrowput r 3 get wsobj 2 |
| 805 | wsrowput r 4 get wsobj 0 |
| 806 | wsrowput r 5 get wsobj 1 |
| 807 | put wsorder r r |
| 808 | put wsrn 0 add r 1 |
| 809 | end |
| 810 | fn wsload rel view uchar * mode ulong to void |
| 811 | wssetname rel |
| 812 | fd = int fopen wsname 0 get wsnamn 0 0 0 |
| 813 | if lt fd 0 |
| 814 | exit 70 |
| 815 | end |
| 816 | n = ulong 0 |
| 817 | while true bound 524288 |
| 818 | if eq n len wsin |
| 819 | exit 61 |
| 820 | end |
| 821 | r = read fd wsin n sub len wsin n |
| 822 | if lt r 0 |
| 823 | exit 70 |
| 824 | end |
| 825 | if eq r 0 |
| 826 | break |
| 827 | end |
| 828 | n = add n ulong r |
| 829 | end |
| 830 | wsclosefd fd |
| 831 | put wsinp 0 0 |
| 832 | put wsinp 1 n |
| 833 | wsexpect 91 |
| 834 | while true bound 4096 |
| 835 | wsnext |
| 836 | if eq get wstok 0 93 |
| 837 | break |
| 838 | end |
| 839 | if ne get wstok 0 123 |
| 840 | exit 62 |
| 841 | end |
| 842 | wsobject |
| 843 | if eq mode 0 |
| 844 | wstemplate get wsobj 0 |
| 845 | else |
| 846 | wsdiagnose mode |
| 847 | end |
| 848 | wsnext |
| 849 | if eq get wstok 0 93 |
| 850 | break |
| 851 | end |
| 852 | if ne get wstok 0 44 |
| 853 | exit 62 |
| 854 | end |
| 855 | end |
| 856 | end |
| 857 | |
| 858 | note CPython sample(range(1,10),2) takes the small-population pool branch. |
| 859 | fn wspairdigits n ulong to void |
| 860 | a = wsbelow 9 |
| 861 | b = wsbelow 8 |
| 862 | if eq b a |
| 863 | b = 8 |
| 864 | end |
| 865 | for i ulong n |
| 866 | v = a |
| 867 | if eq rem div i 2 2 1 |
| 868 | v = b |
| 869 | end |
| 870 | put wsdig i uchar add v 49 |
| 871 | end |
| 872 | end |
| 873 | fn wsdraw n ulong pat ulong to void |
| 874 | if eq pat 0 |
| 875 | for i ulong n |
| 876 | put wsdig i uchar add wsbelow 10 48 |
| 877 | end |
| 878 | ret |
| 879 | end |
| 880 | if eq pat 1 |
| 881 | a = add wsbelow 9 1 |
| 882 | step = wsbelow 2 |
| 883 | for i ulong n |
| 884 | v = add a i |
| 885 | if eq step 1 |
| 886 | v = add a sub 10 rem i 10 |
| 887 | end |
| 888 | put wsdig i uchar add rem v 10 48 |
| 889 | end |
| 890 | ret |
| 891 | end |
| 892 | wspairdigits n |
| 893 | end |
| 894 | fn wsident n ulong pat ulong to ulong |
| 895 | p = pat |
| 896 | tries = ulong 0 |
| 897 | while true bound 999999 |
| 898 | tries = add tries 1 |
| 899 | if gt tries 200 |
| 900 | p = 0 |
| 901 | end |
| 902 | wsdraw n p |
| 903 | if eq get wsdig 0 48 |
| 904 | continue |
| 905 | end |
| 906 | v = ulong 0 |
| 907 | for i ulong n |
| 908 | v = add mul v 10 sub ulong get wsdig i 48 |
| 909 | end |
| 910 | if wsinsert v n |
| 911 | put wsids 0 p |
| 912 | wsreset |
| 913 | for i ulong n |
| 914 | wsbyte ulong get wsdig i |
| 915 | end |
| 916 | ret wsstore |
| 917 | end |
| 918 | end |
| 919 | exit 63 |
| 920 | end |
| 921 | fn wsgoaltext form ulong to ulong |
| 922 | vals = new ulong 64 0 |
| 923 | k = ulong 0 |
| 924 | for i ulong get wsalen form |
| 925 | if eq wsch form i 123 |
| 926 | k = add k 1 |
| 927 | end |
| 928 | end |
| 929 | for i ulong k |
| 930 | if lt i sub k 1 |
| 931 | put vals i add wsbelow 8 2 |
| 932 | else |
| 933 | put vals i add wsbelow 99 1 |
| 934 | end |
| 935 | end |
| 936 | if wscontains form wsloop |
| 937 | put vals 0 add wsbelow 8 2 |
| 938 | put vals 1 add wsbelow 5 1 |
| 939 | put vals 2 add wsbelow 99 1 |
| 940 | end |
| 941 | wsreset |
| 942 | i = ulong 0 |
| 943 | j = ulong 0 |
| 944 | while lt i get wsalen form bound 524288 |
| 945 | c = wsch form i |
| 946 | if eq c 123 |
| 947 | if ne wsch form add i 1 125 |
| 948 | exit 62 |
| 949 | end |
| 950 | wsnum get vals j |
| 951 | j = add j 1 |
| 952 | i = add i 2 |
| 953 | else |
| 954 | wsbyte c |
| 955 | i = add i 1 |
| 956 | end |
| 957 | end |
| 958 | ret wsstore |
| 959 | end |
| 960 | fn wsgenpath r ulong ids ulong to void |
| 961 | wsreset |
| 962 | wsapp wsjobs |
| 963 | wsadds ids |
| 964 | wsapp wsext |
| 965 | pathid = wsstore |
| 966 | wsrowput r 3 pathid |
| 967 | ti = wsbelow get wstn 0 |
| 968 | taskid = get wstpls ti |
| 969 | fi = wsbelow get wstn 1 |
| 970 | goalid = wsgoaltext get wstpls add fi 256 |
| 971 | wsreset |
| 972 | wsadds taskid |
| 973 | wsapp wsfileln |
| 974 | wsadds pathid |
| 975 | wsbyte 10 |
| 976 | wsadds goalid |
| 977 | wsapp wsstatex |
| 978 | wsrowput r 4 wsstore |
| 979 | wsreset |
| 980 | wsapp wsans1 |
| 981 | wsadds pathid |
| 982 | wsapp wsans2 |
| 983 | wsrowput r 5 wsstore |
| 984 | end |
| 985 | fn wsgenword r ulong ids ulong to void |
| 986 | wsreset |
| 987 | wsapp wshello |
| 988 | wsadds ids |
| 989 | wsrowput r 3 wsstore |
| 990 | wsreset |
| 991 | wsapp wsg1 |
| 992 | wsadds ids |
| 993 | wsapp wsg2 |
| 994 | wsrowput r 4 wsstore |
| 995 | wsreset |
| 996 | wsapp wsg3 |
| 997 | wsadds ids |
| 998 | wsapp wsg4 |
| 999 | wsrowput r 5 wsstore |
| 1000 | end |
| 1001 | fn wsgenrow splitid ulong n ulong i ulong word bool to void |
| 1002 | p = rem i 4 |
| 1003 | if lt p 2 |
| 1004 | p = 0 |
| 1005 | else |
| 1006 | p = sub p 1 |
| 1007 | end |
| 1008 | ids = wsident n p |
| 1009 | r = get wsrn 0 |
| 1010 | wsrowput r 0 splitid |
| 1011 | wsrowput r 1 n |
| 1012 | p = get wsids 0 |
| 1013 | patid = ulong 0 |
| 1014 | if eq p 0 |
| 1015 | patid = wsstr wsrandom |
| 1016 | end |
| 1017 | if eq p 1 |
| 1018 | patid = wsstr wsrunpat |
| 1019 | end |
| 1020 | if eq p 2 |
| 1021 | patid = wsstr wspair |
| 1022 | end |
| 1023 | wsrowput r 2 patid |
| 1024 | if word |
| 1025 | wsgenword r ids |
| 1026 | else |
| 1027 | wsgenpath r ids |
| 1028 | end |
| 1029 | put wsorder r r |
| 1030 | put wsrn 0 add r 1 |
| 1031 | end |
| 1032 | fn wsshuffle to void |
| 1033 | i = sub get wsrn 0 1 |
| 1034 | while gt i 0 bound 1024 |
| 1035 | j = wsbelow add i 1 |
| 1036 | v = get wsorder i |
| 1037 | put wsorder i get wsorder j |
| 1038 | put wsorder j v |
| 1039 | i = sub i 1 |
| 1040 | end |
| 1041 | end |
| 1042 | fn wsgenerate name ulong seed ulong per ulong ctrl ulong word bool to void |
| 1043 | put wsrn 0 0 |
| 1044 | wsseed add seed get wsopts 1 |
| 1045 | wsreset |
| 1046 | wsbyte name |
| 1047 | splitid = wsstore |
| 1048 | for g ulong 6 |
| 1049 | n = add g 6 |
| 1050 | count = per |
| 1051 | if ge g 3 |
| 1052 | n = g |
| 1053 | count = ctrl |
| 1054 | end |
| 1055 | if and word eq n 3 |
| 1056 | continue |
| 1057 | end |
| 1058 | for i ulong count |
| 1059 | wsgenrow splitid n i word |
| 1060 | end |
| 1061 | end |
| 1062 | wsshuffle |
| 1063 | wsemit name false word |
| 1064 | end |
| 1065 | |
| 1066 | note json.dumps(indent=1, ensure_ascii=True): lowercase hex; no terminal newline. |
| 1067 | fn wsuesc v ulong to void |
| 1068 | wsbyte 92 |
| 1069 | wsbyte 117 |
| 1070 | for i ulong 4 |
| 1071 | j = and shr v mul sub 3 i 4 15 |
| 1072 | wsbyte ulong get wshex j |
| 1073 | end |
| 1074 | end |
| 1075 | fn wsquoted id ulong to void |
| 1076 | wsbyte 34 |
| 1077 | i = ulong 0 |
| 1078 | while lt i get wsalen id bound 524288 |
| 1079 | c = wsch id i |
| 1080 | i = add i 1 |
| 1081 | if or eq c 34 eq c 92 |
| 1082 | wsbyte 92 |
| 1083 | wsbyte c |
| 1084 | continue |
| 1085 | end |
| 1086 | if lt c 32 |
| 1087 | esc = ulong 0 |
| 1088 | if eq c 8 |
| 1089 | esc = 98 |
| 1090 | end |
| 1091 | if eq c 9 |
| 1092 | esc = 116 |
| 1093 | end |
| 1094 | if eq c 10 |
| 1095 | esc = 110 |
| 1096 | end |
| 1097 | if eq c 12 |
| 1098 | esc = 102 |
| 1099 | end |
| 1100 | if eq c 13 |
| 1101 | esc = 114 |
| 1102 | end |
| 1103 | if ne esc 0 |
| 1104 | wsbyte 92 |
| 1105 | wsbyte esc |
| 1106 | else |
| 1107 | wsuesc c |
| 1108 | end |
| 1109 | continue |
| 1110 | end |
| 1111 | if eq c 127 |
| 1112 | wsuesc c |
| 1113 | continue |
| 1114 | end |
| 1115 | if ge c 128 |
| 1116 | k = ulong 0 |
| 1117 | if and ge c 194 lt c 224 |
| 1118 | k = 1 |
| 1119 | c = and c 31 |
| 1120 | else |
| 1121 | if lt c 240 |
| 1122 | k = 2 |
| 1123 | c = and c 15 |
| 1124 | else |
| 1125 | if gt c 244 |
| 1126 | exit 62 |
| 1127 | end |
| 1128 | k = 3 |
| 1129 | c = and c 7 |
| 1130 | end |
| 1131 | end |
| 1132 | for j ulong k |
| 1133 | d = wsch id i |
| 1134 | if ne and d 192 128 |
| 1135 | exit 62 |
| 1136 | end |
| 1137 | c = or shl c 6 and d 63 |
| 1138 | i = add i 1 |
| 1139 | end |
| 1140 | if gt c 65535 |
| 1141 | v = sub c 65536 |
| 1142 | wsuesc add 55296 shr v 10 |
| 1143 | wsuesc add 56320 and v 1023 |
| 1144 | else |
| 1145 | wsuesc c |
| 1146 | end |
| 1147 | else |
| 1148 | wsbyte c |
| 1149 | end |
| 1150 | end |
| 1151 | wsbyte 34 |
| 1152 | end |
| 1153 | fn wskey s view uchar * to void |
| 1154 | wsapp wsfld |
| 1155 | wsapp s |
| 1156 | wsapp wscolon |
| 1157 | end |
| 1158 | fn wsroleout n ulong quotes bool to void |
| 1159 | if quotes |
| 1160 | wsbyte 34 |
| 1161 | end |
| 1162 | if ge n 6 |
| 1163 | wsapp wstarget |
| 1164 | else |
| 1165 | wsapp wsctrl |
| 1166 | end |
| 1167 | if quotes |
| 1168 | wsbyte 34 |
| 1169 | end |
| 1170 | end |
| 1171 | fn wsjsonrow idx ulong diag bool word bool to void |
| 1172 | r = get wsorder idx |
| 1173 | n = wsrowget r 1 |
| 1174 | wsapp wsrow |
| 1175 | if diag |
| 1176 | wskey wssrc |
| 1177 | else |
| 1178 | wskey wssplit |
| 1179 | end |
| 1180 | wsquoted wsrowget r 0 |
| 1181 | wsapp wssep |
| 1182 | wskey wslength |
| 1183 | wsnum n |
| 1184 | wsapp wssep |
| 1185 | if not diag |
| 1186 | wskey wsrole |
| 1187 | wsroleout n true |
| 1188 | wsapp wssep |
| 1189 | end |
| 1190 | wskey wspatt |
| 1191 | wsquoted wsrowget r 2 |
| 1192 | wsapp wssep |
| 1193 | if word |
| 1194 | wskey wsword |
| 1195 | else |
| 1196 | wskey wspath |
| 1197 | end |
| 1198 | wsquoted wsrowget r 3 |
| 1199 | wsapp wssep |
| 1200 | wskey wsprompt |
| 1201 | wsquoted wsrowget r 4 |
| 1202 | wsapp wssep |
| 1203 | wskey wsanswer |
| 1204 | wsquoted wsrowget r 5 |
| 1205 | wsapp wssep |
| 1206 | wskey wsidx |
| 1207 | wsnum idx |
| 1208 | if diag |
| 1209 | wsapp wssep |
| 1210 | wskey wsrole |
| 1211 | wsroleout n true |
| 1212 | end |
| 1213 | wsapp wsend |
| 1214 | end |
| 1215 | fn wswriteout fd int to void |
| 1216 | p = ulong 0 |
| 1217 | n = get wson 0 |
| 1218 | while lt p n bound 524288 |
| 1219 | r = write fd wsout p sub n p |
| 1220 | if le r 0 |
| 1221 | exit 70 |
| 1222 | end |
| 1223 | p = add p ulong r |
| 1224 | end |
| 1225 | end |
| 1226 | fn wsprint to void |
| 1227 | wswriteout 1 |
| 1228 | end |
| 1229 | fn wsoutname name ulong ext view uchar * to void |
| 1230 | n = get wsodn 0 |
| 1231 | for i ulong n |
| 1232 | put wsname i get wsodir i |
| 1233 | end |
| 1234 | put wsname n 47 |
| 1235 | put wsname add n 1 uchar name |
| 1236 | for i ulong len ext |
| 1237 | put wsname add add n 2 i get ext i |
| 1238 | end |
| 1239 | put wsnamn 0 add add n 2 len ext |
| 1240 | end |
| 1241 | fn wssave name ulong ext view uchar * to void |
| 1242 | wsoutname name ext |
| 1243 | fd = int fopen wsname 0 get wsnamn 0 577 420 |
| 1244 | if lt fd 0 |
| 1245 | exit 70 |
| 1246 | end |
| 1247 | wswriteout fd |
| 1248 | wsclosefd fd |
| 1249 | end |
| 1250 | fn wshash to ulong |
| 1251 | c = new uchar 104 0 |
| 1252 | d = new uchar 32 0 |
| 1253 | b = new uchar 65536 0 |
| 1254 | sha256_init c |
| 1255 | p = ulong 0 |
| 1256 | n = get wson 0 |
| 1257 | while lt p n bound 524288 |
| 1258 | k = sub n p |
| 1259 | if gt k len b |
| 1260 | k = len b |
| 1261 | end |
| 1262 | for i ulong k |
| 1263 | put b i get wsout add p i |
| 1264 | end |
| 1265 | sha256_update c part b 0 k |
| 1266 | p = add p k |
| 1267 | end |
| 1268 | sha256_final c d |
| 1269 | wsreset |
| 1270 | for i ulong 32 |
| 1271 | v = ulong get d i |
| 1272 | wsbyte ulong get wshex shr v 4 |
| 1273 | wsbyte ulong get wshex and v 15 |
| 1274 | end |
| 1275 | ret wsstore |
| 1276 | end |
| 1277 | fn wsemit name ulong diag bool word bool to void |
| 1278 | n = get wsrn 0 |
| 1279 | wsreset |
| 1280 | wsapp wshead |
| 1281 | for i ulong n |
| 1282 | if gt i 0 |
| 1283 | wsapp wssep |
| 1284 | end |
| 1285 | wsjsonrow i diag word |
| 1286 | end |
| 1287 | wsapp wsclose |
| 1288 | wssave name wsjson |
| 1289 | jhash = wshash |
| 1290 | wsreset |
| 1291 | for i ulong n |
| 1292 | r = get wsorder i |
| 1293 | wsadds wsrowget r 4 |
| 1294 | if not word |
| 1295 | wsbyte 31 |
| 1296 | wsadds wsrowget r 5 |
| 1297 | end |
| 1298 | wsbyte 0 |
| 1299 | end |
| 1300 | wssave name wsrec |
| 1301 | rhash = wshash |
| 1302 | wsreset |
| 1303 | for i ulong n |
| 1304 | r = get wsorder i |
| 1305 | wsnum i |
| 1306 | wsbyte 32 |
| 1307 | wsroleout wsrowget r 1 false |
| 1308 | wsbyte 32 |
| 1309 | wsnum wsrowget r 1 |
| 1310 | wsbyte 32 |
| 1311 | if word |
| 1312 | wsapp wsword |
| 1313 | else |
| 1314 | wsapp wsfile |
| 1315 | end |
| 1316 | wsbyte 10 |
| 1317 | end |
| 1318 | wssave name wsmeta |
| 1319 | wsreset |
| 1320 | wsbyte name |
| 1321 | wsbyte 32 |
| 1322 | wsnum n |
| 1323 | wsbyte 32 |
| 1324 | wsadds jhash |
| 1325 | wsbyte 32 |
| 1326 | wsadds rhash |
| 1327 | wsbyte 10 |
| 1328 | wsprint |
| 1329 | end |
| 1330 | fn wsarguments to void |
| 1331 | b = new uchar 32 0 |
| 1332 | if or lt argcnt 3 gt argcnt 4 |
| 1333 | wsreset |
| 1334 | wsapp wsusage |
| 1335 | wswriteout 2 |
| 1336 | exit 2 |
| 1337 | end |
| 1338 | r = argread 1 b 0 len b |
| 1339 | if lt r 0 |
| 1340 | exit 2 |
| 1341 | end |
| 1342 | id = wsstr part b 0 ulong r |
| 1343 | if wseq id wssplits |
| 1344 | put wsopts 0 1 |
| 1345 | else |
| 1346 | if wseq id wsd |
| 1347 | put wsopts 0 2 |
| 1348 | else |
| 1349 | exit 2 |
| 1350 | end |
| 1351 | end |
| 1352 | r = argread 2 wsodir 0 4000 |
| 1353 | if le r 0 |
| 1354 | exit 2 |
| 1355 | end |
| 1356 | put wsodn 0 ulong r |
| 1357 | if eq argcnt 4 |
| 1358 | if ne get wsopts 0 1 |
| 1359 | exit 2 |
| 1360 | end |
| 1361 | r = argread 3 b 0 len b |
| 1362 | if or le r 0 gt r 6 |
| 1363 | exit 2 |
| 1364 | end |
| 1365 | v = ulong 0 |
| 1366 | for i ulong ulong r |
| 1367 | c = ulong get b i |
| 1368 | if not wsdigit c |
| 1369 | exit 2 |
| 1370 | end |
| 1371 | v = add mul v 10 sub c 48 |
| 1372 | end |
| 1373 | put wsopts 1 v |
| 1374 | end |
| 1375 | end |
| 1376 | fn wsexclusions mode ulong to void |
| 1377 | wssetname wsdata |
| 1378 | wswalk false mode 0 |
| 1379 | wssetname wsr41 |
| 1380 | wswalk true mode 0 |
| 1381 | end |
| 1382 | fn main to int |
| 1383 | wsarguments |
| 1384 | if eq get wsopts 0 2 |
| 1385 | wsload wssel 1 |
| 1386 | wsload wsdiag 2 |
| 1387 | wsemit 68 true false |
| 1388 | ret 0 |
| 1389 | end |
| 1390 | wsload wsgrid 0 |
| 1391 | wsload wsdiag 0 |
| 1392 | wsload wslocal 0 |
| 1393 | wsload wstarg 0 |
| 1394 | wsexclusions 0 |
| 1395 | wsreset |
| 1396 | wsapp wstempl |
| 1397 | wsnum get wstn 0 |
| 1398 | wsapp wsforms |
| 1399 | wsnum get wstn 1 |
| 1400 | wsapp wsexcl |
| 1401 | wsnum get wsunc 0 |
| 1402 | wsbyte 10 |
| 1403 | wsprint |
| 1404 | wsgenerate 83 187001 24 8 false |
| 1405 | wsgenerate 72 187002 64 32 false |
| 1406 | wsexclusions 1 |
| 1407 | wsgenerate 71 187003 24 12 true |
| 1408 | ret 0 |
| 1409 | end |