summaryrefslogtreecommitdiff
path: root/Tools/LuaMacro/tests/str.l.c
diff options
context:
space:
mode:
Diffstat (limited to 'Tools/LuaMacro/tests/str.l.c')
-rw-r--r--Tools/LuaMacro/tests/str.l.c19
1 files changed, 19 insertions, 0 deletions
diff --git a/Tools/LuaMacro/tests/str.l.c b/Tools/LuaMacro/tests/str.l.c
new file mode 100644
index 0000000..e15891c
--- /dev/null
+++ b/Tools/LuaMacro/tests/str.l.c
@@ -0,0 +1,19 @@
+// preprocess using luam -C -llc -o str.c str.l.c
+#include <string.h>
+
+module "str" {
+
+ def at (Str s, Int i = 0) {
+ lua_pushlstring(L,&s[i-1],1);
+ return 1;
+ }
+
+ def upto (Str s, Str delim = " ") {
+ lua_pushinteger(L, strcspn(s,delim) + 1);
+ return 1;
+ }
+
+}
+
+
+