summaryrefslogtreecommitdiffstats
path: root/tapset/string.stp
diff options
context:
space:
mode:
authorWenji Huang <wenji.huang@oracle.com>2009-04-27 04:34:42 -0400
committerWenji Huang <wenji.huang@oracle.com>2009-04-26 23:04:52 -0400
commit40fc3e43cea224623400ac07b6f03c700d209dec (patch)
treea515fed92b082c8f1140c31deb006ef1254fabbc /tapset/string.stp
parent9f38e65363878d1e1bc8f51a0ad2cc4fd0316e13 (diff)
downloadsystemtap-steved-40fc3e43cea224623400ac07b6f03c700d209dec.tar.gz
systemtap-steved-40fc3e43cea224623400ac07b6f03c700d209dec.tar.xz
systemtap-steved-40fc3e43cea224623400ac07b6f03c700d209dec.zip
Add function of returning the char in given position of string
* tapset/string.stp: New function stringat. * testsuite/systemtap.printf/char1.exp: Update test case. * testsuite/systemtap.printf/char1.stp: Ditto.
Diffstat (limited to 'tapset/string.stp')
-rw-r--r--tapset/string.stp12
1 files changed, 12 insertions, 0 deletions
diff --git a/tapset/string.stp b/tapset/string.stp
index 2f43aecc..35ee9fa2 100644
--- a/tapset/string.stp
+++ b/tapset/string.stp
@@ -25,6 +25,18 @@ function substr:string(str:string,start:long, length:long) %{ /* pure */
strlcpy(THIS->__retvalue, THIS->str + THIS->start, length);
%}
+/** @addtogroup library
+* @code function stringat:string(str:string, pos:long) @endcode
+* @param str string
+* @param pos the given position. 0 = start of the string
+* @return Returns the char in given position of string.
+*/
+function stringat:long(str:string, pos:long) %{ /* pure */
+ if (THIS->pos >= 0 && THIS->pos < strlen(THIS->str))
+ THIS->__retvalue = THIS->str[THIS->pos];
+ else
+ THIS->__retvalue = 0;
+%}
/** @addtogroup library
* @code isinstr:long(s1:string,s2:string) @endcode