On Thu, Aug 15, 2013 at 01:06:25PM +0200, Roberto E. Vargas Caballero wrote:
> Only other sugestion, this loop could be done better with a do while:
> 
> dostrings(FILE *fp, const char *fname)
> {
>       unsigned char buf[BUFSIZ];
>       int c, i = 0;
>       off_t offset = 0;
>       do {
>               offset++;
>               if (isprint(c = getc(fp)))
>                       buf[i++] = c
> 
>               if ((!isprint(c) && i >= 6) || i == sizeof(buf) - 1) {
>                       buf[i] = '\0';
>                       printf("%8ld: %s\n", (long)offset - i - 1, buf);
>                       i = 0;
>               }
>       } while (c != EOF);
>       
>       if (ferror(fp))
>               eprintf("%s read error:", fname);
>       }
> }

Much better, will incorporate this.

Thanks,
sin

Reply via email to