Gábor Kövesdán wrote, On 10.3.2009 22:33:
> Hello,
> 
> I have a problem when reading files with fgetc when a 0xff character
> comes. In my code the reading stops at that point as if EOF had been
> reached, but that's not actually the case.
> The code is here:
> http://p4web.freebsd.org/@md=d&cd=//&c=Nsd@//depot/projects/soc2008/gabor_textproc/grep/file.c?ac=64&rev1=40
You have a bug in the grep_fgetc() function in the BZIP case. Char type is
signed on FreeBSD and you are sign extending the c variable in the "return
(c)" statement. The line should read "return ((unsigned char)c)", if you want
to model the function using the same semantics as C99 fgetc().

> 
> And the problem occurs in grep_fgetln() when the buffers is being filled
> in:
>            for (; i < bufsiz && !grep_feof(f); i++)
>                binbuf[i] = grep_fgetc(f);
> 
> Thanks in advance,
> 

--
VH
_______________________________________________
freebsd-hackers@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-hackers
To unsubscribe, send any mail to "freebsd-hackers-unsubscr...@freebsd.org"

Reply via email to