summaryrefslogtreecommitdiffstats
path: root/Modules/structmodule.c
Commit message (Collapse)AuthorAgeFilesLines
* (Most of) SF patch 601369 (Christos Georgiou): obmalloc,structmodule:Guido van Rossum2002-09-031-27/+54
| | | | | | | 64bit, big endian (issue 2 only). This adds a bunch of memcpy calls via a temporary variable to avoid alignment errors. That's needed for some platforms.
* Excise DL_EXPORT/DL_IMPORT from Modules/*. Required adding a prototypeMark Hammond2002-08-021-1/+1
| | | | | | for Py_Main(). Thanks to Kalle Svensson and Skip Montanaro for the patches.
* Patch #568124: Add doc string macros.Martin v. Löwis2002-06-131-16/+15
|
* Get rid of more PyArg_Parse & METH_OLDARGS.Neal Norwitz2002-04-021-1/+2
| | | | | PyArg_Parse( "s" ) -> PyString_AsString PyArg_Parse( "t#" ) -> PyString_AsStringAndSize
* Fix typo.Fred Drake2002-02-141-1/+1
|
* Use PyModule_AddObject() instead of accessing the module dict directly.Fred Drake2002-02-141-6/+8
|
* SF patch #474590 -- RISC OS supportGuido van Rossum2001-10-241-13/+13
|
* The 'p' (Pascal string) pack code acts unreasonably when the string sizeTim Peters2001-09-151-0/+2
| | | | | and count exceed 255. Changed to preserve as much of the string as possible (instead of count%256 characters).
* SF bug #442520: test_struct fails on SPARC.Tim Peters2001-07-181-4/+10
| | | | | | | | The ob_sval member of a string object isn't necessarily aligned to better than a native long, so the new "q" and "Q" struct codes can't get away w/ casting tricks on platforms where LONG_LONG requires stricter-than-long alignment. After I thought of a few elaborate workarounds, Guido bashed me over the head with the obvious memcpy approach, herewith implemented.
* The new {b,l}p_{u,}longlong() didn't check get_pylong()'s return for NULL.Tim Peters2001-06-131-0/+8
| | | | Repaired that, and added appropriate tests for it to test_struct.py.
* Added q/Q standard (x-platform 8-byte ints) mode in struct module.Tim Peters2001-06-121-55/+137
| | | | | | | | | | | | | | This completes the q/Q project. longobject.c _PyLong_AsByteArray: The original code had a gross bug: the most-significant Python digit doesn't necessarily have SHIFT significant bits, and you really need to count how many copies of the sign bit it has else spurious overflow errors result. test_struct.py: This now does exhaustive std q/Q testing at, and on both sides of, all relevant power-of-2 boundaries, both positive and negative. NEWS: Added brief dict news while I was at it.
* Trimmed trailing whitespace.Tim Peters2001-06-111-3/+3
|
* Simplify some convolution by simply not recognizing 'q' and 'Q' at allTim Peters2001-06-111-33/+0
| | | | in native mode on platforms that don't HAVE_LONG_LONG.
* Make clear in the docstring that "std" applies to both size and alignment,Tim Peters2001-06-111-6/+6
| | | | | | not just to alignment. Spotted by Guido. Bugfix candidate.
* Initial support for 'q' and 'Q' struct format codes: for now, only inTim Peters2001-06-101-1/+186
| | | | | | | | | | | | | | | | | | native mode, and only when config #defines HAVE_LONG_LONG. Standard mode will eventually treat them as 8-byte ints across all platforms, but that likely requires a new set of routines in longobject.c first (while sizeof(long) >= 4 is guaranteed by C, there's nothing in C we can rely on x-platform to hold 8 bytes of int, so we'll have to roll our own; I'm thinking of a simple pair of conversion functions, Python long to/from sized vector of unsigned bytes; that may be useful for GMP conversions too; std q/Q would call them with size fixed at 8). test_struct.py: In addition to adding some native-mode 'q' and 'Q' tests, got rid of unused code, and repaired a non-portable assumption about native sizeof(short) (it isn't 2 on some Cray boxes). libstruct.tex: In addition to adding a bit of 'q'/'Q' docs (more needed later), removed an erroneous footnote about 'I' behavior.
* Repair portability of sign extension when reading signed ints on boxesTim Peters2001-04-081-10/+6
| | | | | | | | | | where sizeof(long)==8. This *was* broken on boxes where signed right shifts didn't sign-extend, but not elsewhere. Unfortunately, apart from the Cray T3E I don't know of such a box, and Guido has so far refused to buy me any Cray machines for home Python testing <wink>. More immediately interesting would be if someone could please test this on *any* sizeof(long)==8 box, to make sure I didn't break it.
* Rationalize use of limits.h, moving the inclusion to Python.h.Fred Drake2000-09-261-1/+0
| | | | | | | | Add definitions of INT_MAX and LONG_MAX to pyport.h. Remove includes of limits.h and conditional definitions of INT_MAX and LONG_MAX elsewhere. This closes SourceForge patch #101659 and bug #115323.
* Use symbolic constants for allowable short ranges.Martin v. Löwis2000-09-151-4/+7
|
* Check range for bytes and shorts. Closes bug #110845.Martin v. Löwis2000-09-151-2/+42
|
* 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.
* merge Include/my*.h into Include/pyport.hPeter Schneider-Kamp2000-07-311-1/+0
| | | | marked my*.h as obsolete
* Bunch of minor ANSIfications: 'void initfunc()' -> 'void initfunc(void)',Thomas Wouters2000-07-211-1/+1
| | | | | | | | | | | | | | | | | | and a couple of functions that were missed in the previous batches. Not terribly tested, but very carefully scrutinized, three times. All these were found by the little findkrc.py that I posted to python-dev, which means there might be more lurking. Cases such as this: long func(a, b) long a; long b; /* flagword */ { and other cases where the last ; in the argument list isn't followed by a newline and an opening curly bracket. Regexps to catch all are welcome, of course ;)
* ANSI-ficationPeter Schneider-Kamp2000-07-101-173/+57
|
* Nuke all remaining occurrences of Py_PROTO and Py_FPROTO.Tim Peters2000-07-091-5/+4
|
* Change copyright notice - 2nd try.Guido van Rossum2000-06-301-6/+0
|
* Change copyright notice.Guido van Rossum2000-06-301-22/+7
|
* Michael Hudson <mwh21@cam.ac.uk>:Fred Drake2000-06-011-1/+2
| | | | | Removed PyErr_BadArgument() calls and replaced them with more useful error messages.
* Massive patch by Skip Montanaro to add ":name" to as manyGuido van Rossum2000-02-291-2/+2
| | | | PyArg_ParseTuple() format string arguments as possible.
* Add DL_EXPORT() to all modules that could possibly be usedGuido van Rossum1998-12-041-1/+1
| | | | on BeOS or Windows.
* Patches from Greg Stein to support 'P' format in struct module'sGuido van Rossum1998-09-181-0/+31
| | | | | native format, as void* (translated to Python int or long). Also adds PyLong_FromVoidPtr and PyLong_AsVoidPtr to longobject.c.
* Unsigned 1 and 2 byte sized formats shouldn't result in long integer values!Guido van Rossum1998-06-291-2/+8
|
* get_long(): Use PyErr_ExceptionMatches(...) instead of PyErr_Occurred(...).Fred Drake1998-05-281-1/+1
|
* Make new gcc -Wall happyGuido van Rossum1998-04-101-3/+3
|
* Oops, left in a non-standard multi-line doc string that GCC finds okayGuido van Rossum1997-12-211-4/+4
| | | | but other compilers don't like.
* Added doc strings, suggested by Charles G. Waldman (but massaged quite a bit).Guido van Rossum1997-12-191-7/+41
|
* Fix due to Bill Noon for problem discovered by Ken Manheimer: packingGuido van Rossum1997-11-041-2/+2
| | | | 0.0 as float or double would yield the representation for 1.0!
* Apply two changes, systematically:Guido van Rossum1997-10-011-5/+3
| | | | | | | | | | | | | | | | | (1) Use PyErr_NewException("module.class", NULL, NULL) to create the exception object. (2) Remove all calls to Py_FatalError(); instead, return or ignore the errors -- the import code now checks PyErr_Occurred() after calling a module's init function, so it's no longer a fatal error for the initialization to fail. Also did some small cleanups, e.g. removed unnecessary test for "already initialized" from initfpectl(), and unified initposix()/initnt(). I haven't checked this very thoroughly, so while the changes are pretty trivial -- beware of untested code!
* Contribution by Hannu Krosing (with some changes).Guido van Rossum1997-09-051-0/+38
| | | | | | | Added 'p' format character for Pascal string (i.e. leading length byte). This uses the count prefix line 's' does, except that the count includes the length byte; i.e. '10p' takes 10 bytes packed but has space for a length byte and 9 data bytes.
* Ignore whitespace between formats (not internal to a count+format).Guido van Rossum1997-08-261-0/+7
|
* Keep Microsoft VC happy.Guido van Rossum1997-04-111-8/+8
|
* Changed the ``add/sub_offset'' hacks for dealing with C's unsignedGuido van Rossum1997-01-031-112/+14
| | | | | | | int/long types, and use the new PyLong_FromUnsignedLong() and PyLong_AsUnsignedLong() interfaces instead. Semantic change: the 'I' format will now always return a long int.
* Fill pad bytes with zeros (fixing a bug dating from the very first version!).Guido van Rossum1997-01-031-2/+5
|
* Scratch the ears of gcc -Wall.Barry Warsaw1997-01-031-1/+1
|
* Ok, ok, I've fixed gradual underflow on packing too.Guido van Rossum1997-01-021-45/+47
| | | | | | Still don't know what to do with Inf/NaN, so I raise an exception on pack(), and something random decided by ldexp() will happen on unpack().
* Oops -- unpack float/double didn't do the right thing if e==0.Guido van Rossum1997-01-021-4/+14
|
* Support float and double in non-native formats.Guido van Rossum1997-01-021-2/+365
| | | | | These use the ANSI/IEEE standard, which is also used by XDR; so the _xdr module may become obsolete.
* Added better handling of unsigned longs -- a Python long returned byGuido van Rossum1996-12-311-27/+163
| | | | unpack('L', ...) is now acceptable to pack('L', ...).
* Fix the first bugs... treatment of 0 count was wrong, and memchr()Guido van Rossum1996-12-311-6/+6
| | | | should be memset().
* Pretty much rewritten to fulfull several long-standing wishes:Guido van Rossum1996-12-311-226/+572
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | -- The whole implementation is now more table-driven. -- Unsigned integers. Format characters 'B', 'H', 'I' and 'L' mean unsigned byte, short, int and long. For 'I' and 'L', the return value is a Python long integer if a Python plain integer can't represent the required range (note: this is dependent on the size of the relevant C types only, not of the sign of the actual value). -- A new format character 's' packs/unpacks a string. When given a count prefix, this is the size of the string, not a repeat count like for the other format characters; e.g. '10s' means a single 10-byte string, while '10c' means 10 characters. For packing, the string is truncated or padded with null bytes as appropriate to make it fit. For unpacking, the resulting string always has exactly the specified number of bytes. As a special case, '0s' means a single, empty string (while '0c' means 0 characters). -- Various byte order options. The first character of the format string determines the byte order, size and alignment, as follows: First character Byte order size and alignment '@' native native '=' native standard '<' little-endian standard '>' big-endian standard '!' network (= big-endian) standard If the first character is not one of these, '@' is assumed. Native byte order is big-endian or little-endian, depending on the host system (e.g. Motorola and Sun are big-endian; Intel and DEC are little-endian). Native size and alignment are determined using the C compiler's sizeof expression. This is always combined with native byte order. Standard size and alignment are as follows: no alignment is required for any type (so you have to use pad bytes); short is 2 bytes; int and long are 4 bytes. In this mode, there is no support for float and double. Note the difference between '@' and '=': both use native byte order, but the size and alignment of the latter is standardized. The form '!' is available for those poor souls who can't remember whether network byte order is big-endian or little-endian. There is no way to indicate non-native byte order (i.e. force byte-swapping); use the appropriate choice of '<' or '>'.
* Renamed.Barry Warsaw1996-12-121-82/+88
|