Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit b4f39ee

Browse files
committed
merge
2 parents 20b0f87 + 5b2f184 commit b4f39ee

4 files changed

Lines changed: 16 additions & 41 deletions

File tree

Include/pyport.h

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -393,9 +393,15 @@ typedef size_t Py_uhash_t;
393393
#include <stat.h>
394394
#endif
395395

396-
#if defined(PYCC_VACPP)
396+
#ifndef S_IFMT
397397
/* VisualAge C/C++ Failed to Define MountType Field in sys/stat.h */
398-
#define S_IFMT (S_IFDIR|S_IFCHR|S_IFREG)
398+
#define S_IFMT 0170000
399+
#endif
400+
401+
#ifndef S_IFLNK
402+
/* Windows doesn't define S_IFLNK but posixmodule.c maps
403+
* IO_REPARSE_TAG_SYMLINK to S_IFLNK */
404+
# define S_IFLNK 0120000
399405
#endif
400406

401407
#ifndef S_ISREG
@@ -410,11 +416,6 @@ typedef size_t Py_uhash_t;
410416
#define S_ISCHR(x) (((x) & S_IFMT) == S_IFCHR)
411417
#endif
412418

413-
#ifndef S_ISBLK
414-
#define S_ISBLK(x) (((x) & S_IFMT) == S_IFBLK)
415-
#endif
416-
417-
418419
#ifdef __cplusplus
419420
/* Move this down here since some C++ #include's don't like to be included
420421
inside an extern "C" */

Modules/_io/fileio.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -171,7 +171,7 @@ fileio_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
171171
static int
172172
dircheck(fileio* self, PyObject *nameobj)
173173
{
174-
#if defined(HAVE_FSTAT) && defined(S_IFDIR) && defined(EISDIR)
174+
#if defined(HAVE_FSTAT) && defined(S_ISDIR) && defined(EISDIR)
175175
struct stat buf;
176176
if (self->fd < 0)
177177
return 0;

Modules/_stat.c

Lines changed: 5 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -39,35 +39,18 @@ typedef unsigned short mode_t;
3939
*
4040
* Only the names are defined by POSIX but not their value. All common file
4141
* types seems to have the same numeric value on all platforms, though.
42+
*
43+
* pyport.h guarantees S_IFMT, S_IFDIR, S_IFCHR, S_IFREG and S_IFLNK
4244
*/
43-
#ifndef S_IFMT
44-
# define S_IFMT 0170000
45-
#endif
46-
47-
#ifndef S_IFDIR
48-
# define S_IFDIR 0040000
49-
#endif
50-
51-
#ifndef S_IFCHR
52-
# define S_IFCHR 0020000
53-
#endif
5445

5546
#ifndef S_IFBLK
5647
# define S_IFBLK 0060000
5748
#endif
5849

59-
#ifndef S_IFREG
60-
# define S_IFREG 0100000
61-
#endif
62-
6350
#ifndef S_IFIFO
6451
# define S_IFIFO 0010000
6552
#endif
6653

67-
#ifndef S_IFLNK
68-
# define S_IFLNK 0120000
69-
#endif
70-
7154
#ifndef S_IFSOCK
7255
# define S_IFSOCK 0140000
7356
#endif
@@ -85,23 +68,14 @@ typedef unsigned short mode_t;
8568
#endif
8669

8770

88-
/* S_ISXXX() */
89-
#ifndef S_ISDIR
90-
# define S_ISDIR(mode) (((mode) & S_IFMT) == S_IFDIR)
91-
#endif
92-
93-
#ifndef S_ISCHR
94-
# define S_ISCHR(mode) (((mode) & S_IFMT) == S_IFCHR)
95-
#endif
71+
/* S_ISXXX()
72+
* pyport.h defines S_ISDIR(), S_ISREG() and S_ISCHR()
73+
*/
9674

9775
#ifndef S_ISBLK
9876
# define S_ISBLK(mode) (((mode) & S_IFMT) == S_IFBLK)
9977
#endif
10078

101-
#ifndef S_ISREG
102-
# define S_ISREG(mode) (((mode) & S_IFMT) == S_IFREG)
103-
#endif
104-
10579
#ifndef S_ISFIFO
10680
# define S_ISFIFO(mode) (((mode) & S_IFMT) == S_IFIFO)
10781
#endif

Modules/posixmodule.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1405,9 +1405,9 @@ attribute_data_to_stat(BY_HANDLE_FILE_INFORMATION *info, ULONG reparse_tag, stru
14051405
result->st_ino = (((__int64)info->nFileIndexHigh)<<32) + info->nFileIndexLow;
14061406
if (reparse_tag == IO_REPARSE_TAG_SYMLINK) {
14071407
/* first clear the S_IFMT bits */
1408-
result->st_mode ^= (result->st_mode & 0170000);
1408+
result->st_mode ^= (result->st_mode & S_IFMT);
14091409
/* now set the bits that make this a symlink */
1410-
result->st_mode |= 0120000;
1410+
result->st_mode |= S_IFLNK;
14111411
}
14121412

14131413
return 0;

0 commit comments

Comments
 (0)