Fix scans of more than one character in %[]

This got broken in d8e877a89dae, where we returned 0 on the
first mismatch; we want to return 0 only when we consumed no
characters.
This commit is contained in:
Ori Bernstein 2020-05-15 16:46:20 -07:00
parent ed4645979c
commit 78aec6d5c6
2 changed files with 5 additions and 4 deletions

View file

@ -416,7 +416,7 @@ icvt_sq(FILE *f, va_list *args, int store, int width, int)
}
if(!match(c, pat)){
nungetc(c, f);
return 0;
goto Done;
}
if(store)
*s++=c;
@ -424,5 +424,5 @@ icvt_sq(FILE *f, va_list *args, int store, int width, int)
}
Done:
if(store) *s='\0';
return 1;
return nn > 0;
}

View file

@ -339,6 +339,7 @@ static int icvt_sq(FILE *f, va_list *args, int store, int width, int type){
int c, nn;
register char *s;
register const char *pat;
pat=++fmtp;
if(*fmtp=='^') fmtp++;
if(*fmtp!='\0') fmtp++;
@ -354,12 +355,12 @@ static int icvt_sq(FILE *f, va_list *args, int store, int width, int type){
}
if(!match(c, pat)){
nungetc(c, f);
return 0;
goto Done;
}
if(store) *s++=c;
nn++;
}
Done:
if(store) *s='\0';
return 1;
return nn > 0;
}