home *** CD-ROM | disk | FTP | other *** search
- Newsgroups: comp.lang.c
- Path: sparky!uunet!sun-barr!ames!daffodil!wyvern!alpha
- From: alpha@wyvern.twuug.com (Joe Wright)
- Subject: compiler broken?
- Message-ID: <1992Jul25.054848.11223@wyvern.twuug.com>
- Organization: Box 68621, Virginia Beach, 23455
- X-Newsreader: Tin 1.1 PL4
- Date: Sat, 25 Jul 1992 05:48:48 GMT
- Lines: 27
-
- Is this 'normal'? I wrote the following routine some days ago
- on my C/80 system:
-
- rdlin() {
- int i;
- for (i = 0; i < length && ((record[i] = getc(infile)) != EOF); ++i)
- ;
- return i;
- }
-
- It worked fine on my C/80 system but failed on another i486 Unix
- system. It turned out that if the character read was 0xff it was
- promoted to -1 (EOF) and caused an 'early' exit. I fixed it:
-
- rdlin() {
- int c, i;
- for (i = 0; i < length; ++i) {
- if ((c = getc(infile)) == EOF)
- break;
- record[i] = c;
- }
- return i;
- }
-
- Question: Is the Unix compiler broken?
- --
- Joe Wright alpha@wyvern.twuug.com
-