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

Skip to content

Commit f9836ba

Browse files
committed
Put conditional S_ISDIR definition(s) into pyport.h.
1 parent e00dde2 commit f9836ba

4 files changed

Lines changed: 14 additions & 14 deletions

File tree

Include/pyport.h

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -150,6 +150,19 @@ typedef unsigned LONG_LONG Py_uintptr_t;
150150
#include <stat.h>
151151
#endif
152152

153+
#if defined(PYCC_VACPP)
154+
/* VisualAge C/C++ Failed to Define MountType Field in sys/stat.h */
155+
#define S_IFMT (S_IFDIR|S_IFCHR|S_IFREG)
156+
#endif
157+
158+
#ifndef S_ISREG
159+
#define S_ISREG(x) (((x) & S_IFMT) == S_IFREG)
160+
#endif
161+
162+
#ifndef S_ISDIR
163+
#define S_ISDIR(x) (((x) & S_IFMT) == S_IFDIR)
164+
#endif
165+
153166

154167
#ifdef __cplusplus
155168
/* Move this down here since some C++ #include's don't like to be included

Modules/getpath.c

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55
#include "osdefs.h"
66

77
#include <sys/types.h>
8-
#include <sys/stat.h>
98
#include <string.h>
109

1110
#if HAVE_UNISTD_H
@@ -138,14 +137,6 @@ reduce(char *dir)
138137
}
139138

140139

141-
#ifndef S_ISREG
142-
#define S_ISREG(x) (((x) & S_IFMT) == S_IFREG)
143-
#endif
144-
145-
#ifndef S_ISDIR
146-
#define S_ISDIR(x) (((x) & S_IFMT) == S_IFDIR)
147-
#endif
148-
149140
static int
150141
isfile(char *filename) /* Is file, not directory */
151142
{

Python/bltinmodule.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -592,7 +592,7 @@ builtin_execfile(PyObject *self, PyObject *args)
592592
exists = 0;
593593
/* Test for existence or directory. */
594594
if (!stat(filename, &s)) {
595-
if ((s.st_mode & S_IFMT) == S_IFDIR)
595+
if (S_ISDIR(s.st_mode))
596596
errno = EISDIR;
597597
else
598598
exists = 1;

Python/import.c

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -28,10 +28,6 @@
2828
#define S_IFMT (S_IFDIR|S_IFCHR|S_IFREG)
2929
#endif
3030

31-
#ifndef S_ISDIR
32-
#define S_ISDIR(mode) (((mode) & S_IFMT) == S_IFDIR)
33-
#endif
34-
3531
extern time_t PyOS_GetLastModificationTime(char *, FILE *);
3632
/* In getmtime.c */
3733

0 commit comments

Comments
 (0)