Mercurial > cpython-lru_cache-weakref
diff Modules/structmodule.c @ 14587:e8d8758adfdb legacy-trunk
Use symbolic constants for allowable short ranges.
| author | Martin v. Löwis <martin@v.loewis.de> |
|---|---|
| date | Fri, 15 Sep 2000 08:10:33 +0000 |
| parents | 213dbc880159 |
| children | 25ddd3dc7a7a |
line wrap: on
line diff
--- a/Modules/structmodule.c Fri Sep 15 07:44:49 2000 +0000 +++ b/Modules/structmodule.c Fri Sep 15 08:10:33 2000 +0000 @@ -66,6 +66,8 @@ #define DOUBLE_ALIGN (sizeof(s_double) - sizeof(double)) #define VOID_P_ALIGN (sizeof(s_void_p) - sizeof(void *)) +#define STRINGIFY(x) #x + #ifdef __powerc #pragma options align=reset #endif @@ -519,9 +521,10 @@ long x; if (get_long(v, &x) < 0) return -1; - if (x < -32768 || x > 32767){ + if (x < SHRT_MIN || x > SHRT_MAX){ PyErr_SetString(StructError, - "short format requires -32768<=number<=32767"); + "short format requires " STRINGIFY(SHRT_MIN) + "<=number<=" STRINGIFY(SHRT_MAX)); return -1; } * (short *)p = (short)x; @@ -534,9 +537,9 @@ long x; if (get_long(v, &x) < 0) return -1; - if (x < 0 || x > 65535){ + if (x < 0 || x > USHRT_MAX){ PyErr_SetString(StructError, - "short format requires 0<=number<=65535"); + "short format requires 0<=number<=" STRINGIFY(USHRT_MAX)); return -1; } * (unsigned short *)p = (unsigned short)x;
