From owner-svn-src-all@FreeBSD.ORG Sat Jan 5 23:54:14 2013 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.FreeBSD.org [8.8.178.115]) by hub.freebsd.org (Postfix) with ESMTP id E5F7CCD0 for ; Sat, 5 Jan 2013 23:54:14 +0000 (UTC) (envelope-from mailer-daemon@vniz.net) Received: from mail-la0-f44.google.com (mail-la0-f44.google.com [209.85.215.44]) by mx1.freebsd.org (Postfix) with ESMTP id 53B8BA9B for ; Sat, 5 Jan 2013 23:54:13 +0000 (UTC) Received: by mail-la0-f44.google.com with SMTP id fr10so12230064lab.3 for ; Sat, 05 Jan 2013 15:54:06 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=x-received:message-id:disposition-notification-to:date:from :user-agent:mime-version:to:cc:subject:references:in-reply-to :openpgp:content-type:content-transfer-encoding:x-gm-message-state; bh=JW5vGkFnSzqu2a58iF6mXcVvnta2xy5FhtdrV+6tr3o=; b=NGXs1SfOCjN+O6YBW6jGIWBkNUDz2Fuqqjpfp7IOzNZrvVyps19U/Qux6gfR/+YTK1 s7j9ny2hDLWO43iLagL4k78zhcvNkP3LrjUa85ESurYzgUIj7sab0qUsptFWQNUiNkpd slVHegnhlXeyF6WTeyfvgIw2dn+ArjF7zQn04P63XPjrsDu8CxMRxkOm45hSx7wvCtDI WrAg40c36QiBqbKUGCmHMVsyYsu+g6/YxK4MLltV+HzQ68QqU6kI+HTS65/C63iPJ3fY sNoPeO7Hrd4o4tFbP3T9nwMkuDi/ENW5J9olDD0OQsHUT91Wgh1LMal1cC9CLGYmJH0R vZGQ== X-Received: by 10.112.88.7 with SMTP id bc7mr23476639lbb.108.1357430046681; Sat, 05 Jan 2013 15:54:06 -0800 (PST) Received: from [192.168.1.2] ([89.169.163.3]) by mx.google.com with ESMTPS id fj2sm19274601lbb.6.2013.01.05.15.54.05 (version=SSLv3 cipher=OTHER); Sat, 05 Jan 2013 15:54:06 -0800 (PST) Message-ID: <50E8BD1D.7030209@freebsd.org> Date: Sun, 06 Jan 2013 03:54:05 +0400 From: Andrey Chernov User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:17.0) Gecko/17.0 Thunderbird/17.0 MIME-Version: 1.0 To: Gabor Kovesdan Subject: Re: svn commit: r245057 - head/usr.bin/grep References: <201301051452.r05EqWHt051825@svn.freebsd.org> In-Reply-To: <201301051452.r05EqWHt051825@svn.freebsd.org> OpenPGP: id=964474DD Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit X-Gm-Message-State: ALoCoQlXiyvc1clH0hyd7eH3u3JrOruDvA1DxF9hyksQ1V0DQZr1sUVn3Ly7VsAoj1+2oZ+YpY+R Cc: svn-src-head@freebsd.org, svn-src-all@freebsd.org, src-committers@freebsd.org X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 05 Jan 2013 23:54:15 -0000 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; > } >