This is the mail archive of the
systemtap@sourceware.org
mailing list for the systemtap project.
Re: [PATCH 1/2] [TAKE 3] Add str_replace() To Tapsets
On Friday 19 Jun 2009 10:01:53 am Varun Chandramohan wrote:
> On Friday 19 Jun 2009 12:21:22 am Josh Stone wrote:
> > On 06/18/2009 07:50 AM, Frank Ch. Eigler wrote:
> > >> +function str_replace:string (prnt_str:string, srch_str:string,
> > >> rplc_str:string) +%{
> > >> +[...]
> > >> + if(strlen_srch_str == 0) {
> > >> + CONTEXT->last_error = "Invalid Search String";
> > >> + return;
> > >> + }
> > >
> > > FWIW, I wouldn't bother with signalling an error for this. Just
> > > define a fallback policy, such as returning the original prnt_str,
> > > or perhaps an empty one.
> >
> > I was the one that suggested making it an error, but I don't feel
> > strongly about that. I would prefer returning the original string over
> > an empty one.
> >
> > To compare what other programs do: s/pat/sub/ in vim and sed will reuse/**
* probe socket.writev - Message sent via socket_writev()
* @name: Name of this probe
* @size: Message size in bytes
* @protocol: Protocol value
* @family: Protocol family value
* @state: Socket state value
* @flags: Socket flags value
* @type: Socket type value
*
* Context:
* The message sender
*
* Fires at the beginning of sending a message on a socket
* via the sock_writev() function
*/
Is this how you want my comment to look like? If iam missing something do let
me know.
> > the previous pattern if given an empty pattern, but I don't think we
> > should try to keep that state. Perl's s/pat/sub/, awk's gsub(), and
> > Python's str.replace() all will match alternating characters, so
> > str_replace("abc", "", "x") would return "xaxbxcx".
> >
> >
> > Josh
>
> So, instead of using the error, i return the original string? If this is
> the case then in the testcase we dont need to handle errors as we will have
> none. I will make these changes and send a patch.
Frank,
I was not sure of the markup you mentioned so i tried to catch you on irc. I
googled for it and found few old discussion
http://sourceware.org/ml/systemtap/2007-q3/msg00064.html
so for socket.stp
--
Regards,
Varun Chandramohan