summaryrefslogtreecommitdiffstats
path: root/tapset/string.stp
diff options
context:
space:
mode:
authorDavid Smith <dsmith@redhat.com>2009-06-18 10:12:35 -0500
committerDavid Smith <dsmith@redhat.com>2009-06-18 10:12:35 -0500
commit36b8245df8de0092c5d28765b1ae7d9d8050da6e (patch)
tree099aa846e65490af10a6b925f566a3068c2984d7 /tapset/string.stp
parent9eebc06b5e24480c7b6055a8b6f1c07512f293fb (diff)
parent0e5cd254d3ef39cef5fa6ba56231604274fd85cd (diff)
downloadsystemtap-steved-36b8245df8de0092c5d28765b1ae7d9d8050da6e.tar.gz
systemtap-steved-36b8245df8de0092c5d28765b1ae7d9d8050da6e.tar.xz
systemtap-steved-36b8245df8de0092c5d28765b1ae7d9d8050da6e.zip
Merge commit 'origin/master' into pr7043
Diffstat (limited to 'tapset/string.stp')
-rw-r--r--tapset/string.stp23
1 files changed, 15 insertions, 8 deletions
diff --git a/tapset/string.stp b/tapset/string.stp
index 35ee9fa2..cc842929 100644
--- a/tapset/string.stp
+++ b/tapset/string.stp
@@ -70,25 +70,32 @@ function text_strn:string(input:string, len:long, quoted:long)
/*
* tokenize - Given a string and a token delimiter,
- * return the next token in the string
- * input String to tokenize. If NULL, returns the next token in the
- * string passed in the previous call to tokenize().
- * delim Token delimiter. Note this is a string, but only the first
- * character is used as the delimiter.
+ * return the next non-empty token in the string
+ * or blank when no more non-empty tokens are left
+ * input String to tokenize. If NULL, returns the next non-empty token
+ * in the string passed in the previous call to tokenize().
+ * delim Token delimiter. Set of characters that delimit the tokens.
*/
function tokenize:string(input:string, delim:string)
%{ /* pure */
static char str[MAXSTRINGLEN];
static char *str_start;
+ static char *str_end;
char *token = NULL;
+ char *token_end = NULL;
if (THIS->input[0]) {
strncpy(str, THIS->input, MAXSTRINGLEN);
str_start = &str[0];
+ str_end = &str[0] + strlen(str);
+ }
+ do {
+ token = strsep(&str_start, THIS->delim);
+ } while (token && !token[0]);
+ if (token) {
+ token_end = (str_start ? str_start - 1 : str_end);
+ memcpy(THIS->__retvalue, token, token_end - token + 1);
}
- token = strsep(&str_start, THIS->delim);
- if (token)
- strncpy (THIS->__retvalue, token, MAXSTRINGLEN);
%}
/*