Issue #7117: Prepare for backport of py3k float repr.

Add the Python/dtoa.c file containing the main algorithms;
add corresponding include file and include in Python.h;
include license information for Python/dtoa.c;
add dtoa.c and dtoa.h to Makefile.
This commit is contained in:
Mark Dickinson 2009-10-24 12:13:30 +00:00
parent f98a267be3
commit bb28285ea2
6 changed files with 2667 additions and 0 deletions

View File

@ -708,3 +708,35 @@ The :mod:`select` and contains the following notice for the kqueue interface::
LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
SUCH DAMAGE.
strtod and dtoa
---------------
The file :file:`Python/dtoa.c`, which supplies C functions dtoa and
strtod for conversion of C doubles to and from strings, is derived
from the file of the same name by David M. Gay, currently available
from http://www.netlib.org/fp/. The original file, as retrieved on
March 16, 2009, contains the following copyright and licensing
notice::
/****************************************************************
*
* The author of this software is David M. Gay.
*
* Copyright (c) 1991, 2000, 2001 by Lucent Technologies.
*
* Permission to use, copy, modify, and distribute this software for any
* purpose without fee is hereby granted, provided that this entire notice
* is included in all copies of any software which is or includes a copy
* or modification of this software and in all copies of the supporting
* documentation for such software.
*
* THIS SOFTWARE IS BEING PROVIDED "AS IS", WITHOUT ANY EXPRESS OR IMPLIED
* WARRANTY. IN PARTICULAR, NEITHER THE AUTHOR NOR LUCENT MAKES ANY
* REPRESENTATION OR WARRANTY OF ANY KIND CONCERNING THE MERCHANTABILITY
* OF THIS SOFTWARE OR ITS FITNESS FOR ANY PARTICULAR PURPOSE.
*
***************************************************************/

View File

@ -137,6 +137,7 @@
#include "pyctype.h"
#include "pystrtod.h"
#include "pystrcmp.h"
#include "dtoa.h"
/* _Py_Mangle is defined in compile.c */
PyAPI_FUNC(PyObject*) _Py_Mangle(PyObject *p, PyObject *name);

15
Include/dtoa.h Normal file
View File

@ -0,0 +1,15 @@
#ifndef PY_NO_SHORT_FLOAT_REPR
#ifdef __cplusplus
extern "C" {
#endif
PyAPI_FUNC(double) _Py_dg_strtod(const char *str, char **ptr);
PyAPI_FUNC(char *) _Py_dg_dtoa(double d, int mode, int ndigits,
int *decpt, int *sign, char **rve);
PyAPI_FUNC(void) _Py_dg_freedtoa(char *s);
#ifdef __cplusplus
}
#endif
#endif

View File

@ -290,6 +290,7 @@ PYTHON_OBJS= \
Python/getopt.o \
Python/pystrcmp.o \
Python/pystrtod.o \
Python/dtoa.o \
Python/formatter_unicode.o \
Python/formatter_string.o \
Python/$(DYNLOADFILE) \
@ -606,6 +607,7 @@ PYTHON_HEADERS= \
Include/complexobject.h \
Include/descrobject.h \
Include/dictobject.h \
Include/dtoa.h \
Include/enumobject.h \
Include/errcode.h \
Include/eval.h \

View File

@ -902,6 +902,10 @@
RelativePath="..\Include\pystrtod.h"
>
</File>
<File
RelativePath="..\Include\dtoa.h"
>
</File>
<File
RelativePath="..\Include\Python-ast.h"
>
@ -1798,6 +1802,10 @@
RelativePath="..\Python\pystrtod.c"
>
</File>
<File
RelativePath="..\Python\dtoa.c"
>
</File>
<File
RelativePath="..\Python\Python-ast.c"
>

2609
Python/dtoa.c Normal file

File diff suppressed because it is too large Load Diff