Re: uniq truncates lines > 2048 bytes

From: Scot Hetzel <swhetzel_at_gmail.com>
Date: Wed, 26 Jan 2005 09:27:00 -0600
On Wed, 26 Jan 2005 09:10:47 +1100, Tim Robbins <tjr_at_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
Received on Wed Jan 26 2005 - 14:27:04 UTC

This archive was generated by hypermail 2.4.0 : Wed May 19 2021 - 11:38:26 UTC