[Bug tapsets/20988] New: string tapset could use a strstr() type function
dsmith at redhat dot com
sourceware-bugzilla@sourceware.org
Wed Dec 21 22:03:00 GMT 2016
https://sourceware.org/bugzilla/show_bug.cgi?id=20988
Bug ID: 20988
Summary: string tapset could use a strstr() type function
Product: systemtap
Version: unspecified
Status: NEW
Severity: normal
Priority: P2
Component: tapsets
Assignee: systemtap at sourceware dot org
Reporter: dsmith at redhat dot com
Target Milestone: ---
The string tapset has a function called 'instr()' that tells you if a substring
is present in a string, but the caller doesn't know where that substring is in
the string. It would be nice to have a tapset function that returns the index
of where a substring starts in a string. Then you could use the 'substr()'
tapset function to extract the string parts before and after a substring.
If the substring doesn't exist in string, the new tapset function should raise
an error.
Here's an example in action:
# You've got a string that is in the general format 'FIRST.LAST'.
# You want to break that string down into its parts.
full = "David.Smith"
# Find the index of the '.' character
index = NEW_FUNCTION(full, ".")
# Extract the first part of the string
first = substr(full, 0, index)
# Extract the last part of the string
last = substr(full, index + 1, strlen(full) - index - 1)
(I haven't checked all the indexing logic in the above example, but the idea is
there.)
--
You are receiving this mail because:
You are the assignee for the bug.
More information about the Systemtap
mailing list