Perl script to search sprintf and replace with snprintf
I am new to perl script and would need some help for my 1st script. I wrote a script to search sprintf(buf,"%s", sourcestring) and replace with snprintf(buf, sizeof(buf),"%s", sourcestring). As snprintf() requires an extra argument, so it is not a simple search-and-replace. I need to match sprintf(), grab the first argument and use it for the second argument. This script also need to check and ensure that the destination string, the first argument to sprintf(), is a characeter array and not a pointer before doing the replacement.
My code is as follows:
Re: Perl script to search sprintf and replace with snprintf
Your script is working fine. I have checked with some input file which containing more than 2 sprintf(buf,"%s", sourcestring) line also.
|All times are GMT +5.5. The time now is 15:08.|