]> Nishi Git Mirror - dataworks.git/commitdiff
use fgetc
authornishi <nishi@d4a5a174-5a4a-5b4b-b672-37683c10d7d5>
Mon, 3 Jun 2024 15:35:39 +0000 (15:35 +0000)
committernishi <nishi@d4a5a174-5a4a-5b4b-b672-37683c10d7d5>
Mon, 3 Jun 2024 15:35:39 +0000 (15:35 +0000)
git-svn-id: file:///raid/svn-main/nishi-dataworks/trunk@139 d4a5a174-5a4a-5b4b-b672-37683c10d7d5

Client/main.c

index 7d73307d9599763d2cbf3812709b5d6c1fefa744..8b81c6fe5af22dad0de47747a54a335b0be11131 100644 (file)
@@ -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++;