Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
W
wine-winehq
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
wine
wine-winehq
Commits
c042e13e
Commit
c042e13e
authored
Feb 19, 2004
by
Alexandre Julliard
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fixed varargs handling in the scanf functions (spotted by Eric
Pouech).
parent
80d8cc36
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
124 additions
and
56 deletions
+124
-56
file.c
dlls/msvcrt/file.c
+0
-31
scanf.c
dlls/msvcrt/scanf.c
+110
-16
scanf.h
dlls/msvcrt/scanf.h
+6
-9
stdio.h
include/msvcrt/stdio.h
+8
-0
No files found.
dlls/msvcrt/file.c
View file @
c042e13e
...
...
@@ -73,9 +73,6 @@ MSVCRT_FILE* MSVCRT_files[MSVCRT_MAX_FILES];
int
MSVCRT_flags
[
MSVCRT_MAX_FILES
];
char
*
MSVCRT_tempfiles
[
MSVCRT_MAX_FILES
];
MSVCRT_FILE
MSVCRT__iob
[
3
];
#define MSVCRT_stdin (MSVCRT__iob+STDIN_FILENO)
#define MSVCRT_stdout (MSVCRT__iob+STDOUT_FILENO)
#define MSVCRT_stderr (MSVCRT__iob+STDERR_FILENO)
static
int
MSVCRT_fdstart
=
3
;
/* first unallocated fd */
static
int
MSVCRT_fdend
=
3
;
/* highest allocated fd */
...
...
@@ -2375,34 +2372,6 @@ int _wremove(const MSVCRT_wchar_t *path)
}
/*********************************************************************
* scanf (MSVCRT.@)
*/
int
MSVCRT_scanf
(
const
char
*
format
,
...)
{
va_list
valist
;
int
res
;
va_start
(
valist
,
format
);
res
=
MSVCRT_fscanf
(
MSVCRT_stdin
,
format
,
valist
);
va_end
(
valist
);
return
res
;
}
/*********************************************************************
* wscanf (MSVCRT.@)
*/
int
MSVCRT_wscanf
(
const
MSVCRT_wchar_t
*
format
,
...)
{
va_list
valist
;
int
res
;
va_start
(
valist
,
format
);
res
=
MSVCRT_fwscanf
(
MSVCRT_stdin
,
format
,
valist
);
va_end
(
valist
);
return
res
;
}
/*********************************************************************
* rename (MSVCRT.@)
*/
int
MSVCRT_rename
(
const
char
*
oldpath
,
const
char
*
newpath
)
...
...
dlls/msvcrt/scanf.c
View file @
c042e13e
...
...
@@ -38,6 +38,8 @@
WINE_DEFAULT_DEBUG_CHANNEL
(
msvcrt
);
extern
MSVCRT_FILE
MSVCRT__iob
[];
/* helper function for *scanf. Returns the value of character c in the
* given base, or -1 if the given character is not a digit of the base.
*/
...
...
@@ -60,43 +62,135 @@ static int wchar2digit(MSVCRT_wchar_t c, int base) {
return
-
1
;
}
/*********************************************************************
* fscanf (MSVCRT.@)
*/
/* vfscanf */
#undef WIDE_SCANF
#undef CONSOLE
#undef STRING
#include "scanf.h"
/*********************************************************************
* fwscanf (MSVCRT.@)
*/
/* vfwscanf */
#define WIDE_SCANF 1
#undef CONSOLE
#undef STRING
#include "scanf.h"
/*********************************************************************
* sscanf (MSVCRT.@)
*/
/* vsscanf */
#undef WIDE_SCANF
#undef CONSOLE
#define STRING 1
#include "scanf.h"
/*********************************************************************
* swscanf (MSVCRT.@)
*/
/* vswscanf */
#define WIDE_SCANF 1
#undef CONSOLE
#define STRING 1
#include "scanf.h"
/*********************************************************************
* _cscanf (MSVCRT.@)
*/
/* vcscanf */
#undef WIDE_SCANF
#define CONSOLE 1
#undef STRING
#include "scanf.h"
/*********************************************************************
* fscanf (MSVCRT.@)
*/
int
MSVCRT_fscanf
(
MSVCRT_FILE
*
file
,
const
char
*
format
,
...)
{
va_list
valist
;
int
res
;
va_start
(
valist
,
format
);
res
=
MSVCRT_vfscanf
(
file
,
format
,
valist
);
va_end
(
valist
);
return
res
;
}
/*********************************************************************
* scanf (MSVCRT.@)
*/
int
MSVCRT_scanf
(
const
char
*
format
,
...)
{
va_list
valist
;
int
res
;
va_start
(
valist
,
format
);
res
=
MSVCRT_vfscanf
(
MSVCRT_stdin
,
format
,
valist
);
va_end
(
valist
);
return
res
;
}
/*********************************************************************
* fwscanf (MSVCRT.@)
*/
int
MSVCRT_fwscanf
(
MSVCRT_FILE
*
file
,
const
MSVCRT_wchar_t
*
format
,
...)
{
va_list
valist
;
int
res
;
va_start
(
valist
,
format
);
res
=
MSVCRT_vfwscanf
(
file
,
format
,
valist
);
va_end
(
valist
);
return
res
;
}
/*********************************************************************
* wscanf (MSVCRT.@)
*/
int
MSVCRT_wscanf
(
const
MSVCRT_wchar_t
*
format
,
...)
{
va_list
valist
;
int
res
;
va_start
(
valist
,
format
);
res
=
MSVCRT_vfwscanf
(
MSVCRT_stdin
,
format
,
valist
);
va_end
(
valist
);
return
res
;
}
/*********************************************************************
* sscanf (MSVCRT.@)
*/
int
MSVCRT_sscanf
(
const
char
*
str
,
const
char
*
format
,
...)
{
va_list
valist
;
int
res
;
va_start
(
valist
,
format
);
res
=
MSVCRT_vsscanf
(
str
,
format
,
valist
);
va_end
(
valist
);
return
res
;
}
/*********************************************************************
* swscanf (MSVCRT.@)
*/
int
MSVCRT_swscanf
(
const
MSVCRT_wchar_t
*
str
,
const
MSVCRT_wchar_t
*
format
,
...)
{
va_list
valist
;
int
res
;
va_start
(
valist
,
format
);
res
=
MSVCRT_vswscanf
(
str
,
format
,
valist
);
va_end
(
valist
);
return
res
;
}
/*********************************************************************
* _cscanf (MSVCRT.@)
*/
int
_cscanf
(
const
char
*
format
,
...)
{
va_list
valist
;
int
res
;
va_start
(
valist
,
format
);
res
=
MSVCRT_vcscanf
(
format
,
valist
);
va_end
(
valist
);
return
res
;
}
dlls/msvcrt/scanf.h
View file @
c042e13e
...
...
@@ -48,7 +48,7 @@
#ifdef CONSOLE
#define _GETC_(file) (consumed++, _getch())
#define _UNGETC_(nch, file) do { _ungetch(nch); consumed--; } while(0)
#define _FUNCTION_
_cscanf(const _CHAR_ *format, ...
)
#define _FUNCTION_
static int MSVCRT_vcscanf(const char *format, va_list ap
)
#else
#ifdef STRING
#undef _EOF_
...
...
@@ -56,19 +56,19 @@
#define _GETC_(file) (consumed++, *file++)
#define _UNGETC_(nch, file) do { file--; consumed--; } while(0)
#ifdef WIDE_SCANF
#define _FUNCTION_
MSVCRT_swscanf(const MSVCRT_wchar_t *file, const MSVCRT_wchar_t *format, ...
)
#define _FUNCTION_
static int MSVCRT_vswscanf(const MSVCRT_wchar_t *file, const MSVCRT_wchar_t *format, va_list ap
)
#else
/* WIDE_SCANF */
#define _FUNCTION_
MSVCRT_sscanf(const char *file, const char *format, ...
)
#define _FUNCTION_
static int MSVCRT_vsscanf(const char *file, const char *format, va_list ap
)
#endif
/* WIDE_SCANF */
#else
/* STRING */
#ifdef WIDE_SCANF
#define _GETC_(file) (consumed++, MSVCRT_fgetwc(file))
#define _UNGETC_(nch, file) do { MSVCRT_ungetwc(nch, file); consumed--; } while(0)
#define _FUNCTION_
MSVCRT_fwscanf(MSVCRT_FILE* file, const MSVCRT_wchar_t *format, ...
)
#define _FUNCTION_
static int MSVCRT_vfwscanf(MSVCRT_FILE* file, const MSVCRT_wchar_t *format, va_list ap
)
#else
/* WIDE_SCANF */
#define _GETC_(file) (consumed++, MSVCRT_fgetc(file))
#define _UNGETC_(nch, file) do { MSVCRT_ungetc(nch, file); consumed--; } while(0)
#define _FUNCTION_
MSVCRT_fscanf(MSVCRT_FILE* file, const char *format, ...
)
#define _FUNCTION_
static int MSVCRT_vfscanf(MSVCRT_FILE* file, const char *format, va_list ap
)
#endif
/* WIDE_SCANF */
#endif
/* STRING */
#endif
/* CONSOLE */
...
...
@@ -79,10 +79,9 @@
* Extended by C. Scott Ananian <cananian@alumni.princeton.edu> to handle
* more types of format spec.
*/
int
_FUNCTION_
{
_FUNCTION_
{
int
rd
=
0
,
consumed
=
0
;
int
nch
;
va_list
ap
;
if
(
!*
format
)
return
0
;
#ifndef WIDE_SCANF
#ifdef CONSOLE
...
...
@@ -98,7 +97,6 @@ int _FUNCTION_ {
nch
=
_GETC_
(
file
);
if
(
nch
==
_EOF_
)
return
_EOF_RET
;
va_start
(
ap
,
format
);
while
(
*
format
)
{
/* a whitespace character in the format string causes scanf to read,
* but not store, all consecutive white-space characters in the input
...
...
@@ -512,7 +510,6 @@ int _FUNCTION_ {
if
(
nch
!=
_EOF_
)
{
_UNGETC_
(
nch
,
file
);
}
va_end
(
ap
);
TRACE
(
"returning %d
\n
"
,
rd
);
return
rd
;
}
...
...
include/msvcrt/stdio.h
View file @
c042e13e
...
...
@@ -79,6 +79,10 @@
#else
#define MSVCRT_STDIN_FILENO 0
#define MSVCRT_STDOUT_FILENO 1
#define MSVCRT_STDERR_FILENO 2
/* more file._flag flags, but these conflict with Unix */
#define MSVCRT__IOFBF 0x0000
#define MSVCRT__IONBF 0x0004
...
...
@@ -144,6 +148,10 @@ MSVCRT(FILE)* MSVCRT(__p__iob)(void);
#define stdin (_iob+STDIN_FILENO)
#define stdout (_iob+STDOUT_FILENO)
#define stderr (_iob+STDERR_FILENO)
#else
#define MSVCRT_stdin (MSVCRT__iob+MSVCRT_STDIN_FILENO)
#define MSVCRT_stdout (MSVCRT__iob+MSVCRT_STDOUT_FILENO)
#define MSVCRT_stderr (MSVCRT__iob+MSVCRT_STDERR_FILENO)
#endif
/* USE_MSVCRT_PREFIX */
#ifndef MSVCRT_STDIO_DEFINED
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment