stanonik@nprdc.navy.mil (Ron Stanonik) (07/20/89)
Or maybe it's a feature? But it was news to me. I believe we've encountered an fscanf bug in sunos4.0.1 on sun4's, sun3's, and sun386i's. The apparent bug is that given a control string of "%c", fscanf returns 0, rather than EOF on encountering the end of file. Here's a sample program: #include <stdio.h> main() { int i; char c; for (i = 5; i > 0; i--) { printf("cnt=%d\n", fscanf(stdin, "%c", &c)); printf("%x\n", c); } } Here's a sample file: ab Here's the result: arctic[244] t < a cnt=1 31 cnt=1 33 cnt=1 a cnt=0 a cnt=0 a Back in sunos3.5 days, the 0 cnt's would be -1 (ie, EOF), as expected. Ron Stanonik stanonik@nprdc.navy.mil
stanonik@nprdc.navy.mil (Ron Stanonik) (07/28/89)
Apparently the fscanf bug is known (#1012859). Ask sun for a patch tape. Unfortunately, patches only seem available for sun3's and sun4's; ie, not for sun386i's. Also apparently the bug isn't fixed in sunos4.0.3, so hang onto that patch tape when you upgrade. Ron stanonik@nprdc.navy.mil