omega-harness
Agent skills for operating, encoding and communicating in Omega (.om) and the AIEN repositories
Brought by drakestapleton
omega-harness / coder / eval / selftest / src / st6-stdin.om
| 1 | note selftest: copy stdin to stdout with the case of each letter swapped. Fed its own output it gives back its |
| 2 | note input, so a case line that fed the program expected.out instead of stdin would fail. |
| 3 | global buf uchar 4096 |
| 4 | fn main to int |
| 5 | n = read 0 buf 0 len buf |
| 6 | while gt n 0 |
| 7 | m = ulong n |
| 8 | for i ulong m |
| 9 | c = get buf i |
| 10 | if ge c 97 |
| 11 | if le c 122 |
| 12 | put buf i uchar sub c 32 |
| 13 | end |
| 14 | else |
| 15 | if ge c 65 |
| 16 | if le c 90 |
| 17 | put buf i uchar add c 32 |
| 18 | end |
| 19 | end |
| 20 | end |
| 21 | end |
| 22 | w = write 1 buf 0 ulong n |
| 23 | if ne w n |
| 24 | ret 1 |
| 25 | end |
| 26 | n = read 0 buf 0 len buf |
| 27 | end |
| 28 | if lt n 0 |
| 29 | ret 2 |
| 30 | end |
| 31 | ret 0 |
| 32 | end |