Date: Wed, 26 Jan 2005 09:27:00 -0600 From: Scot Hetzel <swhetzel@gmail.com> To: Tim Robbins <tjr@freebsd.org> Cc: freebsd-current@freebsd.org Subject: Re: uniq truncates lines > 2048 bytes Message-ID: <790a9fff0501260727677bb5df@mail.gmail.com> In-Reply-To: <20050125221047.GA339@cat.robbins.dropbear.id.au> References: <790a9fff05012509511b64e3ad@mail.gmail.com> <20050125221047.GA339@cat.robbins.dropbear.id.au>
next in thread | previous in thread | raw e-mail | index | archive | help
On Wed, 26 Jan 2005 09:10:47 +1100, Tim Robbins <tjr@freebsd.org> 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
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?790a9fff0501260727677bb5df>
