Mercurial > cpython-lru_cache-weakref
diff Objects/stringobject.c @ 35177:27a718221e72 legacy-trunk
SF bug #1224347: int/long unification and hex()
Hex longs now print with lowercase letters like their int counterparts.
| author | Raymond Hettinger <python@rcn.com> |
|---|---|
| date | Wed, 29 Jun 2005 23:29:56 +0000 |
| parents | 1edea4c2b011 |
| children | ef11cbc08dab |
line wrap: on
line diff
--- a/Objects/stringobject.c Wed Jun 29 14:17:05 2005 +0000 +++ b/Objects/stringobject.c Wed Jun 29 23:29:56 2005 +0000 @@ -3753,18 +3753,12 @@ } /* Fix up case for hex conversions. */ - switch (type) { - case 'x': - /* Need to convert all upper case letters to lower case. */ + if (type == 'X') { + /* Need to convert all lower case letters to upper case. + and need to convert 0x to 0X (and -0x to -0X). */ for (i = 0; i < len; i++) - if (buf[i] >= 'A' && buf[i] <= 'F') - buf[i] += 'a'-'A'; - break; - case 'X': - /* Need to convert 0x to 0X (and -0x to -0X). */ - if (buf[sign + 1] == 'x') - buf[sign + 1] = 'X'; - break; + if (buf[i] >= 'a' && buf[i] <= 'x') + buf[i] -= 'a'-'A'; } *pbuf = buf; *plen = len;
