From c48c8db110fd5e3b1f8574e8e52f85d11d4c4fd4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20v=2E=20L=C3=B6wis?= Date: Wed, 5 Apr 2006 18:21:17 +0000 Subject: Add PY_SSIZE_T_MIN, as suggested by Ralf W. Grosse-Kunstleve. --- Include/pyport.h | 2 ++ Objects/longobject.c | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/Include/pyport.h b/Include/pyport.h index 9b5c54d..e0d9b7d 100644 --- a/Include/pyport.h +++ b/Include/pyport.h @@ -99,6 +99,8 @@ typedef Py_intptr_t Py_ssize_t; /* Largest positive value of type Py_ssize_t. */ #define PY_SSIZE_T_MAX ((Py_ssize_t)(((size_t)-1)>>1)) +/* Smallest positive value of type Py_ssize_t. */ +#define PY_SSIZE_T_MIN (-PY_SSIZE_T_MAX-1) /* PY_FORMAT_SIZE_T is a platform-specific modifier for use in a printf * format to convert an argument with the width of a size_t or Py_ssize_t. diff --git a/Objects/longobject.c b/Objects/longobject.c index ebcce45c..26f78c2 100644 --- a/Objects/longobject.c +++ b/Objects/longobject.c @@ -281,7 +281,7 @@ _long_as_ssize_t(PyObject *vv) { if (sign > 0) return PY_SSIZE_T_MAX; else - return -PY_SSIZE_T_MAX-1; + return PY_SSIZE_T_MIN; } /* Get a Py_ssize_t from a long int object. -- cgit v0.12