aboutsummaryrefslogtreecommitdiffstats
path: root/contrib/tools/python3/src/Modules/_decimal
diff options
context:
space:
mode:
authorshadchin <shadchin@yandex-team.ru>2022-02-10 16:44:30 +0300
committerDaniil Cherednik <dcherednik@yandex-team.ru>2022-02-10 16:44:30 +0300
commit2598ef1d0aee359b4b6d5fdd1758916d5907d04f (patch)
tree012bb94d777798f1f56ac1cec429509766d05181 /contrib/tools/python3/src/Modules/_decimal
parent6751af0b0c1b952fede40b19b71da8025b5d8bcf (diff)
downloadydb-2598ef1d0aee359b4b6d5fdd1758916d5907d04f.tar.gz
Restoring authorship annotation for <shadchin@yandex-team.ru>. Commit 1 of 2.
Diffstat (limited to 'contrib/tools/python3/src/Modules/_decimal')
-rw-r--r--contrib/tools/python3/src/Modules/_decimal/_decimal.c442
-rw-r--r--contrib/tools/python3/src/Modules/_decimal/libmpdec/basearith.c12
-rw-r--r--contrib/tools/python3/src/Modules/_decimal/libmpdec/basearith.h8
-rw-r--r--contrib/tools/python3/src/Modules/_decimal/libmpdec/bits.h8
-rw-r--r--contrib/tools/python3/src/Modules/_decimal/libmpdec/constants.c2
-rw-r--r--contrib/tools/python3/src/Modules/_decimal/libmpdec/constants.h12
-rw-r--r--contrib/tools/python3/src/Modules/_decimal/libmpdec/context.c10
-rw-r--r--contrib/tools/python3/src/Modules/_decimal/libmpdec/convolute.c4
-rw-r--r--contrib/tools/python3/src/Modules/_decimal/libmpdec/convolute.h8
-rw-r--r--contrib/tools/python3/src/Modules/_decimal/libmpdec/crt.c12
-rw-r--r--contrib/tools/python3/src/Modules/_decimal/libmpdec/crt.h8
-rw-r--r--contrib/tools/python3/src/Modules/_decimal/libmpdec/difradix2.c10
-rw-r--r--contrib/tools/python3/src/Modules/_decimal/libmpdec/difradix2.h8
-rw-r--r--contrib/tools/python3/src/Modules/_decimal/libmpdec/fnt.c10
-rw-r--r--contrib/tools/python3/src/Modules/_decimal/libmpdec/fnt.h8
-rw-r--r--contrib/tools/python3/src/Modules/_decimal/libmpdec/fourstep.c14
-rw-r--r--contrib/tools/python3/src/Modules/_decimal/libmpdec/fourstep.h8
-rw-r--r--contrib/tools/python3/src/Modules/_decimal/libmpdec/io.c58
-rw-r--r--contrib/tools/python3/src/Modules/_decimal/libmpdec/mpalloc.c712
-rw-r--r--contrib/tools/python3/src/Modules/_decimal/libmpdec/mpalloc.h18
-rw-r--r--contrib/tools/python3/src/Modules/_decimal/libmpdec/mpd_io.h16
-rw-r--r--contrib/tools/python3/src/Modules/_decimal/libmpdec/mpdecimal.c540
-rw-r--r--contrib/tools/python3/src/Modules/_decimal/libmpdec/mpdecimal.h82
-rw-r--r--contrib/tools/python3/src/Modules/_decimal/libmpdec/numbertheory.c10
-rw-r--r--contrib/tools/python3/src/Modules/_decimal/libmpdec/numbertheory.h10
-rw-r--r--contrib/tools/python3/src/Modules/_decimal/libmpdec/sixstep.c12
-rw-r--r--contrib/tools/python3/src/Modules/_decimal/libmpdec/sixstep.h8
-rw-r--r--contrib/tools/python3/src/Modules/_decimal/libmpdec/transpose.c12
-rw-r--r--contrib/tools/python3/src/Modules/_decimal/libmpdec/transpose.h8
-rw-r--r--contrib/tools/python3/src/Modules/_decimal/libmpdec/typearith.h12
-rw-r--r--contrib/tools/python3/src/Modules/_decimal/libmpdec/umodarith.h12
-rw-r--r--contrib/tools/python3/src/Modules/_decimal/libmpdec/vccompat.h18
32 files changed, 1056 insertions, 1056 deletions
diff --git a/contrib/tools/python3/src/Modules/_decimal/_decimal.c b/contrib/tools/python3/src/Modules/_decimal/_decimal.c
index d80d791550..0aec963f04 100644
--- a/contrib/tools/python3/src/Modules/_decimal/_decimal.c
+++ b/contrib/tools/python3/src/Modules/_decimal/_decimal.c
@@ -36,8 +36,8 @@
#include "docstrings.h"
-#if !defined(MPD_VERSION_HEX) || MPD_VERSION_HEX < 0x02050000
- #error "libmpdec version >= 2.5.0 required"
+#if !defined(MPD_VERSION_HEX) || MPD_VERSION_HEX < 0x02050000
+ #error "libmpdec version >= 2.5.0 required"
#endif
@@ -56,11 +56,11 @@
#define BOUNDS_CHECK(x, MIN, MAX) x = (x < MIN || MAX < x) ? MAX : x
-#if defined(__GNUC__) && !defined(__INTEL_COMPILER)
- #define UNUSED __attribute__((unused))
-#else
- #define UNUSED
-#endif
+#if defined(__GNUC__) && !defined(__INTEL_COMPILER)
+ #define UNUSED __attribute__((unused))
+#else
+ #define UNUSED
+#endif
/* _Py_DEC_MINALLOC >= MPD_MINALLOC */
#define _Py_DEC_MINALLOC 4
@@ -99,9 +99,9 @@ static PyTypeObject PyDec_Type;
static PyTypeObject *PyDecSignalDict_Type;
static PyTypeObject PyDecContext_Type;
static PyTypeObject PyDecContextManager_Type;
-#define PyDec_CheckExact(v) Py_IS_TYPE(v, &PyDec_Type)
+#define PyDec_CheckExact(v) Py_IS_TYPE(v, &PyDec_Type)
#define PyDec_Check(v) PyObject_TypeCheck(v, &PyDec_Type)
-#define PyDecSignalDict_Check(v) Py_IS_TYPE(v, PyDecSignalDict_Type)
+#define PyDecSignalDict_Check(v) Py_IS_TYPE(v, PyDecSignalDict_Type)
#define PyDecContext_Check(v) PyObject_TypeCheck(v, &PyDecContext_Type)
#define MPD(v) (&((PyDecObject *)v)->dec)
#define SdFlagAddr(v) (((PyDecSignalDictObject *)v)->flags)
@@ -125,14 +125,14 @@ incr_false(void)
}
-#ifndef WITH_DECIMAL_CONTEXTVAR
-/* Key for thread state dictionary */
-static PyObject *tls_context_key = NULL;
-/* Invariant: NULL or the most recently accessed thread local context */
-static PyDecContextObject *cached_context = NULL;
-#else
-static PyObject *current_context_var = NULL;
-#endif
+#ifndef WITH_DECIMAL_CONTEXTVAR
+/* Key for thread state dictionary */
+static PyObject *tls_context_key = NULL;
+/* Invariant: NULL or the most recently accessed thread local context */
+static PyDecContextObject *cached_context = NULL;
+#else
+static PyObject *current_context_var = NULL;
+#endif
/* Template for creating new thread contexts, calling Context() without
* arguments and initializing the module_context on first access. */
@@ -682,10 +682,10 @@ static PyTypeObject PyDecSignalDictMixin_Type =
sizeof(PyDecSignalDictObject), /* tp_basicsize */
0, /* tp_itemsize */
0, /* tp_dealloc */
- 0, /* tp_vectorcall_offset */
+ 0, /* tp_vectorcall_offset */
(getattrfunc) 0, /* tp_getattr */
(setattrfunc) 0, /* tp_setattr */
- 0, /* tp_as_async */
+ 0, /* tp_as_async */
(reprfunc) signaldict_repr, /* tp_repr */
0, /* tp_as_number */
0, /* tp_as_sequence */
@@ -696,7 +696,7 @@ static PyTypeObject PyDecSignalDictMixin_Type =
PyObject_GenericGetAttr, /* tp_getattro */
(setattrofunc) 0, /* tp_setattro */
(PyBufferProcs *) 0, /* tp_as_buffer */
- Py_TPFLAGS_DEFAULT|Py_TPFLAGS_BASETYPE, /* tp_flags */
+ Py_TPFLAGS_DEFAULT|Py_TPFLAGS_BASETYPE, /* tp_flags */
0, /* tp_doc */
0, /* tp_traverse */
0, /* tp_clear */
@@ -1226,12 +1226,12 @@ context_new(PyTypeObject *type, PyObject *args UNUSED, PyObject *kwds UNUSED)
static void
context_dealloc(PyDecContextObject *self)
{
-#ifndef WITH_DECIMAL_CONTEXTVAR
- if (self == cached_context) {
- cached_context = NULL;
- }
-#endif
-
+#ifndef WITH_DECIMAL_CONTEXTVAR
+ if (self == cached_context) {
+ cached_context = NULL;
+ }
+#endif
+
Py_XDECREF(self->traps);
Py_XDECREF(self->flags);
Py_TYPE(self)->tp_free(self);
@@ -1506,135 +1506,135 @@ static PyGetSetDef context_getsets [] =
* operation.
*/
-#ifndef WITH_DECIMAL_CONTEXTVAR
-/* Get the context from the thread state dictionary. */
-static PyObject *
-current_context_from_dict(void)
-{
- PyObject *dict;
- PyObject *tl_context;
- PyThreadState *tstate;
-
- dict = PyThreadState_GetDict();
- if (dict == NULL) {
- PyErr_SetString(PyExc_RuntimeError,
- "cannot get thread state");
- return NULL;
- }
-
- tl_context = PyDict_GetItemWithError(dict, tls_context_key);
- if (tl_context != NULL) {
- /* We already have a thread local context. */
- CONTEXT_CHECK(tl_context);
- }
- else {
- if (PyErr_Occurred()) {
- return NULL;
- }
-
- /* Set up a new thread local context. */
- tl_context = context_copy(default_context_template, NULL);
- if (tl_context == NULL) {
- return NULL;
- }
- CTX(tl_context)->status = 0;
-
- if (PyDict_SetItem(dict, tls_context_key, tl_context) < 0) {
- Py_DECREF(tl_context);
- return NULL;
- }
- Py_DECREF(tl_context);
- }
-
- /* Cache the context of the current thread, assuming that it
- * will be accessed several times before a thread switch. */
- tstate = PyThreadState_GET();
- if (tstate) {
- cached_context = (PyDecContextObject *)tl_context;
- cached_context->tstate = tstate;
- }
-
- /* Borrowed reference with refcount==1 */
- return tl_context;
-}
-
-/* Return borrowed reference to thread local context. */
-static PyObject *
-current_context(void)
-{
- PyThreadState *tstate;
-
- tstate = PyThreadState_GET();
- if (cached_context && cached_context->tstate == tstate) {
- return (PyObject *)cached_context;
- }
-
- return current_context_from_dict();
-}
-
-/* ctxobj := borrowed reference to the current context */
-#define CURRENT_CONTEXT(ctxobj) \
- ctxobj = current_context(); \
- if (ctxobj == NULL) { \
- return NULL; \
- }
-
-/* Return a new reference to the current context */
-static PyObject *
-PyDec_GetCurrentContext(PyObject *self UNUSED, PyObject *args UNUSED)
-{
- PyObject *context;
-
- context = current_context();
- if (context == NULL) {
- return NULL;
- }
-
- Py_INCREF(context);
- return context;
-}
-
-/* Set the thread local context to a new context, decrement old reference */
-static PyObject *
-PyDec_SetCurrentContext(PyObject *self UNUSED, PyObject *v)
-{
- PyObject *dict;
-
- CONTEXT_CHECK(v);
-
- dict = PyThreadState_GetDict();
- if (dict == NULL) {
- PyErr_SetString(PyExc_RuntimeError,
- "cannot get thread state");
- return NULL;
- }
-
- /* If the new context is one of the templates, make a copy.
- * This is the current behavior of decimal.py. */
- if (v == default_context_template ||
- v == basic_context_template ||
- v == extended_context_template) {
- v = context_copy(v, NULL);
- if (v == NULL) {
- return NULL;
- }
- CTX(v)->status = 0;
- }
- else {
- Py_INCREF(v);
- }
-
- cached_context = NULL;
- if (PyDict_SetItem(dict, tls_context_key, v) < 0) {
- Py_DECREF(v);
- return NULL;
- }
-
- Py_DECREF(v);
- Py_RETURN_NONE;
-}
-#else
+#ifndef WITH_DECIMAL_CONTEXTVAR
+/* Get the context from the thread state dictionary. */
static PyObject *
+current_context_from_dict(void)
+{
+ PyObject *dict;
+ PyObject *tl_context;
+ PyThreadState *tstate;
+
+ dict = PyThreadState_GetDict();
+ if (dict == NULL) {
+ PyErr_SetString(PyExc_RuntimeError,
+ "cannot get thread state");
+ return NULL;
+ }
+
+ tl_context = PyDict_GetItemWithError(dict, tls_context_key);
+ if (tl_context != NULL) {
+ /* We already have a thread local context. */
+ CONTEXT_CHECK(tl_context);
+ }
+ else {
+ if (PyErr_Occurred()) {
+ return NULL;
+ }
+
+ /* Set up a new thread local context. */
+ tl_context = context_copy(default_context_template, NULL);
+ if (tl_context == NULL) {
+ return NULL;
+ }
+ CTX(tl_context)->status = 0;
+
+ if (PyDict_SetItem(dict, tls_context_key, tl_context) < 0) {
+ Py_DECREF(tl_context);
+ return NULL;
+ }
+ Py_DECREF(tl_context);
+ }
+
+ /* Cache the context of the current thread, assuming that it
+ * will be accessed several times before a thread switch. */
+ tstate = PyThreadState_GET();
+ if (tstate) {
+ cached_context = (PyDecContextObject *)tl_context;
+ cached_context->tstate = tstate;
+ }
+
+ /* Borrowed reference with refcount==1 */
+ return tl_context;
+}
+
+/* Return borrowed reference to thread local context. */
+static PyObject *
+current_context(void)
+{
+ PyThreadState *tstate;
+
+ tstate = PyThreadState_GET();
+ if (cached_context && cached_context->tstate == tstate) {
+ return (PyObject *)cached_context;
+ }
+
+ return current_context_from_dict();
+}
+
+/* ctxobj := borrowed reference to the current context */
+#define CURRENT_CONTEXT(ctxobj) \
+ ctxobj = current_context(); \
+ if (ctxobj == NULL) { \
+ return NULL; \
+ }
+
+/* Return a new reference to the current context */
+static PyObject *
+PyDec_GetCurrentContext(PyObject *self UNUSED, PyObject *args UNUSED)
+{
+ PyObject *context;
+
+ context = current_context();
+ if (context == NULL) {
+ return NULL;
+ }
+
+ Py_INCREF(context);
+ return context;
+}
+
+/* Set the thread local context to a new context, decrement old reference */
+static PyObject *
+PyDec_SetCurrentContext(PyObject *self UNUSED, PyObject *v)
+{
+ PyObject *dict;
+
+ CONTEXT_CHECK(v);
+
+ dict = PyThreadState_GetDict();
+ if (dict == NULL) {
+ PyErr_SetString(PyExc_RuntimeError,
+ "cannot get thread state");
+ return NULL;
+ }
+
+ /* If the new context is one of the templates, make a copy.
+ * This is the current behavior of decimal.py. */
+ if (v == default_context_template ||
+ v == basic_context_template ||
+ v == extended_context_template) {
+ v = context_copy(v, NULL);
+ if (v == NULL) {
+ return NULL;
+ }
+ CTX(v)->status = 0;
+ }
+ else {
+ Py_INCREF(v);
+ }
+
+ cached_context = NULL;
+ if (PyDict_SetItem(dict, tls_context_key, v) < 0) {
+ Py_DECREF(v);
+ return NULL;
+ }
+
+ Py_DECREF(v);
+ Py_RETURN_NONE;
+}
+#else
+static PyObject *
init_current_context(void)
{
PyObject *tl_context = context_copy(default_context_template, NULL);
@@ -1713,7 +1713,7 @@ PyDec_SetCurrentContext(PyObject *self UNUSED, PyObject *v)
Py_RETURN_NONE;
}
-#endif
+#endif
/* Context manager object for the 'with' statement. The manager
* owns one reference to the global (outer) context and one
@@ -1809,10 +1809,10 @@ static PyTypeObject PyDecContextManager_Type =
sizeof(PyDecContextManagerObject), /* tp_basicsize */
0, /* tp_itemsize */
(destructor) ctxmanager_dealloc, /* tp_dealloc */
- 0, /* tp_vectorcall_offset */
+ 0, /* tp_vectorcall_offset */
(getattrfunc) 0, /* tp_getattr */
(setattrfunc) 0, /* tp_setattr */
- 0, /* tp_as_async */
+ 0, /* tp_as_async */
(reprfunc) 0, /* tp_repr */
0, /* tp_as_number */
0, /* tp_as_sequence */
@@ -1880,7 +1880,7 @@ dec_dealloc(PyObject *dec)
/******************************************************************************/
Py_LOCAL_INLINE(int)
-is_space(enum PyUnicode_Kind kind, const void *data, Py_ssize_t pos)
+is_space(enum PyUnicode_Kind kind, const void *data, Py_ssize_t pos)
{
Py_UCS4 ch = PyUnicode_READ(kind, data, pos);
return Py_UNICODE_ISSPACE(ch);
@@ -1898,7 +1898,7 @@ static char *
numeric_as_ascii(const PyObject *u, int strip_ws, int ignore_underscores)
{
enum PyUnicode_Kind kind;
- const void *data;
+ const void *data;
Py_UCS4 ch;
char *res, *cp;
Py_ssize_t j, len;
@@ -2728,7 +2728,7 @@ PyDecType_FromObjectExact(PyTypeObject *type, PyObject *v, PyObject *context)
else {
PyErr_Format(PyExc_TypeError,
"conversion from %s to Decimal is not supported",
- Py_TYPE(v)->tp_name);
+ Py_TYPE(v)->tp_name);
return NULL;
}
}
@@ -2777,7 +2777,7 @@ PyDec_FromObject(PyObject *v, PyObject *context)
else {
PyErr_Format(PyExc_TypeError,
"conversion from %s to Decimal is not supported",
- Py_TYPE(v)->tp_name);
+ Py_TYPE(v)->tp_name);
return NULL;
}
}
@@ -2840,7 +2840,7 @@ convert_op(int type_err, PyObject **conv, PyObject *v, PyObject *context)
if (type_err) {
PyErr_Format(PyExc_TypeError,
"conversion from %s to Decimal is not supported",
- Py_TYPE(v)->tp_name);
+ Py_TYPE(v)->tp_name);
}
else {
Py_INCREF(Py_NotImplemented);
@@ -3397,9 +3397,9 @@ dec_as_long(PyObject *dec, PyObject *context, int round)
i--;
}
- Py_SET_SIZE(pylong, i);
+ Py_SET_SIZE(pylong, i);
if (mpd_isnegative(x) && !mpd_iszero(x)) {
- Py_SET_SIZE(pylong, -i);
+ Py_SET_SIZE(pylong, -i);
}
mpd_del(x);
@@ -4735,30 +4735,30 @@ static PyNumberMethods dec_number_methods =
static PyMethodDef dec_methods [] =
{
/* Unary arithmetic functions, optional context arg */
- { "exp", (PyCFunction)(void(*)(void))dec_mpd_qexp, METH_VARARGS|METH_KEYWORDS, doc_exp },
- { "ln", (PyCFunction)(void(*)(void))dec_mpd_qln, METH_VARARGS|METH_KEYWORDS, doc_ln },
- { "log10", (PyCFunction)(void(*)(void))dec_mpd_qlog10, METH_VARARGS|METH_KEYWORDS, doc_log10 },
- { "next_minus", (PyCFunction)(void(*)(void))dec_mpd_qnext_minus, METH_VARARGS|METH_KEYWORDS, doc_next_minus },
- { "next_plus", (PyCFunction)(void(*)(void))dec_mpd_qnext_plus, METH_VARARGS|METH_KEYWORDS, doc_next_plus },
- { "normalize", (PyCFunction)(void(*)(void))dec_mpd_qreduce, METH_VARARGS|METH_KEYWORDS, doc_normalize },
- { "to_integral", (PyCFunction)(void(*)(void))PyDec_ToIntegralValue, METH_VARARGS|METH_KEYWORDS, doc_to_integral },
- { "to_integral_exact", (PyCFunction)(void(*)(void))PyDec_ToIntegralExact, METH_VARARGS|METH_KEYWORDS, doc_to_integral_exact },
- { "to_integral_value", (PyCFunction)(void(*)(void))PyDec_ToIntegralValue, METH_VARARGS|METH_KEYWORDS, doc_to_integral_value },
- { "sqrt", (PyCFunction)(void(*)(void))dec_mpd_qsqrt, METH_VARARGS|METH_KEYWORDS, doc_sqrt },
+ { "exp", (PyCFunction)(void(*)(void))dec_mpd_qexp, METH_VARARGS|METH_KEYWORDS, doc_exp },
+ { "ln", (PyCFunction)(void(*)(void))dec_mpd_qln, METH_VARARGS|METH_KEYWORDS, doc_ln },
+ { "log10", (PyCFunction)(void(*)(void))dec_mpd_qlog10, METH_VARARGS|METH_KEYWORDS, doc_log10 },
+ { "next_minus", (PyCFunction)(void(*)(void))dec_mpd_qnext_minus, METH_VARARGS|METH_KEYWORDS, doc_next_minus },
+ { "next_plus", (PyCFunction)(void(*)(void))dec_mpd_qnext_plus, METH_VARARGS|METH_KEYWORDS, doc_next_plus },
+ { "normalize", (PyCFunction)(void(*)(void))dec_mpd_qreduce, METH_VARARGS|METH_KEYWORDS, doc_normalize },
+ { "to_integral", (PyCFunction)(void(*)(void))PyDec_ToIntegralValue, METH_VARARGS|METH_KEYWORDS, doc_to_integral },
+ { "to_integral_exact", (PyCFunction)(void(*)(void))PyDec_ToIntegralExact, METH_VARARGS|METH_KEYWORDS, doc_to_integral_exact },
+ { "to_integral_value", (PyCFunction)(void(*)(void))PyDec_ToIntegralValue, METH_VARARGS|METH_KEYWORDS, doc_to_integral_value },
+ { "sqrt", (PyCFunction)(void(*)(void))dec_mpd_qsqrt, METH_VARARGS|METH_KEYWORDS, doc_sqrt },
/* Binary arithmetic functions, optional context arg */
- { "compare", (PyCFunction)(void(*)(void))dec_mpd_qcompare, METH_VARARGS|METH_KEYWORDS, doc_compare },
- { "compare_signal", (PyCFunction)(void(*)(void))dec_mpd_qcompare_signal, METH_VARARGS|METH_KEYWORDS, doc_compare_signal },
- { "max", (PyCFunction)(void(*)(void))dec_mpd_qmax, METH_VARARGS|METH_KEYWORDS, doc_max },
- { "max_mag", (PyCFunction)(void(*)(void))dec_mpd_qmax_mag, METH_VARARGS|METH_KEYWORDS, doc_max_mag },
- { "min", (PyCFunction)(void(*)(void))dec_mpd_qmin, METH_VARARGS|METH_KEYWORDS, doc_min },
- { "min_mag", (PyCFunction)(void(*)(void))dec_mpd_qmin_mag, METH_VARARGS|METH_KEYWORDS, doc_min_mag },
- { "next_toward", (PyCFunction)(void(*)(void))dec_mpd_qnext_toward, METH_VARARGS|METH_KEYWORDS, doc_next_toward },
- { "quantize", (PyCFunction)(void(*)(void))dec_mpd_qquantize, METH_VARARGS|METH_KEYWORDS, doc_quantize },
- { "remainder_near", (PyCFunction)(void(*)(void))dec_mpd_qrem_near, METH_VARARGS|METH_KEYWORDS, doc_remainder_near },
+ { "compare", (PyCFunction)(void(*)(void))dec_mpd_qcompare, METH_VARARGS|METH_KEYWORDS, doc_compare },
+ { "compare_signal", (PyCFunction)(void(*)(void))dec_mpd_qcompare_signal, METH_VARARGS|METH_KEYWORDS, doc_compare_signal },
+ { "max", (PyCFunction)(void(*)(void))dec_mpd_qmax, METH_VARARGS|METH_KEYWORDS, doc_max },
+ { "max_mag", (PyCFunction)(void(*)(void))dec_mpd_qmax_mag, METH_VARARGS|METH_KEYWORDS, doc_max_mag },
+ { "min", (PyCFunction)(void(*)(void))dec_mpd_qmin, METH_VARARGS|METH_KEYWORDS, doc_min },
+ { "min_mag", (PyCFunction)(void(*)(void))dec_mpd_qmin_mag, METH_VARARGS|METH_KEYWORDS, doc_min_mag },
+ { "next_toward", (PyCFunction)(void(*)(void))dec_mpd_qnext_toward, METH_VARARGS|METH_KEYWORDS, doc_next_toward },
+ { "quantize", (PyCFunction)(void(*)(void))dec_mpd_qquantize, METH_VARARGS|METH_KEYWORDS, doc_quantize },
+ { "remainder_near", (PyCFunction)(void(*)(void))dec_mpd_qrem_near, METH_VARARGS|METH_KEYWORDS, doc_remainder_near },
/* Ternary arithmetic functions, optional context arg */
- { "fma", (PyCFunction)(void(*)(void))dec_mpd_qfma, METH_VARARGS|METH_KEYWORDS, doc_fma },
+ { "fma", (PyCFunction)(void(*)(void))dec_mpd_qfma, METH_VARARGS|METH_KEYWORDS, doc_fma },
/* Boolean functions, no context arg */
{ "is_canonical", dec_mpd_iscanonical, METH_NOARGS, doc_is_canonical },
@@ -4771,8 +4771,8 @@ static PyMethodDef dec_methods [] =
{ "is_zero", dec_mpd_iszero, METH_NOARGS, doc_is_zero },
/* Boolean functions, optional context arg */
- { "is_normal", (PyCFunction)(void(*)(void))dec_mpd_isnormal, METH_VARARGS|METH_KEYWORDS, doc_is_normal },
- { "is_subnormal", (PyCFunction)(void(*)(void))dec_mpd_issubnormal, METH_VARARGS|METH_KEYWORDS, doc_is_subnormal },
+ { "is_normal", (PyCFunction)(void(*)(void))dec_mpd_isnormal, METH_VARARGS|METH_KEYWORDS, doc_is_normal },
+ { "is_subnormal", (PyCFunction)(void(*)(void))dec_mpd_issubnormal, METH_VARARGS|METH_KEYWORDS, doc_is_subnormal },
/* Unary functions, no context arg */
{ "adjusted", dec_mpd_adjexp, METH_NOARGS, doc_adjusted },
@@ -4785,24 +4785,24 @@ static PyMethodDef dec_methods [] =
{ "copy_negate", dec_mpd_qcopy_negate, METH_NOARGS, doc_copy_negate },
/* Unary functions, optional context arg */
- { "logb", (PyCFunction)(void(*)(void))dec_mpd_qlogb, METH_VARARGS|METH_KEYWORDS, doc_logb },
- { "logical_invert", (PyCFunction)(void(*)(void))dec_mpd_qinvert, METH_VARARGS|METH_KEYWORDS, doc_logical_invert },
- { "number_class", (PyCFunction)(void(*)(void))dec_mpd_class, METH_VARARGS|METH_KEYWORDS, doc_number_class },
- { "to_eng_string", (PyCFunction)(void(*)(void))dec_mpd_to_eng, METH_VARARGS|METH_KEYWORDS, doc_to_eng_string },
+ { "logb", (PyCFunction)(void(*)(void))dec_mpd_qlogb, METH_VARARGS|METH_KEYWORDS, doc_logb },
+ { "logical_invert", (PyCFunction)(void(*)(void))dec_mpd_qinvert, METH_VARARGS|METH_KEYWORDS, doc_logical_invert },
+ { "number_class", (PyCFunction)(void(*)(void))dec_mpd_class, METH_VARARGS|METH_KEYWORDS, doc_number_class },
+ { "to_eng_string", (PyCFunction)(void(*)(void))dec_mpd_to_eng, METH_VARARGS|METH_KEYWORDS, doc_to_eng_string },
/* Binary functions, optional context arg for conversion errors */
- { "compare_total", (PyCFunction)(void(*)(void))dec_mpd_compare_total, METH_VARARGS|METH_KEYWORDS, doc_compare_total },
- { "compare_total_mag", (PyCFunction)(void(*)(void))dec_mpd_compare_total_mag, METH_VARARGS|METH_KEYWORDS, doc_compare_total_mag },
- { "copy_sign", (PyCFunction)(void(*)(void))dec_mpd_qcopy_sign, METH_VARARGS|METH_KEYWORDS, doc_copy_sign },
- { "same_quantum", (PyCFunction)(void(*)(void))dec_mpd_same_quantum, METH_VARARGS|METH_KEYWORDS, doc_same_quantum },
+ { "compare_total", (PyCFunction)(void(*)(void))dec_mpd_compare_total, METH_VARARGS|METH_KEYWORDS, doc_compare_total },
+ { "compare_total_mag", (PyCFunction)(void(*)(void))dec_mpd_compare_total_mag, METH_VARARGS|METH_KEYWORDS, doc_compare_total_mag },
+ { "copy_sign", (PyCFunction)(void(*)(void))dec_mpd_qcopy_sign, METH_VARARGS|METH_KEYWORDS, doc_copy_sign },
+ { "same_quantum", (PyCFunction)(void(*)(void))dec_mpd_same_quantum, METH_VARARGS|METH_KEYWORDS, doc_same_quantum },
/* Binary functions, optional context arg */
- { "logical_and", (PyCFunction)(void(*)(void))dec_mpd_qand, METH_VARARGS|METH_KEYWORDS, doc_logical_and },
- { "logical_or", (PyCFunction)(void(*)(void))dec_mpd_qor, METH_VARARGS|METH_KEYWORDS, doc_logical_or },
- { "logical_xor", (PyCFunction)(void(*)(void))dec_mpd_qxor, METH_VARARGS|METH_KEYWORDS, doc_logical_xor },
- { "rotate", (PyCFunction)(void(*)(void))dec_mpd_qrotate, METH_VARARGS|METH_KEYWORDS, doc_rotate },
- { "scaleb", (PyCFunction)(void(*)(void))dec_mpd_qscaleb, METH_VARARGS|METH_KEYWORDS, doc_scaleb },
- { "shift", (PyCFunction)(void(*)(void))dec_mpd_qshift, METH_VARARGS|METH_KEYWORDS, doc_shift },
+ { "logical_and", (PyCFunction)(void(*)(void))dec_mpd_qand, METH_VARARGS|METH_KEYWORDS, doc_logical_and },
+ { "logical_or", (PyCFunction)(void(*)(void))dec_mpd_qor, METH_VARARGS|METH_KEYWORDS, doc_logical_or },
+ { "logical_xor", (PyCFunction)(void(*)(void))dec_mpd_qxor, METH_VARARGS|METH_KEYWORDS, doc_logical_xor },
+ { "rotate", (PyCFunction)(void(*)(void))dec_mpd_qrotate, METH_VARARGS|METH_KEYWORDS, doc_rotate },
+ { "scaleb", (PyCFunction)(void(*)(void))dec_mpd_qscaleb, METH_VARARGS|METH_KEYWORDS, doc_scaleb },
+ { "shift", (PyCFunction)(void(*)(void))dec_mpd_qshift, METH_VARARGS|METH_KEYWORDS, doc_shift },
/* Miscellaneous */
{ "from_float", dec_from_float, METH_O|METH_CLASS, doc_from_float },
@@ -4831,10 +4831,10 @@ static PyTypeObject PyDec_Type =
sizeof(PyDecObject), /* tp_basicsize */
0, /* tp_itemsize */
(destructor) dec_dealloc, /* tp_dealloc */
- 0, /* tp_vectorcall_offset */
+ 0, /* tp_vectorcall_offset */
(getattrfunc) 0, /* tp_getattr */
(setattrfunc) 0, /* tp_setattr */
- 0, /* tp_as_async */
+ 0, /* tp_as_async */
(reprfunc) dec_repr, /* tp_repr */
&dec_number_methods, /* tp_as_number */
0, /* tp_as_sequence */
@@ -5440,7 +5440,7 @@ static PyMethodDef context_methods [] =
{ "subtract", ctx_mpd_qsub, METH_VARARGS, doc_ctx_subtract },
/* Binary or ternary arithmetic functions */
- { "power", (PyCFunction)(void(*)(void))ctx_mpd_qpow, METH_VARARGS|METH_KEYWORDS, doc_ctx_power },
+ { "power", (PyCFunction)(void(*)(void))ctx_mpd_qpow, METH_VARARGS|METH_KEYWORDS, doc_ctx_power },
/* Ternary arithmetic functions */
{ "fma", ctx_mpd_qfma, METH_VARARGS, doc_ctx_fma },
@@ -5517,17 +5517,17 @@ static PyTypeObject PyDecContext_Type =
sizeof(PyDecContextObject), /* tp_basicsize */
0, /* tp_itemsize */
(destructor) context_dealloc, /* tp_dealloc */
- 0, /* tp_vectorcall_offset */
+ 0, /* tp_vectorcall_offset */
(getattrfunc) 0, /* tp_getattr */
(setattrfunc) 0, /* tp_setattr */
- 0, /* tp_as_async */
+ 0, /* tp_as_async */
(reprfunc) context_repr, /* tp_repr */
0, /* tp_as_number */
0, /* tp_as_sequence */
0, /* tp_as_mapping */
(hashfunc) 0, /* tp_hash */
0, /* tp_call */
- 0, /* tp_str */
+ 0, /* tp_str */
(getattrofunc) context_getattr, /* tp_getattro */
(setattrofunc) context_setattr, /* tp_setattro */
(PyBufferProcs *) 0, /* tp_as_buffer */
@@ -5558,7 +5558,7 @@ static PyMethodDef _decimal_methods [] =
{
{ "getcontext", (PyCFunction)PyDec_GetCurrentContext, METH_NOARGS, doc_getcontext},
{ "setcontext", (PyCFunction)PyDec_SetCurrentContext, METH_O, doc_setcontext},
- { "localcontext", (PyCFunction)(void(*)(void))ctxmanager_new, METH_VARARGS|METH_KEYWORDS, doc_localcontext},
+ { "localcontext", (PyCFunction)(void(*)(void))ctxmanager_new, METH_VARARGS|METH_KEYWORDS, doc_localcontext},
#ifdef EXTRA_FUNCTIONALITY
{ "IEEEContext", (PyCFunction)ieee_context, METH_O, doc_ieee_context},
#endif
@@ -5846,16 +5846,16 @@ PyInit__decimal(void)
CHECK_INT(PyModule_AddObject(m, "DefaultContext",
default_context_template));
-#ifndef WITH_DECIMAL_CONTEXTVAR
- ASSIGN_PTR(tls_context_key, PyUnicode_FromString("___DECIMAL_CTX__"));
- Py_INCREF(Py_False);
- CHECK_INT(PyModule_AddObject(m, "HAVE_CONTEXTVAR", Py_False));
-#else
- ASSIGN_PTR(current_context_var, PyContextVar_New("decimal_context", NULL));
- Py_INCREF(Py_True);
- CHECK_INT(PyModule_AddObject(m, "HAVE_CONTEXTVAR", Py_True));
-#endif
+#ifndef WITH_DECIMAL_CONTEXTVAR
+ ASSIGN_PTR(tls_context_key, PyUnicode_FromString("___DECIMAL_CTX__"));
+ Py_INCREF(Py_False);
+ CHECK_INT(PyModule_AddObject(m, "HAVE_CONTEXTVAR", Py_False));
+#else
+ ASSIGN_PTR(current_context_var, PyContextVar_New("decimal_context", NULL));
Py_INCREF(Py_True);
+ CHECK_INT(PyModule_AddObject(m, "HAVE_CONTEXTVAR", Py_True));
+#endif
+ Py_INCREF(Py_True);
CHECK_INT(PyModule_AddObject(m, "HAVE_THREADS", Py_True));
/* Init basic context template */
@@ -5914,11 +5914,11 @@ error:
Py_CLEAR(SignalTuple); /* GCOV_NOT_REACHED */
Py_CLEAR(DecimalTuple); /* GCOV_NOT_REACHED */
Py_CLEAR(default_context_template); /* GCOV_NOT_REACHED */
-#ifndef WITH_DECIMAL_CONTEXTVAR
- Py_CLEAR(tls_context_key); /* GCOV_NOT_REACHED */
-#else
- Py_CLEAR(current_context_var); /* GCOV_NOT_REACHED */
-#endif
+#ifndef WITH_DECIMAL_CONTEXTVAR
+ Py_CLEAR(tls_context_key); /* GCOV_NOT_REACHED */
+#else
+ Py_CLEAR(current_context_var); /* GCOV_NOT_REACHED */
+#endif
Py_CLEAR(basic_context_template); /* GCOV_NOT_REACHED */
Py_CLEAR(extended_context_template); /* GCOV_NOT_REACHED */
Py_CLEAR(m); /* GCOV_NOT_REACHED */
diff --git a/contrib/tools/python3/src/Modules/_decimal/libmpdec/basearith.c b/contrib/tools/python3/src/Modules/_decimal/libmpdec/basearith.c
index 85c608fadf..ce8a84586c 100644
--- a/contrib/tools/python3/src/Modules/_decimal/libmpdec/basearith.c
+++ b/contrib/tools/python3/src/Modules/_decimal/libmpdec/basearith.c
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2008-2020 Stefan Krah. All rights reserved.
+ * Copyright (c) 2008-2020 Stefan Krah. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
@@ -27,11 +27,11 @@
#include "mpdecimal.h"
-
-#include <assert.h>
+
+#include <assert.h>
#include <stdio.h>
-
-#include "basearith.h"
+
+#include "basearith.h"
#include "constants.h"
#include "typearith.h"
@@ -337,7 +337,7 @@ _mpd_basedivmod(mpd_uint_t *q, mpd_uint_t *r,
/* D2: loop */
for (j=m; j != MPD_SIZE_MAX; j--) {
- assert(2 <= j+n && j+n <= nplusm); /* annotation for scan-build */
+ assert(2 <= j+n && j+n <= nplusm); /* annotation for scan-build */
/* D3: calculate qhat and rhat */
rhat = _mpd_shortdiv(w2, u+j+n-1, 2, v[n-1]);
diff --git a/contrib/tools/python3/src/Modules/_decimal/libmpdec/basearith.h b/contrib/tools/python3/src/Modules/_decimal/libmpdec/basearith.h
index d35925aadd..0aac9ba0f9 100644
--- a/contrib/tools/python3/src/Modules/_decimal/libmpdec/basearith.h
+++ b/contrib/tools/python3/src/Modules/_decimal/libmpdec/basearith.h
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2008-2020 Stefan Krah. All rights reserved.
+ * Copyright (c) 2008-2020 Stefan Krah. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
@@ -26,8 +26,8 @@
*/
-#ifndef LIBMPDEC_BASEARITH_H_
-#define LIBMPDEC_BASEARITH_H_
+#ifndef LIBMPDEC_BASEARITH_H_
+#define LIBMPDEC_BASEARITH_H_
#include "mpdecimal.h"
@@ -215,4 +215,4 @@ _mpd_isallnine(const mpd_uint_t *data, mpd_ssize_t len)
MPD_PRAGMA(MPD_HIDE_SYMBOLS_END) /* restore previous scope rules */
-#endif /* LIBMPDEC_BASEARITH_H_ */
+#endif /* LIBMPDEC_BASEARITH_H_ */
diff --git a/contrib/tools/python3/src/Modules/_decimal/libmpdec/bits.h b/contrib/tools/python3/src/Modules/_decimal/libmpdec/bits.h
index aa9c3e7798..85ad10ad3a 100644
--- a/contrib/tools/python3/src/Modules/_decimal/libmpdec/bits.h
+++ b/contrib/tools/python3/src/Modules/_decimal/libmpdec/bits.h
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2008-2020 Stefan Krah. All rights reserved.
+ * Copyright (c) 2008-2020 Stefan Krah. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
@@ -26,8 +26,8 @@
*/
-#ifndef LIBMPDEC_BITS_H_
-#define LIBMPDEC_BITS_H_
+#ifndef LIBMPDEC_BITS_H_
+#define LIBMPDEC_BITS_H_
#include "mpdecimal.h"
@@ -185,4 +185,4 @@ mpd_bsf(mpd_size_t a)
#endif /* BSR/BSF */
-#endif /* LIBMPDEC_BITS_H_ */
+#endif /* LIBMPDEC_BITS_H_ */
diff --git a/contrib/tools/python3/src/Modules/_decimal/libmpdec/constants.c b/contrib/tools/python3/src/Modules/_decimal/libmpdec/constants.c
index 4c4de622bc..c5dcfdb582 100644
--- a/contrib/tools/python3/src/Modules/_decimal/libmpdec/constants.c
+++ b/contrib/tools/python3/src/Modules/_decimal/libmpdec/constants.c
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2008-2020 Stefan Krah. All rights reserved.
+ * Copyright (c) 2008-2020 Stefan Krah. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
diff --git a/contrib/tools/python3/src/Modules/_decimal/libmpdec/constants.h b/contrib/tools/python3/src/Modules/_decimal/libmpdec/constants.h
index 7c1db839c2..48fc359a06 100644
--- a/contrib/tools/python3/src/Modules/_decimal/libmpdec/constants.h
+++ b/contrib/tools/python3/src/Modules/_decimal/libmpdec/constants.h
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2008-2020 Stefan Krah. All rights reserved.
+ * Copyright (c) 2008-2020 Stefan Krah. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
@@ -26,15 +26,15 @@
*/
-#ifndef LIBMPDEC_CONSTANTS_H_
-#define LIBMPDEC_CONSTANTS_H_
+#ifndef LIBMPDEC_CONSTANTS_H_
+#define LIBMPDEC_CONSTANTS_H_
#include "mpdecimal.h"
-#include <stdint.h>
-
+#include <stdint.h>
+
/* Internal header file: all symbols have local scope in the DSO */
MPD_PRAGMA(MPD_HIDE_SYMBOLS_START)
@@ -86,4 +86,4 @@ extern const mpd_uint_t UH_P1P2;
MPD_PRAGMA(MPD_HIDE_SYMBOLS_END) /* restore previous scope rules */
-#endif /* LIBMPDEC_CONSTANTS_H_ */
+#endif /* LIBMPDEC_CONSTANTS_H_ */
diff --git a/contrib/tools/python3/src/Modules/_decimal/libmpdec/context.c b/contrib/tools/python3/src/Modules/_decimal/libmpdec/context.c
index 9cbc205095..cc2e965e49 100644
--- a/contrib/tools/python3/src/Modules/_decimal/libmpdec/context.c
+++ b/contrib/tools/python3/src/Modules/_decimal/libmpdec/context.c
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2008-2020 Stefan Krah. All rights reserved.
+ * Copyright (c) 2008-2020 Stefan Krah. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
@@ -27,16 +27,16 @@
#include "mpdecimal.h"
-
-#include <signal.h>
+
+#include <signal.h>
#include <stdio.h>
#include <string.h>
void
-mpd_dflt_traphandler(mpd_context_t *ctx)
+mpd_dflt_traphandler(mpd_context_t *ctx)
{
- (void)ctx;
+ (void)ctx;
raise(SIGFPE);
}
diff --git a/contrib/tools/python3/src/Modules/_decimal/libmpdec/convolute.c b/contrib/tools/python3/src/Modules/_decimal/libmpdec/convolute.c
index 4bc8e8b5fd..5de2570538 100644
--- a/contrib/tools/python3/src/Modules/_decimal/libmpdec/convolute.c
+++ b/contrib/tools/python3/src/Modules/_decimal/libmpdec/convolute.c
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2008-2020 Stefan Krah. All rights reserved.
+ * Copyright (c) 2008-2020 Stefan Krah. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
@@ -29,7 +29,7 @@
#include "mpdecimal.h"
#include "bits.h"
#include "constants.h"
-#include "convolute.h"
+#include "convolute.h"
#include "fnt.h"
#include "fourstep.h"
#include "numbertheory.h"
diff --git a/contrib/tools/python3/src/Modules/_decimal/libmpdec/convolute.h b/contrib/tools/python3/src/Modules/_decimal/libmpdec/convolute.h
index 62edb3e457..18716b23ff 100644
--- a/contrib/tools/python3/src/Modules/_decimal/libmpdec/convolute.h
+++ b/contrib/tools/python3/src/Modules/_decimal/libmpdec/convolute.h
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2008-2020 Stefan Krah. All rights reserved.
+ * Copyright (c) 2008-2020 Stefan Krah. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
@@ -26,8 +26,8 @@
*/
-#ifndef LIBMPDEC_CONVOLUTE_H_
-#define LIBMPDEC_CONVOLUTE_H_
+#ifndef LIBMPDEC_CONVOLUTE_H_
+#define LIBMPDEC_CONVOLUTE_H_
#include "mpdecimal.h"
@@ -46,4 +46,4 @@ int fnt_autoconvolute(mpd_uint_t *c1, mpd_size_t n, int modnum);
MPD_PRAGMA(MPD_HIDE_SYMBOLS_END) /* restore previous scope rules */
-#endif /* LIBMPDEC_CONVOLUTE_H_ */
+#endif /* LIBMPDEC_CONVOLUTE_H_ */
diff --git a/contrib/tools/python3/src/Modules/_decimal/libmpdec/crt.c b/contrib/tools/python3/src/Modules/_decimal/libmpdec/crt.c
index 613274ee0c..dd8418671d 100644
--- a/contrib/tools/python3/src/Modules/_decimal/libmpdec/crt.c
+++ b/contrib/tools/python3/src/Modules/_decimal/libmpdec/crt.c
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2008-2020 Stefan Krah. All rights reserved.
+ * Copyright (c) 2008-2020 Stefan Krah. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
@@ -27,14 +27,14 @@
#include "mpdecimal.h"
-
+
#include <assert.h>
-
-#include "constants.h"
-#include "crt.h"
+
+#include "constants.h"
+#include "crt.h"
#include "numbertheory.h"
#include "umodarith.h"
-#include "typearith.h"
+#include "typearith.h"
/* Bignum: Chinese Remainder Theorem, extends the maximum transform length. */
diff --git a/contrib/tools/python3/src/Modules/_decimal/libmpdec/crt.h b/contrib/tools/python3/src/Modules/_decimal/libmpdec/crt.h
index 15a347d4cb..ae0765ee10 100644
--- a/contrib/tools/python3/src/Modules/_decimal/libmpdec/crt.h
+++ b/contrib/tools/python3/src/Modules/_decimal/libmpdec/crt.h
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2008-2020 Stefan Krah. All rights reserved.
+ * Copyright (c) 2008-2020 Stefan Krah. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
@@ -26,8 +26,8 @@
*/
-#ifndef LIBMPDEC_CRT_H_
-#define LIBMPDEC_CRT_H_
+#ifndef LIBMPDEC_CRT_H_
+#define LIBMPDEC_CRT_H_
#include "mpdecimal.h"
@@ -43,4 +43,4 @@ void crt3(mpd_uint_t *x1, mpd_uint_t *x2, mpd_uint_t *x3, mpd_size_t nmemb);
MPD_PRAGMA(MPD_HIDE_SYMBOLS_END) /* restore previous scope rules */
-#endif /* LIBMPDEC_CRT_H_ */
+#endif /* LIBMPDEC_CRT_H_ */
diff --git a/contrib/tools/python3/src/Modules/_decimal/libmpdec/difradix2.c b/contrib/tools/python3/src/Modules/_decimal/libmpdec/difradix2.c
index 049ecff65b..661783cc15 100644
--- a/contrib/tools/python3/src/Modules/_decimal/libmpdec/difradix2.c
+++ b/contrib/tools/python3/src/Modules/_decimal/libmpdec/difradix2.c
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2008-2020 Stefan Krah. All rights reserved.
+ * Copyright (c) 2008-2020 Stefan Krah. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
@@ -27,12 +27,12 @@
#include "mpdecimal.h"
-
+
#include <assert.h>
-
+
#include "bits.h"
-#include "constants.h"
-#include "difradix2.h"
+#include "constants.h"
+#include "difradix2.h"
#include "numbertheory.h"
#include "umodarith.h"
diff --git a/contrib/tools/python3/src/Modules/_decimal/libmpdec/difradix2.h b/contrib/tools/python3/src/Modules/_decimal/libmpdec/difradix2.h
index cdcbcf9a71..868878e439 100644
--- a/contrib/tools/python3/src/Modules/_decimal/libmpdec/difradix2.h
+++ b/contrib/tools/python3/src/Modules/_decimal/libmpdec/difradix2.h
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2008-2020 Stefan Krah. All rights reserved.
+ * Copyright (c) 2008-2020 Stefan Krah. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
@@ -26,8 +26,8 @@
*/
-#ifndef LIBMPDEC_DIFRADIX2_H_
-#define LIBMPDEC_DIFRADIX2_H_
+#ifndef LIBMPDEC_DIFRADIX2_H_
+#define LIBMPDEC_DIFRADIX2_H_
#include "mpdecimal.h"
@@ -44,4 +44,4 @@ void fnt_dif2(mpd_uint_t a[], mpd_size_t n, struct fnt_params *tparams);
MPD_PRAGMA(MPD_HIDE_SYMBOLS_END) /* restore previous scope rules */
-#endif /* LIBMPDEC_DIFRADIX2_H_ */
+#endif /* LIBMPDEC_DIFRADIX2_H_ */
diff --git a/contrib/tools/python3/src/Modules/_decimal/libmpdec/fnt.c b/contrib/tools/python3/src/Modules/_decimal/libmpdec/fnt.c
index 0dbe98fc71..56f39dcfda 100644
--- a/contrib/tools/python3/src/Modules/_decimal/libmpdec/fnt.c
+++ b/contrib/tools/python3/src/Modules/_decimal/libmpdec/fnt.c
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2008-2020 Stefan Krah. All rights reserved.
+ * Copyright (c) 2008-2020 Stefan Krah. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
@@ -27,13 +27,13 @@
#include "mpdecimal.h"
-
-#include <assert.h>
+
+#include <assert.h>
#include <stdio.h>
-
+
#include "bits.h"
#include "difradix2.h"
-#include "fnt.h"
+#include "fnt.h"
#include "numbertheory.h"
diff --git a/contrib/tools/python3/src/Modules/_decimal/libmpdec/fnt.h b/contrib/tools/python3/src/Modules/_decimal/libmpdec/fnt.h
index 5222c476a3..92f352d43d 100644
--- a/contrib/tools/python3/src/Modules/_decimal/libmpdec/fnt.h
+++ b/contrib/tools/python3/src/Modules/_decimal/libmpdec/fnt.h
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2008-2020 Stefan Krah. All rights reserved.
+ * Copyright (c) 2008-2020 Stefan Krah. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
@@ -26,8 +26,8 @@
*/
-#ifndef LIBMPDEC_FNT_H_
-#define LIBMPDEC_FNT_H_
+#ifndef LIBMPDEC_FNT_H_
+#define LIBMPDEC_FNT_H_
#include "mpdecimal.h"
@@ -44,4 +44,4 @@ int std_inv_fnt(mpd_uint_t a[], mpd_size_t n, int modnum);
MPD_PRAGMA(MPD_HIDE_SYMBOLS_END) /* restore previous scope rules */
-#endif /* LIBMPDEC_FNT_H_ */
+#endif /* LIBMPDEC_FNT_H_ */
diff --git a/contrib/tools/python3/src/Modules/_decimal/libmpdec/fourstep.c b/contrib/tools/python3/src/Modules/_decimal/libmpdec/fourstep.c
index fb173ed5a5..c54f39561d 100644
--- a/contrib/tools/python3/src/Modules/_decimal/libmpdec/fourstep.c
+++ b/contrib/tools/python3/src/Modules/_decimal/libmpdec/fourstep.c
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2008-2020 Stefan Krah. All rights reserved.
+ * Copyright (c) 2008-2020 Stefan Krah. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
@@ -27,11 +27,11 @@
#include "mpdecimal.h"
-
+
#include <assert.h>
-
-#include "constants.h"
-#include "fourstep.h"
+
+#include "constants.h"
+#include "fourstep.h"
#include "numbertheory.h"
#include "sixstep.h"
#include "umodarith.h"
@@ -189,7 +189,7 @@ four_step_fnt(mpd_uint_t *a, mpd_size_t n, int modnum)
#if 0
/* An unordered transform is sufficient for convolution. */
/* Transpose the matrix. */
- #include "transpose.h"
+ #include "transpose.h"
transpose_3xpow2(a, R, C);
#endif
@@ -220,7 +220,7 @@ inv_four_step_fnt(mpd_uint_t *a, mpd_size_t n, int modnum)
#if 0
/* An unordered transform is sufficient for convolution. */
/* Transpose the matrix, producing an R*C matrix. */
- #include "transpose.h"
+ #include "transpose.h"
transpose_3xpow2(a, C, R);
#endif
diff --git a/contrib/tools/python3/src/Modules/_decimal/libmpdec/fourstep.h b/contrib/tools/python3/src/Modules/_decimal/libmpdec/fourstep.h
index 5ffb6fcc8e..123d59b57b 100644
--- a/contrib/tools/python3/src/Modules/_decimal/libmpdec/fourstep.h
+++ b/contrib/tools/python3/src/Modules/_decimal/libmpdec/fourstep.h
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2008-2020 Stefan Krah. All rights reserved.
+ * Copyright (c) 2008-2020 Stefan Krah. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
@@ -26,8 +26,8 @@
*/
-#ifndef LIBMPDEC_FOURSTEP_H_
-#define LIBMPDEC_FOURSTEP_H_
+#ifndef LIBMPDEC_FOURSTEP_H_
+#define LIBMPDEC_FOURSTEP_H_
#include "mpdecimal.h"
@@ -44,4 +44,4 @@ int inv_four_step_fnt(mpd_uint_t *a, mpd_size_t n, int modnum);
MPD_PRAGMA(MPD_HIDE_SYMBOLS_END) /* restore previous scope rules */
-#endif /* LIBMPDEC_FOURSTEP_H_ */
+#endif /* LIBMPDEC_FOURSTEP_H_ */
diff --git a/contrib/tools/python3/src/Modules/_decimal/libmpdec/io.c b/contrib/tools/python3/src/Modules/_decimal/libmpdec/io.c
index 03f2acfc1a..c873fd1670 100644
--- a/contrib/tools/python3/src/Modules/_decimal/libmpdec/io.c
+++ b/contrib/tools/python3/src/Modules/_decimal/libmpdec/io.c
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2008-2020 Stefan Krah. All rights reserved.
+ * Copyright (c) 2008-2020 Stefan Krah. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
@@ -27,16 +27,16 @@
#include "mpdecimal.h"
-
-#include <assert.h>
-#include <ctype.h>
-#include <errno.h>
-#include <limits.h>
-#include <locale.h>
+
+#include <assert.h>
+#include <ctype.h>
+#include <errno.h>
+#include <limits.h>
+#include <locale.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
-
+
#include "typearith.h"
#include "mpd_io.h"
@@ -277,7 +277,7 @@ mpd_qset_string(mpd_t *dec, const char *s, const mpd_context_t *ctx,
}
}
- digits = end - coeff;
+ digits = end - coeff;
if (dpoint) {
size_t fracdigits = end-dpoint-1;
if (dpoint > coeff) digits--;
@@ -326,22 +326,22 @@ conversion_error:
mpd_seterror(dec, MPD_Conversion_syntax, status);
}
-/* convert a character string to a decimal, use a maxcontext for conversion */
-void
-mpd_qset_string_exact(mpd_t *dec, const char *s, uint32_t *status)
-{
- mpd_context_t maxcontext;
-
- mpd_maxcontext(&maxcontext);
- mpd_qset_string(dec, s, &maxcontext, status);
-
- if (*status & (MPD_Inexact|MPD_Rounded|MPD_Clamped)) {
- /* we want exact results */
- mpd_seterror(dec, MPD_Invalid_operation, status);
- }
- *status &= MPD_Errors;
-}
-
+/* convert a character string to a decimal, use a maxcontext for conversion */
+void
+mpd_qset_string_exact(mpd_t *dec, const char *s, uint32_t *status)
+{
+ mpd_context_t maxcontext;
+
+ mpd_maxcontext(&maxcontext);
+ mpd_qset_string(dec, s, &maxcontext, status);
+
+ if (*status & (MPD_Inexact|MPD_Rounded|MPD_Clamped)) {
+ /* we want exact results */
+ mpd_seterror(dec, MPD_Invalid_operation, status);
+ }
+ *status &= MPD_Errors;
+}
+
/* Print word x with n decimal digits to string s. dot is either NULL
or the location of a decimal point. */
#define EXTRACT_DIGIT(s, x, d, dot) \
@@ -555,8 +555,8 @@ _mpd_to_string(char **result, const mpd_t *dec, int flags, mpd_ssize_t dplace)
dplace = -1 + mod_mpd_ssize_t(dec->exp+2, 3);
}
else { /* ldigits-1 is the adjusted exponent, which
- * should be divisible by three. If not, move
- * dplace one or two places to the right. */
+ * should be divisible by three. If not, move
+ * dplace one or two places to the right. */
dplace += mod_mpd_ssize_t(ldigits-1, 3);
}
}
@@ -1263,7 +1263,7 @@ mpd_qformat_spec(const mpd_t *dec, const mpd_spec_t *spec,
}
if (isupper((uchar)type)) {
- type = (char)tolower((uchar)type);
+ type = (char)tolower((uchar)type);
flags |= MPD_FMT_UPPER;
}
if (spec->sign == ' ') {
@@ -1281,7 +1281,7 @@ mpd_qformat_spec(const mpd_t *dec, const mpd_spec_t *spec,
stackspec.align = '>';
spec = &stackspec;
}
- assert(strlen(spec->fill) == 1); /* annotation for scan-build */
+ assert(strlen(spec->fill) == 1); /* annotation for scan-build */
if (type == '%') {
flags |= MPD_FMT_PERCENT;
}
diff --git a/contrib/tools/python3/src/Modules/_decimal/libmpdec/mpalloc.c b/contrib/tools/python3/src/Modules/_decimal/libmpdec/mpalloc.c
index eb5ee7a807..04a42e7058 100644
--- a/contrib/tools/python3/src/Modules/_decimal/libmpdec/mpalloc.c
+++ b/contrib/tools/python3/src/Modules/_decimal/libmpdec/mpalloc.c
@@ -1,356 +1,356 @@
-/*
- * Copyright (c) 2008-2020 Stefan Krah. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- *
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS "AS IS" AND
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
- * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
- * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
- * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
- * 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.
- */
-
-
-#include "mpdecimal.h"
-
-#include <assert.h>
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-
-#include "mpalloc.h"
-#include "typearith.h"
-
-
-#if defined(_MSC_VER)
- #pragma warning(disable : 4232)
-#endif
-
-
-/* Guaranteed minimum allocation for a coefficient. May be changed once
- at program start using mpd_setminalloc(). */
-mpd_ssize_t MPD_MINALLOC = MPD_MINALLOC_MIN;
-
-/* Custom allocation and free functions */
-void *(* mpd_mallocfunc)(size_t size) = malloc;
-void *(* mpd_reallocfunc)(void *ptr, size_t size) = realloc;
-void *(* mpd_callocfunc)(size_t nmemb, size_t size) = calloc;
-void (* mpd_free)(void *ptr) = free;
-
-
-/* emulate calloc if it is not available */
-void *
-mpd_callocfunc_em(size_t nmemb, size_t size)
-{
- void *ptr;
- size_t req;
- mpd_size_t overflow;
-
-#if MPD_SIZE_MAX < SIZE_MAX
- /* full_coverage test only */
- if (nmemb > MPD_SIZE_MAX || size > MPD_SIZE_MAX) {
- return NULL;
- }
-#endif
-
- req = mul_size_t_overflow((mpd_size_t)nmemb, (mpd_size_t)size,
- &overflow);
- if (overflow) {
- return NULL;
- }
-
- ptr = mpd_mallocfunc(req);
- if (ptr == NULL) {
- return NULL;
- }
- /* used on uint32_t or uint64_t */
- memset(ptr, 0, req);
-
- return ptr;
-}
-
-
-/* malloc with overflow checking */
-void *
-mpd_alloc(mpd_size_t nmemb, mpd_size_t size)
-{
- mpd_size_t req, overflow;
-
- req = mul_size_t_overflow(nmemb, size, &overflow);
- if (overflow) {
- return NULL;
- }
-
- return mpd_mallocfunc(req);
-}
-
-/* calloc with overflow checking */
-void *
-mpd_calloc(mpd_size_t nmemb, mpd_size_t size)
-{
- mpd_size_t overflow;
-
- (void)mul_size_t_overflow(nmemb, size, &overflow);
- if (overflow) {
- return NULL;
- }
-
- return mpd_callocfunc(nmemb, size);
-}
-
-/* realloc with overflow checking */
-void *
-mpd_realloc(void *ptr, mpd_size_t nmemb, mpd_size_t size, uint8_t *err)
-{
- void *new;
- mpd_size_t req, overflow;
-
- req = mul_size_t_overflow(nmemb, size, &overflow);
- if (overflow) {
- *err = 1;
- return ptr;
- }
-
- new = mpd_reallocfunc(ptr, req);
- if (new == NULL) {
- *err = 1;
- return ptr;
- }
-
- return new;
-}
-
-/* struct hack malloc with overflow checking */
-void *
-mpd_sh_alloc(mpd_size_t struct_size, mpd_size_t nmemb, mpd_size_t size)
-{
- mpd_size_t req, overflow;
-
- req = mul_size_t_overflow(nmemb, size, &overflow);
- if (overflow) {
- return NULL;
- }
-
- req = add_size_t_overflow(req, struct_size, &overflow);
- if (overflow) {
- return NULL;
- }
-
- return mpd_mallocfunc(req);
-}
-
-
-/* Allocate a new decimal with a coefficient of length 'nwords'. In case
- of an error the return value is NULL. */
-mpd_t *
-mpd_qnew_size(mpd_ssize_t nwords)
-{
- mpd_t *result;
-
- nwords = (nwords < MPD_MINALLOC) ? MPD_MINALLOC : nwords;
-
- result = mpd_alloc(1, sizeof *result);
- if (result == NULL) {
- return NULL;
- }
-
- result->data = mpd_alloc(nwords, sizeof *result->data);
- if (result->data == NULL) {
- mpd_free(result);
- return NULL;
- }
-
- result->flags = 0;
- result->exp = 0;
- result->digits = 0;
- result->len = 0;
- result->alloc = nwords;
-
- return result;
-}
-
-/* Allocate a new decimal with a coefficient of length MPD_MINALLOC.
- In case of an error the return value is NULL. */
-mpd_t *
-mpd_qnew(void)
-{
- return mpd_qnew_size(MPD_MINALLOC);
-}
-
-/* Allocate new decimal. Caller can check for NULL or MPD_Malloc_error.
- Raises on error. */
-mpd_t *
-mpd_new(mpd_context_t *ctx)
-{
- mpd_t *result;
-
- result = mpd_qnew();
- if (result == NULL) {
- mpd_addstatus_raise(ctx, MPD_Malloc_error);
- }
- return result;
-}
-
-/*
- * Input: 'result' is a static mpd_t with a static coefficient.
- * Assumption: 'nwords' >= result->alloc.
- *
- * Resize the static coefficient to a larger dynamic one and copy the
- * existing data. If successful, the value of 'result' is unchanged.
- * Otherwise, set 'result' to NaN and update 'status' with MPD_Malloc_error.
- */
-int
-mpd_switch_to_dyn(mpd_t *result, mpd_ssize_t nwords, uint32_t *status)
-{
- mpd_uint_t *p = result->data;
-
- assert(nwords >= result->alloc);
-
- result->data = mpd_alloc(nwords, sizeof *result->data);
- if (result->data == NULL) {
- result->data = p;
- mpd_set_qnan(result);
- mpd_set_positive(result);
- result->exp = result->digits = result->len = 0;
- *status |= MPD_Malloc_error;
- return 0;
- }
-
- memcpy(result->data, p, result->alloc * (sizeof *result->data));
- result->alloc = nwords;
- mpd_set_dynamic_data(result);
- return 1;
-}
-
-/*
- * Input: 'result' is a static mpd_t with a static coefficient.
- *
- * Convert the coefficient to a dynamic one that is initialized to zero. If
- * malloc fails, set 'result' to NaN and update 'status' with MPD_Malloc_error.
- */
-int
-mpd_switch_to_dyn_zero(mpd_t *result, mpd_ssize_t nwords, uint32_t *status)
-{
- mpd_uint_t *p = result->data;
-
- result->data = mpd_calloc(nwords, sizeof *result->data);
- if (result->data == NULL) {
- result->data = p;
- mpd_set_qnan(result);
- mpd_set_positive(result);
- result->exp = result->digits = result->len = 0;
- *status |= MPD_Malloc_error;
- return 0;
- }
-
- result->alloc = nwords;
- mpd_set_dynamic_data(result);
-
- return 1;
-}
-
-/*
- * Input: 'result' is a static or a dynamic mpd_t with a dynamic coefficient.
- * Resize the coefficient to length 'nwords':
- * Case nwords > result->alloc:
- * If realloc is successful:
- * 'result' has a larger coefficient but the same value. Return 1.
- * Otherwise:
- * Set 'result' to NaN, update status with MPD_Malloc_error and return 0.
- * Case nwords < result->alloc:
- * If realloc is successful:
- * 'result' has a smaller coefficient. result->len is undefined. Return 1.
- * Otherwise (unlikely):
- * 'result' is unchanged. Reuse the now oversized coefficient. Return 1.
- */
-int
-mpd_realloc_dyn(mpd_t *result, mpd_ssize_t nwords, uint32_t *status)
-{
- uint8_t err = 0;
-
- result->data = mpd_realloc(result->data, nwords, sizeof *result->data, &err);
- if (!err) {
- result->alloc = nwords;
- }
- else if (nwords > result->alloc) {
- mpd_set_qnan(result);
- mpd_set_positive(result);
- result->exp = result->digits = result->len = 0;
- *status |= MPD_Malloc_error;
- return 0;
- }
-
- return 1;
-}
-
-/*
- * Input: 'result' is a static mpd_t with a static coefficient.
- * Assumption: 'nwords' >= result->alloc.
- *
- * Resize the static coefficient to a larger dynamic one and copy the
- * existing data.
- *
- * On failure the value of 'result' is unchanged.
- */
-int
-mpd_switch_to_dyn_cxx(mpd_t *result, mpd_ssize_t nwords)
-{
- assert(nwords >= result->alloc);
-
- mpd_uint_t *data = mpd_alloc(nwords, sizeof *result->data);
- if (data == NULL) {
- return 0;
- }
-
- memcpy(data, result->data, result->alloc * (sizeof *result->data));
- result->data = data;
- result->alloc = nwords;
- mpd_set_dynamic_data(result);
- return 1;
-}
-
-/*
- * Input: 'result' is a static or a dynamic mpd_t with a dynamic coefficient.
- * Resize the coefficient to length 'nwords':
- * Case nwords > result->alloc:
- * If realloc is successful:
- * 'result' has a larger coefficient but the same value. Return 1.
- * Otherwise:
- * 'result' has a the same coefficient. Return 0.
- * Case nwords < result->alloc:
- * If realloc is successful:
- * 'result' has a smaller coefficient. result->len is undefined. Return 1.
- * Otherwise (unlikely):
- * 'result' is unchanged. Reuse the now oversized coefficient. Return 1.
- */
-int
-mpd_realloc_dyn_cxx(mpd_t *result, mpd_ssize_t nwords)
-{
- uint8_t err = 0;
-
- mpd_uint_t *p = mpd_realloc(result->data, nwords, sizeof *result->data, &err);
- if (!err) {
- result->data = p;
- result->alloc = nwords;
- }
- else if (nwords > result->alloc) {
- return 0;
- }
-
- return 1;
-}
+/*
+ * Copyright (c) 2008-2020 Stefan Krah. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS "AS IS" AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * 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.
+ */
+
+
+#include "mpdecimal.h"
+
+#include <assert.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+
+#include "mpalloc.h"
+#include "typearith.h"
+
+
+#if defined(_MSC_VER)
+ #pragma warning(disable : 4232)
+#endif
+
+
+/* Guaranteed minimum allocation for a coefficient. May be changed once
+ at program start using mpd_setminalloc(). */
+mpd_ssize_t MPD_MINALLOC = MPD_MINALLOC_MIN;
+
+/* Custom allocation and free functions */
+void *(* mpd_mallocfunc)(size_t size) = malloc;
+void *(* mpd_reallocfunc)(void *ptr, size_t size) = realloc;
+void *(* mpd_callocfunc)(size_t nmemb, size_t size) = calloc;
+void (* mpd_free)(void *ptr) = free;
+
+
+/* emulate calloc if it is not available */
+void *
+mpd_callocfunc_em(size_t nmemb, size_t size)
+{
+ void *ptr;
+ size_t req;
+ mpd_size_t overflow;
+
+#if MPD_SIZE_MAX < SIZE_MAX
+ /* full_coverage test only */
+ if (nmemb > MPD_SIZE_MAX || size > MPD_SIZE_MAX) {
+ return NULL;
+ }
+#endif
+
+ req = mul_size_t_overflow((mpd_size_t)nmemb, (mpd_size_t)size,
+ &overflow);
+ if (overflow) {
+ return NULL;
+ }
+
+ ptr = mpd_mallocfunc(req);
+ if (ptr == NULL) {
+ return NULL;
+ }
+ /* used on uint32_t or uint64_t */
+ memset(ptr, 0, req);
+
+ return ptr;
+}
+
+
+/* malloc with overflow checking */
+void *
+mpd_alloc(mpd_size_t nmemb, mpd_size_t size)
+{
+ mpd_size_t req, overflow;
+
+ req = mul_size_t_overflow(nmemb, size, &overflow);
+ if (overflow) {
+ return NULL;
+ }
+
+ return mpd_mallocfunc(req);
+}
+
+/* calloc with overflow checking */
+void *
+mpd_calloc(mpd_size_t nmemb, mpd_size_t size)
+{
+ mpd_size_t overflow;
+
+ (void)mul_size_t_overflow(nmemb, size, &overflow);
+ if (overflow) {
+ return NULL;
+ }
+
+ return mpd_callocfunc(nmemb, size);
+}
+
+/* realloc with overflow checking */
+void *
+mpd_realloc(void *ptr, mpd_size_t nmemb, mpd_size_t size, uint8_t *err)
+{
+ void *new;
+ mpd_size_t req, overflow;
+
+ req = mul_size_t_overflow(nmemb, size, &overflow);
+ if (overflow) {
+ *err = 1;
+ return ptr;
+ }
+
+ new = mpd_reallocfunc(ptr, req);
+ if (new == NULL) {
+ *err = 1;
+ return ptr;
+ }
+
+ return new;
+}
+
+/* struct hack malloc with overflow checking */
+void *
+mpd_sh_alloc(mpd_size_t struct_size, mpd_size_t nmemb, mpd_size_t size)
+{
+ mpd_size_t req, overflow;
+
+ req = mul_size_t_overflow(nmemb, size, &overflow);
+ if (overflow) {
+ return NULL;
+ }
+
+ req = add_size_t_overflow(req, struct_size, &overflow);
+ if (overflow) {
+ return NULL;
+ }
+
+ return mpd_mallocfunc(req);
+}
+
+
+/* Allocate a new decimal with a coefficient of length 'nwords'. In case
+ of an error the return value is NULL. */
+mpd_t *
+mpd_qnew_size(mpd_ssize_t nwords)
+{
+ mpd_t *result;
+
+ nwords = (nwords < MPD_MINALLOC) ? MPD_MINALLOC : nwords;
+
+ result = mpd_alloc(1, sizeof *result);
+ if (result == NULL) {
+ return NULL;
+ }
+
+ result->data = mpd_alloc(nwords, sizeof *result->data);
+ if (result->data == NULL) {
+ mpd_free(result);
+ return NULL;
+ }
+
+ result->flags = 0;
+ result->exp = 0;
+ result->digits = 0;
+ result->len = 0;
+ result->alloc = nwords;
+
+ return result;
+}
+
+/* Allocate a new decimal with a coefficient of length MPD_MINALLOC.
+ In case of an error the return value is NULL. */
+mpd_t *
+mpd_qnew(void)
+{
+ return mpd_qnew_size(MPD_MINALLOC);
+}
+
+/* Allocate new decimal. Caller can check for NULL or MPD_Malloc_error.
+ Raises on error. */
+mpd_t *
+mpd_new(mpd_context_t *ctx)
+{
+ mpd_t *result;
+
+ result = mpd_qnew();
+ if (result == NULL) {
+ mpd_addstatus_raise(ctx, MPD_Malloc_error);
+ }
+ return result;
+}
+
+/*
+ * Input: 'result' is a static mpd_t with a static coefficient.
+ * Assumption: 'nwords' >= result->alloc.
+ *
+ * Resize the static coefficient to a larger dynamic one and copy the
+ * existing data. If successful, the value of 'result' is unchanged.
+ * Otherwise, set 'result' to NaN and update 'status' with MPD_Malloc_error.
+ */
+int
+mpd_switch_to_dyn(mpd_t *result, mpd_ssize_t nwords, uint32_t *status)
+{
+ mpd_uint_t *p = result->data;
+
+ assert(nwords >= result->alloc);
+
+ result->data = mpd_alloc(nwords, sizeof *result->data);
+ if (result->data == NULL) {
+ result->data = p;
+ mpd_set_qnan(result);
+ mpd_set_positive(result);
+ result->exp = result->digits = result->len = 0;
+ *status |= MPD_Malloc_error;
+ return 0;
+ }
+
+ memcpy(result->data, p, result->alloc * (sizeof *result->data));
+ result->alloc = nwords;
+ mpd_set_dynamic_data(result);
+ return 1;
+}
+
+/*
+ * Input: 'result' is a static mpd_t with a static coefficient.
+ *
+ * Convert the coefficient to a dynamic one that is initialized to zero. If
+ * malloc fails, set 'result' to NaN and update 'status' with MPD_Malloc_error.
+ */
+int
+mpd_switch_to_dyn_zero(mpd_t *result, mpd_ssize_t nwords, uint32_t *status)
+{
+ mpd_uint_t *p = result->data;
+
+ result->data = mpd_calloc(nwords, sizeof *result->data);
+ if (result->data == NULL) {
+ result->data = p;
+ mpd_set_qnan(result);
+ mpd_set_positive(result);
+ result->exp = result->digits = result->len = 0;
+ *status |= MPD_Malloc_error;
+ return 0;
+ }
+
+ result->alloc = nwords;
+ mpd_set_dynamic_data(result);
+
+ return 1;
+}
+
+/*
+ * Input: 'result' is a static or a dynamic mpd_t with a dynamic coefficient.
+ * Resize the coefficient to length 'nwords':
+ * Case nwords > result->alloc:
+ * If realloc is successful:
+ * 'result' has a larger coefficient but the same value. Return 1.
+ * Otherwise:
+ * Set 'result' to NaN, update status with MPD_Malloc_error and return 0.
+ * Case nwords < result->alloc:
+ * If realloc is successful:
+ * 'result' has a smaller coefficient. result->len is undefined. Return 1.
+ * Otherwise (unlikely):
+ * 'result' is unchanged. Reuse the now oversized coefficient. Return 1.
+ */
+int
+mpd_realloc_dyn(mpd_t *result, mpd_ssize_t nwords, uint32_t *status)
+{
+ uint8_t err = 0;
+
+ result->data = mpd_realloc(result->data, nwords, sizeof *result->data, &err);
+ if (!err) {
+ result->alloc = nwords;
+ }
+ else if (nwords > result->alloc) {
+ mpd_set_qnan(result);
+ mpd_set_positive(result);
+ result->exp = result->digits = result->len = 0;
+ *status |= MPD_Malloc_error;
+ return 0;
+ }
+
+ return 1;
+}
+
+/*
+ * Input: 'result' is a static mpd_t with a static coefficient.
+ * Assumption: 'nwords' >= result->alloc.
+ *
+ * Resize the static coefficient to a larger dynamic one and copy the
+ * existing data.
+ *
+ * On failure the value of 'result' is unchanged.
+ */
+int
+mpd_switch_to_dyn_cxx(mpd_t *result, mpd_ssize_t nwords)
+{
+ assert(nwords >= result->alloc);
+
+ mpd_uint_t *data = mpd_alloc(nwords, sizeof *result->data);
+ if (data == NULL) {
+ return 0;
+ }
+
+ memcpy(data, result->data, result->alloc * (sizeof *result->data));
+ result->data = data;
+ result->alloc = nwords;
+ mpd_set_dynamic_data(result);
+ return 1;
+}
+
+/*
+ * Input: 'result' is a static or a dynamic mpd_t with a dynamic coefficient.
+ * Resize the coefficient to length 'nwords':
+ * Case nwords > result->alloc:
+ * If realloc is successful:
+ * 'result' has a larger coefficient but the same value. Return 1.
+ * Otherwise:
+ * 'result' has a the same coefficient. Return 0.
+ * Case nwords < result->alloc:
+ * If realloc is successful:
+ * 'result' has a smaller coefficient. result->len is undefined. Return 1.
+ * Otherwise (unlikely):
+ * 'result' is unchanged. Reuse the now oversized coefficient. Return 1.
+ */
+int
+mpd_realloc_dyn_cxx(mpd_t *result, mpd_ssize_t nwords)
+{
+ uint8_t err = 0;
+
+ mpd_uint_t *p = mpd_realloc(result->data, nwords, sizeof *result->data, &err);
+ if (!err) {
+ result->data = p;
+ result->alloc = nwords;
+ }
+ else if (nwords > result->alloc) {
+ return 0;
+ }
+
+ return 1;
+}
diff --git a/contrib/tools/python3/src/Modules/_decimal/libmpdec/mpalloc.h b/contrib/tools/python3/src/Modules/_decimal/libmpdec/mpalloc.h
index 186808457b..f8f3ae2e5c 100644
--- a/contrib/tools/python3/src/Modules/_decimal/libmpdec/mpalloc.h
+++ b/contrib/tools/python3/src/Modules/_decimal/libmpdec/mpalloc.h
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2008-2020 Stefan Krah. All rights reserved.
+ * Copyright (c) 2008-2020 Stefan Krah. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
@@ -26,15 +26,15 @@
*/
-#ifndef LIBMPDEC_MPALLOC_H_
-#define LIBMPDEC_MPALLOC_H_
+#ifndef LIBMPDEC_MPALLOC_H_
+#define LIBMPDEC_MPALLOC_H_
#include "mpdecimal.h"
-#include <stdint.h>
-
+#include <stdint.h>
+
/* Internal header file: all symbols have local scope in the DSO */
MPD_PRAGMA(MPD_HIDE_SYMBOLS_START)
@@ -43,11 +43,11 @@ int mpd_switch_to_dyn(mpd_t *result, mpd_ssize_t size, uint32_t *status);
int mpd_switch_to_dyn_zero(mpd_t *result, mpd_ssize_t size, uint32_t *status);
int mpd_realloc_dyn(mpd_t *result, mpd_ssize_t size, uint32_t *status);
-int mpd_switch_to_dyn_cxx(mpd_t *result, mpd_ssize_t size);
-int mpd_realloc_dyn_cxx(mpd_t *result, mpd_ssize_t size);
-
+int mpd_switch_to_dyn_cxx(mpd_t *result, mpd_ssize_t size);
+int mpd_realloc_dyn_cxx(mpd_t *result, mpd_ssize_t size);
+
MPD_PRAGMA(MPD_HIDE_SYMBOLS_END) /* restore previous scope rules */
-#endif /* LIBMPDEC_MPALLOC_H_ */
+#endif /* LIBMPDEC_MPALLOC_H_ */
diff --git a/contrib/tools/python3/src/Modules/_decimal/libmpdec/mpd_io.h b/contrib/tools/python3/src/Modules/_decimal/libmpdec/mpd_io.h
index 79d7c05ce3..2c7a37c3dd 100644
--- a/contrib/tools/python3/src/Modules/_decimal/libmpdec/mpd_io.h
+++ b/contrib/tools/python3/src/Modules/_decimal/libmpdec/mpd_io.h
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2008-2020 Stefan Krah. All rights reserved.
+ * Copyright (c) 2008-2020 Stefan Krah. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
@@ -26,20 +26,20 @@
*/
-#ifndef LIBMPDEC_IO_H_
-#define LIBMPDEC_IO_H_
+#ifndef LIBMPDEC_IO_H_
+#define LIBMPDEC_IO_H_
#include "mpdecimal.h"
-#include <stdint.h>
-
+#include <stdint.h>
+
#if SIZE_MAX == MPD_SIZE_MAX
#define mpd_strtossize _mpd_strtossize
#else
-#include <errno.h>
-
+#include <errno.h>
+
static inline mpd_ssize_t
mpd_strtossize(const char *s, char **end, int base)
{
@@ -59,4 +59,4 @@ mpd_strtossize(const char *s, char **end, int base)
#endif
-#endif /* LIBMPDEC_IO_H_ */
+#endif /* LIBMPDEC_IO_H_ */
diff --git a/contrib/tools/python3/src/Modules/_decimal/libmpdec/mpdecimal.c b/contrib/tools/python3/src/Modules/_decimal/libmpdec/mpdecimal.c
index 28b639ccb4..a73d20bd68 100644
--- a/contrib/tools/python3/src/Modules/_decimal/libmpdec/mpdecimal.c
+++ b/contrib/tools/python3/src/Modules/_decimal/libmpdec/mpdecimal.c
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2008-2020 Stefan Krah. All rights reserved.
+ * Copyright (c) 2008-2020 Stefan Krah. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
@@ -27,17 +27,17 @@
#include "mpdecimal.h"
-
-#include <assert.h>
-#include <limits.h>
-#include <math.h>
+
+#include <assert.h>
+#include <limits.h>
+#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
-
+
#include "basearith.h"
#include "bits.h"
-#include "constants.h"
+#include "constants.h"
#include "convolute.h"
#include "crt.h"
#include "mpalloc.h"
@@ -64,7 +64,7 @@
#if defined(_MSC_VER)
#define ALWAYS_INLINE __forceinline
-#elif defined(__IBMC__) || defined(LEGACY_COMPILER)
+#elif defined(__IBMC__) || defined(LEGACY_COMPILER)
#define ALWAYS_INLINE
#undef inline
#define inline
@@ -244,7 +244,7 @@ mpd_lsd(mpd_uint_t word)
}
/* Coefficient size needed to store 'digits' */
-mpd_ssize_t
+mpd_ssize_t
mpd_digits_to_size(mpd_ssize_t digits)
{
mpd_ssize_t q, r;
@@ -263,9 +263,9 @@ mpd_exp_digits(mpd_ssize_t exp)
/* Canonical */
ALWAYS_INLINE int
-mpd_iscanonical(const mpd_t *dec)
+mpd_iscanonical(const mpd_t *dec)
{
- (void)dec;
+ (void)dec;
return 1;
}
@@ -516,28 +516,28 @@ mpd_qresize(mpd_t *result, mpd_ssize_t nwords, uint32_t *status)
return mpd_realloc_dyn(result, nwords, status);
}
-/* Same as mpd_qresize, but do not set the result no NaN on failure. */
-static ALWAYS_INLINE int
-mpd_qresize_cxx(mpd_t *result, mpd_ssize_t nwords)
-{
- assert(!mpd_isconst_data(result)); /* illegal operation for a const */
- assert(!mpd_isshared_data(result)); /* illegal operation for a shared */
- assert(MPD_MINALLOC <= result->alloc);
-
- nwords = (nwords <= MPD_MINALLOC) ? MPD_MINALLOC : nwords;
- if (nwords == result->alloc) {
- return 1;
- }
- if (mpd_isstatic_data(result)) {
- if (nwords > result->alloc) {
- return mpd_switch_to_dyn_cxx(result, nwords);
- }
- return 1;
- }
-
- return mpd_realloc_dyn_cxx(result, nwords);
-}
-
+/* Same as mpd_qresize, but do not set the result no NaN on failure. */
+static ALWAYS_INLINE int
+mpd_qresize_cxx(mpd_t *result, mpd_ssize_t nwords)
+{
+ assert(!mpd_isconst_data(result)); /* illegal operation for a const */
+ assert(!mpd_isshared_data(result)); /* illegal operation for a shared */
+ assert(MPD_MINALLOC <= result->alloc);
+
+ nwords = (nwords <= MPD_MINALLOC) ? MPD_MINALLOC : nwords;
+ if (nwords == result->alloc) {
+ return 1;
+ }
+ if (mpd_isstatic_data(result)) {
+ if (nwords > result->alloc) {
+ return mpd_switch_to_dyn_cxx(result, nwords);
+ }
+ return 1;
+ }
+
+ return mpd_realloc_dyn_cxx(result, nwords);
+}
+
/* Same as mpd_qresize, but the complete coefficient (including the old
* memory area!) is initialized to zero. */
ALWAYS_INLINE int
@@ -1218,7 +1218,7 @@ _c32setu64(mpd_t *result, uint64_t u, uint8_t sign, uint32_t *status)
result->data[i] = w[i];
}
- mpd_set_flags(result, sign);
+ mpd_set_flags(result, sign);
result->exp = 0;
result->len = len;
mpd_setdigits(result);
@@ -1270,26 +1270,26 @@ mpd_qset_i64(mpd_t *result, int64_t a, const mpd_context_t *ctx,
#endif
}
-/* quietly set a decimal from an int64_t, use a maxcontext for conversion */
-void
-mpd_qset_i64_exact(mpd_t *result, int64_t a, uint32_t *status)
-{
- mpd_context_t maxcontext;
-
- mpd_maxcontext(&maxcontext);
-#ifdef CONFIG_64
- mpd_qset_ssize(result, a, &maxcontext, status);
-#else
- _c32_qset_i64(result, a, &maxcontext, status);
-#endif
-
- if (*status & (MPD_Inexact|MPD_Rounded|MPD_Clamped)) {
- /* we want exact results */
- mpd_seterror(result, MPD_Invalid_operation, status);
- }
- *status &= MPD_Errors;
-}
-
+/* quietly set a decimal from an int64_t, use a maxcontext for conversion */
+void
+mpd_qset_i64_exact(mpd_t *result, int64_t a, uint32_t *status)
+{
+ mpd_context_t maxcontext;
+
+ mpd_maxcontext(&maxcontext);
+#ifdef CONFIG_64
+ mpd_qset_ssize(result, a, &maxcontext, status);
+#else
+ _c32_qset_i64(result, a, &maxcontext, status);
+#endif
+
+ if (*status & (MPD_Inexact|MPD_Rounded|MPD_Clamped)) {
+ /* we want exact results */
+ mpd_seterror(result, MPD_Invalid_operation, status);
+ }
+ *status &= MPD_Errors;
+}
+
/* quietly set a decimal from a uint64_t */
void
mpd_qset_u64(mpd_t *result, uint64_t a, const mpd_context_t *ctx,
@@ -1301,26 +1301,26 @@ mpd_qset_u64(mpd_t *result, uint64_t a, const mpd_context_t *ctx,
_c32_qset_u64(result, a, ctx, status);
#endif
}
-
-/* quietly set a decimal from a uint64_t, use a maxcontext for conversion */
-void
-mpd_qset_u64_exact(mpd_t *result, uint64_t a, uint32_t *status)
-{
- mpd_context_t maxcontext;
-
- mpd_maxcontext(&maxcontext);
-#ifdef CONFIG_64
- mpd_qset_uint(result, a, &maxcontext, status);
-#else
- _c32_qset_u64(result, a, &maxcontext, status);
-#endif
-
- if (*status & (MPD_Inexact|MPD_Rounded|MPD_Clamped)) {
- /* we want exact results */
- mpd_seterror(result, MPD_Invalid_operation, status);
- }
- *status &= MPD_Errors;
-}
+
+/* quietly set a decimal from a uint64_t, use a maxcontext for conversion */
+void
+mpd_qset_u64_exact(mpd_t *result, uint64_t a, uint32_t *status)
+{
+ mpd_context_t maxcontext;
+
+ mpd_maxcontext(&maxcontext);
+#ifdef CONFIG_64
+ mpd_qset_uint(result, a, &maxcontext, status);
+#else
+ _c32_qset_u64(result, a, &maxcontext, status);
+#endif
+
+ if (*status & (MPD_Inexact|MPD_Rounded|MPD_Clamped)) {
+ /* we want exact results */
+ mpd_seterror(result, MPD_Invalid_operation, status);
+ }
+ *status &= MPD_Errors;
+}
#endif /* !LEGACY_COMPILER */
/*
@@ -1410,13 +1410,13 @@ mpd_qabs_uint(const mpd_t *a, uint32_t *status)
mpd_ssize_t
mpd_qget_ssize(const mpd_t *a, uint32_t *status)
{
- uint32_t workstatus = 0;
+ uint32_t workstatus = 0;
mpd_uint_t u;
int isneg;
- u = mpd_qabs_uint(a, &workstatus);
- if (workstatus&MPD_Invalid_operation) {
- *status |= workstatus;
+ u = mpd_qabs_uint(a, &workstatus);
+ if (workstatus&MPD_Invalid_operation) {
+ *status |= workstatus;
return MPD_SSIZE_MAX;
}
@@ -1536,11 +1536,11 @@ mpd_qget_i64(const mpd_t *a, uint32_t *status)
uint32_t
mpd_qget_u32(const mpd_t *a, uint32_t *status)
{
- uint32_t workstatus = 0;
- uint64_t x = mpd_qget_uint(a, &workstatus);
+ uint32_t workstatus = 0;
+ uint64_t x = mpd_qget_uint(a, &workstatus);
- if (workstatus&MPD_Invalid_operation) {
- *status |= workstatus;
+ if (workstatus&MPD_Invalid_operation) {
+ *status |= workstatus;
return UINT32_MAX;
}
if (x > UINT32_MAX) {
@@ -1555,11 +1555,11 @@ mpd_qget_u32(const mpd_t *a, uint32_t *status)
int32_t
mpd_qget_i32(const mpd_t *a, uint32_t *status)
{
- uint32_t workstatus = 0;
- int64_t x = mpd_qget_ssize(a, &workstatus);
+ uint32_t workstatus = 0;
+ int64_t x = mpd_qget_ssize(a, &workstatus);
- if (workstatus&MPD_Invalid_operation) {
- *status |= workstatus;
+ if (workstatus&MPD_Invalid_operation) {
+ *status |= workstatus;
return INT32_MAX;
}
if (x < INT32_MIN || x > INT32_MAX) {
@@ -1575,20 +1575,20 @@ mpd_qget_i32(const mpd_t *a, uint32_t *status)
uint64_t
mpd_qget_u64(const mpd_t *a, uint32_t *status)
{
- uint32_t workstatus = 0;
- uint64_t x = _c32_qget_u64(1, a, &workstatus);
- *status |= workstatus;
- return x;
+ uint32_t workstatus = 0;
+ uint64_t x = _c32_qget_u64(1, a, &workstatus);
+ *status |= workstatus;
+ return x;
}
/* quietly get an int64_t from a decimal */
int64_t
mpd_qget_i64(const mpd_t *a, uint32_t *status)
{
- uint32_t workstatus = 0;
- int64_t x = _c32_qget_i64(a, &workstatus);
- *status |= workstatus;
- return x;
+ uint32_t workstatus = 0;
+ int64_t x = _c32_qget_i64(a, &workstatus);
+ *status |= workstatus;
+ return x;
}
#endif
@@ -2014,25 +2014,25 @@ mpd_qcopy(mpd_t *result, const mpd_t *a, uint32_t *status)
return 1;
}
-/* Same as mpd_qcopy, but do not set the result to NaN on failure. */
-int
-mpd_qcopy_cxx(mpd_t *result, const mpd_t *a)
-{
- if (result == a) return 1;
-
- if (!mpd_qresize_cxx(result, a->len)) {
- return 0;
- }
-
- mpd_copy_flags(result, a);
- result->exp = a->exp;
- result->digits = a->digits;
- result->len = a->len;
- memcpy(result->data, a->data, a->len * (sizeof *result->data));
-
- return 1;
-}
-
+/* Same as mpd_qcopy, but do not set the result to NaN on failure. */
+int
+mpd_qcopy_cxx(mpd_t *result, const mpd_t *a)
+{
+ if (result == a) return 1;
+
+ if (!mpd_qresize_cxx(result, a->len)) {
+ return 0;
+ }
+
+ mpd_copy_flags(result, a);
+ result->exp = a->exp;
+ result->digits = a->digits;
+ result->len = a->len;
+ memcpy(result->data, a->data, a->len * (sizeof *result->data));
+
+ return 1;
+}
+
/*
* Copy to a decimal with a static buffer. The caller has to make sure that
* the buffer is big enough. Cannot fail.
@@ -3876,72 +3876,72 @@ void
mpd_qdiv(mpd_t *q, const mpd_t *a, const mpd_t *b,
const mpd_context_t *ctx, uint32_t *status)
{
- MPD_NEW_STATIC(aa,0,0,0,0);
- MPD_NEW_STATIC(bb,0,0,0,0);
- uint32_t xstatus = 0;
-
- if (q == a) {
- if (!mpd_qcopy(&aa, a, status)) {
- mpd_seterror(q, MPD_Malloc_error, status);
- goto out;
- }
- a = &aa;
- }
-
- if (q == b) {
- if (!mpd_qcopy(&bb, b, status)) {
- mpd_seterror(q, MPD_Malloc_error, status);
- goto out;
- }
- b = &bb;
- }
-
- _mpd_qdiv(SET_IDEAL_EXP, q, a, b, ctx, &xstatus);
-
- if (xstatus & (MPD_Malloc_error|MPD_Division_impossible)) {
- /* Inexact quotients (the usual case) fill the entire context precision,
- * which can lead to the above errors for very high precisions. Retry
- * the operation with a lower precision in case the result is exact.
- *
- * We need an upper bound for the number of digits of a_coeff / b_coeff
- * when the result is exact. If a_coeff' * 1 / b_coeff' is in lowest
- * terms, then maxdigits(a_coeff') + maxdigits(1 / b_coeff') is a suitable
- * bound.
- *
- * 1 / b_coeff' is exact iff b_coeff' exclusively has prime factors 2 or 5.
- * The largest amount of digits is generated if b_coeff' is a power of 2 or
- * a power of 5 and is less than or equal to log5(b_coeff') <= log2(b_coeff').
- *
- * We arrive at a total upper bound:
- *
- * maxdigits(a_coeff') + maxdigits(1 / b_coeff') <=
- * log10(a_coeff) + log2(b_coeff) =
- * log10(a_coeff) + log10(b_coeff) / log10(2) <=
- * a->digits + b->digits * 4;
- */
- mpd_context_t workctx = *ctx;
- uint32_t ystatus = 0;
-
- workctx.prec = a->digits + b->digits * 4;
- if (workctx.prec >= ctx->prec) {
- *status |= (xstatus&MPD_Errors);
- goto out; /* No point in retrying, keep the original error. */
- }
-
- _mpd_qdiv(SET_IDEAL_EXP, q, a, b, &workctx, &ystatus);
- if (ystatus != 0) {
- ystatus = *status | ((ystatus|xstatus)&MPD_Errors);
- mpd_seterror(q, ystatus, status);
- }
- }
- else {
- *status |= xstatus;
- }
-
-
-out:
- mpd_del(&aa);
- mpd_del(&bb);
+ MPD_NEW_STATIC(aa,0,0,0,0);
+ MPD_NEW_STATIC(bb,0,0,0,0);
+ uint32_t xstatus = 0;
+
+ if (q == a) {
+ if (!mpd_qcopy(&aa, a, status)) {
+ mpd_seterror(q, MPD_Malloc_error, status);
+ goto out;
+ }
+ a = &aa;
+ }
+
+ if (q == b) {
+ if (!mpd_qcopy(&bb, b, status)) {
+ mpd_seterror(q, MPD_Malloc_error, status);
+ goto out;
+ }
+ b = &bb;
+ }
+
+ _mpd_qdiv(SET_IDEAL_EXP, q, a, b, ctx, &xstatus);
+
+ if (xstatus & (MPD_Malloc_error|MPD_Division_impossible)) {
+ /* Inexact quotients (the usual case) fill the entire context precision,
+ * which can lead to the above errors for very high precisions. Retry
+ * the operation with a lower precision in case the result is exact.
+ *
+ * We need an upper bound for the number of digits of a_coeff / b_coeff
+ * when the result is exact. If a_coeff' * 1 / b_coeff' is in lowest
+ * terms, then maxdigits(a_coeff') + maxdigits(1 / b_coeff') is a suitable
+ * bound.
+ *
+ * 1 / b_coeff' is exact iff b_coeff' exclusively has prime factors 2 or 5.
+ * The largest amount of digits is generated if b_coeff' is a power of 2 or
+ * a power of 5 and is less than or equal to log5(b_coeff') <= log2(b_coeff').
+ *
+ * We arrive at a total upper bound:
+ *
+ * maxdigits(a_coeff') + maxdigits(1 / b_coeff') <=
+ * log10(a_coeff) + log2(b_coeff) =
+ * log10(a_coeff) + log10(b_coeff) / log10(2) <=
+ * a->digits + b->digits * 4;
+ */
+ mpd_context_t workctx = *ctx;
+ uint32_t ystatus = 0;
+
+ workctx.prec = a->digits + b->digits * 4;
+ if (workctx.prec >= ctx->prec) {
+ *status |= (xstatus&MPD_Errors);
+ goto out; /* No point in retrying, keep the original error. */
+ }
+
+ _mpd_qdiv(SET_IDEAL_EXP, q, a, b, &workctx, &ystatus);
+ if (ystatus != 0) {
+ ystatus = *status | ((ystatus|xstatus)&MPD_Errors);
+ mpd_seterror(q, ystatus, status);
+ }
+ }
+ else {
+ *status |= xstatus;
+ }
+
+
+out:
+ mpd_del(&aa);
+ mpd_del(&bb);
}
/* Internal function. */
@@ -4031,7 +4031,7 @@ _mpd_qdivmod(mpd_t *q, mpd_t *r, const mpd_t *a, const mpd_t *b,
}
if (b->len == 1) {
- assert(b->data[0] != 0); /* annotation for scan-build */
+ assert(b->data[0] != 0); /* annotation for scan-build */
if (a->len == 1) {
_mpd_div_word(&q->data[0], &r->data[0], a->data[0], b->data[0]);
}
@@ -6376,11 +6376,11 @@ _mpd_qpow_int(mpd_t *result, const mpd_t *base, const mpd_t *exp,
workctx.round = MPD_ROUND_HALF_EVEN;
workctx.clamp = 0;
if (mpd_isnegative(exp)) {
- uint32_t workstatus = 0;
+ uint32_t workstatus = 0;
workctx.prec += 1;
- mpd_qdiv(&tbase, &one, base, &workctx, &workstatus);
- *status |= workstatus;
- if (workstatus&MPD_Errors) {
+ mpd_qdiv(&tbase, &one, base, &workctx, &workstatus);
+ *status |= workstatus;
+ if (workstatus&MPD_Errors) {
mpd_setspecial(result, MPD_POS, MPD_NAN);
goto finish;
}
@@ -7115,8 +7115,8 @@ mpd_qrem_near(mpd_t *r, const mpd_t *a, const mpd_t *b,
mpd_ssize_t expdiff, qdigits;
int cmp, isodd, allnine;
- assert(r != NULL); /* annotation for scan-build */
-
+ assert(r != NULL); /* annotation for scan-build */
+
if (mpd_isspecial(a) || mpd_isspecial(b)) {
if (mpd_qcheck_nans(r, a, b, ctx, status)) {
return;
@@ -7347,11 +7347,11 @@ void
mpd_qtrunc(mpd_t *result, const mpd_t *a, const mpd_context_t *ctx,
uint32_t *status)
{
- if (mpd_isspecial(a)) {
- mpd_seterror(result, MPD_Invalid_operation, status);
- return;
- }
-
+ if (mpd_isspecial(a)) {
+ mpd_seterror(result, MPD_Invalid_operation, status);
+ return;
+ }
+
(void)_mpd_qround_to_integral(TO_INT_TRUNC, result, a, ctx, status);
}
@@ -7360,12 +7360,12 @@ mpd_qfloor(mpd_t *result, const mpd_t *a, const mpd_context_t *ctx,
uint32_t *status)
{
mpd_context_t workctx = *ctx;
-
- if (mpd_isspecial(a)) {
- mpd_seterror(result, MPD_Invalid_operation, status);
- return;
- }
-
+
+ if (mpd_isspecial(a)) {
+ mpd_seterror(result, MPD_Invalid_operation, status);
+ return;
+ }
+
workctx.round = MPD_ROUND_FLOOR;
(void)_mpd_qround_to_integral(TO_INT_SILENT, result, a,
&workctx, status);
@@ -7376,12 +7376,12 @@ mpd_qceil(mpd_t *result, const mpd_t *a, const mpd_context_t *ctx,
uint32_t *status)
{
mpd_context_t workctx = *ctx;
-
- if (mpd_isspecial(a)) {
- mpd_seterror(result, MPD_Invalid_operation, status);
- return;
- }
-
+
+ if (mpd_isspecial(a)) {
+ mpd_seterror(result, MPD_Invalid_operation, status);
+ return;
+ }
+
workctx.round = MPD_ROUND_CEILING;
(void)_mpd_qround_to_integral(TO_INT_SILENT, result, a,
&workctx, status);
@@ -7885,9 +7885,9 @@ mpd_qinvroot(mpd_t *result, const mpd_t *a, const mpd_context_t *ctx,
/* END LIBMPDEC_ONLY */
/* Algorithm from decimal.py */
-static void
-_mpd_qsqrt(mpd_t *result, const mpd_t *a, const mpd_context_t *ctx,
- uint32_t *status)
+static void
+_mpd_qsqrt(mpd_t *result, const mpd_t *a, const mpd_context_t *ctx,
+ uint32_t *status)
{
mpd_context_t maxcontext;
MPD_NEW_STATIC(c,0,0,0,0);
@@ -8019,57 +8019,57 @@ malloc_error:
goto out;
}
-void
-mpd_qsqrt(mpd_t *result, const mpd_t *a, const mpd_context_t *ctx,
- uint32_t *status)
-{
- MPD_NEW_STATIC(aa,0,0,0,0);
- uint32_t xstatus = 0;
-
- if (result == a) {
- if (!mpd_qcopy(&aa, a, status)) {
- mpd_seterror(result, MPD_Malloc_error, status);
- goto out;
- }
- a = &aa;
- }
-
- _mpd_qsqrt(result, a, ctx, &xstatus);
-
- if (xstatus & (MPD_Malloc_error|MPD_Division_impossible)) {
- /* The above conditions can occur at very high context precisions
- * if intermediate values get too large. Retry the operation with
- * a lower context precision in case the result is exact.
- *
- * If the result is exact, an upper bound for the number of digits
- * is the number of digits in the input.
- *
- * NOTE: sqrt(40e9) = 2.0e+5 /\ digits(40e9) = digits(2.0e+5) = 2
- */
- uint32_t ystatus = 0;
- mpd_context_t workctx = *ctx;
-
- workctx.prec = a->digits;
- if (workctx.prec >= ctx->prec) {
- *status |= (xstatus|MPD_Errors);
- goto out; /* No point in repeating this, keep the original error. */
- }
-
- _mpd_qsqrt(result, a, &workctx, &ystatus);
- if (ystatus != 0) {
- ystatus = *status | ((xstatus|ystatus)&MPD_Errors);
- mpd_seterror(result, ystatus, status);
- }
- }
- else {
- *status |= xstatus;
- }
-
-out:
- mpd_del(&aa);
-}
-
-
+void
+mpd_qsqrt(mpd_t *result, const mpd_t *a, const mpd_context_t *ctx,
+ uint32_t *status)
+{
+ MPD_NEW_STATIC(aa,0,0,0,0);
+ uint32_t xstatus = 0;
+
+ if (result == a) {
+ if (!mpd_qcopy(&aa, a, status)) {
+ mpd_seterror(result, MPD_Malloc_error, status);
+ goto out;
+ }
+ a = &aa;
+ }
+
+ _mpd_qsqrt(result, a, ctx, &xstatus);
+
+ if (xstatus & (MPD_Malloc_error|MPD_Division_impossible)) {
+ /* The above conditions can occur at very high context precisions
+ * if intermediate values get too large. Retry the operation with
+ * a lower context precision in case the result is exact.
+ *
+ * If the result is exact, an upper bound for the number of digits
+ * is the number of digits in the input.
+ *
+ * NOTE: sqrt(40e9) = 2.0e+5 /\ digits(40e9) = digits(2.0e+5) = 2
+ */
+ uint32_t ystatus = 0;
+ mpd_context_t workctx = *ctx;
+
+ workctx.prec = a->digits;
+ if (workctx.prec >= ctx->prec) {
+ *status |= (xstatus|MPD_Errors);
+ goto out; /* No point in repeating this, keep the original error. */
+ }
+
+ _mpd_qsqrt(result, a, &workctx, &ystatus);
+ if (ystatus != 0) {
+ ystatus = *status | ((xstatus|ystatus)&MPD_Errors);
+ mpd_seterror(result, ystatus, status);
+ }
+ }
+ else {
+ *status |= xstatus;
+ }
+
+out:
+ mpd_del(&aa);
+}
+
+
/******************************************************************************/
/* Base conversions */
/******************************************************************************/
@@ -8080,7 +8080,7 @@ mpd_sizeinbase(const mpd_t *a, uint32_t base)
{
double x;
size_t digits;
- double upper_bound;
+ double upper_bound;
assert(mpd_isinteger(a));
assert(base >= 2);
@@ -8097,14 +8097,14 @@ mpd_sizeinbase(const mpd_t *a, uint32_t base)
if (digits > 2711437152599294ULL) {
return SIZE_MAX;
}
-
- upper_bound = (double)((1ULL<<53)-1);
-#else
- upper_bound = (double)(SIZE_MAX-1);
+
+ upper_bound = (double)((1ULL<<53)-1);
+#else
+ upper_bound = (double)(SIZE_MAX-1);
#endif
x = (double)digits / log10(base);
- return (x > upper_bound) ? SIZE_MAX : (size_t)x + 1;
+ return (x > upper_bound) ? SIZE_MAX : (size_t)x + 1;
}
/* Space needed to import a base 'base' integer of length 'srclen'. */
@@ -8112,7 +8112,7 @@ static mpd_ssize_t
_mpd_importsize(size_t srclen, uint32_t base)
{
double x;
- double upper_bound;
+ double upper_bound;
assert(srclen > 0);
assert(base >= 2);
@@ -8121,15 +8121,15 @@ _mpd_importsize(size_t srclen, uint32_t base)
if (srclen > (1ULL<<53)) {
return MPD_SSIZE_MAX;
}
-
- assert((1ULL<<53) <= MPD_MAXIMPORT);
- upper_bound = (double)((1ULL<<53)-1);
-#else
- upper_bound = MPD_MAXIMPORT-1;
+
+ assert((1ULL<<53) <= MPD_MAXIMPORT);
+ upper_bound = (double)((1ULL<<53)-1);
+#else
+ upper_bound = MPD_MAXIMPORT-1;
#endif
x = (double)srclen * (log10(base)/MPD_RDIGITS);
- return (x > upper_bound) ? MPD_SSIZE_MAX : (mpd_ssize_t)x + 1;
+ return (x > upper_bound) ? MPD_SSIZE_MAX : (mpd_ssize_t)x + 1;
}
static uint8_t
diff --git a/contrib/tools/python3/src/Modules/_decimal/libmpdec/mpdecimal.h b/contrib/tools/python3/src/Modules/_decimal/libmpdec/mpdecimal.h
index f66f6e5920..10adca58de 100644
--- a/contrib/tools/python3/src/Modules/_decimal/libmpdec/mpdecimal.h
+++ b/contrib/tools/python3/src/Modules/_decimal/libmpdec/mpdecimal.h
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2008-2020 Stefan Krah. All rights reserved.
+ * Copyright (c) 2008-2020 Stefan Krah. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
@@ -26,42 +26,42 @@
*/
-#ifndef LIBMPDEC_MPDECIMAL_H_
-#define LIBMPDEC_MPDECIMAL_H_
+#ifndef LIBMPDEC_MPDECIMAL_H_
+#define LIBMPDEC_MPDECIMAL_H_
-#ifndef _MSC_VER
- #include "pyconfig.h"
-#endif
-
+#ifndef _MSC_VER
+ #include "pyconfig.h"
+#endif
+
#ifdef __cplusplus
- #include <cinttypes>
- #include <climits>
- #include <cstdint>
- #include <cstdio>
- #include <cstdlib>
+ #include <cinttypes>
+ #include <climits>
+ #include <cstdint>
+ #include <cstdio>
+ #include <cstdlib>
extern "C" {
-#else
- #include <inttypes.h>
- #include <limits.h>
- #include <stdint.h>
- #include <stdio.h>
- #include <stdlib.h>
+#else
+ #include <inttypes.h>
+ #include <limits.h>
+ #include <stdint.h>
+ #include <stdio.h>
+ #include <stdlib.h>
#endif
-#if (defined(__linux__) || defined(__FreeBSD__) || defined(__APPLE__)) && \
- defined(__GNUC__) && __GNUC__ >= 4 && !defined(__INTEL_COMPILER)
- #define MPD_PRAGMA(x) _Pragma(x)
- #define MPD_HIDE_SYMBOLS_START "GCC visibility push(hidden)"
- #define MPD_HIDE_SYMBOLS_END "GCC visibility pop"
-#else
- #define MPD_PRAGMA(x)
- #define MPD_HIDE_SYMBOLS_START
- #define MPD_HIDE_SYMBOLS_END
+#if (defined(__linux__) || defined(__FreeBSD__) || defined(__APPLE__)) && \
+ defined(__GNUC__) && __GNUC__ >= 4 && !defined(__INTEL_COMPILER)
+ #define MPD_PRAGMA(x) _Pragma(x)
+ #define MPD_HIDE_SYMBOLS_START "GCC visibility push(hidden)"
+ #define MPD_HIDE_SYMBOLS_END "GCC visibility pop"
+#else
+ #define MPD_PRAGMA(x)
+ #define MPD_HIDE_SYMBOLS_START
+ #define MPD_HIDE_SYMBOLS_END
#endif
-#if defined(_MSC_VER)
+#if defined(_MSC_VER)
#include "vccompat.h"
#define EXTINLINE extern inline
#else
@@ -89,10 +89,10 @@ MPD_PRAGMA(MPD_HIDE_SYMBOLS_START)
/******************************************************************************/
#define MPD_MAJOR_VERSION 2
-#define MPD_MINOR_VERSION 5
-#define MPD_MICRO_VERSION 0
+#define MPD_MINOR_VERSION 5
+#define MPD_MICRO_VERSION 0
-#define MPD_VERSION "2.5.0"
+#define MPD_VERSION "2.5.0"
#define MPD_VERSION_HEX ((MPD_MAJOR_VERSION << 24) | \
(MPD_MINOR_VERSION << 16) | \
@@ -121,9 +121,9 @@ const char *mpd_version(void);
#elif defined(__x86_64__)
#define CONFIG_64
#define ASM
- #elif defined(__arm64__)
- #define CONFIG_64
- #define ANSI
+ #elif defined(__arm64__)
+ #define CONFIG_64
+ #define ANSI
#else
#error "unknown architecture for universal build."
#endif
@@ -412,7 +412,7 @@ void mpd_print(const mpd_t *dec);
/* assignment from a string */
void mpd_qset_string(mpd_t *dec, const char *s, const mpd_context_t *ctx, uint32_t *status);
-void mpd_qset_string_exact(mpd_t *dec, const char *s, uint32_t *status);
+void mpd_qset_string_exact(mpd_t *dec, const char *s, uint32_t *status);
/* set to NaN with error flags */
void mpd_seterror(mpd_t *result, uint32_t flags, uint32_t *status);
@@ -430,8 +430,8 @@ void mpd_qset_u32(mpd_t *result, uint32_t a, const mpd_context_t *ctx, uint32_t
#ifndef LEGACY_COMPILER
void mpd_qset_i64(mpd_t *result, int64_t a, const mpd_context_t *ctx, uint32_t *status);
void mpd_qset_u64(mpd_t *result, uint64_t a, const mpd_context_t *ctx, uint32_t *status);
-void mpd_qset_i64_exact(mpd_t *result, int64_t a, uint32_t *status);
-void mpd_qset_u64_exact(mpd_t *result, uint64_t a, uint32_t *status);
+void mpd_qset_i64_exact(mpd_t *result, int64_t a, uint32_t *status);
+void mpd_qset_u64_exact(mpd_t *result, uint64_t a, uint32_t *status);
#endif
/* quietly assign a C integer type to an mpd_t with a static coefficient */
@@ -459,8 +459,8 @@ void mpd_qfinalize(mpd_t *result, const mpd_context_t *ctx, uint32_t *status);
const char *mpd_class(const mpd_t *a, const mpd_context_t *ctx);
-int mpd_qcopy(mpd_t *result, const mpd_t *a, uint32_t *status);
-int mpd_qcopy_cxx(mpd_t *result, const mpd_t *a);
+int mpd_qcopy(mpd_t *result, const mpd_t *a, uint32_t *status);
+int mpd_qcopy_cxx(mpd_t *result, const mpd_t *a);
mpd_t *mpd_qncopy(const mpd_t *a);
int mpd_qcopy_abs(mpd_t *result, const mpd_t *a, uint32_t *status);
int mpd_qcopy_negate(mpd_t *result, const mpd_t *a, uint32_t *status);
@@ -714,7 +714,7 @@ EXTINLINE mpd_uint_t mpd_lsd(mpd_uint_t word);
EXTINLINE mpd_ssize_t mpd_digits_to_size(mpd_ssize_t digits);
/* number of digits in the exponent, undefined for MPD_SSIZE_MIN */
EXTINLINE int mpd_exp_digits(mpd_ssize_t exp);
-EXTINLINE int mpd_iscanonical(const mpd_t *dec);
+EXTINLINE int mpd_iscanonical(const mpd_t *dec);
EXTINLINE int mpd_isfinite(const mpd_t *dec);
EXTINLINE int mpd_isinfinite(const mpd_t *dec);
EXTINLINE int mpd_isinteger(const mpd_t *dec);
@@ -830,4 +830,4 @@ MPD_PRAGMA(MPD_HIDE_SYMBOLS_END) /* restore previous scope rules */
#endif
-#endif /* LIBMPDEC_MPDECIMAL_H_ */
+#endif /* LIBMPDEC_MPDECIMAL_H_ */
diff --git a/contrib/tools/python3/src/Modules/_decimal/libmpdec/numbertheory.c b/contrib/tools/python3/src/Modules/_decimal/libmpdec/numbertheory.c
index 210e0deb37..b476b8682c 100644
--- a/contrib/tools/python3/src/Modules/_decimal/libmpdec/numbertheory.c
+++ b/contrib/tools/python3/src/Modules/_decimal/libmpdec/numbertheory.c
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2008-2020 Stefan Krah. All rights reserved.
+ * Copyright (c) 2008-2020 Stefan Krah. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
@@ -27,12 +27,12 @@
#include "mpdecimal.h"
-
-#include <assert.h>
+
+#include <assert.h>
#include <stdlib.h>
-
+
#include "bits.h"
-#include "numbertheory.h"
+#include "numbertheory.h"
#include "umodarith.h"
diff --git a/contrib/tools/python3/src/Modules/_decimal/libmpdec/numbertheory.h b/contrib/tools/python3/src/Modules/_decimal/libmpdec/numbertheory.h
index 47b7753b83..20db08b080 100644
--- a/contrib/tools/python3/src/Modules/_decimal/libmpdec/numbertheory.h
+++ b/contrib/tools/python3/src/Modules/_decimal/libmpdec/numbertheory.h
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2008-2020 Stefan Krah. All rights reserved.
+ * Copyright (c) 2008-2020 Stefan Krah. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
@@ -26,11 +26,11 @@
*/
-#ifndef LIBMPDEC_NUMBERTHEORY_H_
-#define LIBMPDEC_NUMBERTHEORY_H_
+#ifndef LIBMPDEC_NUMBERTHEORY_H_
+#define LIBMPDEC_NUMBERTHEORY_H_
-#include "mpdecimal.h"
+#include "mpdecimal.h"
#include "constants.h"
@@ -73,4 +73,4 @@ std_setmodulus(int modnum, mpd_uint_t *umod)
MPD_PRAGMA(MPD_HIDE_SYMBOLS_END) /* restore previous scope rules */
-#endif /* LIBMPDEC_NUMBERTHEORY_H_ */
+#endif /* LIBMPDEC_NUMBERTHEORY_H_ */
diff --git a/contrib/tools/python3/src/Modules/_decimal/libmpdec/sixstep.c b/contrib/tools/python3/src/Modules/_decimal/libmpdec/sixstep.c
index a4d1dbed78..8e643603ac 100644
--- a/contrib/tools/python3/src/Modules/_decimal/libmpdec/sixstep.c
+++ b/contrib/tools/python3/src/Modules/_decimal/libmpdec/sixstep.c
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2008-2020 Stefan Krah. All rights reserved.
+ * Copyright (c) 2008-2020 Stefan Krah. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
@@ -27,15 +27,15 @@
#include "mpdecimal.h"
-
-#include <assert.h>
+
+#include <assert.h>
#include <stdio.h>
-
+
#include "bits.h"
-#include "constants.h"
+#include "constants.h"
#include "difradix2.h"
#include "numbertheory.h"
-#include "sixstep.h"
+#include "sixstep.h"
#include "transpose.h"
#include "umodarith.h"
diff --git a/contrib/tools/python3/src/Modules/_decimal/libmpdec/sixstep.h b/contrib/tools/python3/src/Modules/_decimal/libmpdec/sixstep.h
index 89b4a33afc..6af6243a14 100644
--- a/contrib/tools/python3/src/Modules/_decimal/libmpdec/sixstep.h
+++ b/contrib/tools/python3/src/Modules/_decimal/libmpdec/sixstep.h
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2008-2020 Stefan Krah. All rights reserved.
+ * Copyright (c) 2008-2020 Stefan Krah. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
@@ -26,8 +26,8 @@
*/
-#ifndef LIBMPDEC_SIXSTEP_H_
-#define LIBMPDEC_SIXSTEP_H_
+#ifndef LIBMPDEC_SIXSTEP_H_
+#define LIBMPDEC_SIXSTEP_H_
#include "mpdecimal.h"
@@ -44,4 +44,4 @@ int inv_six_step_fnt(mpd_uint_t *a, mpd_size_t n, int modnum);
MPD_PRAGMA(MPD_HIDE_SYMBOLS_END) /* restore previous scope rules */
-#endif /* LIBMPDEC_SIXSTEP_H_ */
+#endif /* LIBMPDEC_SIXSTEP_H_ */
diff --git a/contrib/tools/python3/src/Modules/_decimal/libmpdec/transpose.c b/contrib/tools/python3/src/Modules/_decimal/libmpdec/transpose.c
index 56321b5f39..4604335622 100644
--- a/contrib/tools/python3/src/Modules/_decimal/libmpdec/transpose.c
+++ b/contrib/tools/python3/src/Modules/_decimal/libmpdec/transpose.c
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2008-2020 Stefan Krah. All rights reserved.
+ * Copyright (c) 2008-2020 Stefan Krah. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
@@ -27,16 +27,16 @@
#include "mpdecimal.h"
-
-#include <assert.h>
-#include <limits.h>
+
+#include <assert.h>
+#include <limits.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
-
+
#include "bits.h"
#include "constants.h"
-#include "transpose.h"
+#include "transpose.h"
#include "typearith.h"
diff --git a/contrib/tools/python3/src/Modules/_decimal/libmpdec/transpose.h b/contrib/tools/python3/src/Modules/_decimal/libmpdec/transpose.h
index e91c18d743..ec6da2b7c5 100644
--- a/contrib/tools/python3/src/Modules/_decimal/libmpdec/transpose.h
+++ b/contrib/tools/python3/src/Modules/_decimal/libmpdec/transpose.h
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2008-2020 Stefan Krah. All rights reserved.
+ * Copyright (c) 2008-2020 Stefan Krah. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
@@ -26,8 +26,8 @@
*/
-#ifndef LIBMPDEC_TRANSPOSE_H_
-#define LIBMPDEC_TRANSPOSE_H_
+#ifndef LIBMPDEC_TRANSPOSE_H_
+#define LIBMPDEC_TRANSPOSE_H_
#include "mpdecimal.h"
@@ -58,4 +58,4 @@ static inline void pointerswap(mpd_uint_t **a, mpd_uint_t **b)
MPD_PRAGMA(MPD_HIDE_SYMBOLS_END) /* restore previous scope rules */
-#endif /* LIBMPDEC_TRANSPOSE_H_ */
+#endif /* LIBMPDEC_TRANSPOSE_H_ */
diff --git a/contrib/tools/python3/src/Modules/_decimal/libmpdec/typearith.h b/contrib/tools/python3/src/Modules/_decimal/libmpdec/typearith.h
index 47961788d7..886c527296 100644
--- a/contrib/tools/python3/src/Modules/_decimal/libmpdec/typearith.h
+++ b/contrib/tools/python3/src/Modules/_decimal/libmpdec/typearith.h
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2008-2020 Stefan Krah. All rights reserved.
+ * Copyright (c) 2008-2020 Stefan Krah. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
@@ -26,15 +26,15 @@
*/
-#ifndef LIBMPDEC_TYPEARITH_H_
-#define LIBMPDEC_TYPEARITH_H_
+#ifndef LIBMPDEC_TYPEARITH_H_
+#define LIBMPDEC_TYPEARITH_H_
#include "mpdecimal.h"
-#include <assert.h>
-
+#include <assert.h>
+
/*****************************************************************************/
/* Low level native arithmetic on basic types */
/*****************************************************************************/
@@ -665,4 +665,4 @@ mulmod_size_t(mpd_size_t a, mpd_size_t b, mpd_size_t m)
}
-#endif /* LIBMPDEC_TYPEARITH_H_ */
+#endif /* LIBMPDEC_TYPEARITH_H_ */
diff --git a/contrib/tools/python3/src/Modules/_decimal/libmpdec/umodarith.h b/contrib/tools/python3/src/Modules/_decimal/libmpdec/umodarith.h
index d7dbbbe6a7..62633ae395 100644
--- a/contrib/tools/python3/src/Modules/_decimal/libmpdec/umodarith.h
+++ b/contrib/tools/python3/src/Modules/_decimal/libmpdec/umodarith.h
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2008-2020 Stefan Krah. All rights reserved.
+ * Copyright (c) 2008-2020 Stefan Krah. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
@@ -26,12 +26,12 @@
*/
-#ifndef LIBMPDEC_UMODARITH_H_
-#define LIBMPDEC_UMODARITH_H_
+#ifndef LIBMPDEC_UMODARITH_H_
+#define LIBMPDEC_UMODARITH_H_
-#include "mpdecimal.h"
-
+#include "mpdecimal.h"
+
#include "constants.h"
#include "typearith.h"
@@ -645,4 +645,4 @@ ppro_powmod(mpd_uint_t base, mpd_uint_t exp, double *dmod, uint32_t *dinvmod)
#endif /* CONFIG_32 */
-#endif /* LIBMPDEC_UMODARITH_H_ */
+#endif /* LIBMPDEC_UMODARITH_H_ */
diff --git a/contrib/tools/python3/src/Modules/_decimal/libmpdec/vccompat.h b/contrib/tools/python3/src/Modules/_decimal/libmpdec/vccompat.h
index e2e1c42cc0..8e349a7cf0 100644
--- a/contrib/tools/python3/src/Modules/_decimal/libmpdec/vccompat.h
+++ b/contrib/tools/python3/src/Modules/_decimal/libmpdec/vccompat.h
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2008-2020 Stefan Krah. All rights reserved.
+ * Copyright (c) 2008-2020 Stefan Krah. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
@@ -26,16 +26,16 @@
*/
-#ifndef LIBMPDEC_VCCOMPAT_H_
-#define LIBMPDEC_VCCOMPAT_H_
+#ifndef LIBMPDEC_VCCOMPAT_H_
+#define LIBMPDEC_VCCOMPAT_H_
-/* Visual C fixes: no snprintf ... */
+/* Visual C fixes: no snprintf ... */
#ifdef _MSC_VER
- #ifndef __cplusplus
- #undef inline
- #define inline __inline
- #endif
+ #ifndef __cplusplus
+ #undef inline
+ #define inline __inline
+ #endif
#undef random
#define random rand
#undef srandom
@@ -53,4 +53,4 @@
#endif
-#endif /* LIBMPDEC_VCCOMPAT_H_ */
+#endif /* LIBMPDEC_VCCOMPAT_H_ */