[comp.sys.mac.programmer] small bug in scanf in TC 4.0

james@utastro.UUCP (James McCartney) (08/24/89)

   Scanf.c saves characters to oblivion when doing %*s or %*[...]
Here's the change in scanf.c :


string:
                if (!F.haveWidth)
                        F.fieldWidth = INT_MAX;
                if (!F.suppress)
                        s = va_arg(arg, char *);
                for (; c != EOF; c = getc(fp), ++nread) {
                        --F.fieldWidth;
                        if (!testbit(c))
                                break;
                        F.valid = TRUE;
>                       *s++ = c;
                        if (F.fieldWidth == 0)
                                goto endstring;
                }
                ungetc(c, fp), --nread;



string:
                if (!F.haveWidth)
                        F.fieldWidth = INT_MAX;
                if (!F.suppress)
                        s = va_arg(arg, char *);
                for (; c != EOF; c = getc(fp), ++nread) {
                        --F.fieldWidth;
                        if (!testbit(c))
                                break;
                        F.valid = TRUE;
>                       if (!F.suppress)
>                               *s++ = c;
                        if (F.fieldWidth == 0)
                                goto endstring;
                }
                ungetc(c, fp), --nread;

--- James McCartney --- Univ. of Texas Astronomy