[9633] | 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 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
---|
| 24 | */
|
---|
| 25 |
|
---|
| 26 | #include "winbase.h"
|
---|
| 27 | #include "winternl.h"
|
---|
| 28 | #include "msvcrt.h"
|
---|
| 29 | #include "msvcrt/conio.h"
|
---|
[10005] | 30 | #include "msvcrt/ctype.h"
|
---|
[9633] | 31 | #include "msvcrt/io.h"
|
---|
| 32 | #include "msvcrt/stdio.h"
|
---|
| 33 | #include "msvcrt/wctype.h"
|
---|
| 34 | #include "wine/debug.h"
|
---|
[10005] | 35 | #include <ctype.h>
|
---|
[9633] | 36 | WINE_DEFAULT_DEBUG_CHANNEL(msvcrt);
|
---|
| 37 |
|
---|
| 38 | /* helper function for *scanf. Returns the value of character c in the
|
---|
| 39 | * given base, or -1 if the given character is not a digit of the base.
|
---|
| 40 | */
|
---|
| 41 | static int char2digit(char c, int base) {
|
---|
| 42 | if ((c>='0') && (c<='9') && (c<='0'+base-1)) return (c-'0');
|
---|
| 43 | if (base<=10) return -1;
|
---|
| 44 | if ((c>='A') && (c<='Z') && (c<='A'+base-11)) return (c-'A'+10);
|
---|
| 45 | if ((c>='a') && (c<='z') && (c<='a'+base-11)) return (c-'a'+10);
|
---|
| 46 | return -1;
|
---|
| 47 | }
|
---|
| 48 |
|
---|
| 49 | /* helper function for *wscanf. Returns the value of character c in the
|
---|
| 50 | * given base, or -1 if the given character is not a digit of the base.
|
---|
| 51 | */
|
---|
| 52 | static int wchar2digit(MSVCRT_wchar_t c, int base) {
|
---|
| 53 | if ((c>=L'0') && (c<=L'9') && (c<=L'0'+base-1)) return (c-L'0');
|
---|
| 54 | if (base<=10) return -1;
|
---|
| 55 | if ((c>=L'A') && (c<=L'Z') && (c<=L'A'+base-11)) return (c-L'A'+10);
|
---|
| 56 | if ((c>=L'a') && (c<=L'z') && (c<=L'a'+base-11)) return (c-L'a'+10);
|
---|
| 57 | return -1;
|
---|
| 58 | }
|
---|
| 59 |
|
---|
| 60 |
|
---|
| 61 | /*********************************************************************
|
---|
| 62 | * fscanf (MSVCRT.@)
|
---|
| 63 | */
|
---|
| 64 | #undef WIDE_SCANF
|
---|
| 65 | #undef CONSOLE
|
---|
| 66 | #undef STRING
|
---|
| 67 | #include "scanf.h"
|
---|
| 68 |
|
---|
| 69 | /*********************************************************************
|
---|
| 70 | * fwscanf (MSVCRT.@)
|
---|
| 71 | */
|
---|
| 72 | #define WIDE_SCANF 1
|
---|
| 73 | #undef CONSOLE
|
---|
| 74 | #undef STRING
|
---|
| 75 | #include "scanf.h"
|
---|
| 76 |
|
---|
| 77 | /*********************************************************************
|
---|
| 78 | * sscanf (MSVCRT.@)
|
---|
| 79 | */
|
---|
| 80 | #undef WIDE_SCANF
|
---|
| 81 | #undef CONSOLE
|
---|
| 82 | #define STRING 1
|
---|
| 83 | #include "scanf.h"
|
---|
| 84 |
|
---|
| 85 | /*********************************************************************
|
---|
| 86 | * swscanf (MSVCRT.@)
|
---|
| 87 | */
|
---|
| 88 | #define WIDE_SCANF 1
|
---|
| 89 | #undef CONSOLE
|
---|
| 90 | #define STRING 1
|
---|
| 91 | #include "scanf.h"
|
---|
| 92 |
|
---|
| 93 | /*********************************************************************
|
---|
| 94 | * _cscanf (MSVCRT.@)
|
---|
| 95 | */
|
---|
| 96 | #undef WIDE_SCANF
|
---|
| 97 | #define CONSOLE 1
|
---|
| 98 | #undef STRING
|
---|
| 99 | #include "scanf.h"
|
---|