[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: fgetc doubts
- To: Gábor Kövesdán <gabor_(_at_)_FreeBSD_(_dot_)_org>
- Subject: Re: fgetc doubts
- From: Xin LI <delphij_(_at_)_delphij_(_dot_)_net>
- Date: Tue, 10 Mar 2009 15:24:21 -0700
- Cc: Ed Schouten <ed_(_at_)_80386_(_dot_)_nl>, FreeBSD Hackers <freebsd-hackers_(_at_)_freebsd_(_dot_)_org>
- Openpgp: id=18EDEBA0; url=http://www.delphij.net/delphij.asc
- Organization: The FreeBSD Project
- Reply-to: d_(_at_)_delphij_(_dot_)_net
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
Hi, Gábor,
Gábor Kövesdán wrote:
> Ed Schouten escribió:
>> * Gábor Kövesdán <gabor_(_at_)_FreeBSD_(_dot_)_org> wrote:
>>
>>> 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
>>>
>>> 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,
>>>
>>
>> Sign extension bug?
>>
> I tried to substitute everything with int, because fgetc can return some
> error code afaik, but using int didn't help.
Is binbuf[] an array of char or unsigned char? If it's signed char then
you may want something like ch = binbufptr[0] & 0xff I guess.
Cheers,
- --
Xin LI <delphij_(_at_)_delphij_(_dot_)_net> http://www.delphij.net/
FreeBSD - The Power to Serve!
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v2.0.11 (FreeBSD)
iEYEARECAAYFAkm26JUACgkQi+vbBBjt66CePwCgtXlqAYcdP6G1EUUtGk0nu7vD
I1sAoIJ+Hpop5mIHDdbfcXAbwMsqht2P
=A8DH
-----END PGP SIGNATURE-----
_______________________________________________
freebsd-hackers_(_at_)_freebsd_(_dot_)_org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-hackers
To unsubscribe, send any mail to "freebsd-hackers-unsubscribe_(_at_)_freebsd_(_dot_)_org"
Visit your host, monkey.org