From 9a0a4ee19eebc08e5ec3b2d256476016d128b090 Mon Sep 17 00:00:00 2001 From: ubq323 Date: Fri, 29 Nov 2024 10:45:17 +0000 Subject: schars-ascii -> sbytes --- doc.txt | 2 +- lib.c | 8 ++++---- tests/sbytes.bth | 1 + tests/sbytes.out | 2 ++ tests/schars_ascii.bth | 1 - tests/schars_ascii.out | 2 -- 6 files changed, 8 insertions(+), 8 deletions(-) create mode 100644 tests/sbytes.bth create mode 100644 tests/sbytes.out delete mode 100644 tests/schars_ascii.bth delete mode 100644 tests/schars_ascii.out diff --git a/doc.txt b/doc.txt index b597f46..f4b2439 100644 --- a/doc.txt +++ b/doc.txt @@ -57,7 +57,7 @@ (s,@ a): spendsplat. (s,@ [a b c]) <=> (s, a b c) (ssub? needle haystack): is substring? (ssplit delim text): splits text on delim, delim is removed from sections - (schars-ascii s): returns arr containing ascii chars (bytes) in s + (sbytes s): returns arr containing bytes in s (sin x) (cos x) (ceil x) (floor x) (abs x): should be obvious # cmdline args diff --git a/lib.c b/lib.c index 01f5110..33ca58b 100644 --- a/lib.c +++ b/lib.c @@ -156,9 +156,9 @@ static Val fn_ssplit(State *S, int nargs, Val *args) { return VAL_OBJ(out); } -static Val fn_schars_ascii(State *S, int nargs, Val *args) { - CHECK(nargs==1, "need exactly 1 args for schars-ascii"); - CHECK(IS_STRING(args[0]), "need string arg for schars-ascii"); +static Val fn_sbytes(State *S, int nargs, Val *args) { + CHECK(nargs==1, "need exactly 1 args for sbytes"); + CHECK(IS_STRING(args[0]), "need string arg for sbytes"); ObjString *s = AS_STRING(args[0]); ObjArr *a = objarr_new(S); for (int i = 0; i < s->len; i++) @@ -220,7 +220,7 @@ static BuiltinFunc builtin_funcs[] = { { "s,@", fn_spendsplat }, { "ssub?", fn_ssub }, { "ssplit", fn_ssplit }, - { "schars-ascii", fn_schars_ascii }, + { "sbytes", fn_sbytes }, { "sin", fn_sin }, { "cos", fn_cos }, diff --git a/tests/sbytes.bth b/tests/sbytes.bth new file mode 100644 index 0000000..cce7c8a --- /dev/null +++ b/tests/sbytes.bth @@ -0,0 +1 @@ +(say (sbytes "hello world\n")) diff --git a/tests/sbytes.out b/tests/sbytes.out new file mode 100644 index 0000000..b00b046 --- /dev/null +++ b/tests/sbytes.out @@ -0,0 +1,2 @@ +[h e l l o w o r l d +] diff --git a/tests/schars_ascii.bth b/tests/schars_ascii.bth deleted file mode 100644 index 402017b..0000000 --- a/tests/schars_ascii.bth +++ /dev/null @@ -1 +0,0 @@ -(say (schars-ascii "hello world\n")) diff --git a/tests/schars_ascii.out b/tests/schars_ascii.out deleted file mode 100644 index b00b046..0000000 --- a/tests/schars_ascii.out +++ /dev/null @@ -1,2 +0,0 @@ -[h e l l o w o r l d -] -- cgit v1.2.3