Date: Sun, 06 Jan 2013 03:54:05 +0400 From: Andrey Chernov <ache@freebsd.org> To: Gabor Kovesdan <gabor@FreeBSD.org> Cc: svn-src-head@freebsd.org, svn-src-all@freebsd.org, src-committers@freebsd.org Subject: Re: svn commit: r245057 - head/usr.bin/grep Message-ID: <50E8BD1D.7030209@freebsd.org> In-Reply-To: <201301051452.r05EqWHt051825@svn.freebsd.org> References: <201301051452.r05EqWHt051825@svn.freebsd.org>
next in thread | previous in thread | raw e-mail | index | archive | help
Thanks. I think the fix below can be improved further, because strdup(3) is unneeded here and can be omitted. We don't have either constant argument nor want to preserve it. On 05.01.2013 18:52, Gabor Kovesdan wrote: > case 'e': > - add_pattern(optarg, strlen(optarg)); > + { > + char *token; > + char *string = strdup(optarg); > + > + while ((token = strsep(&string, "\n")) != NULL) > + add_pattern(token, strlen(token)); > + } > needpattern = 0; > break; > case 'F': > @@ -668,7 +674,11 @@ main(int argc, char *argv[]) > > /* Process patterns from command line */ > if (aargc != 0 && needpattern) { > - add_pattern(*aargv, strlen(*aargv)); > + char *token; > + char *string = strdup(*aargv); > + > + while ((token = strsep(&string, "\n")) != NULL) > + add_pattern(token, strlen(token)); > --aargc; > ++aargv; > } >
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?50E8BD1D.7030209>