summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--sys/src/ape/lib/ap/stdio/vfscanf.c8
-rw-r--r--sys/src/libstdio/vfscanf.c7
2 files changed, 8 insertions, 7 deletions
diff --git a/sys/src/ape/lib/ap/stdio/vfscanf.c b/sys/src/ape/lib/ap/stdio/vfscanf.c
index c44bd7576..95c14b7b2 100644
--- a/sys/src/ape/lib/ap/stdio/vfscanf.c
+++ b/sys/src/ape/lib/ap/stdio/vfscanf.c
@@ -72,7 +72,6 @@ int vfscanf(FILE *f, const char *s, va_list args)
do
c=ngetc(f);
while(isspace(c));
- if(c==EOF) return ncvt?ncvt:EOF;
nungetc(c, f);
break;
}
@@ -396,13 +395,14 @@ icvt_sq(FILE *f, va_list *args, int store, int width, int)
if(nn==0) return 0;
else goto Done;
}
- if(!match(c, pat))
- break;
+ if(!match(c, pat)){
+ nungetc(c, f);
+ return 0;
+ }
if(store)
*s++=c;
nn++;
}
- nungetc(c, f);
Done:
if(store) *s='\0';
return 1;
diff --git a/sys/src/libstdio/vfscanf.c b/sys/src/libstdio/vfscanf.c
index d17dcf2c4..d811b7803 100644
--- a/sys/src/libstdio/vfscanf.c
+++ b/sys/src/libstdio/vfscanf.c
@@ -68,7 +68,6 @@ int vfscanf(FILE *f, const char *s, va_list args){
do
c=ngetc(f);
while(isspace(c));
- if(c==EOF) return ncvt?ncvt:EOF;
nungetc(c, f);
break;
}
@@ -353,11 +352,13 @@ static int icvt_sq(FILE *f, va_list *args, int store, int width, int type){
if(nn==0) return 0;
else goto Done;
}
- if(!match(c, pat)) break;
+ if(!match(c, pat)){
+ nungetc(c, f);
+ return 0;
+ }
if(store) *s++=c;
nn++;
}
- nungetc(c, f);
Done:
if(store) *s='\0';
return 1;