mirror of https://github.com/python/cpython
Merged revisions 81036 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk ........ r81036 | mark.dickinson | 2010-05-09 21:30:29 +0100 (Sun, 09 May 2010) | 1 line Post-detabification cleanup: whitespace fixes and long line rewraps only. ........
This commit is contained in:
parent
e43baaba73
commit
22b20183d5
|
@ -516,7 +516,8 @@ PyLong_AsUnsignedLong(PyObject *vv)
|
||||||
x = (x << PyLong_SHIFT) | v->ob_digit[i];
|
x = (x << PyLong_SHIFT) | v->ob_digit[i];
|
||||||
if ((x >> PyLong_SHIFT) != prev) {
|
if ((x >> PyLong_SHIFT) != prev) {
|
||||||
PyErr_SetString(PyExc_OverflowError,
|
PyErr_SetString(PyExc_OverflowError,
|
||||||
"python int too large to convert to C unsigned long");
|
"python int too large to convert "
|
||||||
|
"to C unsigned long");
|
||||||
return (unsigned long) -1;
|
return (unsigned long) -1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -671,7 +672,7 @@ _PyLong_NumBits(PyObject *vv)
|
||||||
}
|
}
|
||||||
return result;
|
return result;
|
||||||
|
|
||||||
Overflow:
|
Overflow:
|
||||||
PyErr_SetString(PyExc_OverflowError, "int has too many bits "
|
PyErr_SetString(PyExc_OverflowError, "int has too many bits "
|
||||||
"to express in a platform size_t");
|
"to express in a platform size_t");
|
||||||
return (size_t)-1;
|
return (size_t)-1;
|
||||||
|
@ -681,7 +682,7 @@ PyObject *
|
||||||
_PyLong_FromByteArray(const unsigned char* bytes, size_t n,
|
_PyLong_FromByteArray(const unsigned char* bytes, size_t n,
|
||||||
int little_endian, int is_signed)
|
int little_endian, int is_signed)
|
||||||
{
|
{
|
||||||
const unsigned char* pstartbyte;/* LSB of bytes */
|
const unsigned char* pstartbyte; /* LSB of bytes */
|
||||||
int incr; /* direction to move pstartbyte */
|
int incr; /* direction to move pstartbyte */
|
||||||
const unsigned char* pendbyte; /* MSB of bytes */
|
const unsigned char* pendbyte; /* MSB of bytes */
|
||||||
size_t numsignificantbytes; /* number of bytes that matter */
|
size_t numsignificantbytes; /* number of bytes that matter */
|
||||||
|
@ -769,8 +770,7 @@ _PyLong_FromByteArray(const unsigned char* bytes, size_t n,
|
||||||
if (accumbits >= PyLong_SHIFT) {
|
if (accumbits >= PyLong_SHIFT) {
|
||||||
/* There's enough to fill a Python digit. */
|
/* There's enough to fill a Python digit. */
|
||||||
assert(idigit < ndigits);
|
assert(idigit < ndigits);
|
||||||
v->ob_digit[idigit] = (digit)(accum &
|
v->ob_digit[idigit] = (digit)(accum & PyLong_MASK);
|
||||||
PyLong_MASK);
|
|
||||||
++idigit;
|
++idigit;
|
||||||
accum >>= PyLong_SHIFT;
|
accum >>= PyLong_SHIFT;
|
||||||
accumbits -= PyLong_SHIFT;
|
accumbits -= PyLong_SHIFT;
|
||||||
|
@ -856,8 +856,7 @@ _PyLong_AsByteArray(PyLongObject* v,
|
||||||
/* Count # of sign bits -- they needn't be stored,
|
/* Count # of sign bits -- they needn't be stored,
|
||||||
* although for signed conversion we need later to
|
* although for signed conversion we need later to
|
||||||
* make sure at least one sign bit gets stored. */
|
* make sure at least one sign bit gets stored. */
|
||||||
digit s = do_twos_comp ? thisdigit ^ PyLong_MASK :
|
digit s = do_twos_comp ? thisdigit ^ PyLong_MASK : thisdigit;
|
||||||
thisdigit;
|
|
||||||
while (s != 0) {
|
while (s != 0) {
|
||||||
s >>= 1;
|
s >>= 1;
|
||||||
accumbits++;
|
accumbits++;
|
||||||
|
@ -917,7 +916,7 @@ _PyLong_AsByteArray(PyLongObject* v,
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
Overflow:
|
Overflow:
|
||||||
PyErr_SetString(PyExc_OverflowError, "int too big to convert");
|
PyErr_SetString(PyExc_OverflowError, "int too big to convert");
|
||||||
return -1;
|
return -1;
|
||||||
|
|
||||||
|
@ -1172,8 +1171,7 @@ PyLong_AsLongLong(PyObject *vv)
|
||||||
case 0: return 0;
|
case 0: return 0;
|
||||||
case 1: return v->ob_digit[0];
|
case 1: return v->ob_digit[0];
|
||||||
}
|
}
|
||||||
res = _PyLong_AsByteArray(
|
res = _PyLong_AsByteArray((PyLongObject *)vv, (unsigned char *)&bytes,
|
||||||
(PyLongObject *)vv, (unsigned char *)&bytes,
|
|
||||||
SIZEOF_LONG_LONG, IS_LITTLE_ENDIAN, 1);
|
SIZEOF_LONG_LONG, IS_LITTLE_ENDIAN, 1);
|
||||||
|
|
||||||
/* Plan 9 can't handle PY_LONG_LONG in ? : expressions */
|
/* Plan 9 can't handle PY_LONG_LONG in ? : expressions */
|
||||||
|
@ -1205,8 +1203,7 @@ PyLong_AsUnsignedLongLong(PyObject *vv)
|
||||||
case 1: return v->ob_digit[0];
|
case 1: return v->ob_digit[0];
|
||||||
}
|
}
|
||||||
|
|
||||||
res = _PyLong_AsByteArray(
|
res = _PyLong_AsByteArray((PyLongObject *)vv, (unsigned char *)&bytes,
|
||||||
(PyLongObject *)vv, (unsigned char *)&bytes,
|
|
||||||
SIZEOF_LONG_LONG, IS_LITTLE_ENDIAN, 0);
|
SIZEOF_LONG_LONG, IS_LITTLE_ENDIAN, 0);
|
||||||
|
|
||||||
/* Plan 9 can't handle PY_LONG_LONG in ? : expressions */
|
/* Plan 9 can't handle PY_LONG_LONG in ? : expressions */
|
||||||
|
@ -1998,8 +1995,8 @@ digit beyond the first.
|
||||||
twodigits convmax = base;
|
twodigits convmax = base;
|
||||||
int i = 1;
|
int i = 1;
|
||||||
|
|
||||||
log_base_BASE[base] = log((double)base) /
|
log_base_BASE[base] = (log((double)base) /
|
||||||
log((double)PyLong_BASE);
|
log((double)PyLong_BASE));
|
||||||
for (;;) {
|
for (;;) {
|
||||||
twodigits next = convmax * base;
|
twodigits next = convmax * base;
|
||||||
if (next > PyLong_BASE)
|
if (next > PyLong_BASE)
|
||||||
|
@ -2428,7 +2425,8 @@ _PyLong_Frexp(PyLongObject *a, Py_ssize_t *e)
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
assert(1 <= x_size && x_size <= (Py_ssize_t)(sizeof(x_digits)/sizeof(digit)));
|
assert(1 <= x_size &&
|
||||||
|
x_size <= (Py_ssize_t)(sizeof(x_digits)/sizeof(digit)));
|
||||||
|
|
||||||
/* Round, and convert to double. */
|
/* Round, and convert to double. */
|
||||||
x_digits[0] += half_even_correction[x_digits[0] & 7];
|
x_digits[0] += half_even_correction[x_digits[0] & 7];
|
||||||
|
@ -2832,7 +2830,10 @@ x_mul(PyLongObject *a, PyLongObject *b)
|
||||||
Returns 0 on success, -1 on failure.
|
Returns 0 on success, -1 on failure.
|
||||||
*/
|
*/
|
||||||
static int
|
static int
|
||||||
kmul_split(PyLongObject *n, Py_ssize_t size, PyLongObject **high, PyLongObject **low)
|
kmul_split(PyLongObject *n,
|
||||||
|
Py_ssize_t size,
|
||||||
|
PyLongObject **high,
|
||||||
|
PyLongObject **low)
|
||||||
{
|
{
|
||||||
PyLongObject *hi, *lo;
|
PyLongObject *hi, *lo;
|
||||||
Py_ssize_t size_lo, size_hi;
|
Py_ssize_t size_lo, size_hi;
|
||||||
|
@ -3819,12 +3820,11 @@ long_rshift(PyLongObject *a, PyLongObject *b)
|
||||||
for (i = 0, j = wordshift; i < newsize; i++, j++) {
|
for (i = 0, j = wordshift; i < newsize; i++, j++) {
|
||||||
z->ob_digit[i] = (a->ob_digit[j] >> loshift) & lomask;
|
z->ob_digit[i] = (a->ob_digit[j] >> loshift) & lomask;
|
||||||
if (i+1 < newsize)
|
if (i+1 < newsize)
|
||||||
z->ob_digit[i] |=
|
z->ob_digit[i] |= (a->ob_digit[j+1] << hishift) & himask;
|
||||||
(a->ob_digit[j+1] << hishift) & himask;
|
|
||||||
}
|
}
|
||||||
z = long_normalize(z);
|
z = long_normalize(z);
|
||||||
}
|
}
|
||||||
rshift_error:
|
rshift_error:
|
||||||
return (PyObject *) maybe_small_long(z);
|
return (PyObject *) maybe_small_long(z);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -3874,7 +3874,7 @@ long_lshift(PyObject *v, PyObject *w)
|
||||||
else
|
else
|
||||||
assert(!accum);
|
assert(!accum);
|
||||||
z = long_normalize(z);
|
z = long_normalize(z);
|
||||||
lshift_error:
|
lshift_error:
|
||||||
return (PyObject *) maybe_small_long(z);
|
return (PyObject *) maybe_small_long(z);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -4371,7 +4371,7 @@ long_bit_length(PyLongObject *v)
|
||||||
|
|
||||||
return (PyObject *)result;
|
return (PyObject *)result;
|
||||||
|
|
||||||
error:
|
error:
|
||||||
Py_DECREF(result);
|
Py_DECREF(result);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
@ -4633,19 +4633,19 @@ string, use the optional base. It is an error to supply a base when\n\
|
||||||
converting a non-string.");
|
converting a non-string.");
|
||||||
|
|
||||||
static PyNumberMethods long_as_number = {
|
static PyNumberMethods long_as_number = {
|
||||||
(binaryfunc) long_add, /*nb_add*/
|
(binaryfunc)long_add, /*nb_add*/
|
||||||
(binaryfunc) long_sub, /*nb_subtract*/
|
(binaryfunc)long_sub, /*nb_subtract*/
|
||||||
(binaryfunc) long_mul, /*nb_multiply*/
|
(binaryfunc)long_mul, /*nb_multiply*/
|
||||||
long_mod, /*nb_remainder*/
|
long_mod, /*nb_remainder*/
|
||||||
long_divmod, /*nb_divmod*/
|
long_divmod, /*nb_divmod*/
|
||||||
long_pow, /*nb_power*/
|
long_pow, /*nb_power*/
|
||||||
(unaryfunc) long_neg, /*nb_negative*/
|
(unaryfunc)long_neg, /*nb_negative*/
|
||||||
(unaryfunc) long_long, /*tp_positive*/
|
(unaryfunc)long_long, /*tp_positive*/
|
||||||
(unaryfunc) long_abs, /*tp_absolute*/
|
(unaryfunc)long_abs, /*tp_absolute*/
|
||||||
(inquiry) long_bool, /*tp_bool*/
|
(inquiry)long_bool, /*tp_bool*/
|
||||||
(unaryfunc) long_invert, /*nb_invert*/
|
(unaryfunc)long_invert, /*nb_invert*/
|
||||||
long_lshift, /*nb_lshift*/
|
long_lshift, /*nb_lshift*/
|
||||||
(binaryfunc) long_rshift, /*nb_rshift*/
|
(binaryfunc)long_rshift, /*nb_rshift*/
|
||||||
long_and, /*nb_and*/
|
long_and, /*nb_and*/
|
||||||
long_xor, /*nb_xor*/
|
long_xor, /*nb_xor*/
|
||||||
long_or, /*nb_or*/
|
long_or, /*nb_or*/
|
||||||
|
@ -4722,8 +4722,7 @@ internal representation of integers. The attributes are read only.");
|
||||||
|
|
||||||
static PyStructSequence_Field int_info_fields[] = {
|
static PyStructSequence_Field int_info_fields[] = {
|
||||||
{"bits_per_digit", "size of a digit in bits"},
|
{"bits_per_digit", "size of a digit in bits"},
|
||||||
{"sizeof_digit", "size in bytes of the C type used to "
|
{"sizeof_digit", "size in bytes of the C type used to represent a digit"},
|
||||||
"represent a digit"},
|
|
||||||
{NULL, NULL}
|
{NULL, NULL}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue