summaryrefslogtreecommitdiffstats
path: root/Python/mystrtoul.c
Commit message (Collapse)AuthorAgeFilesLines
* Revert r61969 which added casts to Py_CHARMASK to avoid compiler warnings.Neal Norwitz2008-03-281-8/+8
| | | | | | Rather than sprinkle casts throughout the code, change Py_CHARMASK to always cast it's result to an unsigned char. This should ensure we do the right thing when accessing an array with the result.
* Fix warnings about using char as an array subscript. This is not portableNeal Norwitz2008-03-271-8/+8
| | | | since char is signed on some platforms and unsigned on others.
* Finished backporting PEP 3127, Integer Literal Support and Syntax.Eric Smith2008-03-171-6/+54
| | | | | | | | Added 0b and 0o literals to tokenizer. Modified PyOS_strtoul to support 0b and 0o inputs. Modified PyLong_FromString to support guessing 0b and 0o inputs. Renamed test_hexoct.py to test_int_literal.py and added binary tests. Added upper and lower case 0b, 0O, and 0X tests to test_int_literal.py
* Removed duplicate Py_CHARMASK define. It's already defined in Python.h.Eric Smith2008-02-231-8/+0
|
* Fix #1679: "0x" was taken as a valid integer literal.Georg Brandl2008-01-191-15/+28
| | | | | Fixes the tokenizer, tokenize.py and int() to reject this. Patches by Malte Helmert.
* Forward-port of r52136,52138: a review of overflow-detecting code.Armin Rigo2006-10-041-8/+4
| | | | | | | | | | | | | | | | | | | | | | | * unified the way intobject, longobject and mystrtoul handle values around -sys.maxint-1. * in general, trying to entierely avoid overflows in any computation involving signed ints or longs is extremely involved. Fixed a few simple cases where a compiler might be too clever (but that's all guesswork). * more overflow checks against bad data in marshal.c. * 2.5 specific: fixed a number of places that were still confusing int and Py_ssize_t. Some of them could potentially have caused "real-world" breakage. * list.pop(x): fixing overflow issues on x was messy. I just reverted to PyArg_ParseTuple("n"), which does the right thing. (An obscure test was trying to give a Decimal to list.pop()... doesn't make sense any more IMHO) * trying to write a few tests...
* Bug #1521947: possible bug in mystrtol.c with recent gcc.Tim Peters2006-07-271-9/+21
| | | | | | | | | | | | | | | | | | | | | In general, C doesn't define anything about what happens when an operation on a signed integral type overflows, and PyOS_strtol() did several formally undefined things of that nature on signed longs. Some version of gcc apparently tries to exploit that now, and PyOS_strtol() could fail to detect overflow then. Tried to repair all that, although it seems at least as likely to me that we'll get screwed by bad platform definitions for LONG_MIN and/or LONG_MAX now. For that reason, I don't recommend backporting this. Note that I have no box on which this makes a lick of difference -- can't really test it, except to note that it didn't break anything on my boxes. Silent change: PyOS_strtol() used to return the hard-coded 0x7fffffff in case of overflow. Now it returns LONG_MAX. They're the same only on 32-bit boxes (although C doesn't guarantee that either ...).
* On 64 bit systems, int literals that use less than 64 bits are now intsNeal Norwitz2006-07-091-0/+11
| | | | rather than longs. This also fixes the test for eval(-sys.maxint - 1).
* Patch #1495999: Part two of Windows CE changes.Martin v. Löwis2006-06-101-1/+1
| | | | | | - update header checks, using autoconf - provide dummies for getenv, environ, and GetVersion - adjust MSC_VER check in socketmodule.c
* A new table to help string->integer conversion was added yesterday toTim Peters2006-05-251-30/+2
| | | | | | both mystrtoul.c and longobject.c. Share the table instead. Also cut its size by 64 entries (they had been used for an inscrutable trick originally, but the code no longer tries to use that trick).
* Bug #1334662 / patch #1335972: int(string, base) wrong answers.Tim Peters2006-05-231-88/+178
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | In rare cases of strings specifying true values near sys.maxint, and oddball bases (not decimal or a power of 2), int(string, base) could deliver insane answers. This repairs all such problems, and also speeds string->int significantly. On my box, here are % speedups for decimal strings of various lengths: length speedup ------ ------- 1 12.4% 2 15.7% 3 20.6% 4 28.1% 5 33.2% 6 37.5% 7 41.9% 8 46.3% 9 51.2% 10 19.5% 11 19.9% 12 23.9% 13 23.7% 14 23.3% 15 24.9% 16 25.3% 17 28.3% 18 27.9% 19 35.7% Note that the difference between 9 and 10 is the difference between short and long Python ints on a 32-bit box. The patch doesn't actually do anything to speed conversion to long: the speedup is due to detecting "unsigned long" overflow more quickly. This is a bugfix candidate, but it's a non-trivial patch and it would be painful to separate the "bug fix" from the "speed up" parts.
* Getting rid of support for the ancient Apple MPW compiler.Jack Jansen2003-11-191-2/+0
|
* REMOVED all CWI, CNRI and BeOpen copyright markings.Guido van Rossum2000-09-011-9/+0
| | | | This should match the situation in the 1.6b1 tree.
* Mass ANSIfication of function definitions. Doesn't cover all 'extern'Thomas Wouters2000-07-221-8/+2
| | | | declarations yet, those come later.
* Change copyright notice - 2nd try.Guido van Rossum2000-06-301-6/+0
|
* Change copyright notice.Guido van Rossum2000-06-301-22/+7
|
* Changes by Mark Hammond for Windows CE. Mostly of the formGuido van Rossum1999-04-071-0/+2
| | | | #ifdef DONT_HAVE_header_H ... #endif around #include <header.h>.
* Chris H. writes:Guido van Rossum1998-12-181-1/+1
| | | | | If we're going to put the PyOS_strtol() proto in intobject.h we should include it here or the symbol isn't exported on PowerPC.
* Sigh. The hack to enable special treatment for errno on SGI machinesGuido van Rossum1998-07-071-0/+4
| | | | | | | | | must be enabled here, otherwise the errno we set on overflows is not the errno that's being read by compile.c. Wonder how many other files that do their own "#include config.h" need this too :-( (Because of the structure of autoconf, it's not so simple to get this into config.h...)
* Address warnings issued by the MSVC++ compilerGuido van Rossum1998-04-101-1/+1
|
* For base 10, cast unsigned long to long before testing overflow.Guido van Rossum1997-12-151-2/+8
| | | | This prevents 4294967296 from being an acceptable way to spell zero!
* Oops, missed some renamings.Guido van Rossum1997-05-071-5/+3
|
* Tweaks to keep the Microsoft compiler quier.Guido van Rossum1997-04-091-1/+1
|
* Keep gcc -Wall happy.Guido van Rossum1996-12-051-1/+1
|
* New permission notice, includes CNRI.Guido van Rossum1996-10-251-13/+20
|
* Always include config.hGuido van Rossum1996-08-191-2/+0
|
* Put definition of _REENTRANT in config.hGuido van Rossum1996-08-011-4/+0
|
* Added _REENTRANT definitionGuido van Rossum1996-07-311-0/+4
|
* use Py_CHARMASKGuido van Rossum1995-02-101-3/+11
|
* include rename2.hGuido van Rossum1995-01-171-0/+2
|
* Added 1995 to copyright message.Guido van Rossum1995-01-041-2/+2
| | | | | | bltinmodule.c: fixed coerce() nightmare in ternary pow(). modsupport.c (initmodule2): pass METH_FREENAME flag to newmethodobject(). pythonrun.c: move flushline() into and around print_error().
* Merge alpha100 branch back to main trunkGuido van Rossum1994-08-011-4/+12
|
* New files.Guido van Rossum1993-12-241-0/+156