Path: utzoo!attcan!utgpu!jarvis.csri.toronto.edu!mailrus!wasatch!cs.utexas.edu!utastro!james From: james@utastro.UUCP (James McCartney) Newsgroups: comp.sys.mac.programmer Subject: small bug in scanf in TC 4.0 Keywords: think c scanf bug Message-ID: <4241@utastro.UUCP> Date: 23 Aug 89 21:01:29 GMT Organization: U. Texas, Astronomy, Austin, TX Lines: 41 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