44#include "Python.h"
55#include "pycore_call.h" // _PyObject_CallNoArgs()
66
7- #include <ctype.h>
87#include <assert.h>
98
109#include "tokenizer.h"
@@ -158,7 +157,7 @@ get_normal_name(const char *s) /* for utf-8 and latin-1 */
158157 else if (c == '_' )
159158 buf [i ] = '-' ;
160159 else
161- buf [i ] = tolower (c );
160+ buf [i ] = Py_TOLOWER (c );
162161 }
163162 buf [i ] = '\0' ;
164163 if (strcmp (buf , "utf-8" ) == 0 ||
@@ -1715,12 +1714,12 @@ tok_decimal_tail(struct tok_state *tok)
17151714 while (1 ) {
17161715 do {
17171716 c = tok_nextc (tok );
1718- } while (isdigit (c ));
1717+ } while (Py_ISDIGIT (c ));
17191718 if (c != '_' ) {
17201719 break ;
17211720 }
17221721 c = tok_nextc (tok );
1723- if (!isdigit (c )) {
1722+ if (!Py_ISDIGIT (c )) {
17241723 tok_backup (tok , c );
17251724 syntaxerror (tok , "invalid decimal literal" );
17261725 return 0 ;
@@ -2108,7 +2107,7 @@ tok_get_normal_mode(struct tok_state *tok, tokenizer_mode* current_tok, struct t
21082107 /* Period or number starting with period? */
21092108 if (c == '.' ) {
21102109 c = tok_nextc (tok );
2111- if (isdigit (c )) {
2110+ if (Py_ISDIGIT (c )) {
21122111 goto fraction ;
21132112 } else if (c == '.' ) {
21142113 c = tok_nextc (tok );
@@ -2131,7 +2130,7 @@ tok_get_normal_mode(struct tok_state *tok, tokenizer_mode* current_tok, struct t
21312130 }
21322131
21332132 /* Number */
2134- if (isdigit (c )) {
2133+ if (Py_ISDIGIT (c )) {
21352134 if (c == '0' ) {
21362135 /* Hex, octal or binary -- maybe. */
21372136 c = tok_nextc (tok );
@@ -2142,13 +2141,13 @@ tok_get_normal_mode(struct tok_state *tok, tokenizer_mode* current_tok, struct t
21422141 if (c == '_' ) {
21432142 c = tok_nextc (tok );
21442143 }
2145- if (!isxdigit (c )) {
2144+ if (!Py_ISXDIGIT (c )) {
21462145 tok_backup (tok , c );
21472146 return MAKE_TOKEN (syntaxerror (tok , "invalid hexadecimal literal" ));
21482147 }
21492148 do {
21502149 c = tok_nextc (tok );
2151- } while (isxdigit (c ));
2150+ } while (Py_ISXDIGIT (c ));
21522151 } while (c == '_' );
21532152 if (!verify_end_of_number (tok , c , "hexadecimal" )) {
21542153 return MAKE_TOKEN (ERRORTOKEN );
@@ -2162,7 +2161,7 @@ tok_get_normal_mode(struct tok_state *tok, tokenizer_mode* current_tok, struct t
21622161 c = tok_nextc (tok );
21632162 }
21642163 if (c < '0' || c >= '8' ) {
2165- if (isdigit (c )) {
2164+ if (Py_ISDIGIT (c )) {
21662165 return MAKE_TOKEN (syntaxerror (tok ,
21672166 "invalid digit '%c' in octal literal" , c ));
21682167 }
@@ -2175,7 +2174,7 @@ tok_get_normal_mode(struct tok_state *tok, tokenizer_mode* current_tok, struct t
21752174 c = tok_nextc (tok );
21762175 } while ('0' <= c && c < '8' );
21772176 } while (c == '_' );
2178- if (isdigit (c )) {
2177+ if (Py_ISDIGIT (c )) {
21792178 return MAKE_TOKEN (syntaxerror (tok ,
21802179 "invalid digit '%c' in octal literal" , c ));
21812180 }
@@ -2191,7 +2190,7 @@ tok_get_normal_mode(struct tok_state *tok, tokenizer_mode* current_tok, struct t
21912190 c = tok_nextc (tok );
21922191 }
21932192 if (c != '0' && c != '1' ) {
2194- if (isdigit (c )) {
2193+ if (Py_ISDIGIT (c )) {
21952194 return MAKE_TOKEN (syntaxerror (tok , "invalid digit '%c' in binary literal" , c ));
21962195 }
21972196 else {
@@ -2203,7 +2202,7 @@ tok_get_normal_mode(struct tok_state *tok, tokenizer_mode* current_tok, struct t
22032202 c = tok_nextc (tok );
22042203 } while (c == '0' || c == '1' );
22052204 } while (c == '_' );
2206- if (isdigit (c )) {
2205+ if (Py_ISDIGIT (c )) {
22072206 return MAKE_TOKEN (syntaxerror (tok , "invalid digit '%c' in binary literal" , c ));
22082207 }
22092208 if (!verify_end_of_number (tok , c , "binary" )) {
@@ -2217,7 +2216,7 @@ tok_get_normal_mode(struct tok_state *tok, tokenizer_mode* current_tok, struct t
22172216 while (1 ) {
22182217 if (c == '_' ) {
22192218 c = tok_nextc (tok );
2220- if (!isdigit (c )) {
2219+ if (!Py_ISDIGIT (c )) {
22212220 tok_backup (tok , c );
22222221 return MAKE_TOKEN (syntaxerror (tok , "invalid decimal literal" ));
22232222 }
@@ -2228,7 +2227,7 @@ tok_get_normal_mode(struct tok_state *tok, tokenizer_mode* current_tok, struct t
22282227 c = tok_nextc (tok );
22292228 }
22302229 char * zeros_end = tok -> cur ;
2231- if (isdigit (c )) {
2230+ if (Py_ISDIGIT (c )) {
22322231 nonzero = 1 ;
22332232 c = tok_decimal_tail (tok );
22342233 if (c == 0 ) {
@@ -2272,7 +2271,7 @@ tok_get_normal_mode(struct tok_state *tok, tokenizer_mode* current_tok, struct t
22722271 c = tok_nextc (tok );
22732272 fraction :
22742273 /* Fraction */
2275- if (isdigit (c )) {
2274+ if (Py_ISDIGIT (c )) {
22762275 c = tok_decimal_tail (tok );
22772276 if (c == 0 ) {
22782277 return MAKE_TOKEN (ERRORTOKEN );
@@ -2287,11 +2286,11 @@ tok_get_normal_mode(struct tok_state *tok, tokenizer_mode* current_tok, struct t
22872286 c = tok_nextc (tok );
22882287 if (c == '+' || c == '-' ) {
22892288 c = tok_nextc (tok );
2290- if (!isdigit (c )) {
2289+ if (!Py_ISDIGIT (c )) {
22912290 tok_backup (tok , c );
22922291 return MAKE_TOKEN (syntaxerror (tok , "invalid decimal literal" ));
22932292 }
2294- } else if (!isdigit (c )) {
2293+ } else if (!Py_ISDIGIT (c )) {
22952294 tok_backup (tok , c );
22962295 if (!verify_end_of_number (tok , e , "decimal" )) {
22972296 return MAKE_TOKEN (ERRORTOKEN );
@@ -2326,7 +2325,7 @@ tok_get_normal_mode(struct tok_state *tok, tokenizer_mode* current_tok, struct t
23262325 }
23272326
23282327 f_string_quote :
2329- if (((tolower (* tok -> start ) == 'f' || tolower (* tok -> start ) == 'r' ) && (c == '\'' || c == '"' ))) {
2328+ if (((Py_TOLOWER (* tok -> start ) == 'f' || Py_TOLOWER (* tok -> start ) == 'r' ) && (c == '\'' || c == '"' ))) {
23302329 int quote = c ;
23312330 int quote_size = 1 ; /* 1 or 3 */
23322331
@@ -2377,7 +2376,7 @@ tok_get_normal_mode(struct tok_state *tok, tokenizer_mode* current_tok, struct t
23772376 switch (* tok -> start ) {
23782377 case 'F' :
23792378 case 'f' :
2380- the_current_tok -> f_string_raw = tolower (* (tok -> start + 1 )) == 'r' ;
2379+ the_current_tok -> f_string_raw = Py_TOLOWER (* (tok -> start + 1 )) == 'r' ;
23812380 break ;
23822381 case 'R' :
23832382 case 'r' :
0 commit comments