]> granicus.if.org Git - python/commitdiff
Rationalize use of limits.h, moving the inclusion to Python.h.
authorFred Drake <fdrake@acm.org>
Tue, 26 Sep 2000 05:46:01 +0000 (05:46 +0000)
committerFred Drake <fdrake@acm.org>
Tue, 26 Sep 2000 05:46:01 +0000 (05:46 +0000)
Add definitions of INT_MAX and LONG_MAX to pyport.h.
Remove includes of limits.h and conditional definitions of INT_MAX
and LONG_MAX elsewhere.

This closes SourceForge patch #101659 and bug #115323.

25 files changed:
Include/Python.h
Include/longobject.h
Include/pyport.h
Modules/_localemodule.c
Modules/_sre.c
Modules/arraymodule.c
Modules/md5.h
Modules/selectmodule.c
Modules/stropmodule.c
Modules/structmodule.c
Objects/complexobject.c
Objects/fileobject.c
Objects/floatobject.c
Objects/intobject.c
Objects/listobject.c
Objects/object.c
Objects/stringobject.c
Objects/unicodeobject.c
Parser/myreadline.c
Python/bltinmodule.c
Python/ceval.c
Python/codecs.c
Python/compile.c
Python/getargs.c
Python/modsupport.c

index 153ba079786909b51ae51bb3793f263b8e4b7949..308655250de1e4cd7df842ab858cd28dab2a1f8d 100644 (file)
 #include "patchlevel.h"
 #include "config.h"
 
+#ifdef HAVE_LIMITS_H
+#include <limits.h>
+#endif
+
 /* config.h may or may not define DL_IMPORT */
 #ifndef DL_IMPORT      /* declarations for DLL import/export */
 #define DL_IMPORT(RTYPE) RTYPE
index f2dea9340b53ab48537f4875eeb933a7bb2ec0fa..7ebceecaed7fb7be145a2e49277511f16943f6a4 100644 (file)
@@ -24,14 +24,7 @@ extern DL_IMPORT(void *) PyLong_AsVoidPtr(PyObject *);
 
 #ifdef HAVE_LONG_LONG
 
-#ifdef HAVE_LIMITS_H
-#include <limits.h>
-#endif
-
 /* Hopefully this is portable... */
-#ifndef LONG_MAX
-#define LONG_MAX 2147483647L
-#endif
 #ifndef ULONG_MAX
 #define ULONG_MAX 4294967295U
 #endif
index 48cd45b9442d358a87c7c292faded17323846ac6..4914886df15edb3421bad6608266d9cdbb028ea0 100644 (file)
@@ -354,6 +354,38 @@ typedef    struct fd_set {
 #endif /* fd manipulation macros */
 
 
+/* limits.h constants that may be missing */
+
+#ifndef INT_MAX
+#define INT_MAX 2147483647
+#endif
+
+#ifndef LONG_MAX
+#if SIZEOF_LONG == 4
+#define LONG_MAX 0X7FFFFFFFL
+#elif SIZEOF_LONG == 8
+#define LONG_MAX 0X7FFFFFFFFFFFFFFFL
+#else
+#error "could not set LONG_MAX in pyport.h"
+#endif
+#endif
+
+#ifndef LONG_MIN
+#define LONG_MIN (-LONG_MAX-1)
+#endif
+
+#ifdef __NeXT__
+#ifdef __sparc__
+/*
+ * This works around a bug in the NS/Sparc 3.3 pre-release
+ * limits.h header file.
+ * 10-Feb-1995 bwarsaw@cnri.reston.va.us
+ */
+#undef LONG_MIN
+#define LONG_MIN (-LONG_MAX-1)
+#endif
+#endif
+
 #ifdef __cplusplus
 }
 #endif
index 2588b8e913d2f0731d621cde89e72a8d3d699d73..80bfbb27296cea26ddbb50173ae6ab04ed107e6e 100644 (file)
@@ -15,7 +15,6 @@ This software comes with no warranty. Use at your own risk.
 #include <errno.h>
 #include <locale.h>
 #include <string.h>
-#include <limits.h>
 #include <ctype.h>
 
 #if defined(MS_WIN32)
index cf4982dd5606b15db06d563b9b283494761bdb13..2412d42af1024b817528d9824edc3867820efb3e 100644 (file)
@@ -40,12 +40,6 @@ char copyright[] = " SRE 0.9.8 Copyright (c) 1997-2000 by Secret Labs AB ";
 
 #include "sre.h"
 
-#if defined(HAVE_LIMITS_H)
-#include <limits.h>
-#else
-#define INT_MAX 2147483647
-#endif
-
 #include <ctype.h>
 
 /* name of this module, minus the leading underscore */
index 991fdc22e3f56a80da5e4e529b18f4e1c0c826d3..ad7bcc2bc9b4f3c4f823ee31913c9da00c1251fc 100644 (file)
@@ -12,9 +12,6 @@
 #include <sys/types.h>         /* For size_t */
 #endif /* DONT_HAVE_SYS_TYPES_H */
 #endif /* !STDC_HEADERS */
-#ifdef HAVE_LIMITS_H
-#include <limits.h>
-#endif /* HAVE_LIMITS_H */
 
 struct arrayobject; /* Forward */
 
index 12b3aa3db7dc0e160c4ce8aa207ef24d07dd2bdc..e169f779fab465e5bc0ae0b9d71b9c8cac314cb8 100644 (file)
@@ -33,21 +33,14 @@ typedef unsigned char *POINTER;
 /* UINT2 defines a two byte word */
 typedef unsigned short int UINT2;
 
-#ifdef HAVE_LIMITS_H
-#include <limits.h>
-#else
-/* Wild guess */
-#define LONG_MAX 2147483647L
-#endif
-
 /* UINT4 defines a four byte word */
-#if defined(INT_MAX) && INT_MAX == 2147483647
-typedef unsigned int UINT4;
-#else
-#if defined(LONG_MAX) && LONG_MAX == 2147483647L
+#if SIZEOF_LONG == 4
 typedef unsigned long int UINT4;
+#else
+#if INT_MAX == 2147483647
+typedef unsigned int UINT4;
 #endif
-/* Too bad if neither is */
+/* Too bad if neither is; pyport.h would need to be fixed. */
 #endif
 
 /* ========== End global.h; continue md5.h ========== */
index 55c3a49c5359a19f631d967e362bb82ae2a1c7a0..114ac35fb7ab751d736271d34f90e45ddffeaf0b 100644 (file)
@@ -12,9 +12,6 @@
 #ifdef HAVE_UNISTD_H
 #include <unistd.h>
 #endif
-#ifdef HAVE_LIMITS_H
-#include <limits.h>
-#endif
 #ifdef HAVE_POLL_H
 #include <poll.h>
 #endif
index b8f7519f2dfee07933a60e3ce3aa79af9a7e2314..203feb942d556f79f8d593582fc1fd7f66f86042 100644 (file)
@@ -9,12 +9,6 @@ this module directly.";
 
 #include "Python.h"
 
-#ifdef HAVE_LIMITS_H
-#include <limits.h>
-#else
-#define INT_MAX 2147483647
-#endif
-
 #include <ctype.h>
 /* XXX This file assumes that the <ctype.h> is*() functions
    XXX are defined for all 8-bit characters! */
index 4d6012258b4d8a557d2b54bd92e8f42e664d175b..a28ca548dd962689e1708fdca90b9006708e6a83 100644 (file)
@@ -31,7 +31,6 @@ The variable struct.error is an exception raised on errors.";
 
 #include "Python.h"
 
-#include <limits.h>
 #include <ctype.h>
 
 
index 3c9830f6b196ae871433b55f7ee5f8b46486dc8a..dc1d83741fca2c2062c99989e94c41953c768a65 100644 (file)
@@ -9,10 +9,6 @@
 
 #include "Python.h"
 
-#ifdef HAVE_LIMITS_H
-#include <limits.h>
-#endif
-
 
 /* elementary operations on complex numbers */
 
index 88e60275dfaab21813769718e0e4b699a981da67..2978d259d90f48c57e6323729fbbc3c04f8b5064 100644 (file)
@@ -4,10 +4,6 @@
 #include "Python.h"
 #include "structmember.h"
 
-#ifdef HAVE_LIMITS_H
-#include <limits.h>
-#endif
-
 #ifndef DONT_HAVE_SYS_TYPES_H
 #include <sys/types.h>
 #endif /* DONT_HAVE_SYS_TYPES_H */
index 004cf5747aade49b06f8ab5fe7f576dbb48e84d8..17f70b2210389593f8a16b03de29c5060043d21a 100644 (file)
 #define CHECK(x) /* Don't know how to check */
 #endif
 
-#ifdef HAVE_LIMITS_H
-#include <limits.h>
-#endif
-
-#ifndef LONG_MAX
-#if SIZEOF_LONG == 4
-#define LONG_MAX 0X7FFFFFFFL
-#elif SIZEOF_LONG == 8
-#define LONG_MAX 0X7FFFFFFFFFFFFFFFL
-#else
-#error "could not set LONG_MAX"
-#endif
-#endif
-
-#ifndef LONG_MIN
-#define LONG_MIN (-LONG_MAX-1)
-#endif
-
-#ifdef __NeXT__
-#ifdef __sparc__
-/*
- * This works around a bug in the NS/Sparc 3.3 pre-release
- * limits.h header file.
- * 10-Feb-1995 bwarsaw@cnri.reston.va.us
- */
-#undef LONG_MIN
-#define LONG_MIN (-LONG_MAX-1)
-#endif
-#endif
-
 #if !defined(__STDC__) && !defined(macintosh)
 extern double fmod(double, double);
 extern double pow(double, double);
index 411e4dd17467325537448663e8d4a2f9a69832e7..8477a02381792ce85b6e5515684bfc2297c89549 100644 (file)
@@ -4,18 +4,6 @@
 #include "Python.h"
 #include <ctype.h>
 
-#ifdef HAVE_LIMITS_H
-#include <limits.h>
-#endif
-
-#ifndef LONG_MAX
-#define LONG_MAX 0X7FFFFFFFL
-#endif
-
-#ifndef LONG_MIN
-#define LONG_MIN (-LONG_MAX-1)
-#endif
-
 #ifndef CHAR_BIT
 #define CHAR_BIT 8
 #endif
index 3d02b5f9a2bb54e732564e3956fddd49bf1fe58a..b874af9f543cfb72e96e9ebf8ec831177268e882 100644 (file)
@@ -8,9 +8,6 @@
 #else
 #include <sys/types.h>         /* For size_t */
 #endif
-#ifdef HAVE_LIMITS_H
-#include <limits.h>
-#endif
 
 #define ROUNDUP(n, PyTryBlock) \
        ((((n)+(PyTryBlock)-1)/(PyTryBlock))*(PyTryBlock))
index 4f395ff357129ef010cc8984159634b1979c9f66..9b7c551d85bcf153698a8b7f0784a54a600377fb 100644 (file)
@@ -2,9 +2,6 @@
 /* Generic object operations; and implementation of None (NoObject) */
 
 #include "Python.h"
-#ifdef HAVE_LIMITS_H
-#include <limits.h>
-#endif
 
 #ifdef macintosh
 #include "macglue.h"
index acae88032549493f7d22460822799bd8203b0023..ec7eb908a325f252e16856201cd86395d5ee4709 100644 (file)
@@ -9,13 +9,9 @@
 int null_strings, one_strings;
 #endif
 
-#ifdef HAVE_LIMITS_H
-#include <limits.h>
-#else
-#ifndef UCHAR_MAX
+#if !defined(HAVE_LIMITS_H) && !defined(UCHAR_MAX)
 #define UCHAR_MAX 255
 #endif
-#endif
 
 static PyStringObject *characters[UCHAR_MAX + 1];
 #ifndef DONT_SHARE_SHORT_STRINGS
index 1559542d8aaf1de3e0eaea35edc3eabba69f31e8..b096faa3f29151b5d0e65f9f79d370937ac5fd71 100644 (file)
@@ -67,12 +67,6 @@ Copyright (c) Corporation for National Research Initiatives.
 #include "unicodeobject.h"
 #include "ucnhash.h"
 
-#if defined(HAVE_LIMITS_H)
-#include <limits.h>
-#else
-#define INT_MAX 2147483647
-#endif
-
 #ifdef MS_WIN32
 #include <windows.h>
 #endif
index 6451824ede05d305b3f439b4ce66bfe62404e7ce..963a90e0385a6405266b48acc0a81d3da007eab5 100644 (file)
@@ -10,9 +10,6 @@
 */
 
 #include "Python.h"
-#ifdef HAVE_LIMITS_H
-#include <limits.h>
-#endif
 
 int (*PyOS_InputHook)(void) = NULL;
 
index 88656ca630f09cec1d8f2e5589b365b1b97206f1..4ca1310be2133be3b81b0ed26ed8977ec26cd9b8 100644 (file)
@@ -12,9 +12,6 @@
 #ifdef HAVE_UNISTD_H
 #include <unistd.h>
 #endif
-#ifdef HAVE_LIMITS_H
-#include <limits.h>
-#endif
 
 /* Forward */
 static PyObject *filterstring(PyObject *, PyObject *);
index 491a73bdf1d8c3f40c8cca9af5f90b2b3509053a..36cdab84e5839de04d7d7623ec3b7acb02af38fd 100644 (file)
 
 #include <ctype.h>
 
-#ifdef HAVE_LIMITS_H
-#include <limits.h>
-#else
-#define INT_MAX 2147483647
-#endif
-
 /* Turn this on if your compiler chokes on the big switch: */
 /* #define CASE_TOO_BIG 1 */
 
index c3f93ccda952a9ca8825a7afe980961d572ea5b0..3324b806fc9b227a384d285509ad57bf105b265c 100644 (file)
@@ -10,9 +10,6 @@ Copyright (c) Corporation for National Research Initiatives.
 
 #include "Python.h"
 #include <ctype.h>
-#ifdef HAVE_LIMITS_H
-#include <limits.h>
-#endif
 
 /* --- Globals ------------------------------------------------------------ */
 
index 0409f2d0d8240e1b6934fdd4b529a9859a2d7659..e14fc01df8b04940ab9e10e9a00cbca063dee32a 100644 (file)
 #include "structmember.h"
 
 #include <ctype.h>
-#ifdef HAVE_LIMITS_H
-#include <limits.h>
-#endif
-#ifndef INT_MAX
-#define INT_MAX 2147483647
-#endif
 
 /* Three symbols from graminit.h are also defined in Python.h, with
    Py_ prefixes to their names.  Python.h can't include graminit.h
index 797e9df77d65a19f2edfb4632818a5a22416b3be..46251ae75e3bbde699122b8111f40c66915cd51c 100644 (file)
@@ -9,9 +9,6 @@
 #include "Python.h"
 
 #include <ctype.h>
-#ifdef HAVE_LIMITS_H
-#include <limits.h>
-#endif
 
 
 int PyArg_Parse(PyObject *, char *, ...);
index 9c2dc18a4516e029f7847a98393fc9d1dde5e3d3..ef36d108f5b7085021f6932c837bbacbea3a6fc3 100644 (file)
@@ -2,9 +2,6 @@
 /* Module support implementation */
 
 #include "Python.h"
-#ifdef HAVE_LIMITS_H
-#include <limits.h>
-#endif
 
 #ifdef MPW /* MPW pushes 'extended' for float and double types with varargs */
 typedef extended va_double;