[BusyBox] Re: Another fgetc() issue

Erik Andersen andersen at lineo.com
Thu Jun 1 23:56:41 UTC 2000


On Wed May 31, 2000 at 06:29:26PM -0400, Pavel Roskin wrote:
> Hello, Erik!
> 
> This is against the latest prerelease (busybox-0.44pre-snapshot.patch),
> like the previous patch (I forgot to mention it, sorry).
> 
> fgetc() returns integer. If you read '\0xFF' and if you encounter EOF,
> fgetc() returns different values. In the former case you don't need to
> stop reading the file.
> 
> The patch also fixes a warning on Linux/PPC because char is unsigned there
> by default.
> 
> ===================
> diff -u -r1.8 utility.c
> --- utility.c	2000/05/17 20:57:42	1.8
> +++ utility.c	2000/05/31 22:21:08
> @@ -1584,10 +1584,12 @@
>      int	 target = CSTRING_BUFFER_LENGTH * depth;
>      int  i, len;
>      int  size;
> +    int  c;
>  
>      /* fill buffer */
>      i = 0;
> -    while ((buffer[i] = fgetc(f)) != EOF) {
> +    while ((c = fgetc(f)) != EOF) {
> +		buffer[i] = (char) c;
>  		if (buffer[i++] == 0x0a) { break; }
>  		if (i == CSTRING_BUFFER_LENGTH) { break; }
>      }
> ===================
> 
> Regards,
> Pavel Roskin

Applied.

 -Erik

--
Erik B. Andersen   email:  andersen at lineo.com
--This message was written using 73% post-consumer electrons--





More information about the busybox mailing list