From 40fc3e43cea224623400ac07b6f03c700d209dec Mon Sep 17 00:00:00 2001 From: Wenji Huang Date: Mon, 27 Apr 2009 04:34:42 -0400 Subject: 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. --- tapset/string.stp | 12 ++++++++++++ 1 file changed, 12 insertions(+) (limited to 'tapset/string.stp') 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 -- cgit