diff options
| author | Bob Ippolito <bob@redivi.com> | 2006-05-25 21:09:45 (GMT) | 
|---|---|---|
| committer | Bob Ippolito <bob@redivi.com> | 2006-05-25 21:09:45 (GMT) | 
| commit | 964e02a901558b7c03170e642cb7a6d4609bd15c (patch) | |
| tree | 6ba11914a7564ac7624cc172db9924786dfa8165 /Modules/_struct.c | |
| parent | 955b64c03139ec34ce9307960c3e36d6de20e559 (diff) | |
| download | cpython-964e02a901558b7c03170e642cb7a6d4609bd15c.zip cpython-964e02a901558b7c03170e642cb7a6d4609bd15c.tar.gz cpython-964e02a901558b7c03170e642cb7a6d4609bd15c.tar.bz2  | |
fix test_float regression and 64-bit size mismatch issue
Diffstat (limited to 'Modules/_struct.c')
| -rw-r--r-- | Modules/_struct.c | 18 | 
1 files changed, 16 insertions, 2 deletions
diff --git a/Modules/_struct.c b/Modules/_struct.c index 06676fa..fb3e497 100644 --- a/Modules/_struct.c +++ b/Modules/_struct.c @@ -1486,14 +1486,28 @@ init_struct(void)  			other = lilendian_table;  		else  			other = bigendian_table; +		/* Scan through the native table, find a matching +		   entry in the endian table and swap in the +		   native implementations whenever possible +		   (64-bit platforms may not have "standard" sizes) */  		while (native->format != '\0' && other->format != '\0') {  			ptr = other;  			while (ptr->format != '\0') {  				if (ptr->format == native->format) { -					ptr->pack = native->pack; -					ptr->unpack = native->unpack; +					/* Match faster when formats are +					   listed in the same order */  					if (ptr == other)  						other++; +					/* Only use the trick if the  +					   size matches */ +					if (ptr->size != native->size) +						break; +					/* Skip float and double, could be +					   "unknown" float format */ +					if (ptr->format == 'd' || ptr->format == 'f') +						break; +					ptr->pack = native->pack; +					ptr->unpack = native->unpack;  					break;  				}  				ptr++;  | 
