From f9836ba4fea66d74fc2afddc434a147265a9caa7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20v=2E=20L=C3=B6wis?= Date: Wed, 8 Aug 2001 10:28:06 +0000 Subject: [PATCH] Put conditional S_ISDIR definition(s) into pyport.h. --- Include/pyport.h | 13 +++++++++++++ Modules/getpath.c | 9 --------- Python/bltinmodule.c | 2 +- Python/import.c | 4 ---- 4 files changed, 14 insertions(+), 14 deletions(-) diff --git a/Include/pyport.h b/Include/pyport.h index 35d87130315..e9dc8128617 100644 --- a/Include/pyport.h +++ b/Include/pyport.h @@ -150,6 +150,19 @@ typedef unsigned LONG_LONG Py_uintptr_t; #include #endif +#if defined(PYCC_VACPP) +/* VisualAge C/C++ Failed to Define MountType Field in sys/stat.h */ +#define S_IFMT (S_IFDIR|S_IFCHR|S_IFREG) +#endif + +#ifndef S_ISREG +#define S_ISREG(x) (((x) & S_IFMT) == S_IFREG) +#endif + +#ifndef S_ISDIR +#define S_ISDIR(x) (((x) & S_IFMT) == S_IFDIR) +#endif + #ifdef __cplusplus /* Move this down here since some C++ #include's don't like to be included diff --git a/Modules/getpath.c b/Modules/getpath.c index 2fd8f7513bb..76bc320aed1 100644 --- a/Modules/getpath.c +++ b/Modules/getpath.c @@ -5,7 +5,6 @@ #include "osdefs.h" #include -#include #include #if HAVE_UNISTD_H @@ -138,14 +137,6 @@ reduce(char *dir) } -#ifndef S_ISREG -#define S_ISREG(x) (((x) & S_IFMT) == S_IFREG) -#endif - -#ifndef S_ISDIR -#define S_ISDIR(x) (((x) & S_IFMT) == S_IFDIR) -#endif - static int isfile(char *filename) /* Is file, not directory */ { diff --git a/Python/bltinmodule.c b/Python/bltinmodule.c index 8f5a9325a53..fa6816279df 100644 --- a/Python/bltinmodule.c +++ b/Python/bltinmodule.c @@ -592,7 +592,7 @@ builtin_execfile(PyObject *self, PyObject *args) exists = 0; /* Test for existence or directory. */ if (!stat(filename, &s)) { - if ((s.st_mode & S_IFMT) == S_IFDIR) + if (S_ISDIR(s.st_mode)) errno = EISDIR; else exists = 1; diff --git a/Python/import.c b/Python/import.c index 8e08164d98e..c5234ace617 100644 --- a/Python/import.c +++ b/Python/import.c @@ -28,10 +28,6 @@ #define S_IFMT (S_IFDIR|S_IFCHR|S_IFREG) #endif -#ifndef S_ISDIR -#define S_ISDIR(mode) (((mode) & S_IFMT) == S_IFDIR) -#endif - extern time_t PyOS_GetLastModificationTime(char *, FILE *); /* In getmtime.c */