ReactOS 0.4.16-dev-2104-gb84fa49
scanf.h
Go to the documentation of this file.
1/*
2 * general implementation of scanf used by scanf, sscanf, fscanf,
3 * _cscanf, wscanf, swscanf and fwscanf
4 *
5 * Copyright 1996,1998 Marcus Meissner
6 * Copyright 1996 Jukka Iivonen
7 * Copyright 1997,2000, 2003 Uwe Bonnes
8 * Copyright 2000 Jon Griffiths
9 * Copyright 2002 Daniel Gudbjartsson
10 *
11 * This library is free software; you can redistribute it and/or
12 * modify it under the terms of the GNU Lesser General Public
13 * License as published by the Free Software Foundation; either
14 * version 2.1 of the License, or (at your option) any later version.
15 *
16 * This library is distributed in the hope that it will be useful,
17 * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
19 * Lesser General Public License for more details.
20 *
21 * You should have received a copy of the GNU Lesser General Public
22 * License along with this library; if not, write to the Free Software
23 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
24 */
25
26#ifdef WIDE_SCANF
27#define _CHAR_ wchar_t
28#define _EOF_ WEOF
29#define _EOF_RET (short)WEOF
30#define _ISSPACE_(c) iswspace(c)
31#define _WIDE2SUPPORTED_(c) c /* No conversion needed (wide to wide) */
32#define _CHAR2SUPPORTED_(c) c /* FIXME: convert char to wide char */
33#define _CHAR2DIGIT_(c, base) wchar2digit((c), (base))
34#define _BITMAPSIZE_ 256*256
35#else /* WIDE_SCANF */
36#define _CHAR_ char
37#define _EOF_ EOF
38#define _EOF_RET EOF
39#define _ISSPACE_(c) isspace(c)
40#define _WIDE2SUPPORTED_(c) c /* FIXME: convert wide char to char */
41#define _CHAR2SUPPORTED_(c) c /* No conversion needed (char to char) */
42#define _CHAR2DIGIT_(c, base) char2digit((c), (base))
43#define _BITMAPSIZE_ 256
44#endif /* WIDE_SCANF */
45
46#ifdef CONSOLE
47#define _GETC_FUNC_(file) _getch()
48#define _STRTOD_NAME_(func) console_ ## func
49#define _GETC_(file) (consumed++, _getch())
50#define _UNGETC_(nch, file) do { _ungetch(nch); consumed--; } while(0)
51#define _LOCK_FILE_(file) _lock_file(stdin)
52#define _UNLOCK_FILE_(file) _unlock_file(stdin)
53#ifdef WIDE_SCANF
54#ifdef SECURE
55#define _FUNCTION_ static int vcwscanf_s_l(const wchar_t *format, _locale_t locale, va_list ap)
56#else /* SECURE */
57#define _FUNCTION_ static int vcwscanf_l(const wchar_t *format, _locale_t locale, va_list ap)
58#endif /* SECURE */
59#else /* WIDE_SCANF */
60#ifdef SECURE
61#define _FUNCTION_ static int vcscanf_s_l(const char *format, _locale_t locale, va_list ap)
62#else /* SECURE */
63#define _FUNCTION_ static int vcscanf_l(const char *format, _locale_t locale, va_list ap)
64#endif /* SECURE */
65#endif /* WIDE_SCANF */
66#else
67#ifdef STRING
68#undef _EOF_
69#define _EOF_ 0
70#define _GETC_FUNC_(file) (*file++)
71#ifdef WIDE_SCANF
72#define _STRTOD_NAME_(func) wstr_ ## func
73#else
74#define _STRTOD_NAME_(func) str_ ## func
75#endif
76#ifdef STRING_LEN
77#ifdef WIDE_SCANF
78#define _GETC_(file) (consumed++, consumed>length ? '\0' : *file++)
79#else /* WIDE_SCANF */
80#define _GETC_(file) (consumed++, consumed>length ? '\0' : (unsigned char)*file++)
81#endif /* WIDE_SCANF */
82#define _UNGETC_(nch, file) do { file--; consumed--; } while(0)
83#define _LOCK_FILE_(file) do {} while(0)
84#define _UNLOCK_FILE_(file) do {} while(0)
85#ifdef WIDE_SCANF
86#ifdef SECURE
87#define _FUNCTION_ static int vsnwscanf_s_l(const wchar_t *file, size_t length, const wchar_t *format, _locale_t locale, va_list ap)
88#else /* SECURE */
89#define _FUNCTION_ static int vsnwscanf_l(const wchar_t *file, size_t length, const wchar_t *format, _locale_t locale, va_list ap)
90#endif /* SECURE */
91#else /* WIDE_SCANF */
92#ifdef SECURE
93#define _FUNCTION_ static int vsnscanf_s_l(const char *file, size_t length, const char *format, _locale_t locale, va_list ap)
94#else /* SECURE */
95#define _FUNCTION_ static int vsnscanf_l(const char *file, size_t length, const char *format, _locale_t locale, va_list ap)
96#endif /* SECURE */
97#endif /* WIDE_SCANF */
98#else /* STRING_LEN */
99#ifdef WIDE_SCANF
100#define _GETC_(file) (consumed++, *file++)
101#else /* WIDE_SCANF */
102#define _GETC_(file) (consumed++, (unsigned char)*file++)
103#endif /* WIDE_SCANF */
104#define _UNGETC_(nch, file) do { file--; consumed--; } while(0)
105#define _LOCK_FILE_(file) do {} while(0)
106#define _UNLOCK_FILE_(file) do {} while(0)
107#ifdef WIDE_SCANF
108#ifdef SECURE
109#define _FUNCTION_ static int vswscanf_s_l(const wchar_t *file, const wchar_t *format, _locale_t locale, va_list ap)
110#else /* SECURE */
111#define _FUNCTION_ static int vswscanf_l(const wchar_t *file, const wchar_t *format, _locale_t locale, va_list ap)
112#endif /* SECURE */
113#else /* WIDE_SCANF */
114#ifdef SECURE
115#define _FUNCTION_ static int vsscanf_s_l(const char *file, const char *format, _locale_t locale, va_list ap)
116#else /* SECURE */
117#define _FUNCTION_ static int vsscanf_l(const char *file, const char *format, _locale_t locale, va_list ap)
118#endif /* SECURE */
119#endif /* WIDE_SCANF */
120#endif /* STRING_LEN */
121#else /* STRING */
122#ifdef WIDE_SCANF
123#define _GETC_FUNC_(file) fgetwc(file)
124#define _STRTOD_NAME_(func) filew_ ## func
125#define _GETC_(file) (consumed++, fgetwc(file))
126#define _UNGETC_(nch, file) do { ungetwc(nch, file); consumed--; } while(0)
127#define _LOCK_FILE_(file) _lock_file(file)
128#define _UNLOCK_FILE_(file) _unlock_file(file)
129#ifdef SECURE
130#define _FUNCTION_ static int vfwscanf_s_l(FILE* file, const wchar_t *format, _locale_t locale, va_list ap)
131#else /* SECURE */
132#define _FUNCTION_ static int vfwscanf_l(FILE* file, const wchar_t *format, _locale_t locale, va_list ap)
133#endif /* SECURE */
134#else /* WIDE_SCANF */
135#define _GETC_FUNC_(file) fgetc(file)
136#define _STRTOD_NAME_(func) file_ ## func
137#define _GETC_(file) (consumed++, fgetc(file))
138#define _UNGETC_(nch, file) do { ungetc(nch, file); consumed--; } while(0)
139#define _LOCK_FILE_(file) _lock_file(file)
140#define _UNLOCK_FILE_(file) _unlock_file(file)
141#ifdef SECURE
142#define _FUNCTION_ static int vfscanf_s_l(FILE* file, const char *format, _locale_t locale, va_list ap)
143#else /* SECURE */
144#define _FUNCTION_ static int vfscanf_l(FILE* file, const char *format, _locale_t locale, va_list ap)
145#endif /* SECURE */
146#endif /* WIDE_SCANF */
147#endif /* STRING */
148#endif /* CONSOLE */
149
150#if (!defined(SECURE) && !defined(STRING_LEN) && (!defined(CONSOLE) || !defined(WIDE_SCANF)))
151struct _STRTOD_NAME_(strtod_scanf_ctx) {
153#ifdef STRING
154 const _CHAR_ *file;
155#else
156 FILE *file;
157#endif
158 int length;
159 int read;
160 int cur;
161 int unget;
162 BOOL err;
163};
164
165static wchar_t _STRTOD_NAME_(strtod_scanf_get)(void *ctx)
166{
167 struct _STRTOD_NAME_(strtod_scanf_ctx) *context = ctx;
168
169 context->cur = _EOF_;
170 if (!context->length) return WEOF;
171 if (context->unget != _EOF_) {
172 context->cur = context->unget;
173 context->unget = _EOF_;
174 } else {
175 context->cur = _GETC_FUNC_(context->file);
176 if (context->cur == _EOF_) return WEOF;
177 }
178
179 if (context->length > 0) context->length--;
180 context->read++;
181 return context->cur;
182}
183
185{
186 struct _STRTOD_NAME_(strtod_scanf_ctx) *context = ctx;
187
188 if (context->length >= 0) context->length++;
189 context->read--;
190 if (context->unget != _EOF_ || context->cur == _EOF_) {
191 context->err = TRUE;
192 return;
193 }
194 context->unget = context->cur;
195}
196#endif
197
200 int rd = 0, consumed = 0;
201 int nch;
202 if (!*format) return 0;
203#ifndef WIDE_SCANF
204#ifdef CONSOLE
205 TRACE("(%s):\n", debugstr_a(format));
206#else /* CONSOLE */
207#ifdef STRING
208 TRACE("%s (%s)\n", debugstr_a(file), debugstr_a(format));
209#else /* STRING */
210 TRACE("%p (%s)\n", file, debugstr_a(format));
211#endif /* STRING */
212#endif /* CONSOLE */
213#endif /* WIDE_SCANF */
215
216 nch = _GETC_(file);
217 if (nch == _EOF_) {
219 return _EOF_RET;
220 }
221
222 if(!locale)
224 else
225 locinfo = locale->locinfo;
226
227 while (*format) {
228 /* a whitespace character in the format string causes scanf to read,
229 * but not store, all consecutive white-space characters in the input
230 * up to the next non-white-space character. One white space character
231 * in the input matches any number (including zero) and combination of
232 * white-space characters in the input. */
233 if (_ISSPACE_(*format)) {
234 /* skip whitespace */
235 while ((nch!=_EOF_) && _ISSPACE_(nch))
236 nch = _GETC_(file);
237 }
238 /* a format specification causes scanf to read and convert characters
239 * in the input into values of a specified type. The value is assigned
240 * to an argument in the argument list. Format specifications have
241 * the form %[*][width][{h | l | I64 | L}]type */
242 else if (*format == '%') {
243 int st = 0; int suppress = 0; int width = 0;
244 int base;
245 int h_prefix = 0;
246 int l_prefix = 0;
247 int L_prefix = 0;
248 int w_prefix = 0;
249 int prefix_finished = 0;
250 int I64_prefix = 0;
251 format++;
252 /* look for leading asterisk, which means 'suppress assignment of
253 * this field'. */
254 if (*format=='*') {
255 format++;
256 suppress=1;
257 }
258 /* read prefix (if any) */
259 while (!prefix_finished) {
260 /* look for width specification */
261 while (*format >= '0' && *format <= '9') {
262 width *= 10;
263 width += *format++ - '0';
264 }
265
266 switch(*format) {
267 case 'h': h_prefix++; break;
268 case 'l':
269 if(*(format+1) == 'l') {
270 I64_prefix = 1;
271 format++;
272 }
273 l_prefix = 1;
274 break;
275 case 'w': w_prefix = 1; break;
276 case 'L': L_prefix = 1; break;
277 case 'I':
278 if (*(format + 1) == '6' &&
279 *(format + 2) == '4') {
280 I64_prefix = 1;
281 format += 2;
282 break;
283 }
284 else if (*(format + 1) == '3' &&
285 *(format + 2) == '2') {
286 format += 2;
287 break;
288 }
289 /* fall through */
290#if _MSVCR_VER == 0 || _MSVCR_VER >= 140
291 case 'z':
292#endif
293 if (sizeof(void *) == sizeof(LONGLONG)) I64_prefix = 1;
294 break;
295 default:
296 prefix_finished = 1;
297 }
298 if (!prefix_finished) format++;
299 }
300 if (width==0) width=-1; /* no width spec seen */
301 /* read type */
302 switch(*format) {
303 case 'p':
304 case 'P': /* pointer. */
305 if (sizeof(void *) == sizeof(LONGLONG)) I64_prefix = 1;
306 /* fall through */
307 case 'x':
308 case 'X': /* hexadecimal integer. */
309 base = 16;
310 goto number;
311 case 'o': /* octal integer */
312 base = 8;
313 goto number;
314 case 'u': /* unsigned decimal integer */
315 base = 10;
316 goto number;
317 case 'd': /* signed decimal integer */
318 base = 10;
319 goto number;
320 case 'i': /* generic integer */
321 base = 0;
322 number: {
323 /* read an integer */
324 ULONGLONG cur = 0;
325 int negative = 0;
326 int seendigit=0;
327 /* skip initial whitespace */
328 while ((nch!=_EOF_) && _ISSPACE_(nch))
329 nch = _GETC_(file);
330 /* get sign */
331 if (nch == '-' || nch == '+') {
332 negative = (nch=='-');
333 nch = _GETC_(file);
334 if (width>0) width--;
335 }
336 /* look for leading indication of base */
337 if (width!=0 && nch == '0' && *format != 'p' && *format != 'P') {
338 nch = _GETC_(file);
339 if (width>0) width--;
340 seendigit=1;
341 if (width!=0 && (nch=='x' || nch=='X')) {
342 if (base==0)
343 base=16;
344 if (base==16) {
345 nch = _GETC_(file);
346 if (width>0) width--;
347 seendigit=0;
348 }
349 } else if (base==0)
350 base = 8;
351 }
352 /* format %i without indication of base */
353 if (base==0)
354 base = 10;
355 /* throw away leading zeros */
356 while (width!=0 && nch=='0') {
357 nch = _GETC_(file);
358 if (width>0) width--;
359 seendigit=1;
360 }
361 if (width!=0 && _CHAR2DIGIT_(nch, base)!=-1) {
363 nch = _GETC_(file);
364 if (width>0) width--;
365 seendigit=1;
366 }
367 /* read until no more digits */
368 while (width!=0 && (nch!=_EOF_) && _CHAR2DIGIT_(nch, base)!=-1) {
370 nch = _GETC_(file);
371 if (width>0) width--;
372 seendigit=1;
373 }
374 /* okay, done! */
375 if (!seendigit) break; /* not a valid number */
376 st = 1;
377 if (!suppress) {
378#define _SET_NUMBER_(type) *va_arg(ap, type*) = negative ? -cur : cur
379 if (I64_prefix) _SET_NUMBER_(LONGLONG);
380 else if (l_prefix) _SET_NUMBER_(LONG);
381 else if (h_prefix == 1) _SET_NUMBER_(short int);
382#if _MSVCR_VER >= 140
383 else if (h_prefix == 2) _SET_NUMBER_(char);
384#endif
385 else _SET_NUMBER_(int);
386 }
387 }
388 break;
389 case 'e':
390 case 'E':
391 case 'f':
392 case 'g':
393 case 'G': { /* read a float */
394#ifdef CONSOLE
395 struct _STRTOD_NAME_(strtod_scanf_ctx) ctx = {locinfo, 0, width};
396#else
397 struct _STRTOD_NAME_(strtod_scanf_ctx) ctx = {locinfo, file, width};
398#endif
399 int negative = 0;
400 struct fpnum fp;
401 double cur;
402
403 /* skip initial whitespace */
404 while ((nch!=_EOF_) && _ISSPACE_(nch))
405 nch = _GETC_(file);
406 if (nch == _EOF_)
407 break;
408 ctx.unget = nch;
409#ifdef STRING
410 ctx.file = file;
411#endif
412#ifdef STRING_LEN
413 if(ctx.length > length-consumed+1) ctx.length = length-consumed+1;
414#endif
415
418 fpnum_double(&fp, &cur);
419 if(!rd && ctx.err) {
421 return _EOF_RET;
422 }
423 if(ctx.err || !ctx.read)
424 break;
425 consumed += ctx.read;
426#ifdef STRING
427 file = ctx.file;
428#endif
429 nch = ctx.cur;
430
431 st = 1;
432 if (!suppress) {
433 if (L_prefix || l_prefix) _SET_NUMBER_(double);
434 else _SET_NUMBER_(float);
435 }
436 }
437 break;
438 /* According to msdn,
439 * 's' reads a character string in a call to fscanf
440 * and 'S' a wide character string and vice versa in a
441 * call to fwscanf. The 'h', 'w' and 'l' prefixes override
442 * this behaviour. 'h' forces reading char * but 'l' and 'w'
443 * force reading WCHAR. */
444 case 's':
445 if (w_prefix || l_prefix) goto widecharstring;
446 else if (h_prefix) goto charstring;
447#ifdef WIDE_SCANF
448 else goto widecharstring;
449#else /* WIDE_SCANF */
450 else goto charstring;
451#endif /* WIDE_SCANF */
452 case 'S':
453 if (w_prefix || l_prefix) goto widecharstring;
454 else if (h_prefix) goto charstring;
455#ifdef WIDE_SCANF
456 else goto charstring;
457#else /* WIDE_SCANF */
458 else goto widecharstring;
459#endif /* WIDE_SCANF */
460 charstring: { /* read a word into a char */
461 char *sptr = suppress ? NULL : va_arg(ap, char*);
462 char *sptr_beg = sptr;
463#ifdef SECURE
464 unsigned size = suppress ? UINT_MAX : va_arg(ap, unsigned);
465#else
466 unsigned size = UINT_MAX;
467#endif
468 /* skip initial whitespace */
469 while ((nch!=_EOF_) && _ISSPACE_(nch))
470 nch = _GETC_(file);
471 /* read until whitespace */
472 while (width!=0 && (nch!=_EOF_) && !_ISSPACE_(nch)) {
473 if (!suppress) {
474 *sptr++ = _CHAR2SUPPORTED_(nch);
475 if(size>1) size--;
476 else {
478 *sptr_beg = 0;
479 return rd;
480 }
481 }
482 st++;
483 nch = _GETC_(file);
484 if (width>0) width--;
485 }
486 /* if we have reached the EOF and output nothing then report EOF */
487 if (nch==_EOF_ && rd==0 && st==0) {
489 return _EOF_RET;
490 }
491 /* terminate */
492 if (st && !suppress) *sptr = 0;
493 }
494 break;
495 widecharstring: { /* read a word into a wchar_t* */
496 wchar_t *sptr = suppress ? NULL : va_arg(ap, wchar_t*);
497 wchar_t *sptr_beg = sptr;
498#ifdef SECURE
499 unsigned size = suppress ? UINT_MAX : va_arg(ap, unsigned);
500#else
501 unsigned size = UINT_MAX;
502#endif
503 /* skip initial whitespace */
504 while ((nch!=_EOF_) && _ISSPACE_(nch))
505 nch = _GETC_(file);
506 /* read until whitespace */
507 while (width!=0 && (nch!=_EOF_) && !_ISSPACE_(nch)) {
508 if (!suppress) {
509 *sptr++ = _WIDE2SUPPORTED_(nch);
510 if(size>1) size--;
511 else {
513 *sptr_beg = 0;
514 return rd;
515 }
516 }
517 st++;
518 nch = _GETC_(file);
519 if (width>0) width--;
520 }
521#if _MSVCR_VER >= 80
522 /* if we have reached the EOF and output nothing then report EOF */
523 if (nch==_EOF_ && rd==0 && st==0) {
525 return _EOF_RET;
526 }
527#endif
528 /* terminate */
529 if (st && !suppress) *sptr = 0;
530 }
531 break;
532 /* 'c' and 'C work analogously to 's' and 'S' as described
533 * above */
534 case 'c':
535 if (w_prefix || l_prefix) goto widecharacter;
536 else if (h_prefix) goto character;
537#ifdef WIDE_SCANF
538 else goto widecharacter;
539#else /* WIDE_SCANF */
540 else goto character;
541#endif /* WIDE_SCANF */
542 case 'C':
543 if (w_prefix || l_prefix) goto widecharacter;
544 else if (h_prefix) goto character;
545#ifdef WIDE_SCANF
546 else goto character;
547#else /* WIDE_SCANF */
548 else goto widecharacter;
549#endif /* WIDE_SCANF */
550 character: { /* read single character into char */
551 char *str = suppress ? NULL : va_arg(ap, char*);
552 char *pstr = str;
553#ifdef SECURE
554 unsigned size = suppress ? UINT_MAX : va_arg(ap, unsigned);
555#else
556 unsigned size = UINT_MAX;
557#endif
558 if (width == -1) width = 1;
559 while (width && (nch != _EOF_))
560 {
561 if (!suppress) {
562 if(size) size--;
563 else {
565 *pstr = 0;
566 return rd;
567 }
569 }
570 st++;
571 width--;
572 nch = _GETC_(file);
573 }
574 }
575 break;
576 widecharacter: { /* read single character into a wchar_t */
577 wchar_t *str = suppress ? NULL : va_arg(ap, wchar_t*);
578 wchar_t *pstr = str;
579#ifdef SECURE
580 unsigned size = suppress ? UINT_MAX : va_arg(ap, unsigned);
581#else
582 unsigned size = UINT_MAX;
583#endif
584 if (width == -1) width = 1;
585 while (width && (nch != _EOF_))
586 {
587 if (!suppress) {
588 if(size) size--;
589 else {
591 *pstr = 0;
592 return rd;
593 }
595 }
596 st++;
597 width--;
598 nch = _GETC_(file);
599 }
600 }
601 break;
602 case 'n': {
603 if (!suppress) {
604 int*n = va_arg(ap, int*);
605 *n = consumed - 1;
606 }
607 /* This is an odd one: according to the standard,
608 * "Execution of a %n directive does not increment the
609 * assignment count returned at the completion of
610 * execution" even if it wasn't suppressed with the
611 * '*' flag. The Corrigendum to the standard seems
612 * to contradict this (comment out the assignment to
613 * suppress below if you want to implement these
614 * alternate semantics) but the windows program I'm
615 * looking at expects the behavior I've coded here
616 * (which happens to be what glibc does as well).
617 */
618 suppress = 1;
619 st = 1;
620 }
621 break;
622 case '[': {
624 _CHAR_ *sptr = str;
625 RTL_BITMAP bitMask;
626 ULONG *Mask;
627 int invert = 0; /* Set if we are NOT to find the chars */
628#ifdef SECURE
629 unsigned size = suppress ? UINT_MAX : va_arg(ap, unsigned);
630#else
631 unsigned size = UINT_MAX;
632#endif
633
634 /* Init our bitmap */
637
638 /* Read the format */
639 format++;
640 if(*format == '^') {
641 invert = 1;
642 format++;
643 }
644 if(*format == ']') {
645 RtlSetBits(&bitMask, ']', 1);
646 format++;
647 }
648 while(*format && (*format != ']')) {
649 /* According to msdn:
650 * "Note that %[a-z] and %[z-a] are interpreted as equivalent to %[abcde...z]." */
651 if(format[1] == '-' && format[2] && format[2] != ']') {
652 if (format[0] < format[2])
653 RtlSetBits(&bitMask, format[0], format[2] - format[0] + 1);
654 else
655 RtlSetBits(&bitMask, format[2], format[0] - format[2] + 1);
656 format += 2;
657 } else
658 RtlSetBits(&bitMask, *format, 1);
659 format++;
660 }
661 /* read until char is not suitable */
662 while ((width != 0) && (nch != _EOF_)) {
663 if(!invert) {
664 if(RtlAreBitsSet(&bitMask, nch, 1)) {
665 if (!suppress) *sptr++ = _CHAR2SUPPORTED_(nch);
666 } else
667 break;
668 } else {
669 if(RtlAreBitsClear(&bitMask, nch, 1)) {
670 if (!suppress) *sptr++ = _CHAR2SUPPORTED_(nch);
671 } else
672 break;
673 }
674 st++;
675 nch = _GETC_(file);
676 if (width>0) width--;
677 if(size>1) size--;
678 else {
680 *str = 0;
682 return rd;
683 }
684 }
685 /* terminate */
686 if (!suppress) *sptr = 0;
688 }
689 break;
690 default:
691 /* From spec: "if a percent sign is followed by a character
692 * that has no meaning as a format-control character, that
693 * character and the following characters are treated as
694 * an ordinary sequence of characters, that is, a sequence
695 * of characters that must match the input. For example,
696 * to specify that a percent-sign character is to be input,
697 * use %%." */
698 while ((nch!=_EOF_) && _ISSPACE_(nch))
699 nch = _GETC_(file);
700 if ((_CHAR_)nch == *format) {
701 suppress = 1; /* whoops no field to be read */
702 st = 1; /* but we got what we expected */
703 nch = _GETC_(file);
704 }
705 break;
706 }
707 if (st && !suppress) rd++;
708 else if (!st) break;
709 }
710 /* a non-white-space character causes scanf to read, but not store,
711 * a matching non-white-space character. */
712 else {
713 /* check for character match */
714 if ((_CHAR_)nch == *format) {
715 nch = _GETC_(file);
716 } else break;
717 }
718 format++;
719 }
720 if (nch!=_EOF_) {
721 _UNGETC_(nch, file);
722 }
723
724 TRACE("returning %d\n", rd);
726 return rd;
727}
728
729#undef _CHAR_
730#undef _EOF_
731#undef _EOF_RET
732#undef _ISSPACE_
733#undef _CHAR2SUPPORTED_
734#undef _WIDE2SUPPORTED_
735#undef _CHAR2DIGIT_
736#undef _GETC_FUNC_
737#undef _STRTOD_NAME_
738#undef _GETC_
739#undef _UNGETC_
740#undef _LOCK_FILE_
741#undef _UNLOCK_FILE_
742#undef _FUNCTION_
743#undef _BITMAPSIZE_
#define read
Definition: acwin.h:96
Definition: _locale.h:75
#define RtlAreBitsSet
Definition: dbgbitmap.h:328
#define RtlAreBitsClear
Definition: dbgbitmap.h:327
#define RtlInitializeBitMap
Definition: dbgbitmap.h:326
#define RtlSetBits
Definition: dbgbitmap.h:345
#define NULL
Definition: types.h:112
#define TRUE
Definition: types.h:120
#define FALSE
Definition: types.h:117
#define GetProcessHeap()
Definition: compat.h:736
#define HeapAlloc
Definition: compat.h:733
#define HeapFree(x, y, z)
Definition: compat.h:735
#define HEAP_ZERO_MEMORY
Definition: compat.h:134
#define WEOF
#define UINT_MAX
Definition: limits.h:27
#define va_arg(v, l)
Definition: stdarg.h:27
struct fpnum fpnum_parse(wchar_t(*)(void *), void(*)(void *), void *, pthreadlocinfo, BOOL)
int fpnum_double(struct fpnum *, double *)
Definition: string.c:365
static void _STRTOD_NAME_() strtod_scanf_unget(void *ctx)
Definition: scanf.h:184
#define _EOF_RET
Definition: scanf.h:38
int rd
Definition: scanf.h:200
#define _WIDE2SUPPORTED_(c)
Definition: scanf.h:40
#define _LOCK_FILE_(file)
Definition: scanf.h:139
#define _GETC_FUNC_(file)
Definition: scanf.h:135
int nch
Definition: scanf.h:201
#define _SET_NUMBER_(type)
#define _UNLOCK_FILE_(file)
Definition: scanf.h:140
#define _UNGETC_(nch, file)
Definition: scanf.h:138
#define _ISSPACE_(c)
Definition: scanf.h:39
#define _CHAR2SUPPORTED_(c)
Definition: scanf.h:41
#define _GETC_(file)
Definition: scanf.h:137
#define _STRTOD_NAME_(func)
Definition: scanf.h:136
#define _EOF_
Definition: scanf.h:37
#define _CHAR_
Definition: scanf.h:36
int consumed
Definition: scanf.h:200
static wchar_t _STRTOD_NAME_() strtod_scanf_get(void *ctx)
Definition: scanf.h:165
else locinfo
Definition: scanf.h:225
#define _BITMAPSIZE_
Definition: scanf.h:43
#define _FUNCTION_
Definition: scanf.h:144
#define _CHAR2DIGIT_(c, base)
Definition: scanf.h:42
unsigned int BOOL
Definition: ntddk_ex.h:94
unsigned int Mask
Definition: fpcontrol.c:82
FxCollectionEntry * cur
GLint GLint GLsizei width
Definition: gl.h:1546
GLboolean invert
Definition: gl.h:1949
GLdouble n
Definition: glext.h:7729
GLsizeiptr size
Definition: glext.h:5919
GLuint GLsizei GLsizei * length
Definition: glext.h:6040
boolean suppress
Definition: jpeglib.h:1006
#define debugstr_a
Definition: kernel32.h:31
static unsigned int number
Definition: dsound.c:1479
long LONG
Definition: pedump.c:60
#define err(...)
const WCHAR * str
#define TRACE(s)
Definition: solgame.cpp:4
Definition: http.c:7252
Definition: fci.c:127
Definition: format.c:58
Definition: msvcrt.h:359
int64_t LONGLONG
Definition: typedefs.h:68
uint32_t ULONG
Definition: typedefs.h:59
uint64_t ULONGLONG
Definition: typedefs.h:67
#define get_locinfo()
Definition: winesup.h:25
void int int ULONGLONG int va_list * ap
Definition: winesup.h:36