static int
parse_uint(const char *const p, uint8_t *value)
{
- if (!isdigit(*p)) {
+ if (!Py_ISDIGIT(*p)) {
return -1;
}
// '+' ) character, or the minus-sign ( '-' ) character. The std
// and dst fields in this case shall not include the quoting
// characters.
- if (!isalpha(buff) && !isdigit(buff) && buff != '+' &&
+ if (!Py_ISALPHA(buff) && !Py_ISDIGIT(buff) && buff != '+' &&
buff != '-') {
return -1;
}
// In the unquoted form, all characters in these fields shall be
// alphabetic characters from the portable character set in the
// current locale.
- while (isalpha(*ptr)) {
+ while (Py_ISALPHA(*ptr)) {
ptr++;
}
str_end = ptr;
// The hour can be 1 or 2 numeric characters
for (size_t i = 0; i < 2; ++i) {
buff = *ptr;
- if (!isdigit(buff)) {
+ if (!Py_ISDIGIT(buff)) {
if (i == 0) {
return -1;
}
for (size_t j = 0; j < 2; ++j) {
buff = *ptr;
- if (!isdigit(buff)) {
+ if (!Py_ISDIGIT(buff)) {
return -1;
}
*(outputs[i]) *= 10;
}
for (size_t i = 0; i < 3; ++i) {
- if (!isdigit(*ptr)) {
+ if (!Py_ISDIGIT(*ptr)) {
if (i == 0) {
return -1;
}
uint8_t buff = 0;
for (size_t j = 0; j < 2; j++) {
- if (!isdigit(*ptr)) {
+ if (!Py_ISDIGIT(*ptr)) {
if (i == 0 && j > 0) {
break;
}
#include "Python.h"
#include "pycore_call.h" // _PyObject_CallNoArgs()
-#include <ctype.h>
#include <assert.h>
#include "tokenizer.h"
else if (c == '_')
buf[i] = '-';
else
- buf[i] = tolower(c);
+ buf[i] = Py_TOLOWER(c);
}
buf[i] = '\0';
if (strcmp(buf, "utf-8") == 0 ||
while (1) {
do {
c = tok_nextc(tok);
- } while (isdigit(c));
+ } while (Py_ISDIGIT(c));
if (c != '_') {
break;
}
c = tok_nextc(tok);
- if (!isdigit(c)) {
+ if (!Py_ISDIGIT(c)) {
tok_backup(tok, c);
syntaxerror(tok, "invalid decimal literal");
return 0;
/* Period or number starting with period? */
if (c == '.') {
c = tok_nextc(tok);
- if (isdigit(c)) {
+ if (Py_ISDIGIT(c)) {
goto fraction;
} else if (c == '.') {
c = tok_nextc(tok);
}
/* Number */
- if (isdigit(c)) {
+ if (Py_ISDIGIT(c)) {
if (c == '0') {
/* Hex, octal or binary -- maybe. */
c = tok_nextc(tok);
if (c == '_') {
c = tok_nextc(tok);
}
- if (!isxdigit(c)) {
+ if (!Py_ISXDIGIT(c)) {
tok_backup(tok, c);
return MAKE_TOKEN(syntaxerror(tok, "invalid hexadecimal literal"));
}
do {
c = tok_nextc(tok);
- } while (isxdigit(c));
+ } while (Py_ISXDIGIT(c));
} while (c == '_');
if (!verify_end_of_number(tok, c, "hexadecimal")) {
return MAKE_TOKEN(ERRORTOKEN);
c = tok_nextc(tok);
}
if (c < '0' || c >= '8') {
- if (isdigit(c)) {
+ if (Py_ISDIGIT(c)) {
return MAKE_TOKEN(syntaxerror(tok,
"invalid digit '%c' in octal literal", c));
}
c = tok_nextc(tok);
} while ('0' <= c && c < '8');
} while (c == '_');
- if (isdigit(c)) {
+ if (Py_ISDIGIT(c)) {
return MAKE_TOKEN(syntaxerror(tok,
"invalid digit '%c' in octal literal", c));
}
c = tok_nextc(tok);
}
if (c != '0' && c != '1') {
- if (isdigit(c)) {
+ if (Py_ISDIGIT(c)) {
return MAKE_TOKEN(syntaxerror(tok, "invalid digit '%c' in binary literal", c));
}
else {
c = tok_nextc(tok);
} while (c == '0' || c == '1');
} while (c == '_');
- if (isdigit(c)) {
+ if (Py_ISDIGIT(c)) {
return MAKE_TOKEN(syntaxerror(tok, "invalid digit '%c' in binary literal", c));
}
if (!verify_end_of_number(tok, c, "binary")) {
while (1) {
if (c == '_') {
c = tok_nextc(tok);
- if (!isdigit(c)) {
+ if (!Py_ISDIGIT(c)) {
tok_backup(tok, c);
return MAKE_TOKEN(syntaxerror(tok, "invalid decimal literal"));
}
c = tok_nextc(tok);
}
char* zeros_end = tok->cur;
- if (isdigit(c)) {
+ if (Py_ISDIGIT(c)) {
nonzero = 1;
c = tok_decimal_tail(tok);
if (c == 0) {
c = tok_nextc(tok);
fraction:
/* Fraction */
- if (isdigit(c)) {
+ if (Py_ISDIGIT(c)) {
c = tok_decimal_tail(tok);
if (c == 0) {
return MAKE_TOKEN(ERRORTOKEN);
c = tok_nextc(tok);
if (c == '+' || c == '-') {
c = tok_nextc(tok);
- if (!isdigit(c)) {
+ if (!Py_ISDIGIT(c)) {
tok_backup(tok, c);
return MAKE_TOKEN(syntaxerror(tok, "invalid decimal literal"));
}
- } else if (!isdigit(c)) {
+ } else if (!Py_ISDIGIT(c)) {
tok_backup(tok, c);
if (!verify_end_of_number(tok, e, "decimal")) {
return MAKE_TOKEN(ERRORTOKEN);
}
f_string_quote:
- if (((tolower(*tok->start) == 'f' || tolower(*tok->start) == 'r') && (c == '\'' || c == '"'))) {
+ if (((Py_TOLOWER(*tok->start) == 'f' || Py_TOLOWER(*tok->start) == 'r') && (c == '\'' || c == '"'))) {
int quote = c;
int quote_size = 1; /* 1 or 3 */
switch (*tok->start) {
case 'F':
case 'f':
- the_current_tok->f_string_raw = tolower(*(tok->start + 1)) == 'r';
+ the_current_tok->f_string_raw = Py_TOLOWER(*(tok->start + 1)) == 'r';
break;
case 'R':
case 'r':
return 0;
p1 = (const unsigned char *)s1;
p2 = (const unsigned char *)s2;
- for (; (--size > 0) && *p1 && *p2 && (tolower(*p1) == tolower(*p2));
+ for (; (--size > 0) && *p1 && *p2 && (Py_TOLOWER(*p1) == Py_TOLOWER(*p2));
p1++, p2++) {
;
}
- return tolower(*p1) - tolower(*p2);
+ return Py_TOLOWER(*p1) - Py_TOLOWER(*p2);
}
int
{
const unsigned char *p1 = (const unsigned char *)s1;
const unsigned char *p2 = (const unsigned char *)s2;
- for (; *p1 && *p2 && (tolower(*p1) == tolower(*p2)); p1++, p2++) {
+ for (; *p1 && *p2 && (Py_TOLOWER(*p1) == Py_TOLOWER(*p2)); p1++, p2++) {
;
}
- return (tolower(*p1) - tolower(*p2));
+ return (Py_TOLOWER(*p1) - Py_TOLOWER(*p2));
}