Subject: Re: nbsed broken on Solaris?
To: Urban Boquist <>
From: Johnny C. Lam <>
List: tech-pkg
Date: 09/09/2004 20:20:47
On Thu, Sep 09, 2004 at 04:43:28PM +0200, Urban Boquist wrote:
> Urban> I'm seeing a problem where nbsed built (by pkgsrc/bootstrap) on
> Urban> Solaris seems unable to handle really long lines in files,
> Urban> after 1024 chars it adds an extra zero char.
> I found the problem. Unless I am mistaken it is a bug in the
> implementation of fgetln() in the version that is in pkgsrc
> libnbcompat. And it is not really Solaris specific, it should affect
> all systems that use libnbcompat and does not have a native fgetln().
> I've included the faulty version below. It is a simple off-by-one
> error, the code does not account for that fgets() always
> zero-terminates its result (in the case where a line is longer than a
> single call to fgets() will read). In the code below, if you have
> called fgetln() on a line that is 1024 or longer, at return from the
> function "buf[1023]" will always be '\0' . The char that should have
> been at offset 1023 will be in buf[1024]. Same for offset 2047 etc.
> What confuses me a little is that the commit log for fgetln.c from
> libnbcompat says that it is imported from src HEAD, but the actual
> implementation does not look at all like the version that is in NetBSD
> libc. Not even like the 1.12 version of fgetln.c, before the fgetstr()
> generalization. But maybe I am misreading something.

I've uploaded a new version of the bootstrap kit to:

It contains a libnbcompat that really has fgetln() pulled in from src
HEAD.  Could you please test whether the resulting nbsed still has the
problem you reported on Solaris?  Also, could you let me know on what
version of Solaris you are testing?


	-- Johnny Lam <>