summaryrefslogtreecommitdiffstats
path: root/tapset/string.stp
diff options
context:
space:
mode:
Diffstat (limited to 'tapset/string.stp')
-rw-r--r--tapset/string.stp18
1 files changed, 18 insertions, 0 deletions
diff --git a/tapset/string.stp b/tapset/string.stp
new file mode 100644
index 00000000..f6933724
--- /dev/null
+++ b/tapset/string.stp
@@ -0,0 +1,18 @@
+function strlen:long(s:string) %{
+ THIS->__retvalue=strlen(THIS->s);
+%}
+
+function substr:string(str:string,start:long,stop:long) %{
+ int len=strlen(THIS->str);
+ if(THIS->start<0 || THIS->stop<0 ||
+ THIS->start>len || THIS->stop>len ||
+ THIS->start>=THIS->stop)
+ {
+ return;
+ }
+ else {
+ char *s=THIS->str;
+ strncpy(THIS->__retvalue,s+THIS->start,THIS->stop);
+ THIS->__retvalue[THIS->stop]='\0';
+ }
+%}