From aa8297eff407567d5f383bab7702cdded0598e98 Mon Sep 17 00:00:00 2001 From: nishi Date: Mon, 3 Jun 2024 15:35:39 +0000 Subject: [PATCH] use fgetc git-svn-id: file:///raid/svn-main/nishi-dataworks/trunk@139 d4a5a174-5a4a-5b4b-b672-37683c10d7d5 --- Client/main.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Client/main.c b/Client/main.c index 7d73307..8b81c6f 100644 --- a/Client/main.c +++ b/Client/main.c @@ -193,7 +193,7 @@ int main(int argc, char** argv) { char* linebuf = malloc(1); linebuf[0] = 0; while(1) { - if(fread(&ch, 1, 1, fp) <= 0) break; + if((ch = fgetc(fp)) == EOF) break; if(ch == '\n') { if(buf[0] == '.') { if(__dw_strcaseequ(buf, ".bye") || __dw_strcaseequ(buf, ".quit")) { @@ -294,8 +294,8 @@ int main(int argc, char** argv) { for(i = 0; i < len; i++) { newbuf[i] = buf[i]; } - newbuf[i] = ch; - newbuf[i + 1] = 0; + newbuf[len] = ch; + newbuf[len + 1] = 0; free(buf); buf = newbuf; len++; -- 2.43.0