lua: string.byte(s,i,j) supports ranges, returns multi-values
Some checks failed
Test, Build, and Deploy / test-build-deploy (push) Has been cancelled

This commit is contained in:
2026-04-25 01:10:30 +00:00
parent 702e7c8eac
commit fad44ca097
4 changed files with 53 additions and 34 deletions

View File

@@ -990,10 +990,28 @@
lua-string-byte
(fn (&rest args)
(let ((s (first args))
(i (if (> (len args) 1) (nth args 1) 1)))
(cond
((or (< i 1) (> i (len s))) nil)
(else (char-code (char-at s (- i 1))))))))
(i-raw (if (> (len args) 1) (nth args 1) nil))
(j-raw (if (> (len args) 2) (nth args 2) nil)))
(let ((i (if (= i-raw nil) 1 i-raw)))
(let ((j (if (= j-raw nil) i j-raw)))
(let ((slen (len s)))
(let ((ni (cond ((< i 0) (+ slen i 1)) ((= i 0) 1) (else i)))
(nj (cond ((< j 0) (+ slen j 1)) (else j))))
(cond
((or (< ni 1) (> ni slen) (< nj ni)) nil)
((= ni nj) (char-code (char-at s (- ni 1))))
(else
(let ((out (list (quote lua-multi))))
(begin
(define
b-loop
(fn (k)
(when (and (<= k nj) (<= k slen))
(begin
(set! out (append out (list (char-code (char-at s (- k 1))))))
(b-loop (+ k 1))))))
(b-loop ni)
out)))))))))))
(define
lua-char-one

View File

@@ -51,19 +51,19 @@
"name": "attrib.lua",
"status": "fail",
"reason": "other: Unhandled exception: \\\"Unhandled exception: \\\\\\\"lua: module 'C' not found\\\\\\\"\\",
"ms": 6636
"ms": 6698
},
{
"name": "big.lua",
"status": "timeout",
"reason": "per-test timeout",
"ms": 8008
"ms": 8002
},
{
"name": "calls.lua",
"status": "fail",
"reason": "undefined symbol: fat\\",
"ms": 5129
"ms": 5168
},
{
"name": "checktable.lua",
@@ -87,7 +87,7 @@
"name": "constructs.lua",
"status": "fail",
"reason": "other: Unhandled exception: \\\"Unhandled exception: \\\\\\\"lua: attempt to compare incompat",
"ms": 6962
"ms": 7174
},
{
"name": "db.lua",
@@ -99,13 +99,13 @@
"name": "errors.lua",
"status": "fail",
"reason": "other: Unhandled exception: \\\"Unhandled exception: \\\\\\\"assertion failed!\\\\\\\"\\",
"ms": 3442
"ms": 3446
},
{
"name": "events.lua",
"status": "fail",
"reason": "other: Unhandled exception: \\\"Unhandled exception: \\\\\\\"assertion failed!\\\\\\\"\\",
"ms": 7474
"ms": 7749
},
{
"name": "files.lua",
@@ -123,13 +123,13 @@
"name": "literals.lua",
"status": "fail",
"reason": "other: Unhandled exception: \\\"Unhandled exception: \\\\\\\"assertion failed!\\\\\\\"\\",
"ms": 1965
"ms": 1931
},
{
"name": "locals.lua",
"status": "fail",
"reason": "other: Unhandled exception: \\\"Unhandled exception: \\\\\\\"lua: attempt to call non-functio",
"ms": 1784
"ms": 1767
},
{
"name": "main.lua",
@@ -141,43 +141,43 @@
"name": "math.lua",
"status": "fail",
"reason": "other: Unhandled exception: \\\"Unhandled exception: \\\\\\\"lua: attempt to call non-functio",
"ms": 4413
"ms": 4412
},
{
"name": "nextvar.lua",
"status": "fail",
"reason": "other: Unhandled exception: \\\"Unhandled exception: \\\\\\\"assertion failed!\\\\\\\"\\",
"ms": 7389
"ms": 7512
},
{
"name": "pm.lua",
"status": "fail",
"reason": "other: Unhandled exception: \\\"Unhandled exception: \\\\\\\"assertion failed!\\\\\\\"\\",
"ms": 6252
"ms": 6522
},
{
"name": "sort.lua",
"status": "timeout",
"reason": "per-test timeout",
"ms": 8004
"ms": 8008
},
{
"name": "strings.lua",
"status": "fail",
"reason": "other: Unhandled exception: \\\"Unhandled exception: \\\\\\\"assertion failed!\\\\\\\"\\",
"ms": 4236
"ms": 4282
},
{
"name": "vararg.lua",
"status": "fail",
"reason": "other: Unhandled exception: \\\"Unhandled exception: \\\\\\\"assertion failed!\\\\\\\"\\",
"ms": 2348
"ms": 2373
},
{
"name": "verybig.lua",
"status": "pass",
"reason": "",
"ms": 1074
"ms": 1080
}
]
}

View File

@@ -18,25 +18,25 @@ fail=12 timeout=3 skip=8 total=24
|---|---|---|---:|
| all.lua | skip | driver uses dofile to chain other tests | 0 |
| api.lua | skip | requires testC (C debug library) | 0 |
| attrib.lua | fail | other: Unhandled exception: \"Unhandled exception: \\\"lua: module 'C' not found\\\"\ | 6636 |
| big.lua | timeout | per-test timeout | 8008 |
| calls.lua | fail | undefined symbol: fat\ | 5129 |
| attrib.lua | fail | other: Unhandled exception: \"Unhandled exception: \\\"lua: module 'C' not found\\\"\ | 6698 |
| big.lua | timeout | per-test timeout | 8002 |
| calls.lua | fail | undefined symbol: fat\ | 5168 |
| checktable.lua | skip | internal debug helpers | 0 |
| closure.lua | timeout | per-test timeout | 8001 |
| code.lua | skip | bytecode inspection via debug library | 0 |
| constructs.lua | fail | other: Unhandled exception: \"Unhandled exception: \\\"lua: attempt to compare incompat | 6962 |
| constructs.lua | fail | other: Unhandled exception: \"Unhandled exception: \\\"lua: attempt to compare incompat | 7174 |
| db.lua | skip | debug library | 0 |
| errors.lua | fail | other: Unhandled exception: \"Unhandled exception: \\\"assertion failed!\\\"\ | 3442 |
| events.lua | fail | other: Unhandled exception: \"Unhandled exception: \\\"assertion failed!\\\"\ | 7474 |
| errors.lua | fail | other: Unhandled exception: \"Unhandled exception: \\\"assertion failed!\\\"\ | 3446 |
| events.lua | fail | other: Unhandled exception: \"Unhandled exception: \\\"assertion failed!\\\"\ | 7749 |
| files.lua | skip | io library | 0 |
| gc.lua | skip | collectgarbage / finalisers | 0 |
| literals.lua | fail | other: Unhandled exception: \"Unhandled exception: \\\"assertion failed!\\\"\ | 1965 |
| locals.lua | fail | other: Unhandled exception: \"Unhandled exception: \\\"lua: attempt to call non-functio | 1784 |
| literals.lua | fail | other: Unhandled exception: \"Unhandled exception: \\\"assertion failed!\\\"\ | 1931 |
| locals.lua | fail | other: Unhandled exception: \"Unhandled exception: \\\"lua: attempt to call non-functio | 1767 |
| main.lua | skip | standalone interpreter driver | 0 |
| math.lua | fail | other: Unhandled exception: \"Unhandled exception: \\\"lua: attempt to call non-functio | 4413 |
| nextvar.lua | fail | other: Unhandled exception: \"Unhandled exception: \\\"assertion failed!\\\"\ | 7389 |
| pm.lua | fail | other: Unhandled exception: \"Unhandled exception: \\\"assertion failed!\\\"\ | 6252 |
| sort.lua | timeout | per-test timeout | 8004 |
| strings.lua | fail | other: Unhandled exception: \"Unhandled exception: \\\"assertion failed!\\\"\ | 4236 |
| vararg.lua | fail | other: Unhandled exception: \"Unhandled exception: \\\"assertion failed!\\\"\ | 2348 |
| verybig.lua | pass | - | 1074 |
| math.lua | fail | other: Unhandled exception: \"Unhandled exception: \\\"lua: attempt to call non-functio | 4412 |
| nextvar.lua | fail | other: Unhandled exception: \"Unhandled exception: \\\"assertion failed!\\\"\ | 7512 |
| pm.lua | fail | other: Unhandled exception: \"Unhandled exception: \\\"assertion failed!\\\"\ | 6522 |
| sort.lua | timeout | per-test timeout | 8008 |
| strings.lua | fail | other: Unhandled exception: \"Unhandled exception: \\\"assertion failed!\\\"\ | 4282 |
| vararg.lua | fail | other: Unhandled exception: \"Unhandled exception: \\\"assertion failed!\\\"\ | 2373 |
| verybig.lua | pass | - | 1080 |