|
@@ -214,13 +214,14 @@ int vfwscanf(FILE *f, const wchar_t *fmt, va_list ap)
|
|
break;
|
|
break;
|
|
|
|
|
|
case 's':
|
|
case 's':
|
|
|
|
+ if (width < 1) width = -1;
|
|
s = dest;
|
|
s = dest;
|
|
while (width && !iswspace(c=getwc(f)) && c!=EOF) {
|
|
while (width && !iswspace(c=getwc(f)) && c!=EOF) {
|
|
int l = wctomb(s?s:tmp, c);
|
|
int l = wctomb(s?s:tmp, c);
|
|
if (l<0) goto input_fail;
|
|
if (l<0) goto input_fail;
|
|
if (s) s+=l;
|
|
if (s) s+=l;
|
|
pos++;
|
|
pos++;
|
|
- width--;
|
|
|
|
|
|
+ width-=(width>0);
|
|
}
|
|
}
|
|
if (width) ungetwc(c, f);
|
|
if (width) ungetwc(c, f);
|
|
if (s) *s = 0;
|
|
if (s) *s = 0;
|
|
@@ -228,8 +229,9 @@ int vfwscanf(FILE *f, const wchar_t *fmt, va_list ap)
|
|
|
|
|
|
case 'S':
|
|
case 'S':
|
|
wcs = dest;
|
|
wcs = dest;
|
|
|
|
+ if (width < 1) width = -1;
|
|
while (width && !iswspace(c=getwc(f)) && c!=EOF)
|
|
while (width && !iswspace(c=getwc(f)) && c!=EOF)
|
|
- width--, pos++, *wcs++ = c;
|
|
|
|
|
|
+ width-=(width>0), pos++, *wcs++ = c;
|
|
if (width) ungetwc(c, f);
|
|
if (width) ungetwc(c, f);
|
|
if (wcs) *wcs = 0;
|
|
if (wcs) *wcs = 0;
|
|
break;
|
|
break;
|
|
@@ -243,6 +245,8 @@ int vfwscanf(FILE *f, const wchar_t *fmt, va_list ap)
|
|
|
|
|
|
int gotmatch = 0;
|
|
int gotmatch = 0;
|
|
|
|
|
|
|
|
+ if (width < 1) width = -1;
|
|
|
|
+
|
|
while (width) {
|
|
while (width) {
|
|
if ((c=getwc(f))<0) break;
|
|
if ((c=getwc(f))<0) break;
|
|
if (in_set(p, c) == invert)
|
|
if (in_set(p, c) == invert)
|
|
@@ -255,7 +259,7 @@ int vfwscanf(FILE *f, const wchar_t *fmt, va_list ap)
|
|
if (s) s+=l;
|
|
if (s) s+=l;
|
|
}
|
|
}
|
|
pos++;
|
|
pos++;
|
|
- width--;
|
|
|
|
|
|
+ width-=(width>0);
|
|
gotmatch=1;
|
|
gotmatch=1;
|
|
}
|
|
}
|
|
if (width) ungetwc(c, f);
|
|
if (width) ungetwc(c, f);
|