Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
C
cpython
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
cpython
Commits
f64e6514
Commit
f64e6514
authored
Apr 13, 2009
by
Kristján Valur Jónsson
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Merging r70958 from the trunk, regarding
http://bugs.python.org/issue5623
parent
847f30e2
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
24 additions
and
39 deletions
+24
-39
Modules/posixmodule.c
Modules/posixmodule.c
+24
-39
No files found.
Modules/posixmodule.c
View file @
f64e6514
...
...
@@ -263,6 +263,7 @@ extern int lstat(const char *, struct stat *);
#include <process.h>
#endif
#include "osdefs.h"
#include <malloc.h>
#include <windows.h>
#include <shellapi.h>
/* for ShellExecute() */
#endif
/* _MSC_VER */
...
...
@@ -352,47 +353,15 @@ extern int lstat(const char *, struct stat *);
* (all of this is to avoid globally modifying the CRT behaviour using
* _set_invalid_parameter_handler() and _CrtSetReportMode())
*/
#if _MSC_VER >= 1500
/* VS 2008 */
typedef
struct
{
intptr_t
osfhnd
;
char
osfile
;
char
pipech
;
int
lockinitflag
;
CRITICAL_SECTION
lock
;
#ifndef _SAFECRT_IMPL
char
textmode
:
7
;
char
unicode
:
1
;
char
pipech2
[
2
];
__int64
startpos
;
BOOL
utf8translations
;
char
dbcsBuffer
;
BOOL
dbcsBufferUsed
;
#endif
/* _SAFECRT_IMPL */
}
ioinfo
;
#elif _MSC_VER >= 1400
/* VS 2005 */
/* The actual size of the structure is determined at runtime.
* Only the first items must be present.
*/
typedef
struct
{
intptr_t
osfhnd
;
char
osfile
;
char
pipech
;
int
lockinitflag
;
CRITICAL_SECTION
lock
;
#ifndef _SAFECRT_IMPL
char
textmode
:
7
;
char
unicode
:
1
;
char
pipech2
[
2
];
__int64
startpos
;
BOOL
utf8translations
;
#ifndef _DEBUG
/* padding hack. 8 byte extra length observed at
* runtime, for 32 and 64 bits when not in _DEBUG
*/
__int32
_padding
[
2
];
#endif
#endif
/* _SAFECRT_IMPL */
}
ioinfo
;
#endif
extern
__declspec
(
dllimport
)
ioinfo
*
__pioinfo
[];
}
my_ioinfo
;
extern
__declspec
(
dllimport
)
char
*
__pioinfo
[];
#define IOINFO_L2E 5
#define IOINFO_ARRAY_ELTS (1 << IOINFO_L2E)
#define IOINFO_ARRAYS 64
...
...
@@ -406,6 +375,19 @@ _PyVerify_fd(int fd)
{
const
int
i1
=
fd
>>
IOINFO_L2E
;
const
int
i2
=
fd
&
((
1
<<
IOINFO_L2E
)
-
1
);
static
int
sizeof_ioinfo
=
0
;
/* Determine the actual size of the ioinfo structure,
* as used by the CRT loaded in memory
*/
if
(
sizeof_ioinfo
==
0
&&
__pioinfo
[
0
]
!=
NULL
)
{
sizeof_ioinfo
=
_msize
(
__pioinfo
[
0
])
/
IOINFO_ARRAY_ELTS
;
}
if
(
sizeof_ioinfo
==
0
)
{
/* This should not happen... */
goto
fail
;
}
/* See that it isn't a special CLEAR fileno */
if
(
fd
!=
_NO_CONSOLE_FILENO
)
{
...
...
@@ -414,10 +396,13 @@ _PyVerify_fd(int fd)
*/
if
(
0
<=
i1
&&
i1
<
IOINFO_ARRAYS
&&
__pioinfo
[
i1
]
!=
NULL
)
{
/* finally, check that the file is open */
if
(
__pioinfo
[
i1
][
i2
].
osfile
&
FOPEN
)
my_ioinfo
*
info
=
(
my_ioinfo
*
)(
__pioinfo
[
i1
]
+
i2
*
sizeof_ioinfo
);
if
(
info
->
osfile
&
FOPEN
)
{
return
1
;
}
}
}
fail:
errno
=
EBADF
;
return
0
;
}
...
...
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