summaryrefslogtreecommitdiffstats
path: root/Python/mystrtoul.c
diff options
context:
space:
mode:
authorGuido van Rossum <guido@python.org>1995-02-10 17:01:56 (GMT)
committerGuido van Rossum <guido@python.org>1995-02-10 17:01:56 (GMT)
commit7f7f27483996ae9fcb2ed4fb0a3690280cda7b4a (patch)
tree5d67635bbdfd2fe5bb0b055d532c371716c59d91 /Python/mystrtoul.c
parent760dd1031a8db93dc53ae3eb836bcc44a36918a1 (diff)
downloadcpython-7f7f27483996ae9fcb2ed4fb0a3690280cda7b4a.zip
cpython-7f7f27483996ae9fcb2ed4fb0a3690280cda7b4a.tar.gz
cpython-7f7f27483996ae9fcb2ed4fb0a3690280cda7b4a.tar.bz2
use Py_CHARMASK
Diffstat (limited to 'Python/mystrtoul.c')
-rw-r--r--Python/mystrtoul.c14
1 files changed, 11 insertions, 3 deletions
diff --git a/Python/mystrtoul.c b/Python/mystrtoul.c
index e7c0a57..a646283 100644
--- a/Python/mystrtoul.c
+++ b/Python/mystrtoul.c
@@ -26,6 +26,14 @@ OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
#include "config.h"
#endif
+/* Convert a possibly signed character to a nonnegative int */
+/* XXX This assumes characters are 8 bits wide */
+#ifdef __CHAR_UNSIGNED__
+#define Py_CHARMASK(c) (c)
+#else
+#define Py_CHARMASK(c) ((c) & 0xff)
+#endif
+
#include "rename2.h"
/* strtol and strtoul, renamed to avoid conflicts */
@@ -70,7 +78,7 @@ int base;
}
/* skip leading white space */
- while (*str && isspace(*str))
+ while (*str && isspace(Py_CHARMASK(*str)))
str++;
/* check for leading 0 or 0x for auto-base or base 16 */
@@ -99,7 +107,7 @@ int base;
}
/* do the conversion */
- while (c = *str)
+ while (c = Py_CHARMASK(*str))
{
if (isdigit(c) && c - '0' < base)
c -= '0';
@@ -143,7 +151,7 @@ int base;
long result;
char sign;
- while (*str && isspace(*str))
+ while (*str && isspace(Py_CHARMASK(*str)))
str++;
sign = *str;