From d4a597912f94c4253f227a235aaec440c61cd15d Mon Sep 17 00:00:00 2001 From: keie Date: Mon, 21 Jan 1985 23:53:41 +0000 Subject: [PATCH] Tests for EOF returned by stdio routines need the full int width. --- lang/basic/lib/read.c | 26 ++++++++++++++------------ 1 file changed, 14 insertions(+), 12 deletions(-) diff --git a/lang/basic/lib/read.c b/lang/basic/lib/read.c index 60c5f225f..9d9ae5d9d 100644 --- a/lang/basic/lib/read.c +++ b/lang/basic/lib/read.c @@ -6,14 +6,14 @@ _readln() { - char c; + register int c; while( (c=fgetc(_chanrd)) != EOF && c!= '\n') ; } readskip() { - char c; + register int c; #ifdef DEBUG printf("readskip\n"); #endif @@ -73,6 +73,7 @@ _readstr(s) String **s; { char buffer[1024]; + register int kar ; char *c; #ifdef DEBUG @@ -80,17 +81,18 @@ String **s; #endif _asschn(); c= buffer; - *c= fgetc(_chanrd); - while(isspace(*c) && *c!= EOF) - *c= fgetc(_chanrd); - if( *c== '"') + kar= fgetc(_chanrd); + while(isspace(kar) && kar!= EOF) + kar= fgetc(_chanrd); + *c=kar ; + if( kar== '"') { /* read quoted string */ #ifdef DEBUG printf("qouted string\n"); #endif - while( (*c= fgetc(_chanrd)) != '"' && *c!= EOF ) c++; - ungetc(*c,_chanrd); + while ( (kar= fgetc(_chanrd)) != EOF && kar!='"' ) *c++ = kar ; + ungetc(kar,_chanrd); *c=0; }else if( isalpha(*c)) @@ -100,10 +102,10 @@ String **s; #ifdef DEBUG printf("non-qouted string\n"); #endif - while( (*c= fgetc(_chanrd)) != ',' && *c!= EOF && - !isspace(*c) && *c!='\n') - c++; - ungetc(*c,_chanrd); + while( (kar= fgetc(_chanrd)) != ',' && kar!= EOF && + !isspace(kar) && kar!='\n') + *c++= kar ; + ungetc(kar,_chanrd); *c=0; }else{ if( ferror(_chanrd)) error(29);