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 / seed / host / tests / environment.om
| 1 | note envcnt/envread: find OMTEST=hello in the process environment, and refuse a short buffer with -105. |
| 2 | text want "OMTEST=hello" |
| 3 | global buf uchar 128 |
| 4 | fn main to int |
| 5 | c = ulong envcnt |
| 6 | if eq c 0 |
| 7 | ret 1 |
| 8 | end |
| 9 | n0 = envread 0 buf 0 1 |
| 10 | if ne n0 -105 |
| 11 | ret 3 |
| 12 | end |
| 13 | i = ulong 0 |
| 14 | while lt i c |
| 15 | n = envread i buf 0 len buf |
| 16 | if eq n long len want |
| 17 | j = long 0 |
| 18 | same = ulong 1 |
| 19 | while lt j n |
| 20 | if ne get buf j get want j |
| 21 | same = ulong 0 |
| 22 | break |
| 23 | end |
| 24 | j = add j 1 |
| 25 | end |
| 26 | if eq same 1 |
| 27 | ret 0 |
| 28 | end |
| 29 | end |
| 30 | i = add i 1 |
| 31 | end |
| 32 | ret 2 |
| 33 | end |