From owner-freebsd-current@FreeBSD.ORG Wed Jan 26 15:27:04 2005 Return-Path: Delivered-To: freebsd-current@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id D009D16A4CE for ; Wed, 26 Jan 2005 15:27:04 +0000 (GMT) Received: from wproxy.gmail.com (wproxy.gmail.com [64.233.184.201]) by mx1.FreeBSD.org (Postfix) with ESMTP id 2E08943D3F for ; Wed, 26 Jan 2005 15:27:04 +0000 (GMT) (envelope-from swhetzel@gmail.com) Received: by wproxy.gmail.com with SMTP id 58so67491wri for ; Wed, 26 Jan 2005 07:27:00 -0800 (PST) DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=beta; d=gmail.com; h=received:message-id:date:from:reply-to:to:subject:cc:in-reply-to:mime-version:content-type:content-transfer-encoding:references; b=UEpNXKyJdJRdX2DYH8bx2OXjHm6onNR1ysMkJLK4ZbD5N7xvOPFN/Ok7m8UUx7GCUHDTd6+A+4G9sAkl12FpnlFjrCD5kuFFSW7J1C52HxTkMPx5X7l+fT8FDclLHP2OuqSIUWE6eS7n2bKLQ9T3u+ehju7uZ+4PGWC8Zn4t7o4= Received: by 10.54.28.38 with SMTP id b38mr27871wrb; Wed, 26 Jan 2005 07:27:00 -0800 (PST) Received: by 10.54.29.48 with HTTP; Wed, 26 Jan 2005 07:27:00 -0800 (PST) Message-ID: <790a9fff0501260727677bb5df@mail.gmail.com> Date: Wed, 26 Jan 2005 09:27:00 -0600 From: Scot Hetzel To: Tim Robbins In-Reply-To: <20050125221047.GA339@cat.robbins.dropbear.id.au> Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit References: <790a9fff05012509511b64e3ad@mail.gmail.com> <20050125221047.GA339@cat.robbins.dropbear.id.au> cc: freebsd-current@freebsd.org Subject: Re: uniq truncates lines > 2048 bytes X-BeenThere: freebsd-current@freebsd.org X-Mailman-Version: 2.1.1 Precedence: list Reply-To: Scot Hetzel List-Id: Discussions about the use of FreeBSD-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 26 Jan 2005 15:27:05 -0000 On Wed, 26 Jan 2005 09:10:47 +1100, Tim Robbins wrote: > This looks good except for failure to check for realloc() returning NULL > and a few minor style problems. It may be possible to use fgetwln() > to read lines instead of getwc() + realloc() etc., but this function is > new and peculiar to FreeBSD. > I tried to use fgetwln in place of the getline sub-routine: if ((prevline = fgetwln(ifp, prevbuflen)) == NULL) { : } while ((thisline = fgetwln(ifp, thisbuflen)) != NULL) { : } But what is happening is that both thisline and prevline are being set to the same pointer location. I need to change it to: if ((thisline = fgetwln(ifp, thisbuflen)) == NULL) { : /* check error */ } prevline = strdup(thisline); while ((thisline = fgetwln(ifp, thisbuflen)) != NULL) { : if (comp) { : /* place thisline into prevline */ prevline = strdup(thisline); : } : } Is their a function to duplicate wchar strings? Scot