mirror of
				https://github.com/python/cpython.git
				synced 2025-10-31 13:41:24 +00:00 
			
		
		
		
	Merged revisions 72040 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk ........ r72040 | eric.smith | 2009-04-27 15:04:37 -0400 (Mon, 27 Apr 2009) | 1 line Issue #5793: rationalize isdigit / isalpha / tolower, etc. Will port to py3k. Should fix Windows buildbot errors. ........
This commit is contained in:
		
							parent
							
								
									249b898ec7
								
							
						
					
					
						commit
						6dc46f5eaa
					
				
					 13 changed files with 96 additions and 294 deletions
				
			
		|  | @ -3,12 +3,6 @@ | |||
| #include <Python.h> | ||||
| #include <locale.h> | ||||
| 
 | ||||
| /* ascii character tests (as opposed to locale tests) */ | ||||
| #define ISSPACE(c)  ((c) == ' ' || (c) == '\f' || (c) == '\n' || \ | ||||
|                      (c) == '\r' || (c) == '\t' || (c) == '\v') | ||||
| #define ISDIGIT(c)  ((c) >= '0' && (c) <= '9') | ||||
| 
 | ||||
| 
 | ||||
| /**
 | ||||
|  * PyOS_ascii_strtod: | ||||
|  * @nptr:    the string to convert to a numeric value. | ||||
|  | @ -104,7 +98,7 @@ PyOS_ascii_strtod(const char *nptr, char **endptr) | |||
| 
 | ||||
| 	p = nptr; | ||||
| 	/* Skip leading space */ | ||||
| 	while (ISSPACE(*p)) | ||||
| 	while (Py_ISSPACE(*p)) | ||||
| 		p++; | ||||
| 
 | ||||
| 	/* Process leading sign, if present */ | ||||
|  | @ -147,7 +141,7 @@ PyOS_ascii_strtod(const char *nptr, char **endptr) | |||
| 		goto invalid_string; | ||||
| 
 | ||||
| 	/* Check that what's left begins with a digit or decimal point */ | ||||
| 	if (!ISDIGIT(*p) && *p != '.') | ||||
| 	if (!Py_ISDIGIT(*p) && *p != '.') | ||||
| 		goto invalid_string; | ||||
| 
 | ||||
| 	digits_pos = p; | ||||
|  | @ -158,7 +152,7 @@ PyOS_ascii_strtod(const char *nptr, char **endptr) | |||
| 		   swapped for the current locale's decimal point before we | ||||
| 		   call strtod.  On the other hand, if we find the current | ||||
| 		   locale's decimal point then the input is invalid. */ | ||||
| 		while (ISDIGIT(*p)) | ||||
| 		while (Py_ISDIGIT(*p)) | ||||
| 			p++; | ||||
| 
 | ||||
| 		if (*p == '.') | ||||
|  | @ -166,14 +160,14 @@ PyOS_ascii_strtod(const char *nptr, char **endptr) | |||
| 			decimal_point_pos = p++; | ||||
| 
 | ||||
| 			/* locate end of number */ | ||||
| 			while (ISDIGIT(*p)) | ||||
| 			while (Py_ISDIGIT(*p)) | ||||
| 				p++; | ||||
| 
 | ||||
| 			if (*p == 'e' || *p == 'E') | ||||
| 				p++; | ||||
| 			if (*p == '+' || *p == '-') | ||||
| 				p++; | ||||
| 			while (ISDIGIT(*p)) | ||||
| 			while (Py_ISDIGIT(*p)) | ||||
| 				p++; | ||||
| 			end = p; | ||||
| 		} | ||||
|  | @ -269,7 +263,7 @@ change_decimal_from_locale_to_dot(char* buffer) | |||
| 
 | ||||
| 		if (*buffer == '+' || *buffer == '-') | ||||
| 			buffer++; | ||||
| 		while (isdigit(Py_CHARMASK(*buffer))) | ||||
| 		while (Py_ISDIGIT(*buffer)) | ||||
| 			buffer++; | ||||
| 		if (strncmp(buffer, decimal_point, decimal_point_len) == 0) { | ||||
| 			*buffer = '.'; | ||||
|  | @ -312,7 +306,7 @@ ensure_minimum_exponent_length(char* buffer, size_t buf_size) | |||
| 
 | ||||
| 		/* Find the end of the exponent, keeping track of leading
 | ||||
| 		   zeros. */ | ||||
| 		while (*p && isdigit(Py_CHARMASK(*p))) { | ||||
| 		while (*p && Py_ISDIGIT(*p)) { | ||||
| 			if (in_leading_zeros && *p == '0') | ||||
| 				++leading_zero_cnt; | ||||
| 			if (*p != '0') | ||||
|  | @ -375,11 +369,11 @@ ensure_decimal_point(char* buffer, size_t buf_size) | |||
| 		/* Skip leading sign, if present.  I think this could only
 | ||||
| 		   ever be '-', but it can't hurt to check for both. */ | ||||
| 		++p; | ||||
| 	while (*p && isdigit(Py_CHARMASK(*p))) | ||||
| 	while (*p && Py_ISDIGIT(*p)) | ||||
| 		++p; | ||||
| 
 | ||||
| 	if (*p == '.') { | ||||
| 		if (isdigit(Py_CHARMASK(*(p+1)))) { | ||||
| 		if (Py_ISDIGIT(*(p+1))) { | ||||
| 			/* Nothing to do, we already have a decimal
 | ||||
| 			   point and a digit after it */ | ||||
| 		} | ||||
|  |  | |||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue
	
	 Eric Smith
						Eric Smith