summaryrefslogtreecommitdiff
path: root/python
diff options
context:
space:
mode:
authorjbj <devnull@localhost>2003-11-23 19:50:52 +0000
committerjbj <devnull@localhost>2003-11-23 19:50:52 +0000
commit3dcfeb3f9aaf003f29d2c8c0c3a545953f529c08 (patch)
treea78f3112c1c5b7b5c8cd2ce4307056c3db758c35 /python
parentfda9ddca9bcd46cefc145c14cfd901906600c9d2 (diff)
downloadrpm-3dcfeb3f9aaf003f29d2c8c0c3a545953f529c08.tar.gz
rpm-3dcfeb3f9aaf003f29d2c8c0c3a545953f529c08.tar.bz2
rpm-3dcfeb3f9aaf003f29d2c8c0c3a545953f529c08.zip
Merge changes from rpm-4.2.1 development.
CVS patchset: 6959 CVS date: 2003/11/23 19:50:52
Diffstat (limited to 'python')
-rw-r--r--python/Makefile.am20
-rw-r--r--python/_rpmdb.c6
-rw-r--r--python/header-py.h6
-rw-r--r--python/poptmodule.c38
-rw-r--r--python/rpmal-py.c2
-rw-r--r--python/rpmal-py.h2
-rw-r--r--python/rpmbc-py.c200
-rw-r--r--python/rpmbc-py.h2
-rw-r--r--python/rpmdb-py.c20
-rw-r--r--python/rpmdb-py.h6
-rw-r--r--python/rpmdebug-py.c8
-rw-r--r--python/rpmds-py.c6
-rw-r--r--python/rpmds-py.h2
-rw-r--r--python/rpmfd-py.c28
-rw-r--r--python/rpmfd-py.h2
-rw-r--r--python/rpmfi-py.c4
-rw-r--r--python/rpmfi-py.h2
-rw-r--r--python/rpmfts-py.c18
-rw-r--r--python/rpmfts-py.h2
-rw-r--r--python/rpmmi-py.c16
-rw-r--r--python/rpmmi-py.h6
-rw-r--r--python/rpmmodule.c25
-rw-r--r--python/rpmmpw-py.c2340
-rw-r--r--python/rpmmpw-py.h2
-rw-r--r--python/rpmrc-py.c12
-rw-r--r--python/rpmrc-py.h6
-rw-r--r--python/rpmrng-py.c330
-rw-r--r--python/rpmrng-py.h2
-rw-r--r--python/rpmte-py.c6
-rw-r--r--python/rpmte-py.h2
-rw-r--r--python/rpmts-py.c106
-rw-r--r--python/rpmts-py.h2
32 files changed, 166 insertions, 3063 deletions
diff --git a/python/Makefile.am b/python/Makefile.am
index 0a6f43cc1..999321368 100644
--- a/python/Makefile.am
+++ b/python/Makefile.am
@@ -9,7 +9,7 @@ PYVER= @WITH_PYTHON_VERSION@
pylibdir = $(shell python -c 'import sys; print sys.path[1]')
pyincdir = $(prefix)/include/python${PYVER}
-SUBDIRS = rpmdb mpw
+SUBDIRS = rpmdb
EXTRA_DIST = rpmdebug-py.c
@@ -24,7 +24,6 @@ INCLUDES = -I. \
@INCPATH@
noinst_HEADERS = header-py.h \
- rpmbc-py.h rpmmpw-py.h rpmrng-py.h \
rpmal-py.h rpmds-py.h rpmdb-py.h rpmfd-py.h rpmfts-py.h \
rpmfi-py.h rpmmi-py.h rpmrc-py.h rpmte-py.h rpmts-py.h
@@ -46,7 +45,7 @@ rpmdb_PROGRAMS = _rpmdb.so
noinst_PROGRAMS = poptmodule.so
rpmmodule_so_SOURCES =
-rpmmodule_so_LDFLAGS = $(mylibs) $(LIBS) -shared -Wl,-soname,rpmmodule.so
+rpmmodule_so_LDFLAGS = $(mylibs) $(LIBS) -shared -Wl,-soname,rpmmodule.so
rpmmodule_so_LDADD = @WITH_BEECRYPT_LIB@
_rpmdb_so_SOURCES = _rpmdb.c
@@ -57,25 +56,24 @@ poptmodule_so_LDFLAGS = $(mylibs) $(LIBS) -shared -Wl,-soname,poptmodule.so
noinst_LTLIBRARIES = librpmmodule.la
librpmmodule_la_SOURCES = rpmmodule.c header-py.c \
- rpmbc-py.c rpmmpw-py.c rpmrng-py.c \
rpmal-py.c rpmds-py.c rpmdb-py.c rpmfd-py.c rpmfts-py.c \
rpmfi-py.c rpmmi-py.c rpmrc-py.c rpmte-py.c rpmts-py.c
+librpmmodule_OBJECTS = $(subst .c,.o,$(librpmmodule_la_SOURCES))
-rpmmodule.so$(EXEEXT): $(librpmmodule_la_OBJECTS)
- $(CC) -o $@ $(librpmmodule_la_OBJECTS) $(rpmmodule_so_LDFLAGS)
+rpmmodule.so$(EXEEXT): librpmmodule.la
+ $(CC) -o $@ $(librpmmodule_OBJECTS) $(rpmmodule_so_LDFLAGS)
-_rpmdb.so$(EXEEXT): _rpmdb.lo
- $(CC) -o $@ _rpmdb.lo $(_rpmdb_so_LDFLAGS)
+_rpmdb.so$(EXEEXT): _rpmdb.o
+ $(CC) -o $@ _rpmdb.o $(_rpmdb_so_LDFLAGS)
-poptmodule.so$(EXEEXT): poptmodule.lo
- $(CC) -o $@ poptmodule.lo $(poptmodule_so_LDFLAGS)
+poptmodule.so$(EXEEXT): poptmodule.o
+ $(CC) -o $@ poptmodule.o $(poptmodule_so_LDFLAGS)
# rpmmodule.c header-py.c \
# rpmal-py.c rpmds-py.c rpmdb-py.c rpmfd-py.c rpmfi-py.c rpmmi-py.c \
# rpmrc-py.c rpmte-py.c rpmts-py.c
# rpmmodule.c header-py.c
splint_srcs = \
- rpmbc-py.c rpmmpw-py.c rpmrng-py.c \
rpmal-py.c rpmds-py.c rpmdb-py.c rpmfd-py.c rpmfts-py.c \
rpmfi-py.c rpmmi-py.c rpmrc-py.c rpmte-py.c rpmts-py.c
diff --git a/python/_rpmdb.c b/python/_rpmdb.c
index 5a10bf893..659485400 100644
--- a/python/_rpmdb.c
+++ b/python/_rpmdb.c
@@ -579,7 +579,7 @@ static PyObject* _DBCursor_get(DBCursorObject* self, int extra_flags,
char* kwnames[] = { "flags", "dlen", "doff", NULL };
if (!PyArg_ParseTupleAndKeywords(args, kwargs, format, kwnames,
- &flags, &dlen, &doff))
+ &flags, &dlen, &doff))
return NULL;
CHECK_CURSOR_NOT_CLOSED(self);
@@ -1634,7 +1634,7 @@ DB_open(DBObject* self, PyObject* args, PyObject* kwargs)
* explicitly passed) but we are in a transaction ready environment:
* add DB_AUTO_COMMIT to allow for older pybsddb apps using transactions
* to work on BerkeleyDB 4.1 without needing to modify their
- * DBEnv or DB open calls.
+ * DBEnv or DB open calls.
* TODO make this behaviour of the library configurable.
*/
flags |= DB_AUTO_COMMIT;
@@ -2618,7 +2618,7 @@ DBC_get(DBCursorObject* self, PyObject* args, PyObject *kwargs)
{
PyErr_Clear();
if (!PyArg_ParseTupleAndKeywords(args, kwargs, "Oi|ii:get",
- &kwnames[1],
+ &kwnames[1],
&keyobj, &flags, &dlen, &doff))
{
PyErr_Clear();
diff --git a/python/header-py.h b/python/header-py.h
index 046412196..72ebb9c86 100644
--- a/python/header-py.h
+++ b/python/header-py.h
@@ -1,18 +1,18 @@
#ifndef RPMPYTHON_HEADER
#define RPMPYTHON_HEADER
-/** \ingroup py_c
+/** \ingroup py_c
* \file python/header-py.h
*/
-/** \ingroup py_c
+/** \ingroup py_c
*/
typedef struct hdrObject_s hdrObject;
/*@unchecked@*/
extern PyTypeObject hdr_Type;
-/** \ingroup py_c
+/** \ingroup py_c
*/
PyObject * pyrpmError;
diff --git a/python/poptmodule.c b/python/poptmodule.c
index d19f3a4e1..06b665dad 100644
--- a/python/poptmodule.c
+++ b/python/poptmodule.c
@@ -1,12 +1,12 @@
/*
*
- *
- *
+ *
+ *
*/
#define PY_POPT_VERSION "0.2"
-static const char *rcs_id = "$Id: poptmodule.c,v 1.8 2002/12/10 19:46:03 jbj Exp $";
+static const char *rcs_id = "$Id: poptmodule.c,v 1.9 2003/11/23 19:52:38 jbj Exp $";
static char *module_doc = "Python bindings for the popt library\n\
\n\
@@ -23,7 +23,7 @@ and is always available from ftp://ftp.rpm.org/pub/rpm/dist";
#define debug(x, y) { printf("%s: %s\n", x, y); }
#else
#define debug(x, y) {}
-#endif
+#endif
/* Functins and datatypes needed for the context object */
typedef struct poptContext_s {
@@ -65,7 +65,7 @@ static PyObject * __poptOptionValue2PyObject(const struct poptOption *option)
/* Do nothing */
Py_INCREF(Py_None);
return Py_None;
- case POPT_ARG_STRING:
+ case POPT_ARG_STRING:
if (*(char **)(option->arg) == NULL) {
Py_INCREF(Py_None);
return Py_None;
@@ -163,7 +163,7 @@ static PyObject * ctxGetArgs(poptContextObject *self, PyObject *argsFoo)
list = PyList_New(size);
if (list == NULL)
return NULL;
- for (i = 0; i < size; i++)
+ for (i = 0; i < size; i++)
PyList_SetItem(list, i, PyString_FromString(args[i]));
return list;
}
@@ -172,7 +172,7 @@ static PyObject * ctxBadOption(poptContextObject *self, PyObject *args)
{
int flags = 0;
const char *badOption;
- if (!PyArg_ParseTuple(args, "|i", &flags))
+ if (!PyArg_ParseTuple(args, "|i", &flags))
return NULL;
badOption = poptBadOption(self->ctx, flags);
if (badOption == NULL) {
@@ -185,7 +185,7 @@ static PyObject * ctxBadOption(poptContextObject *self, PyObject *args)
static PyObject * ctxReadDefaultConfig(poptContextObject *self, PyObject *args)
{
int flags = 0;
- if (!PyArg_ParseTuple(args, "|i", &flags))
+ if (!PyArg_ParseTuple(args, "|i", &flags))
return NULL;
return PyInt_FromLong(poptReadDefaultConfig(self->ctx, flags));
}
@@ -201,7 +201,7 @@ static PyObject * ctxReadConfigFile(poptContextObject *self, PyObject *args)
static PyObject * ctxSetOtherOptionHelp(poptContextObject *self, PyObject *args)
{
const char *option;
- if (!PyArg_ParseTuple(args, "s", &option))
+ if (!PyArg_ParseTuple(args, "s", &option))
return NULL;
poptSetOtherOptionHelp(self->ctx, option);
Py_INCREF(Py_None);
@@ -213,7 +213,7 @@ static PyObject * ctxPrintHelp(poptContextObject *self, PyObject *args)
FILE *f;
int flags = 0;
PyObject *file;
- if (!PyArg_ParseTuple(args, "|O!i", &PyFile_Type, &file, &flags))
+ if (!PyArg_ParseTuple(args, "|O!i", &PyFile_Type, &file, &flags))
return NULL;
f = PyFile_AsFile(file);
if (f == NULL)
@@ -254,7 +254,7 @@ static PyObject * ctxGetOptValues(poptContextObject *self, PyObject *args)
return NULL;
/* Create the list */
list = PyList_New(self->optionsNo);
- if (list == NULL)
+ if (list == NULL)
return NULL;
for (i = 0; i < self->optionsNo; i++) {
PyObject *item;
@@ -383,7 +383,7 @@ int __setPoptOption(PyObject *list, struct poptOption *opt)
PyErr_SetString(pypoptError, "List is too short");
return 0;
}
-
+
/* longName */
o = PyList_GetItem(list, 0);
/* Sanity check */
@@ -393,10 +393,10 @@ int __setPoptOption(PyObject *list, struct poptOption *opt)
if (!PyString_Check(o)) {
PyErr_SetString(pypoptError, "Long name should be a string");
return 0;
- }
+ }
opt->longName = PyString_AsString(o);
}
-
+
/* shortName */
o = PyList_GetItem(list, 1);
/* Sanity check */
@@ -423,7 +423,7 @@ int __setPoptOption(PyObject *list, struct poptOption *opt)
PyErr_SetString(pypoptError, "At least one of the short name and long name must be specified");
return 0;
}
-
+
/* argInfo */
o = PyList_GetItem(list, 2);
/* Sanity check */
@@ -432,7 +432,7 @@ int __setPoptOption(PyObject *list, struct poptOption *opt)
return 0;
}
opt->argInfo = PyInt_AsLong(o);
-
+
/* Initialize the rest of the arguments with safe defaults */
switch(opt->argInfo) {
case POPT_ARG_STRING:
@@ -464,7 +464,7 @@ int __setPoptOption(PyObject *list, struct poptOption *opt)
/* If nothing left, end the stuff here */
if (listSize == 3)
return 1;
-
+
/* val */
o = PyList_GetItem(list, 3);
/* Sanity check */
@@ -584,7 +584,7 @@ static PyObject * getContext(PyObject *self, PyObject *args)
struct poptOption *opts;
poptContextObject *c;
/* We should receive name, argv and a list */
- if (!PyArg_ParseTuple(args, "zO!O!|i", &name, &PyList_Type, &a,
+ if (!PyArg_ParseTuple(args, "zO!O!|i", &name, &PyList_Type, &a,
&PyList_Type, &o, &flags))
return NULL;
/* Parse argv */
@@ -667,7 +667,7 @@ void initpopt()
module = Py_InitModule3("popt", poptModuleMethods, module_doc);
/* Init the constants */
dict = PyModule_GetDict(module);
- PyDict_SetItemString(dict, "__version__",
+ PyDict_SetItemString(dict, "__version__",
PyString_FromString(PY_POPT_VERSION));
PyDict_SetItemString(dict, "cvsid", PyString_FromString(rcs_id));
for (c = intConstants; c->name; c++) {
diff --git a/python/rpmal-py.c b/python/rpmal-py.c
index 74066717b..b91b861be 100644
--- a/python/rpmal-py.c
+++ b/python/rpmal-py.c
@@ -1,4 +1,4 @@
-/** \ingroup py_c
+/** \ingroup py_c
* \file python/rpmal-py.c
*/
diff --git a/python/rpmal-py.h b/python/rpmal-py.h
index 24de1e3c4..0ed151b25 100644
--- a/python/rpmal-py.h
+++ b/python/rpmal-py.h
@@ -3,7 +3,7 @@
#include "rpmal.h"
-/** \ingroup py_c
+/** \ingroup py_c
* \file python/rpmal-py.h
*/
diff --git a/python/rpmbc-py.c b/python/rpmbc-py.c
deleted file mode 100644
index d897a14f8..000000000
--- a/python/rpmbc-py.c
+++ /dev/null
@@ -1,200 +0,0 @@
-/** \ingroup py_c
- * \file python/rpmbc-py.c
- */
-
-#include "system.h"
-
-#include "Python.h"
-#ifdef __LCLINT__
-#undef PyObject_HEAD
-#define PyObject_HEAD int _PyObjectHead;
-#endif
-
-#include "rpmbc-py.h"
-
-#include "rpmdebug-py.c"
-
-#include "debug.h"
-
-/*@unchecked@*/
-static int _bc_debug = 0;
-
-#define is_rpmbc(o) ((o)->ob_type == &rpmbc_Type)
-
-/*@unchecked@*/ /*@observer@*/
-static const char initialiser_name[] = "rpm.bc";
-
-/* ---------- */
-
-static void
-rpmbc_dealloc(rpmbcObject * s)
- /*@*/
-{
-if (_bc_debug < -1)
-fprintf(stderr, "*** rpmbc_dealloc(%p)\n", s);
-
- PyObject_Del(s);
-}
-
-static int
-rpmbc_print(rpmbcObject * s, FILE * fp, /*@unused@*/ int flags)
- /*@*/
-{
-if (_bc_debug < -1)
-fprintf(stderr, "*** rpmbc_print(%p)\n", s);
- return 0;
-}
-
-/** \ingroup py_c
- */
-static int rpmbc_init(rpmbcObject * z, PyObject *args, PyObject *kwds)
- /*@*/
-{
- PyObject * o = NULL;
-
- if (!PyArg_ParseTuple(args, "|O:Cvt", &o)) return -1;
-
-if (_bc_debug)
-fprintf(stderr, "*** rpmbc_init(%p[%s],%p[%s],%p[%s])\n", z, lbl(z), args, lbl(args), kwds, lbl(kwds));
-
- return 0;
-}
-
-/** \ingroup py_c
- */
-static void rpmbc_free(/*@only@*/ rpmbcObject * s)
- /*@*/
-{
-if (_bc_debug)
-fprintf(stderr, "*** rpmbc_free(%p[%s])\n", s, lbl(s));
- PyObject_Del(s);
-}
-
-/** \ingroup py_c
- */
-static PyObject * rpmbc_alloc(PyTypeObject * subtype, int nitems)
- /*@*/
-{
- PyObject * ns = PyType_GenericAlloc(subtype, nitems);
-
-if (_bc_debug)
-fprintf(stderr, "*** rpmbc_alloc(%p[%s},%d) ret %p[%s]\n", subtype, lbl(subtype), nitems, ns, lbl(ns));
- return (PyObject *) ns;
-}
-
-static PyObject *
-rpmbc_new(PyTypeObject * subtype, PyObject *args, PyObject *kwds)
- /*@*/
-{
- PyObject * ns = (PyObject *) PyObject_New(rpmbcObject, &rpmbc_Type);
-
-if (_bc_debug < -1)
-fprintf(stderr, "*** rpmbc_new(%p[%s],%p[%s],%p[%s]) ret %p[%s]\n", subtype, lbl(subtype), args, lbl(args), kwds, lbl(kwds), ns, lbl(ns));
- return ns;
-}
-
-static rpmbcObject *
-rpmbc_New(void)
-{
- rpmbcObject * ns = PyObject_New(rpmbcObject, &rpmbc_Type);
-
- return ns;
-}
-
-/* ---------- */
-
-/** \ingroup py_c
- */
-static PyObject *
-rpmbc_Debug(/*@unused@*/ rpmbcObject * s, PyObject * args)
- /*@globals _Py_NoneStruct @*/
- /*@modifies _Py_NoneStruct @*/
-{
- if (!PyArg_ParseTuple(args, "i:Debug", &_bc_debug)) return NULL;
-
-if (_bc_debug < 0)
-fprintf(stderr, "*** rpmbc_Debug(%p)\n", s);
-
- Py_INCREF(Py_None);
- return Py_None;
-}
-
-/*@-fullinitblock@*/
-/*@unchecked@*/ /*@observer@*/
-static struct PyMethodDef rpmbc_methods[] = {
- {"Debug", (PyCFunction)rpmbc_Debug, METH_VARARGS,
- NULL},
- {NULL, NULL} /* sentinel */
-};
-/*@=fullinitblock@*/
-
-static PyObject * rpmbc_getattro(PyObject * o, PyObject * n)
- /*@*/
-{
- return PyObject_GenericGetAttr(o, n);
-}
-
-static int rpmbc_setattro(PyObject * o, PyObject * n, PyObject * v)
- /*@*/
-{
- return PyObject_GenericSetAttr(o, n, v);
-}
-
-/* ---------- */
-
-/**
- */
-/*@unchecked@*/ /*@observer@*/
-static char rpmbc_doc[] =
-"";
-
-/*@-fullinitblock@*/
-PyTypeObject rpmbc_Type = {
- PyObject_HEAD_INIT(&PyType_Type)
- 0, /* ob_size */
- "rpm.bc", /* tp_name */
- sizeof(rpmbcObject), /* tp_basicsize */
- 0, /* tp_itemsize */
- /* methods */
- (destructor) rpmbc_dealloc, /* tp_dealloc */
- (printfunc) rpmbc_print, /* tp_print */
- (getattrfunc)0, /* tp_getattr */
- (setattrfunc)0, /* tp_setattr */
- (cmpfunc)0, /* tp_compare */
- (reprfunc)0, /* tp_repr */
- 0, /* tp_as_number */
- 0, /* tp_as_sequence */
- 0, /* tp_as_mapping */
- (hashfunc)0, /* tp_hash */
- (ternaryfunc)0, /* tp_call */
- (reprfunc)0, /* tp_str */
- (getattrofunc) rpmbc_getattro, /* tp_getattro */
- (setattrofunc) rpmbc_setattro, /* tp_setattro */
- 0, /* tp_as_buffer */
- Py_TPFLAGS_DEFAULT, /* tp_flags */
- rpmbc_doc, /* tp_doc */
-#if Py_TPFLAGS_HAVE_ITER
- 0, /* tp_traverse */
- 0, /* tp_clear */
- 0, /* tp_richcompare */
- 0, /* tp_weaklistoffset */
- (getiterfunc)0, /* tp_iter */
- (iternextfunc)0, /* tp_iternext */
- rpmbc_methods, /* tp_methods */
- 0, /* tp_members */
- 0, /* tp_getset */
- 0, /* tp_base */
- 0, /* tp_dict */
- 0, /* tp_descr_get */
- 0, /* tp_descr_set */
- 0, /* tp_dictoffset */
- (initproc) rpmbc_init, /* tp_init */
- (allocfunc) rpmbc_alloc, /* tp_alloc */
- (newfunc) rpmbc_new, /* tp_new */
- (destructor) rpmbc_free, /* tp_free */
- 0, /* tp_is_gc */
-#endif
-};
-/*@=fullinitblock@*/
-
-/* ---------- */
diff --git a/python/rpmbc-py.h b/python/rpmbc-py.h
index 550976602..b75409326 100644
--- a/python/rpmbc-py.h
+++ b/python/rpmbc-py.h
@@ -3,7 +3,7 @@
#include "rpmio_internal.h"
-/** \ingroup py_c
+/** \ingroup py_c
* \file python/rpmbc-py.h
*/
diff --git a/python/rpmdb-py.c b/python/rpmdb-py.c
index 6373cd1b6..88b80a9f1 100644
--- a/python/rpmdb-py.c
+++ b/python/rpmdb-py.c
@@ -1,4 +1,4 @@
-/** \ingroup py_c
+/** \ingroup py_c
* \file python/rpmdb-py.c
*/
@@ -23,37 +23,37 @@
/** \ingroup python
* \class Rpmdb
* \brief A python rpmdb object represents an RPM database.
- *
+ *
* Instances of the rpmdb object provide access to the records of a
* RPM database. The records are accessed by index number. To
* retrieve the header data in the RPM database, the rpmdb object is
* subscripted as you would access members of a list.
- *
+ *
* The rpmdb class contains the following methods:
- *
+ *
* - firstkey() Returns the index of the first record in the database.
* @deprecated Use mi = ts.dbMatch() (or db.match()) instead.
- *
+ *
* - nextkey(index) Returns the index of the next record after "index" in the
* database.
* @param index current rpmdb location
* @deprecated Use hdr = mi.next() instead.
- *
+ *
* - findbyfile(file) Returns a list of the indexes to records that own file
* "file".
* @param file absolute path to file
* @deprecated Use mi = ts.dbMatch('basename') instead.
- *
+ *
* - findbyname(name) Returns a list of the indexes to records for packages
* named "name".
* @param name package name
* @deprecated Use mi = ts.dbMatch('name') instead.
- *
+ *
* - findbyprovides(dep) Returns a list of the indexes to records for packages
* that provide "dep".
* @param dep provided dependency string
* @deprecated Use mi = ts.dbMmatch('providename') instead.
- *
+ *
* To obtain a db object explicitly, the opendb function in the rpm module
* can be called. The opendb function takes two optional arguments.
* The first optional argument is a boolean flag that specifies if the
@@ -76,7 +76,7 @@
* db = rpm.opendb()
* mi = db.match()
* \endcode
- *
+ *
* An example of opening a database and retrieving the first header in
* the database, then printing the name of the package that the header
* represents:
diff --git a/python/rpmdb-py.h b/python/rpmdb-py.h
index 4fe934a01..533b545e0 100644
--- a/python/rpmdb-py.h
+++ b/python/rpmdb-py.h
@@ -3,15 +3,15 @@
#include "rpmdb.h"
-/** \ingroup py_c
+/** \ingroup py_c
* \file python/rpmdb-py.h
*/
-/** \ingroup py_c
+/** \ingroup py_c
*/
typedef struct rpmdbObject_s rpmdbObject;
-/** \ingroup py_c
+/** \ingroup py_c
*/
struct rpmdbObject_s {
PyObject_HEAD
diff --git a/python/rpmdebug-py.c b/python/rpmdebug-py.c
index 8179671fa..e5920731e 100644
--- a/python/rpmdebug-py.c
+++ b/python/rpmdebug-py.c
@@ -6,7 +6,6 @@ extern PyTypeObject PyDictIter_Type;
/*@unchecked@*/
extern PyTypeObject PyFrame_Type;
-#include "rpmbc-py.h" /* XXX debug only */
#include <rpmcli.h> /* XXX debug only */
#include "header-py.h" /* XXX debug only */
@@ -16,9 +15,7 @@ extern PyTypeObject PyFrame_Type;
#include "rpmfi-py.h" /* XXX debug only */
#include "rpmfts-py.h" /* XXX debug only */
#include "rpmmi-py.h" /* XXX debug only */
-#include "rpmmpw-py.h" /* XXX debug only */
#include "rpmrc-py.h" /* XXX debug only */
-#include "rpmrng-py.h" /* XXX debug only */
#include "rpmte-py.h" /* XXX debug only */
#include "rpmts-py.h" /* XXX debug only */
@@ -32,7 +29,7 @@ static const char * lbl(void * s)
if (o == NULL) return "null";
if (o == Py_None) return "None";
-
+
if (o->ob_type == &PyType_Type) return o->ob_type->tp_name;
@@ -71,10 +68,7 @@ static const char * lbl(void * s)
if (o->ob_type == &PyUnicode_Type) return "Unicode";
if (o->ob_type == &hdr_Type) return "hdr";
- if (o->ob_type == &mpw_Type) return "mpw";
- if (o->ob_type == &rng_Type) return "rng";
if (o->ob_type == &rpmal_Type) return "rpmal";
- if (o->ob_type == &rpmbc_Type) return "rpmbc";
if (o->ob_type == &rpmds_Type) return "rpmds";
if (o->ob_type == &rpmfd_Type) return "rpmfd";
if (o->ob_type == &rpmfi_Type) return "rpmfi";
diff --git a/python/rpmds-py.c b/python/rpmds-py.c
index 7862db4c8..f2035164b 100644
--- a/python/rpmds-py.c
+++ b/python/rpmds-py.c
@@ -1,4 +1,4 @@
-/** \ingroup py_c
+/** \ingroup py_c
* \file python/rpmds-py.c
*/
@@ -146,7 +146,7 @@ rpmds_iternext(rpmdsObject * s)
PyTuple_SET_ITEM(result, 1, Py_BuildValue("s", EVR));
PyTuple_SET_ITEM(result, 2, PyInt_FromLong(Flags));
}
-
+
} else
s->active = 0;
@@ -235,7 +235,7 @@ static struct PyMethodDef rpmds_methods[] = {
"ds.Refs -> Refs - Return current Refs.\n" },
{"next", (PyCFunction)rpmds_Next, METH_VARARGS,
"ds.next() -> (N, EVR, Flags)\n\
-- Retrieve next dependency triple.\n" },
+- Retrieve next dependency triple.\n" },
{"SetNoPromote",(PyCFunction)rpmds_SetNoPromote, METH_VARARGS,
NULL},
{"Notify", (PyCFunction)rpmds_Notify, METH_VARARGS,
diff --git a/python/rpmds-py.h b/python/rpmds-py.h
index 5f45d217f..b0c15b42c 100644
--- a/python/rpmds-py.h
+++ b/python/rpmds-py.h
@@ -3,7 +3,7 @@
#include "rpmds.h"
-/** \ingroup py_c
+/** \ingroup py_c
* \file python/rpmds-py.h
*/
diff --git a/python/rpmfd-py.c b/python/rpmfd-py.c
index 354797887..e3ae9c65d 100644
--- a/python/rpmfd-py.c
+++ b/python/rpmfd-py.c
@@ -1,4 +1,4 @@
-/** \ingroup py_c
+/** \ingroup py_c
* \file python/rpmfd-py.c
*/
@@ -91,7 +91,7 @@ static int closeCallback(FILE * f)
node->fd = fdFree(node->fd, "closeCallback");
node = _free (node);
}
- return 0;
+ return 0;
}
/**
@@ -104,12 +104,12 @@ rpmfd_Fopen(/*@unused@*/ PyObject * s, PyObject * args)
char * path;
char * mode = "r.ufdio";
FDlist *node;
-
+
if (!PyArg_ParseTuple(args, "s|s", &path, &mode))
return NULL;
-
+
node = xmalloc (sizeof(FDlist));
-
+
node->fd = Fopen(path, mode);
node->fd = fdLink(node->fd, "doFopen");
node->note = xstrdup (path);
@@ -119,7 +119,7 @@ rpmfd_Fopen(/*@unused@*/ PyObject * s, PyObject * args)
node = _free (node);
return NULL;
}
-
+
if (Ferror(node->fd)) {
const char *err = Fstrerror(node->fd);
node = _free(node);
@@ -144,11 +144,11 @@ rpmfd_Fopen(/*@unused@*/ PyObject * s, PyObject * args)
fdhead = node;
}
fdtail = node;
-
+
return PyFile_FromFile (node->f, path, mode, closeCallback);
}
-/** \ingroup py_c
+/** \ingroup py_c
*/
/*@-fullinitblock@*/
/*@unchecked@*/ /*@observer@*/
@@ -163,7 +163,7 @@ static struct PyMethodDef rpmfd_methods[] = {
/* ---------- */
-/** \ingroup py_c
+/** \ingroup py_c
*/
static void
rpmfd_dealloc(/*@only@*/ /*@null@*/ rpmfdObject * s)
@@ -188,7 +188,7 @@ static int rpmfd_setattro(PyObject * o, PyObject * n, PyObject * v)
return PyObject_GenericSetAttr(o, n, v);
}
-/** \ingroup py_c
+/** \ingroup py_c
*/
static int rpmfd_init(rpmfdObject * s, PyObject *args, PyObject *kwds)
/*@modifies s @*/
@@ -220,7 +220,7 @@ fprintf(stderr, "*** rpmfd_init(%p,%p,%p)\n", s, args, kwds);
return 0;
}
-/** \ingroup py_c
+/** \ingroup py_c
*/
static void rpmfd_free(/*@only@*/ rpmfdObject * s)
/*@modifies s @*/
@@ -233,7 +233,7 @@ fprintf(stderr, "%p -- fd %p\n", s, s->fd);
PyObject_Del((PyObject *)s);
}
-/** \ingroup py_c
+/** \ingroup py_c
*/
static PyObject * rpmfd_alloc(PyTypeObject * subtype, int nitems)
/*@*/
@@ -245,7 +245,7 @@ fprintf(stderr, "*** rpmfd_alloc(%p,%d) ret %p\n", subtype, nitems, s);
return s;
}
-/** \ingroup py_c
+/** \ingroup py_c
*/
static rpmfdObject * rpmfd_new(PyTypeObject * subtype, PyObject *args, PyObject *kwds)
/*@*/
@@ -270,7 +270,7 @@ fprintf(stderr, "%p ++ fd %p\n", s, s->fd);
static char rpmfd_doc[] =
"";
-/** \ingroup py_c
+/** \ingroup py_c
*/
/*@-fullinitblock@*/
PyTypeObject rpmfd_Type = {
diff --git a/python/rpmfd-py.h b/python/rpmfd-py.h
index 23e230836..edea5e8ae 100644
--- a/python/rpmfd-py.h
+++ b/python/rpmfd-py.h
@@ -1,7 +1,7 @@
#ifndef H_RPMFD_PY
#define H_RPMFD_PY
-/** \ingroup py_c
+/** \ingroup py_c
* \file python/rpmfd-py.h
*/
diff --git a/python/rpmfi-py.c b/python/rpmfi-py.c
index 54af9626d..bd77e15fa 100644
--- a/python/rpmfi-py.c
+++ b/python/rpmfi-py.c
@@ -1,4 +1,4 @@
-/** \ingroup py_c
+/** \ingroup py_c
* \file python/rpmfi-py.c
*/
@@ -126,7 +126,7 @@ rpmfi_MD5(rpmfiObject * s, PyObject * args)
char fmd5[33];
char * t;
int i;
-
+
if (!PyArg_ParseTuple(args, ":MD5")) return NULL;
MD5 = rpmfiMD5(s->fi);
for (i = 0, t = fmd5; i < 16; i++, t += 2)
diff --git a/python/rpmfi-py.h b/python/rpmfi-py.h
index 84b95b9ca..e721a349b 100644
--- a/python/rpmfi-py.h
+++ b/python/rpmfi-py.h
@@ -3,7 +3,7 @@
#include "rpmfi.h"
-/** \ingroup py_c
+/** \ingroup py_c
* \file python/rpmfi-py.h
*/
diff --git a/python/rpmfts-py.c b/python/rpmfts-py.c
index 1d3f845ad..eee87e1c3 100644
--- a/python/rpmfts-py.c
+++ b/python/rpmfts-py.c
@@ -1,4 +1,4 @@
-/** \ingroup py_c
+/** \ingroup py_c
* \file python/rpmfts-py.c
*/
@@ -48,7 +48,7 @@ static const char * ftsInfoStr(int fts_info)
/*@*/
{
if (!(fts_info >= 1 && fts_info <= 14))
- fts_info = 0;
+ fts_info = 0;
return ftsInfoStrings[ fts_info ];
}
@@ -88,7 +88,7 @@ rpmfts_initialize(rpmftsObject * s, const char * root, int options, int ignore)
s->roots[0] = t;
s->roots[ac] = NULL;
(void) stpcpy(t, root);
-
+
s->options = options;
s->ignore = ignore;
s->compare = NULL;
@@ -267,7 +267,7 @@ rpmfts_debug(__FUNCTION__, s);
return Py_BuildValue("i", rc);
}
-/** \ingroup py_c
+/** \ingroup py_c
*/
/*@-fullinitblock@*/
/*@unchecked@*/ /*@observer@*/
@@ -294,13 +294,13 @@ static PyMemberDef rpmfts_members[] = {
{"__dict__",T_OBJECT,offsetof(rpmftsObject, md_dict), READONLY,
NULL},
{"callbacks",T_OBJECT,offsetof(rpmftsObject, callbacks), 0,
-"Callback dictionary per fts_info state: FTS_{D|DC|DEFAULT|DNR|DOT|DP|ERR|F|INIT|NS|NSOK|SL|SLNONE|W}"},
+"Callback dictionary per fts_info state: FTS_{D|DC|DEFAULT|DNR|DOT|DP|ERR|F|INIT|NS|NSOK|SL|SLNONE|W}"},
{"options", T_INT, offsetof(rpmftsObject, options), 0,
"Option bit(s): FTS_{COMFOLLOW|LOGICAL|NOCHDIR|NOSTAT|PHYSICAL|SEEDOT|XDEV}"},
{"ignore", T_INT, offsetof(rpmftsObject, ignore), 0,
-"Ignore bit(s): (1 << info) with info one of FTS_{D|DC|DEFAULT|DNR|DOT|DP|ERR|F|INIT|NS|NSOK|SL|SLNONE|W}"},
+"Ignore bit(s): (1 << info) with info one of FTS_{D|DC|DEFAULT|DNR|DOT|DP|ERR|F|INIT|NS|NSOK|SL|SLNONE|W}"},
{NULL, 0, 0, 0, NULL}
-};
+};
static PyObject * rpmfts_getattro(PyObject * o, PyObject * n)
/*@*/
@@ -454,7 +454,7 @@ rpmfts_debug(__FUNCTION__, s);
CONSTANT(FTS_DONTCHDIR);
CONSTANT(FTS_SYMFOLLOW);
-
+
CONSTANT(FTS_AGAIN);
CONSTANT(FTS_FOLLOW);
CONSTANT(FTS_NOINSTR);
@@ -505,7 +505,7 @@ static int rpmfts_print(rpmftsObject * s, FILE * fp, /*@unused@*/ int flags)
static char rpmfts_doc[] =
"";
-/** \ingroup py_c
+/** \ingroup py_c
*/
/*@-fullinitblock@*/
PyTypeObject rpmfts_Type = {
diff --git a/python/rpmfts-py.h b/python/rpmfts-py.h
index 90aa2afc0..d6b4b411a 100644
--- a/python/rpmfts-py.h
+++ b/python/rpmfts-py.h
@@ -1,7 +1,7 @@
#ifndef H_RPMFTS_PY
#define H_RPMFTS_PY
-/** \ingroup py_c
+/** \ingroup py_c
* \file python/rpmfts-py.h
*/
diff --git a/python/rpmmi-py.c b/python/rpmmi-py.c
index 3023968e7..5fc40207f 100644
--- a/python/rpmmi-py.c
+++ b/python/rpmmi-py.c
@@ -1,4 +1,4 @@
-/** \ingroup py_c
+/** \ingroup py_c
* \file python/rpmmi-py.c
*/
@@ -90,7 +90,7 @@ rpmmi_iternext(rpmmiObject * s)
/*@modifies s, rpmGlobalMacroContext @*/
{
Header h;
-
+
if (s->mi == NULL || (h = rpmdbNextIterator(s->mi)) == NULL) {
s->mi = rpmdbFreeIterator(s->mi);
return NULL;
@@ -106,7 +106,7 @@ rpmmi_Next(rpmmiObject * s, PyObject *args)
/*@modifies s, rpmGlobalMacroContext, _Py_NoneStruct @*/
{
PyObject * result;
-
+
if (!PyArg_ParseTuple(args, ":Next"))
return NULL;
@@ -164,7 +164,7 @@ rpmmi_Pattern(rpmmiObject * s, PyObject * args)
int type;
char * pattern;
rpmTag tag;
-
+
if (!PyArg_ParseTuple(args, "Ois:Pattern", &TagN, &type, &pattern))
return NULL;
@@ -177,10 +177,10 @@ rpmmi_Pattern(rpmmiObject * s, PyObject * args)
Py_INCREF (Py_None);
return Py_None;
-
+
}
-/** \ingroup py_c
+/** \ingroup py_c
*/
/*@-fullinitblock@*/
/*@unchecked@*/ /*@observer@*/
@@ -199,7 +199,7 @@ static struct PyMethodDef rpmmi_methods[] = {
};
/*@=fullinitblock@*/
-/** \ingroup py_c
+/** \ingroup py_c
*/
static void rpmmi_dealloc(/*@only@*/ /*@null@*/ rpmmiObject * s)
/*@globals rpmGlobalMacroContext @*/
@@ -229,7 +229,7 @@ static int rpmmi_setattro(PyObject * o, PyObject * n, PyObject * v)
static char rpmmi_doc[] =
"";
-/** \ingroup py_c
+/** \ingroup py_c
*/
/*@-fullinitblock@*/
PyTypeObject rpmmi_Type = {
diff --git a/python/rpmmi-py.h b/python/rpmmi-py.h
index 712b12f83..4c08bd63e 100644
--- a/python/rpmmi-py.h
+++ b/python/rpmmi-py.h
@@ -1,15 +1,15 @@
#ifndef H_RPMMI_PY
#define H_RPMMI_PY
-/** \ingroup py_c
+/** \ingroup py_c
* \file python/rpmmi-py.h
*/
-/** \ingroup py_c
+/** \ingroup py_c
*/
typedef struct rpmmiObject_s rpmmiObject;
-/** \ingroup py_c
+/** \ingroup py_c
*/
struct rpmmiObject_s {
PyObject_HEAD
diff --git a/python/rpmmodule.c b/python/rpmmodule.c
index 1d70f65ea..7fecd2bfb 100644
--- a/python/rpmmodule.c
+++ b/python/rpmmodule.c
@@ -1,4 +1,4 @@
-/** \ingroup py_c
+/** \ingroup py_c
* \file python/rpmmodule.c
*/
@@ -19,10 +19,6 @@
#include "header_internal.h"
#include "header-py.h"
-#include "rpmbc-py.h"
-#include "rpmmpw-py.h"
-#include "rpmrng-py.h"
-
#include "rpmal-py.h"
#include "rpmds-py.h"
#include "rpmfd-py.h"
@@ -187,10 +183,7 @@ void initrpm(void)
#if Py_TPFLAGS_HAVE_ITER /* XXX backport to python-1.5.2 */
if (PyType_Ready(&hdr_Type) < 0) return;
- if (PyType_Ready(&mpw_Type) < 0) return;
- if (PyType_Ready(&rng_Type) < 0) return;
if (PyType_Ready(&rpmal_Type) < 0) return;
- if (PyType_Ready(&rpmbc_Type) < 0) return;
if (PyType_Ready(&rpmds_Type) < 0) return;
if (PyType_Ready(&rpmfd_Type) < 0) return;
if (PyType_Ready(&rpmfts_Type) < 0) return;
@@ -226,18 +219,9 @@ void initrpm(void)
Py_INCREF(&hdr_Type);
PyModule_AddObject(m, "hdr", (PyObject *) &hdr_Type);
- Py_INCREF(&mpw_Type);
- PyModule_AddObject(m, "mpw", (PyObject *) &mpw_Type);
-
- Py_INCREF(&rng_Type);
- PyModule_AddObject(m, "rng", (PyObject *) &rng_Type);
-
Py_INCREF(&rpmal_Type);
PyModule_AddObject(m, "al", (PyObject *) &rpmal_Type);
- Py_INCREF(&rpmbc_Type);
- PyModule_AddObject(m, "bc", (PyObject *) &rpmbc_Type);
-
Py_INCREF(&rpmds_Type);
PyModule_AddObject(m, "ds", (PyObject *) &rpmds_Type);
@@ -263,10 +247,7 @@ void initrpm(void)
PyModule_AddObject(m, "ts", (PyObject *) &rpmts_Type);
#else
hdr_Type.ob_type = &PyType_Type;
- mpw_Type.ob_type = &PyType_Type;
- rng_Type.ob_type = &PyType_Type;
rpmal_Type.ob_type = &PyType_Type;
- rpmbc_Type.ob_type = &PyType_Type;
rpmds_Type.ob_type = &PyType_Type;
rpmfd_Type.ob_type = &PyType_Type;
rpmfts_Type.ob_type = &PyType_Type;
@@ -292,7 +273,7 @@ void initrpm(void)
PyDict_SetItemString(d, (char *) extensions->name, o=PyCObject_FromVoidPtr(ext, NULL));
Py_DECREF(o);
PyDict_SetItem(dict, tag, o=PyString_FromString(ext->name + 7));
- Py_DECREF(o);
+ Py_DECREF(o);
}
extensions++;
}
@@ -304,7 +285,7 @@ void initrpm(void)
#define REGISTER_ENUM(val) \
PyDict_SetItemString(d, #val, o=PyInt_FromLong( val )); \
Py_DECREF(o);
-
+
REGISTER_ENUM(RPMFILE_STATE_NORMAL);
REGISTER_ENUM(RPMFILE_STATE_REPLACED);
REGISTER_ENUM(RPMFILE_STATE_NOTINSTALLED);
diff --git a/python/rpmmpw-py.c b/python/rpmmpw-py.c
deleted file mode 100644
index 3bf1912f0..000000000
--- a/python/rpmmpw-py.c
+++ /dev/null
@@ -1,2340 +0,0 @@
-/** \ingroup py_c
- * \file python/rpmmpw-py.c
- */
-
-#include "system.h"
-
-#include "Python.h"
-#include "longintrepr.h"
-
-#ifdef __LCLINT__
-#undef PyObject_HEAD
-#define PyObject_HEAD int _PyObjectHead;
-#endif
-
-#include "rpmmpw-py.h"
-#include "rpmrng-py.h"
-
-#include "rpmdebug-py.c"
-
-#include "debug.h"
-
-#define ABS(_x) ((_x) < 0 ? -(_x) : (_x))
-
-#define MPBITCNT(_s, _d) (MP_WORDS_TO_BITS(_s) - mpmszcnt((_s), (_d)))
-
-#define BITS_TO_DIGITS(_b) (((_b) + SHIFT - 1)/SHIFT)
-#define DIGITS_TO_BITS(_d) ((_d) * SHIFT)
-
-/*@unchecked@*/
-static int _ie = 0x44332211;
-/*@unchecked@*/
-static union _dendian {
-/*@unused@*/
- int i;
- char b[4];
-} *_endian = (union _dendian *)&_ie;
-#define IS_BIG_ENDIAN() (_endian->b[0] == '\x44')
-#define IS_LITTLE_ENDIAN() (_endian->b[0] == '\x11')
-
-/*@unchecked@*/
-static int _mpw_debug = 0;
-
-/*@unchecked@*/ /*@observer@*/
-static const char *initialiser_name = "";
-
-/*@unchecked@*/ /*@observer@*/
-static const struct {
- /* Number of digits in the conversion base that always fits in an mp_limb_t.
- For example, for base 10 on a machine where a mp_limb_t has 32 bits this
- is 9, since 10**9 is the largest number that fits into a mp_limb_t. */
- int chars_per_limb;
-
- /* log(2)/log(conversion_base) */
- double chars_per_bit_exactly;
-
- /* base**chars_per_limb, i.e. the biggest number that fits a word, built by
- factors of base. Exception: For 2, 4, 8, etc, big_base is log2(base),
- i.e. the number of bits used to represent each digit in the base. */
- unsigned int big_base;
-
- /* A BITS_PER_MP_LIMB bit approximation to 1/big_base, represented as a
- fixed-point number. Instead of dividing by big_base an application can
- choose to multiply by big_base_inverted. */
- unsigned int big_base_inverted;
-} mp_bases[257] = {
- /* 0 */ {0, 0.0, 0, 0},
- /* 1 */ {0, 1e37, 0, 0},
- /* 2 */ {32, 1.0000000000000000, 0x1, 0x0},
- /* 3 */ {20, 0.6309297535714574, 0xcfd41b91, 0x3b563c24},
- /* 4 */ {16, 0.5000000000000000, 0x2, 0x0},
- /* 5 */ {13, 0.4306765580733931, 0x48c27395, 0xc25c2684},
- /* 6 */ {12, 0.3868528072345416, 0x81bf1000, 0xf91bd1b6},
- /* 7 */ {11, 0.3562071871080222, 0x75db9c97, 0x1607a2cb},
- /* 8 */ {10, 0.3333333333333333, 0x3, 0x0},
- /* 9 */ {10, 0.3154648767857287, 0xcfd41b91, 0x3b563c24},
- /* 10 */ {9, 0.3010299956639812, 0x3b9aca00, 0x12e0be82},
- /* 11 */ {9, 0.2890648263178878, 0x8c8b6d2b, 0xd24cde04},
- /* 12 */ {8, 0.2789429456511298, 0x19a10000, 0x3fa39ab5},
- /* 13 */ {8, 0.2702381544273197, 0x309f1021, 0x50f8ac5f},
- /* 14 */ {8, 0.2626495350371935, 0x57f6c100, 0x74843b1e},
- /* 15 */ {8, 0.2559580248098155, 0x98c29b81, 0xad0326c2},
- /* 16 */ {8, 0.2500000000000000, 0x4, 0x0},
- /* 17 */ {7, 0.2446505421182260, 0x18754571, 0x4ef0b6bd},
- /* 18 */ {7, 0.2398124665681314, 0x247dbc80, 0xc0fc48a1},
- /* 19 */ {7, 0.2354089133666382, 0x3547667b, 0x33838942},
- /* 20 */ {7, 0.2313782131597592, 0x4c4b4000, 0xad7f29ab},
- /* 21 */ {7, 0.2276702486969530, 0x6b5a6e1d, 0x313c3d15},
- /* 22 */ {7, 0.2242438242175754, 0x94ace180, 0xb8cca9e0},
- /* 23 */ {7, 0.2210647294575037, 0xcaf18367, 0x42ed6de9},
- /* 24 */ {6, 0.2181042919855316, 0xb640000, 0x67980e0b},
- /* 25 */ {6, 0.2153382790366965, 0xe8d4a51, 0x19799812},
- /* 26 */ {6, 0.2127460535533632, 0x1269ae40, 0xbce85396},
- /* 27 */ {6, 0.2103099178571525, 0x17179149, 0x62c103a9},
- /* 28 */ {6, 0.2080145976765095, 0x1cb91000, 0x1d353d43},
- /* 29 */ {6, 0.2058468324604344, 0x23744899, 0xce1decea},
- /* 30 */ {6, 0.2037950470905062, 0x2b73a840, 0x790fc511},
- /* 31 */ {6, 0.2018490865820999, 0x34e63b41, 0x35b865a0},
- /* 32 */ {6, 0.2000000000000000, 0x5, 0x0},
- /* 33 */ {6, 0.1982398631705605, 0x4cfa3cc1, 0xa9aed1b3},
- /* 34 */ {6, 0.1965616322328226, 0x5c13d840, 0x63dfc229},
- /* 35 */ {6, 0.1949590218937863, 0x6d91b519, 0x2b0fee30},
- /* 36 */ {6, 0.1934264036172708, 0x81bf1000, 0xf91bd1b6},
- /* 37 */ {6, 0.1919587200065601, 0x98ede0c9, 0xac89c3a9},
- /* 38 */ {6, 0.1905514124267734, 0xb3773e40, 0x6d2c32fe},
- /* 39 */ {6, 0.1892003595168700, 0xd1bbc4d1, 0x387907c9},
- /* 40 */ {6, 0.1879018247091076, 0xf4240000, 0xc6f7a0b},
- /* 41 */ {5, 0.1866524112389434, 0x6e7d349, 0x28928154},
- /* 42 */ {5, 0.1854490234153689, 0x7ca30a0, 0x6e8629d},
- /* 43 */ {5, 0.1842888331487062, 0x8c32bbb, 0xd373dca0},
- /* 44 */ {5, 0.1831692509136336, 0x9d46c00, 0xa0b17895},
- /* 45 */ {5, 0.1820879004699383, 0xaffacfd, 0x746811a5},
- /* 46 */ {5, 0.1810425967800402, 0xc46bee0, 0x4da6500f},
- /* 47 */ {5, 0.1800313266566926, 0xdab86ef, 0x2ba23582},
- /* 48 */ {5, 0.1790522317510414, 0xf300000, 0xdb20a88},
- /* 49 */ {5, 0.1781035935540111, 0x10d63af1, 0xe68d5ce4},
- /* 50 */ {5, 0.1771838201355579, 0x12a05f20, 0xb7cdfd9d},
- /* 51 */ {5, 0.1762914343888821, 0x1490aae3, 0x8e583933},
- /* 52 */ {5, 0.1754250635819545, 0x16a97400, 0x697cc3ea},
- /* 53 */ {5, 0.1745834300480449, 0x18ed2825, 0x48a5ca6c},
- /* 54 */ {5, 0.1737653428714400, 0x1b5e4d60, 0x2b52db16},
- /* 55 */ {5, 0.1729696904450771, 0x1dff8297, 0x111586a6},
- /* 56 */ {5, 0.1721954337940981, 0x20d38000, 0xf31d2b36},
- /* 57 */ {5, 0.1714416005739134, 0x23dd1799, 0xc8d76d19},
- /* 58 */ {5, 0.1707072796637201, 0x271f35a0, 0xa2cb1eb4},
- /* 59 */ {5, 0.1699916162869140, 0x2a9ce10b, 0x807c3ec3},
- /* 60 */ {5, 0.1692938075987814, 0x2e593c00, 0x617ec8bf},
- /* 61 */ {5, 0.1686130986895011, 0x3257844d, 0x45746cbe},
- /* 62 */ {5, 0.1679487789570419, 0x369b13e0, 0x2c0aa273},
- /* 63 */ {5, 0.1673001788101741, 0x3b27613f, 0x14f90805},
- /* 64 */ {5, 0.1666666666666667, 0x6, 0x0},
- /* 65 */ {5, 0.1660476462159378, 0x4528a141, 0xd9cf0829},
- /* 66 */ {5, 0.1654425539190583, 0x4aa51420, 0xb6fc4841},
- /* 67 */ {5, 0.1648508567221603, 0x50794633, 0x973054cb},
- /* 68 */ {5, 0.1642720499620502, 0x56a94400, 0x7a1dbe4b},
- /* 69 */ {5, 0.1637056554452156, 0x5d393975, 0x5f7fcd7f},
- /* 70 */ {5, 0.1631512196835108, 0x642d7260, 0x47196c84},
- /* 71 */ {5, 0.1626083122716342, 0x6b8a5ae7, 0x30b43635},
- /* 72 */ {5, 0.1620765243931223, 0x73548000, 0x1c1fa5f6},
- /* 73 */ {5, 0.1615554674429964, 0x7b908fe9, 0x930634a},
- /* 74 */ {5, 0.1610447717564444, 0x84435aa0, 0xef7f4a3c},
- /* 75 */ {5, 0.1605440854340214, 0x8d71d25b, 0xcf5552d2},
- /* 76 */ {5, 0.1600530732548213, 0x97210c00, 0xb1a47c8e},
- /* 77 */ {5, 0.1595714156699382, 0xa1563f9d, 0x9634b43e},
- /* 78 */ {5, 0.1590988078692941, 0xac16c8e0, 0x7cd3817d},
- /* 79 */ {5, 0.1586349589155960, 0xb768278f, 0x65536761},
- /* 80 */ {5, 0.1581795909397823, 0xc3500000, 0x4f8b588e},
- /* 81 */ {5, 0.1577324383928644, 0xcfd41b91, 0x3b563c24},
- /* 82 */ {5, 0.1572932473495469, 0xdcfa6920, 0x28928154},
- /* 83 */ {5, 0.1568617748594410, 0xeac8fd83, 0x1721bfb0},
- /* 84 */ {5, 0.1564377883420715, 0xf9461400, 0x6e8629d},
- /* 85 */ {4, 0.1560210650222250, 0x31c84b1, 0x491cc17c},
- /* 86 */ {4, 0.1556113914024939, 0x342ab10, 0x3a11d83b},
- /* 87 */ {4, 0.1552085627701551, 0x36a2c21, 0x2be074cd},
- /* 88 */ {4, 0.1548123827357682, 0x3931000, 0x1e7a02e7},
- /* 89 */ {4, 0.1544226628011101, 0x3bd5ee1, 0x11d10edd},
- /* 90 */ {4, 0.1540392219542636, 0x3e92110, 0x5d92c68},
- /* 91 */ {4, 0.1536618862898642, 0x4165ef1, 0xf50dbfb2},
- /* 92 */ {4, 0.1532904886526781, 0x4452100, 0xdf9f1316},
- /* 93 */ {4, 0.1529248683028321, 0x4756fd1, 0xcb52a684},
- /* 94 */ {4, 0.1525648706011593, 0x4a75410, 0xb8163e97},
- /* 95 */ {4, 0.1522103467132434, 0x4dad681, 0xa5d8f269},
- /* 96 */ {4, 0.1518611533308632, 0x5100000, 0x948b0fcd},
- /* 97 */ {4, 0.1515171524096389, 0x546d981, 0x841e0215},
- /* 98 */ {4, 0.1511782109217764, 0x57f6c10, 0x74843b1e},
- /* 99 */ {4, 0.1508442006228941, 0x5b9c0d1, 0x65b11e6e},
- /* 100 */ {4, 0.1505149978319906, 0x5f5e100, 0x5798ee23},
- /* 101 */ {4, 0.1501904832236880, 0x633d5f1, 0x4a30b99b},
- /* 102 */ {4, 0.1498705416319474, 0x673a910, 0x3d6e4d94},
- /* 103 */ {4, 0.1495550618645152, 0x6b563e1, 0x314825b0},
- /* 104 */ {4, 0.1492439365274121, 0x6f91000, 0x25b55f2e},
- /* 105 */ {4, 0.1489370618588283, 0x73eb721, 0x1aadaccb},
- /* 106 */ {4, 0.1486343375718350, 0x7866310, 0x10294ba2},
- /* 107 */ {4, 0.1483356667053617, 0x7d01db1, 0x620f8f6},
- /* 108 */ {4, 0.1480409554829326, 0x81bf100, 0xf91bd1b6},
- /* 109 */ {4, 0.1477501131786861, 0x869e711, 0xe6d37b2a},
- /* 110 */ {4, 0.1474630519902391, 0x8ba0a10, 0xd55cff6e},
- /* 111 */ {4, 0.1471796869179852, 0x90c6441, 0xc4ad2db2},
- /* 112 */ {4, 0.1468999356504447, 0x9610000, 0xb4b985cf},
- /* 113 */ {4, 0.1466237184553111, 0x9b7e7c1, 0xa5782bef},
- /* 114 */ {4, 0.1463509580758620, 0xa112610, 0x96dfdd2a},
- /* 115 */ {4, 0.1460815796324244, 0xa6cc591, 0x88e7e509},
- /* 116 */ {4, 0.1458155105286054, 0xacad100, 0x7b8813d3},
- /* 117 */ {4, 0.1455526803620167, 0xb2b5331, 0x6eb8b595},
- /* 118 */ {4, 0.1452930208392429, 0xb8e5710, 0x627289db},
- /* 119 */ {4, 0.1450364656948130, 0xbf3e7a1, 0x56aebc07},
- /* 120 */ {4, 0.1447829506139581, 0xc5c1000, 0x4b66dc33},
- /* 121 */ {4, 0.1445324131589439, 0xcc6db61, 0x4094d8a3},
- /* 122 */ {4, 0.1442847926987864, 0xd345510, 0x3632f7a5},
- /* 123 */ {4, 0.1440400303421672, 0xda48871, 0x2c3bd1f0},
- /* 124 */ {4, 0.1437980688733776, 0xe178100, 0x22aa4d5f},
- /* 125 */ {4, 0.1435588526911310, 0xe8d4a51, 0x19799812},
- /* 126 */ {4, 0.1433223277500932, 0xf05f010, 0x10a523e5},
- /* 127 */ {4, 0.1430884415049874, 0xf817e01, 0x828a237},
- /* 128 */ {4, 0.1428571428571428, 0x7, 0x0},
- /* 129 */ {4, 0.1426283821033600, 0x10818201, 0xf04ec452},
- /* 130 */ {4, 0.1424021108869747, 0x11061010, 0xe136444a},
- /* 131 */ {4, 0.1421782821510107, 0x118db651, 0xd2af9589},
- /* 132 */ {4, 0.1419568500933153, 0x12188100, 0xc4b42a83},
- /* 133 */ {4, 0.1417377701235801, 0x12a67c71, 0xb73dccf5},
- /* 134 */ {4, 0.1415209988221527, 0x1337b510, 0xaa4698c5},
- /* 135 */ {4, 0.1413064939005528, 0x13cc3761, 0x9dc8f729},
- /* 136 */ {4, 0.1410942141636095, 0x14641000, 0x91bf9a30},
- /* 137 */ {4, 0.1408841194731412, 0x14ff4ba1, 0x86257887},
- /* 138 */ {4, 0.1406761707131039, 0x159df710, 0x7af5c98c},
- /* 139 */ {4, 0.1404703297561400, 0x16401f31, 0x702c01a0},
- /* 140 */ {4, 0.1402665594314587, 0x16e5d100, 0x65c3ceb1},
- /* 141 */ {4, 0.1400648234939879, 0x178f1991, 0x5bb91502},
- /* 142 */ {4, 0.1398650865947379, 0x183c0610, 0x5207ec23},
- /* 143 */ {4, 0.1396673142523192, 0x18eca3c1, 0x48ac9c19},
- /* 144 */ {4, 0.1394714728255649, 0x19a10000, 0x3fa39ab5},
- /* 145 */ {4, 0.1392775294872041, 0x1a592841, 0x36e98912},
- /* 146 */ {4, 0.1390854521985406, 0x1b152a10, 0x2e7b3140},
- /* 147 */ {4, 0.1388952096850913, 0x1bd51311, 0x2655840b},
- /* 148 */ {4, 0.1387067714131417, 0x1c98f100, 0x1e7596ea},
- /* 149 */ {4, 0.1385201075671774, 0x1d60d1b1, 0x16d8a20d},
- /* 150 */ {4, 0.1383351890281539, 0x1e2cc310, 0xf7bfe87},
- /* 151 */ {4, 0.1381519873525671, 0x1efcd321, 0x85d2492},
- /* 152 */ {4, 0.1379704747522905, 0x1fd11000, 0x179a9f4},
- /* 153 */ {4, 0.1377906240751463, 0x20a987e1, 0xf59e80eb},
- /* 154 */ {4, 0.1376124087861776, 0x21864910, 0xe8b768db},
- /* 155 */ {4, 0.1374358029495937, 0x226761f1, 0xdc39d6d5},
- /* 156 */ {4, 0.1372607812113589, 0x234ce100, 0xd021c5d1},
- /* 157 */ {4, 0.1370873187823978, 0x2436d4d1, 0xc46b5e37},
- /* 158 */ {4, 0.1369153914223921, 0x25254c10, 0xb912f39c},
- /* 159 */ {4, 0.1367449754241439, 0x26185581, 0xae150294},
- /* 160 */ {4, 0.1365760475984821, 0x27100000, 0xa36e2eb1},
- /* 161 */ {4, 0.1364085852596902, 0x280c5a81, 0x991b4094},
- /* 162 */ {4, 0.1362425662114337, 0x290d7410, 0x8f19241e},
- /* 163 */ {4, 0.1360779687331669, 0x2a135bd1, 0x8564e6b7},
- /* 164 */ {4, 0.1359147715670014, 0x2b1e2100, 0x7bfbb5b4},
- /* 165 */ {4, 0.1357529539050150, 0x2c2dd2f1, 0x72dadcc8},
- /* 166 */ {4, 0.1355924953769864, 0x2d428110, 0x69ffc498},
- /* 167 */ {4, 0.1354333760385373, 0x2e5c3ae1, 0x6167f154},
- /* 168 */ {4, 0.1352755763596663, 0x2f7b1000, 0x5911016e},
- /* 169 */ {4, 0.1351190772136599, 0x309f1021, 0x50f8ac5f},
- /* 170 */ {4, 0.1349638598663645, 0x31c84b10, 0x491cc17c},
- /* 171 */ {4, 0.1348099059658080, 0x32f6d0b1, 0x417b26d8},
- /* 172 */ {4, 0.1346571975321549, 0x342ab100, 0x3a11d83b},
- /* 173 */ {4, 0.1345057169479844, 0x3563fc11, 0x32dee622},
- /* 174 */ {4, 0.1343554469488779, 0x36a2c210, 0x2be074cd},
- /* 175 */ {4, 0.1342063706143054, 0x37e71341, 0x2514bb58},
- /* 176 */ {4, 0.1340584713587979, 0x39310000, 0x1e7a02e7},
- /* 177 */ {4, 0.1339117329233981, 0x3a8098c1, 0x180ea5d0},
- /* 178 */ {4, 0.1337661393673756, 0x3bd5ee10, 0x11d10edd},
- /* 179 */ {4, 0.1336216750601996, 0x3d311091, 0xbbfb88e},
- /* 180 */ {4, 0.1334783246737591, 0x3e921100, 0x5d92c68},
- /* 181 */ {4, 0.1333360731748201, 0x3ff90031, 0x1c024c},
- /* 182 */ {4, 0.1331949058177136, 0x4165ef10, 0xf50dbfb2},
- /* 183 */ {4, 0.1330548081372441, 0x42d8eea1, 0xea30efa3},
- /* 184 */ {4, 0.1329157659418126, 0x44521000, 0xdf9f1316},
- /* 185 */ {4, 0.1327777653067443, 0x45d16461, 0xd555c0c9},
- /* 186 */ {4, 0.1326407925678156, 0x4756fd10, 0xcb52a684},
- /* 187 */ {4, 0.1325048343149731, 0x48e2eb71, 0xc193881f},
- /* 188 */ {4, 0.1323698773862368, 0x4a754100, 0xb8163e97},
- /* 189 */ {4, 0.1322359088617821, 0x4c0e0f51, 0xaed8b724},
- /* 190 */ {4, 0.1321029160581950, 0x4dad6810, 0xa5d8f269},
- /* 191 */ {4, 0.1319708865228925, 0x4f535d01, 0x9d15039d},
- /* 192 */ {4, 0.1318398080287045, 0x51000000, 0x948b0fcd},
- /* 193 */ {4, 0.1317096685686114, 0x52b36301, 0x8c394d1d},
- /* 194 */ {4, 0.1315804563506306, 0x546d9810, 0x841e0215},
- /* 195 */ {4, 0.1314521597928493, 0x562eb151, 0x7c3784f8},
- /* 196 */ {4, 0.1313247675185968, 0x57f6c100, 0x74843b1e},
- /* 197 */ {4, 0.1311982683517524, 0x59c5d971, 0x6d02985d},
- /* 198 */ {4, 0.1310726513121843, 0x5b9c0d10, 0x65b11e6e},
- /* 199 */ {4, 0.1309479056113158, 0x5d796e61, 0x5e8e5c64},
- /* 200 */ {4, 0.1308240206478128, 0x5f5e1000, 0x5798ee23},
- /* 201 */ {4, 0.1307009860033912, 0x614a04a1, 0x50cf7bde},
- /* 202 */ {4, 0.1305787914387386, 0x633d5f10, 0x4a30b99b},
- /* 203 */ {4, 0.1304574268895465, 0x65383231, 0x43bb66bd},
- /* 204 */ {4, 0.1303368824626505, 0x673a9100, 0x3d6e4d94},
- /* 205 */ {4, 0.1302171484322746, 0x69448e91, 0x374842ee},
- /* 206 */ {4, 0.1300982152363760, 0x6b563e10, 0x314825b0},
- /* 207 */ {4, 0.1299800734730872, 0x6d6fb2c1, 0x2b6cde75},
- /* 208 */ {4, 0.1298627138972530, 0x6f910000, 0x25b55f2e},
- /* 209 */ {4, 0.1297461274170591, 0x71ba3941, 0x2020a2c5},
- /* 210 */ {4, 0.1296303050907487, 0x73eb7210, 0x1aadaccb},
- /* 211 */ {4, 0.1295152381234257, 0x7624be11, 0x155b891f},
- /* 212 */ {4, 0.1294009178639407, 0x78663100, 0x10294ba2},
- /* 213 */ {4, 0.1292873358018581, 0x7aafdeb1, 0xb160fe9},
- /* 214 */ {4, 0.1291744835645007, 0x7d01db10, 0x620f8f6},
- /* 215 */ {4, 0.1290623529140715, 0x7f5c3a21, 0x14930ef},
- /* 216 */ {4, 0.1289509357448472, 0x81bf1000, 0xf91bd1b6},
- /* 217 */ {4, 0.1288402240804449, 0x842a70e1, 0xefdcb0c7},
- /* 218 */ {4, 0.1287302100711566, 0x869e7110, 0xe6d37b2a},
- /* 219 */ {4, 0.1286208859913518, 0x891b24f1, 0xddfeb94a},
- /* 220 */ {4, 0.1285122442369443, 0x8ba0a100, 0xd55cff6e},
- /* 221 */ {4, 0.1284042773229231, 0x8e2ef9d1, 0xcceced50},
- /* 222 */ {4, 0.1282969778809442, 0x90c64410, 0xc4ad2db2},
- /* 223 */ {4, 0.1281903386569819, 0x93669481, 0xbc9c75f9},
- /* 224 */ {4, 0.1280843525090381, 0x96100000, 0xb4b985cf},
- /* 225 */ {4, 0.1279790124049077, 0x98c29b81, 0xad0326c2},
- /* 226 */ {4, 0.1278743114199984, 0x9b7e7c10, 0xa5782bef},
- /* 227 */ {4, 0.1277702427352035, 0x9e43b6d1, 0x9e1771a9},
- /* 228 */ {4, 0.1276667996348261, 0xa1126100, 0x96dfdd2a},
- /* 229 */ {4, 0.1275639755045533, 0xa3ea8ff1, 0x8fd05c41},
- /* 230 */ {4, 0.1274617638294791, 0xa6cc5910, 0x88e7e509},
- /* 231 */ {4, 0.1273601581921740, 0xa9b7d1e1, 0x8225759d},
- /* 232 */ {4, 0.1272591522708010, 0xacad1000, 0x7b8813d3},
- /* 233 */ {4, 0.1271587398372755, 0xafac2921, 0x750eccf9},
- /* 234 */ {4, 0.1270589147554692, 0xb2b53310, 0x6eb8b595},
- /* 235 */ {4, 0.1269596709794558, 0xb5c843b1, 0x6884e923},
- /* 236 */ {4, 0.1268610025517973, 0xb8e57100, 0x627289db},
- /* 237 */ {4, 0.1267629036018709, 0xbc0cd111, 0x5c80c07b},
- /* 238 */ {4, 0.1266653683442337, 0xbf3e7a10, 0x56aebc07},
- /* 239 */ {4, 0.1265683910770258, 0xc27a8241, 0x50fbb19b},
- /* 240 */ {4, 0.1264719661804097, 0xc5c10000, 0x4b66dc33},
- /* 241 */ {4, 0.1263760881150453, 0xc91209c1, 0x45ef7c7c},
- /* 242 */ {4, 0.1262807514205999, 0xcc6db610, 0x4094d8a3},
- /* 243 */ {4, 0.1261859507142915, 0xcfd41b91, 0x3b563c24},
- /* 244 */ {4, 0.1260916806894653, 0xd3455100, 0x3632f7a5},
- /* 245 */ {4, 0.1259979361142023, 0xd6c16d31, 0x312a60c3},
- /* 246 */ {4, 0.1259047118299582, 0xda488710, 0x2c3bd1f0},
- /* 247 */ {4, 0.1258120027502338, 0xdddab5a1, 0x2766aa45},
- /* 248 */ {4, 0.1257198038592741, 0xe1781000, 0x22aa4d5f},
- /* 249 */ {4, 0.1256281102107963, 0xe520ad61, 0x1e06233c},
- /* 250 */ {4, 0.1255369169267456, 0xe8d4a510, 0x19799812},
- /* 251 */ {4, 0.1254462191960791, 0xec940e71, 0x15041c33},
- /* 252 */ {4, 0.1253560122735751, 0xf05f0100, 0x10a523e5},
- /* 253 */ {4, 0.1252662914786691, 0xf4359451, 0xc5c2749},
- /* 254 */ {4, 0.1251770521943144, 0xf817e010, 0x828a237},
- /* 255 */ {4, 0.1250882898658681, 0xfc05fc01, 0x40a1423},
- /* 256 */ {4, 0.1250000000000000, 0x8, 0x0},
-};
-
-static void prtmpw(const char * msg, mpwObject * x)
- /*@global stderr, fileSystem @*/
- /*@modifies stderr, fileSystem @*/
-{
-fprintf(stderr, "%5.5s %p[%d]:\t", msg, MPW_DATA(x), MPW_SIZE(x)), mpfprintln(stderr, MPW_SIZE(x), MPW_DATA(x));
-}
-
-static size_t
-mpsizeinbase(size_t xsize, mpw* xdata, size_t base)
- /*@*/
-{
- size_t nbits;
- size_t res;
-
- if (xsize == 0)
- return 1;
-
- /* XXX assumes positive integer. */
- nbits = MP_WORDS_TO_BITS(xsize) - mpmszcnt(xsize, xdata);
- if ((base & (base-1)) == 0) { /* exact power of 2 */
- size_t lbits = mp_bases[base].big_base;
- res = (nbits + (lbits - 1)) / lbits;
- } else {
- res = (nbits * mp_bases[base].chars_per_bit_exactly) + 1;
- }
-if (_mpw_debug < -1)
-fprintf(stderr, "*** mpsizeinbase(%p[%d], %d) res %u\n", xdata, xsize, base, (unsigned)res);
- return res;
-}
-
-#ifdef DYING
-/*@-boundswrite@*/
-static void myndivmod(mpw* result, size_t xsize, const mpw* xdata, size_t ysize, const mpw* ydata, register mpw* workspace)
-{
- /* result must be xsize+1 in length */
- /* workspace must be ysize+1 in length */
- /* expect ydata to be normalized */
- mpw q;
- mpw msw = *ydata;
- size_t qsize = xsize-ysize;
-
- *result = (mpge(ysize, xdata, ydata) ? 1 : 0);
- mpcopy(xsize, result+1, xdata);
- if (*result)
- (void) mpsub(ysize, result+1, ydata);
- result++;
-
- while (qsize--)
- {
- q = mppndiv(result[0], result[1], msw);
-
-/*@-evalorder@*/
- *workspace = mpsetmul(ysize, workspace+1, ydata, q);
-/*@=evalorder@*/
-
- while (mplt(ysize+1, result, workspace))
- {
- (void) mpsubx(ysize+1, workspace, ysize, ydata);
- q--;
- }
- (void) mpsub(ysize+1, result, workspace);
- *(result++) = q;
- }
-}
-/*@=boundswrite@*/
-#endif
-
-static char *
-mpstr(char * t, size_t nt, size_t size, mpw* data, mpw base)
- /*@modifies t @*/
-{
- static char bchars[] = "0123456789abcdefghijklmnopqrstuvwxyz";
- size_t asize = size + 1;
- mpw* adata = alloca(asize * sizeof(*adata));
- size_t anorm;
- mpw* zdata = alloca((asize+1) * sizeof(*zdata));
- mpw* wksp = alloca((1+1) * sizeof(*wksp));
- size_t result;
-
-if (_mpw_debug < -1)
-fprintf(stderr, "*** mpstr(%p[%d], %p[%d], %d):\t", t, nt, data, size, base), mpfprintln(stderr, size, data);
-
- mpsetx(asize, adata, size, data);
-
- t[nt] = '\0';
- while (nt--) {
-
- mpndivmod(zdata, asize, adata, 1, &base, wksp);
-
-if (_mpw_debug < -1) {
-fprintf(stderr, " a %p[%d]:\t", adata, asize), mpfprintln(stderr, asize, adata);
-fprintf(stderr, " z %p[%d]:\t", zdata, asize+1), mpfprintln(stderr, asize+1, zdata);
-}
- result = zdata[asize];
- t[nt] = bchars[result];
-
- if (mpz(asize, zdata))
- break;
-
- anorm = asize - mpsize(asize, zdata);
- if (anorm < asize)
- asize -= anorm;
- mpsetx(asize+1, adata, asize, zdata+anorm);
- asize++;
- }
- /* XXX Fill leading zeroes (if any). */
- while (nt--)
- t[nt] = '0';
- return t;
-}
-
-static PyObject *
-mpw_format(mpwObject * z, size_t base, int addL)
- /*@modifies t @*/
-{
- size_t zsize = MPW_SIZE(z);
- mpw* zdata = MPW_DATA(z);
- PyStringObject * so;
- size_t i;
- size_t nt;
- size_t size;
- mpw* data;
- char * t, * te;
- char prefix[5];
- char * tcp = prefix;
- int sign;
-
- if (z == NULL || !mpw_Check(z)) {
- PyErr_BadInternalCall();
- return NULL;
- }
-
-if (_mpw_debug < -1)
-fprintf(stderr, "*** mpw_format(%p,%d,%d):\t", z, base, addL), mpfprintln(stderr, zsize, zdata);
-
- assert(base >= 2 && base <= 36);
-
- i = 0;
- if (addL && initialiser_name != NULL)
- i = strlen(initialiser_name) + 2; /* e.g. 'mpw(' + ')' */
-
- sign = z->ob_size;
- nt = MPBITCNT(zsize, zdata);
- if (nt == 0) {
- base = 10; /* '0' in every base, right */
- nt = 1;
- size = 1;
- data = alloca(size * sizeof(*data));
- *data = 0;
- } else if (sign < 0) {
- *tcp++ = '-';
- i += 1; /* space to hold '-' */
- size = MP_ROUND_B2W(nt);
- data = zdata + (zsize - size);
- } else {
- size = MP_ROUND_B2W(nt);
- data = zdata + (zsize - size);
- }
-
- if (addL && size > 1)
- i++; /* space for 'L' suffix */
-
- nt = mpsizeinbase(size, data, base);
- i += nt;
-
- if (base == 16) {
- *tcp++ = '0';
- *tcp++ = 'x';
- i += 2; /* space to hold '0x' */
- } else if (base == 8) {
- *tcp++ = '0';
- i += 1; /* space to hold the extra '0' */
- } else if (base > 10) {
- *tcp++ = '0' + base / 10;
- *tcp++ = '0' + base % 10;
- *tcp++ = '#';
- i += 3; /* space to hold e.g. '12#' */
- } else if (base < 10) {
- *tcp++ = '0' + base;
- *tcp++ = '#';
- i += 2; /* space to hold e.g. '6#' */
- }
-
- so = (PyStringObject *)PyString_FromStringAndSize((char *)0, i);
- if (so == NULL)
- return NULL;
-
- /* get the beginning of the string memory and start copying things */
- te = PyString_AS_STRING(so);
- if (addL && initialiser_name != NULL && *initialiser_name != '\0') {
- te = stpcpy(te, initialiser_name);
- *te++ = '('; /*')'*/
- }
-
- /* copy the already prepared prefix; e.g. sign and base indicator */
- *tcp = '\0';
- t = te = stpcpy(te, prefix);
-
- (void) mpstr(te, nt, size, data, base);
-
- /* Nuke leading zeroes. */
- nt = 0;
- while (t[nt] == '0')
- nt++;
- if (t[nt] == '\0') /* all zeroes special case. */
- nt--;
- if (nt > 0)
- do {
- *t = t[nt];
- } while (*t++ != '\0');
-
- te += strlen(te);
-
- if (addL) {
- if (size > 1)
- *te++ = 'L';
- if (initialiser_name != NULL && *initialiser_name != '\0')
- *te++ = /*'('*/ ')';
- }
- *te = '\0';
-
- assert(te - PyString_AS_STRING(so) <= i);
-
- if (te - PyString_AS_STRING(so) != i)
- so->ob_size -= i - (te - PyString_AS_STRING(so));
-
- return (PyObject *)so;
-}
-
-/**
- * Precomputes the sliding window table for computing powers of x.
- *
- * Sliding Window Exponentiation, Algorithm 14.85 in "Handbook of Applied Cryptography".
- *
- * First of all, the table with the powers of g can be reduced by
- * about half; the even powers don't need to be accessed or stored.
- *
- * Get up to K bits starting with a one, if we have that many still available.
- *
- * Do the number of squarings of A in the first column, then multiply by
- * the value in column two, and finally do the number of squarings in
- * column three.
- *
- * This table can be used for K=2,3,4 and can be extended.
- *
- *
-\verbatim
- 0 : - | - | -
- 1 : 1 | g1 @ 0 | 0
- 10 : 1 | g1 @ 0 | 1
- 11 : 2 | g3 @ 1 | 0
- 100 : 1 | g1 @ 0 | 2
- 101 : 3 | g5 @ 2 | 0
- 110 : 2 | g3 @ 1 | 1
- 111 : 3 | g7 @ 3 | 0
- 1000 : 1 | g1 @ 0 | 3
- 1001 : 4 | g9 @ 4 | 0
- 1010 : 3 | g5 @ 2 | 1
- 1011 : 4 | g11 @ 5 | 0
- 1100 : 2 | g3 @ 1 | 2
- 1101 : 4 | g13 @ 6 | 0
- 1110 : 3 | g7 @ 3 | 1
- 1111 : 4 | g15 @ 7 | 0
-\endverbatim
- *
- */
-static void mpslide(size_t xsize, const mpw* xdata,
- size_t size, /*@out@*/ mpw* slide)
- /*@modifies slide @*/
-{
- size_t rsize = (xsize > size ? xsize : size);
- mpw* result = alloca(2 * rsize * sizeof(*result));
-
- mpsqr(result, xsize, xdata); /* x^2 temp */
- mpsetx(size, slide, xsize+xsize, result);
-if (_mpw_debug < 0)
-fprintf(stderr, "\t x^2:\t"), mpfprintln(stderr, size, slide);
- mpmul(result, xsize, xdata, size, slide); /* x^3 */
- mpsetx(size, slide+size, xsize+size, result);
-if (_mpw_debug < 0)
-fprintf(stderr, "\t x^3:\t"), mpfprintln(stderr, size, slide+size);
- mpmul(result, size, slide, size, slide+size); /* x^5 */
- mpsetx(size, slide+2*size, size+size, result);
-if (_mpw_debug < 0)
-fprintf(stderr, "\t x^5:\t"), mpfprintln(stderr, size, slide+2*size);
- mpmul(result, size, slide, size, slide+2*size); /* x^7 */
- mpsetx(size, slide+3*size, size+size, result);
-if (_mpw_debug < 0)
-fprintf(stderr, "\t x^7:\t"), mpfprintln(stderr, size, slide+3*size);
- mpmul(result, size, slide, size, slide+3*size); /* x^9 */
- mpsetx(size, slide+4*size, size+size, result);
-if (_mpw_debug < 0)
-fprintf(stderr, "\t x^9:\t"), mpfprintln(stderr, size, slide+4*size);
- mpmul(result, size, slide, size, slide+4*size); /* x^11 */
- mpsetx(size, slide+5*size, size+size, result);
-if (_mpw_debug < 0)
-fprintf(stderr, "\t x^11:\t"), mpfprintln(stderr, size, slide+5*size);
- mpmul(result, size, slide, size, slide+5*size); /* x^13 */
- mpsetx(size, slide+6*size, size+size, result);
-if (_mpw_debug < 0)
-fprintf(stderr, "\t x^13:\t"), mpfprintln(stderr, size, slide+6*size);
- mpmul(result, size, slide, size, slide+6*size); /* x^15 */
- mpsetx(size, slide+7*size, size+size, result);
-if (_mpw_debug < 0)
-fprintf(stderr, "\t x^15:\t"), mpfprintln(stderr, size, slide+7*size);
- mpsetx(size, slide, xsize, xdata); /* x^1 */
-if (_mpw_debug < 0)
-fprintf(stderr, "\t x^1:\t"), mpfprintln(stderr, size, slide);
-}
-
-/*@observer@*/ /*@unchecked@*/
-static byte mpslide_presq[16] =
-{ 0, 1, 1, 2, 1, 3, 2, 3, 1, 4, 3, 4, 2, 4, 3, 4 };
-
-/*@observer@*/ /*@unchecked@*/
-static byte mpslide_mulg[16] =
-{ 0, 0, 0, 1, 0, 2, 1, 3, 0, 4, 2, 5, 1, 6, 3, 7 };
-
-/*@observer@*/ /*@unchecked@*/
-static byte mpslide_postsq[16] =
-{ 0, 0, 1, 0, 2, 0, 1, 0, 3, 0, 1, 0, 2, 0, 1, 0 };
-
-/**
- * Exponentiation with precomputed sliding window table.
- */
-/*@-boundsread@*/
-static void mpnpowsld_w(mpnumber* n, size_t size, const mpw* slide,
- size_t psize, const mpw* pdata)
- /*@modifies n @*/
-{
- size_t rsize = (n->size > size ? n->size : size);
- mpw* rdata = alloca(2 * rsize * sizeof(*rdata));
- short lbits = 0;
- short kbits = 0;
- byte s;
- mpw temp;
- short count;
-
-if (_mpw_debug < 0)
-fprintf(stderr, "npowsld: p\t"), mpfprintln(stderr, psize, pdata);
- /* 2. A = 1, i = t. */
- mpzero(n->size, n->data);
- n->data[n->size-1] = 1;
-
- /* Find first bit set in exponent. */
- temp = *pdata;
- count = 8 * sizeof(temp);
- while (count != 0) {
- if (temp & MP_MSBMASK)
- break;
- temp <<= 1;
- count--;
- }
-
- while (psize) {
- while (count != 0) {
-
- /* Shift next bit of exponent into sliding window. */
- kbits <<= 1;
- if (temp & MP_MSBMASK)
- kbits++;
-
- /* On 1st non-zero in window, try to collect K bits. */
- if (kbits != 0) {
- if (lbits != 0)
- lbits++;
- else if (temp & MP_MSBMASK)
- lbits = 1;
- else
- {};
-
- /* If window is full, then compute and clear window. */
- if (lbits == 4) {
-if (_mpw_debug < 0)
-fprintf(stderr, "*** #1 lbits %d kbits %d\n", lbits, kbits);
- for (s = mpslide_presq[kbits]; s > 0; s--) {
- mpsqr(rdata, n->size, n->data);
- mpsetx(n->size, n->data, 2*n->size, rdata);
-if (_mpw_debug < 0)
-fprintf(stderr, "\t pre1:\t"), mpfprintln(stderr, n->size, n->data);
- }
-
- mpmul(rdata, n->size, n->data,
- size, slide+mpslide_mulg[kbits]*size);
- mpsetx(n->size, n->data, n->size+size, rdata);
-if (_mpw_debug < 0)
-fprintf(stderr, "\t mul1:\t"), mpfprintln(stderr, n->size, n->data);
-
- for (s = mpslide_postsq[kbits]; s > 0; s--) {
- mpsqr(rdata, n->size, n->data);
- mpsetx(n->size, n->data, 2*n->size, rdata);
-if (_mpw_debug < 0)
-fprintf(stderr, "\tpost1:\t"), mpfprintln(stderr, n->size, n->data);
- }
-
- lbits = kbits = 0;
- }
- } else {
- mpsqr(rdata, n->size, n->data);
- mpsetx(n->size, n->data, 2*n->size, rdata);
-if (_mpw_debug < 0)
-fprintf(stderr, "\t sqr:\t"), mpfprintln(stderr, n->size, n->data);
- }
-
- temp <<= 1;
- count--;
- }
- if (--psize) {
- count = 8 * sizeof(temp);
- temp = *(pdata++);
- }
- }
-
- if (kbits != 0) {
-if (_mpw_debug < 0)
-fprintf(stderr, "*** #1 lbits %d kbits %d\n", lbits, kbits);
- for (s = mpslide_presq[kbits]; s > 0; s--) {
- mpsqr(rdata, n->size, n->data);
- mpsetx(n->size, n->data, 2*n->size, rdata);
-if (_mpw_debug < 0)
-fprintf(stderr, "\t pre2:\t"), mpfprintln(stderr, n->size, n->data);
- }
-
- mpmul(rdata, n->size, n->data,
- size, slide+mpslide_mulg[kbits]*size);
- mpsetx(n->size, n->data, n->size+size, rdata);
-if (_mpw_debug < 0)
-fprintf(stderr, "\t mul2:\t"), mpfprintln(stderr, n->size, n->data);
-
- for (s = mpslide_postsq[kbits]; s > 0; s--) {
- mpsqr(rdata, n->size, n->data);
- mpsetx(n->size, n->data, 2*n->size, rdata);
-if (_mpw_debug < 0)
-fprintf(stderr, "\tpost2:\t"), mpfprintln(stderr, n->size, n->data);
- }
- }
-}
-/*@=boundsread@*/
-
-/**
- * mpnpow_w
- *
- * Uses sliding window exponentiation; needs extra storage:
- * if K=3, needs 4*size, if K=4, needs 8*size
- */
-/*@-boundsread@*/
-static void mpnpow_w(mpnumber* n, size_t xsize, const mpw* xdata,
- size_t psize, const mpw* pdata)
- /*@modifies n @*/
-{
- size_t xbits = MPBITCNT(xsize, xdata);
- size_t pbits = MPBITCNT(psize, pdata);
- size_t nbits;
- mpw *slide;
- size_t nsize;
- size_t size;
-
- /* Special case: 0**P and X**(-P) */
- if (xbits == 0 || (psize > 0 && mpmsbset(psize, pdata))) {
- mpnsetw(n, 0);
- return;
- }
- /* Special case: X**0 and 1**P */
- if (pbits == 0 || mpisone(xsize, xdata)) {
- mpnsetw(n, 1);
- return;
- }
-
- /* Normalize (to mpw boundary) exponent. */
- pdata += psize - MP_ROUND_B2W(pbits);
- psize -= MP_BITS_TO_WORDS(pbits);
-
- /* Calculate size of result. */
- if (xbits == 0) xbits = 1;
- nbits = (*pdata) * xbits;
- nsize = MP_ROUND_B2W(nbits);
-
- /* XXX Add 1 word to carry sign bit */
- if (!mpmsbset(xsize, xdata) && (nbits & (MP_WBITS - 1)) == 0)
- nsize++;
-
- size = MP_ROUND_B2W(15 * xbits);
-
-if (_mpw_debug < 0)
-fprintf(stderr, "*** pbits %d xbits %d nsize %d size %d\n", pbits, xbits, nsize, size);
- mpnsize(n, nsize);
-
- /* 1. Precompute odd powers of x (up to 2**K). */
- slide = (mpw*) alloca( (8*size) * sizeof(mpw));
-
- mpslide(xsize, xdata, size, slide);
-
- /*@-internalglobs -mods@*/ /* noisy */
- mpnpowsld_w(n, size, slide, psize, pdata);
- /*@=internalglobs =mods@*/
-
-}
-/*@=boundsread@*/
-
-/* ---------- */
-
-mpwObject *
-mpw_New(int ob_size)
- /*@*/
-{
- size_t size = ABS(ob_size);
- mpwObject * z;
-
- /* XXX Make sure that 0 has allocated space. */
- if (size == 0)
- size++;
- z = PyObject_NEW_VAR(mpwObject, &mpw_Type, size);
- if (z == NULL)
- return NULL;
-
- z->ob_size = ob_size;
-
- if (size > 0)
- memset(&z->data, 0, size * sizeof(*z->data));
-
- return z;
-}
-
-static mpwObject *
-mpw_Copy(mpwObject *a)
- /*@*/
-{
- mpwObject * z;
-
- z = mpw_FromMPW(MPW_SIZE(a), MPW_DATA(a), 1);
- if (z != NULL)
- z->ob_size = a->ob_size;
- return z;
-}
-
-static mpwObject *
-mpw_FromLong(long ival)
- /*@*/
-{
- mpwObject * z = mpw_New(1);
-
- if (z == NULL)
- return NULL;
-
- if (ival < 0) {
- z->ob_size = -z->ob_size;
- ival = -ival;
- }
- z->data[0] = (mpw) ival;
-
- return z;
-}
-
-static mpwObject *
-mpw_FromDouble(double dval)
-{
- mpwObject * z = mpw_New(1);
-
- if (z == NULL)
- return NULL;
-
- if (dval < 0) {
- z->ob_size = -z->ob_size;
- dval = -dval;
- }
- z->data[0] = (mpw) dval;
-
- return z;
-}
-
-#ifdef NOTYET
-static mpwObject *
-mpw_FromString(const char * str, char ** sep, int base)
- /*@*/
-{
- const char * s = str, * se;
- mpwObject * z = NULL;
- mpw zbase, zval;
- int sign = 1;
- int ndigits;
-
- if ((base != 0 && base < 2) || base > 36) {
- PyErr_SetString(PyExc_ValueError, "mpw() arg 2 must be >= 2 and <= 36");
- return NULL;
- }
- while (*s != '\0' && isspace(Py_CHARMASK(*s)))
- s++;
- if (*s == '+')
- ++s;
- else if (*s == '-') {
- ++s;
- sign = -1;
- }
- while (*s != '\0' && isspace(Py_CHARMASK(*s)))
- s++;
- if (base == 0) {
- if (s[0] != '0')
- base = 10;
- else if (s[1] == 'x' || s[1] == 'X')
- base = 16;
- else
- base = 8;
- }
- if (base == 16 && s[0] == '0' && (s[1] == 'x' || s[1] == 'X'))
- s += 2;
-
- /* Validate characters as digits of base. */
- for (se = s; *se != '\0'; se++) {
- int k;
-
- if (*se <= '9')
- k = *se - '0';
- else if (*se >= 'a')
- k = *se - 'a' + 10;
- else if (*se >= 'A')
- k = *se - 'A' + 10;
- else
- k = -1;
- if (k < 0 || k >= base)
- break;
- }
- if (se == s)
- goto onError;
-
- ndigits = (se - s);
-
- if (*se == 'L' || *se == 'l')
- se++;
- while (*se && isspace(Py_CHARMASK(*se)))
- se++;
- if (sep)
- *sep = se;
- if (*se != '\0')
- goto onError;
-
- /* Allocate mpw. */
-
- /* Convert digit string. */
- zbase = base;
- for (se = s; *se != '\0'; se++) {
- if (*se <= '9')
- zval = *se - '0';
- else if (*se >= 'a')
- zval = *se - 'a' + 10;
- else if (*se >= 'A')
- zval = *se - 'A' + 10;
- }
-
- if (sign < 0 && z != NULL && z->ob_size != 0)
- z->ob_size = -(z->ob_size);
-
- return z;
-
-onError:
- PyErr_Format(PyExc_ValueError, "invalid literal for mpw(): %.200s", str);
- Py_XDECREF(z);
- return NULL;
-}
-#endif
-
-static mpwObject *
-mpw_FromHEX(const char * hex)
- /*@*/
-{
- size_t len = strlen(hex);
- size_t size = MP_NIBBLES_TO_WORDS(len + MP_WNIBBLES - 1);
- mpwObject * z = mpw_New(size);
-
- if (z != NULL && size > 0)
- hs2ip(MPW_DATA(z), size, hex, len);
-
- return z;
-}
-
-mpwObject *
-mpw_FromMPW(size_t size, mpw* data, int normalize)
-{
- mpwObject * z;
-
- if (normalize) {
- size_t norm = size - MP_ROUND_B2W(MPBITCNT(size, data));
- if (norm > 0 && norm < size) {
- size -= norm;
- data += norm;
- }
- }
-
- z = mpw_New(size);
- if (z == NULL)
- return NULL;
-
- if (size > 0)
- memcpy(&z->data, data, size * sizeof(*z->data));
-
- return z;
-}
-
-static mpwObject *
-mpw_FromLongObject(PyLongObject *lo)
- /*@*/
-{
- mpwObject * z;
- int lsize = ABS(lo->ob_size);
- int lbits = DIGITS_TO_BITS(lsize);
- size_t zsize = MP_BITS_TO_WORDS(lbits) + 1;
- mpw* zdata;
- unsigned char * zb;
- size_t nzb;
- int is_littleendian = 0;
- int is_signed = 0;
-
- lsize = zsize;
- if (lo->ob_size < 0)
- lsize = -lsize;
- z = mpw_New(lsize);
- if (z == NULL)
- return NULL;
-
- zdata = MPW_DATA(z);
- zb = (unsigned char *) zdata;
- nzb = MP_WORDS_TO_BYTES(zsize);
-
- /* Grab long as big-endian unsigned octets. */
- if (_PyLong_AsByteArray(lo, zb, nzb, is_littleendian, is_signed)) {
- Py_DECREF(z);
- return NULL;
- }
-
- /* Endian swap zdata's mpw elements. */
- if (IS_LITTLE_ENDIAN()) {
- mpw w = 0;
- int zx = 0;
- while (nzb) {
- w <<= 8;
- w |= *zb++;
- nzb--;
- if ((nzb % MP_WBYTES) == 0) {
- zdata[zx++] = w;
- w = 0;
- }
- }
- }
-
- return z;
-}
-
-/* ---------- */
-
-static void
-mpw_dealloc(/*@only@*/mpwObject * s)
- /*@modifies s @*/
-{
-if (_mpw_debug < -1)
-fprintf(stderr, "*** mpw_dealloc(%p[%s])\n", s, lbl(s));
-
- PyObject_Del(s);
-}
-
-static int
-mpw_compare(mpwObject * a, mpwObject * b)
- /*@*/
-{
- size_t asize = MPW_SIZE(a);
- mpw* adata = MPW_DATA(a);
- size_t bsize = MPW_SIZE(b);
- mpw* bdata = MPW_DATA(b);
- int ret;
-
- if (mpeqx(asize, adata, bsize, bdata))
- ret = 0;
- else if (mpgtx(asize, adata, bsize, bdata))
- ret = 1;
- else
- ret = -1;
-
-if (_mpw_debug)
-fprintf(stderr, "*** mpw_compare(%p[%s],%p[%s]) ret %d\n", a, lbl(a), b, lbl(b), ret);
- return ret;
-}
-
-static PyObject *
-mpw_repr(mpwObject * a)
- /*@*/
-{
- PyObject * so = mpw_format(a, 10, 1);
-if (_mpw_debug && so != NULL)
-fprintf(stderr, "*** mpw_repr(%p): \"%s\"\n", a, PyString_AS_STRING(so));
- return so;
-}
-
-/** \ingroup py_c
- */
-static PyObject *
-mpw_str(mpwObject * a)
- /*@*/
-{
- PyObject * so = mpw_format(a, 10, 0);
-if (so != NULL && _mpw_debug < -1)
-fprintf(stderr, "*** mpw_str(%p): \"%s\"\n", a, PyString_AS_STRING(so));
- return so;
-}
-
-#ifdef DYING
-/** \ingroup py_c
- */
-static int mpw_init(mpwObject * z, PyObject *args, PyObject *kwds)
- /*@modifies s @*/
-{
- PyObject * o = NULL;
- long l = 0;
-
- if (!PyArg_ParseTuple(args, "|O:Cvt", &o)) return -1;
-
- if (o == NULL) {
- mpnsetw(&z->n, l);
- } else if (PyInt_Check(o)) {
- l = PyInt_AsLong(o);
- mpnsetw(&z->n, l);
- } else if (PyLong_Check(o)) {
- PyLongObject *lo = (PyLongObject *)o;
- int lsize = ABS(lo->ob_size);
- int lbits = DIGITS_TO_BITS(lsize);
- size_t zsize = MP_BITS_TO_WORDS(lbits) + 1;
- mpw* zdata = alloca(zsize * sizeof(*zdata));
- unsigned char * zb = (unsigned char *) zdata;
- size_t nzb = MP_WORDS_TO_BYTES(zsize);
- int is_littleendian = 0;
- int is_signed = 1;
-
- /* Grab long as big-endian signed octets. */
- if (_PyLong_AsByteArray(lo, zb, nzb, is_littleendian, is_signed))
- return -1;
-
- /* Endian swap zdata's mpw elements. */
- if (IS_LITTLE_ENDIAN()) {
- mpw w = 0;
- int zx = 0;
- while (nzb) {
- w <<= 8;
- w |= *zb++;
- nzb--;
- if ((nzb % MP_WBYTES) == 0) {
- zdata[zx++] = w;
- w = 0;
- }
- }
- }
- mpnset(&z->n, zsize, zdata);
- } else if (PyFloat_Check(o)) {
- double d = PyFloat_AsDouble(o);
- /* XXX TODO: check for overflow/underflow. */
- l = (long) (d + 0.5);
- mpnsetw(&z->n, l);
- } else if (PyString_Check(o)) {
- const unsigned char * hex = PyString_AsString(o);
- /* XXX TODO: check for hex. */
- mpnsethex(&z->n, hex);
- } else if (mpw_Check(o)) {
- mpwObject *a = (mpwObject *)o;
- mpncopy(&z->n, &a->n);
- } else {
- PyErr_SetString(PyExc_TypeError, "non-numeric coercion failed (mpw_init)");
- return -1;
- }
-
-if (_mpw_debug)
-fprintf(stderr, "*** mpw_init(%p[%s],%p[%s],%p[%s]):\t", z, lbl(z), args, lbl(args), kwds, lbl(kwds)), mpfprintln(stderr, MPW_SIZE(z), MPW_DATA(z));
-
- return 0;
-}
-#endif
-
-/** \ingroup py_c
- */
-static void mpw_free(/*@only@*/ mpwObject * s)
- /*@modifies s @*/
-{
-if (_mpw_debug)
-fprintf(stderr, "*** mpw_free(%p[%s])\n", s, lbl(s));
- PyObject_Del(s);
-}
-
-/** \ingroup py_c
- * Convert integer to mpw.
- */
-static mpwObject *
-mpw_i2mpw(PyObject * o)
- /*@modifies o @*/
-{
- if (mpw_Check(o)) {
- Py_INCREF(o);
- return (mpwObject *)o;
- }
- if (PyInt_Check(o))
- return mpw_FromLong(PyInt_AsLong(o));
- else if (PyLong_Check(o))
- return mpw_FromLongObject((PyLongObject *)o);
- else if (PyFloat_Check(o))
- return mpw_FromDouble(PyFloat_AsDouble(o));
- else if (PyString_Check(o))
- return mpw_FromHEX(PyString_AS_STRING(o));
-
- PyErr_SetString(PyExc_TypeError, "number coercion (to mpwObject) failed");
- return NULL;
-}
-
-static PyObject *
-mpw_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
- /*@*/
-{
- mpwObject *z;
-
- if (type != &mpw_Type) {
- mpwObject *tz;
- size_t size;
-
- assert(PyType_IsSubtype(type, &mpw_Type));
- tz = (mpwObject *)mpw_new(&mpw_Type, args, kwds);
- if (tz == NULL)
- return NULL;
-
- size = ABS(tz->ob_size);
- z = (mpwObject *) type->tp_alloc(type, size);
- if (z == NULL)
- return NULL;
-
- z->ob_size = tz->ob_size;
- if (size > 0)
- memcpy(&z->data, &tz->data, size * sizeof(*z->data));
- Py_DECREF(tz);
- } else {
- PyObject * x = NULL;
- int base = -909;
- static char *kwlist[] = {"x", "base", 0};
-
- if (!PyArg_ParseTupleAndKeywords(args, kwds, "|Oi:mpw", kwlist, &x, &base))
- return NULL;
-
- if (x != NULL) {
- /* XXX make sure new instance, not old reference. */
- if (mpw_Check(x)) {
- mpwObject *zo = (mpwObject *)x;
- z = mpw_Copy(zo);
- } else
- z = mpw_i2mpw(x);
- } else
- z = mpw_FromLong(0);
- }
-
-if (_mpw_debug < -1)
-fprintf(stderr, "*** mpw_new(%p[%s],%p[%s],%p[%s])\t", type, lbl(type), args, lbl(args), kwds, lbl(kwds)), mpfprintln(stderr, MPW_SIZE(z), MPW_DATA(z));
-
- return (PyObject *)z;
-}
-
-/** \ingroup py_c
- * Compute 2 argument operations.
- */
-static PyObject *
-mpw_ops2(const char *fname, char op, mpwObject *x, mpwObject *m)
- /*@*/
-{
- mpwObject * z = NULL;
- size_t xsize;
- mpw* xdata;
- size_t msize;
- mpw* mdata;
- size_t mnorm;
- size_t asize;
- mpw* adata;
- size_t bsize;
- mpw* bdata;
- size_t shift;
- size_t zsize;
- mpw* zdata;
- mpw* wksp;
- mpbarrett b;
- int carry;
- int zsign = 0;
-
- mpbzero(&b);
- if (x == NULL || m == NULL)
- goto exit;
-
- xsize = MPW_SIZE(x);
- xdata = MPW_DATA(x);
- msize = MPW_SIZE(m);
- mdata = MPW_DATA(m);
- mnorm = msize - mpsize(msize, mdata);
- if (mnorm > 0 && mnorm < msize) {
- msize -= mnorm;
- mdata += mnorm;
- }
-
-if (_mpw_debug < 0) {
-prtmpw("a", x);
-prtmpw("b", m);
-}
-
- switch (op) {
- default:
- goto exit;
- /*@notreached@*/ break;
- case '+':
- zsize = MAX(xsize, msize) + 1;
- zdata = alloca(zsize * sizeof(*zdata));
- mpsetx(zsize, zdata, xsize, xdata);
- if (x->ob_size < 0) {
- zsign = 1;
- if (m->ob_size < 0) {
- carry = mpaddx(zsize-1, zdata+1, msize, mdata);
- if (carry) {
-if (_mpw_debug)
-fprintf(stderr, "add --: carry\n");
- *zdata = 1;
- }
- } else {
- carry = mpsubx(zsize-1, zdata+1, msize, mdata);
- if (carry) {
-if (_mpw_debug)
-fprintf(stderr, "add -+: borrow\n");
- *zdata = MP_ALLMASK;
- mpneg(zsize, zdata);
- zsign = 0;
- }
- }
- } else {
- zsign = 0;
- if (m->ob_size < 0) {
- carry = mpsubx(zsize-1, zdata+1, msize, mdata);
- if (carry) {
-if (_mpw_debug)
-fprintf(stderr, "add +-: borrow\n");
- *zdata = MP_ALLMASK;
- mpneg(zsize, zdata);
- zsign = 1;
- }
- } else {
- carry = mpaddx(zsize-1, zdata+1, msize, mdata);
- if (carry) {
-if (_mpw_debug)
-fprintf(stderr, "add ++: carry\n");
- *zdata = 1;
- }
- }
- }
- z = mpw_FromMPW(zsize, zdata, 1);
- if (zsign)
- z->ob_size = -z->ob_size;
- break;
- case '-':
- zsize = MAX(xsize, msize) + 1;
- zdata = alloca(zsize * sizeof(*zdata));
- mpsetx(zsize, zdata, xsize, xdata);
- if (x->ob_size < 0) {
- zsign = 1;
- if (m->ob_size < 0) {
- carry = mpsubx(zsize-1, zdata+1, msize, mdata);
- if (carry) {
-if (_mpw_debug)
-fprintf(stderr, "sub --: borrow\n");
- *zdata = MP_ALLMASK;
- mpneg(zsize, zdata);
- zsign = 0;
- }
- } else {
- carry = mpaddx(zsize-1, zdata+1, msize, mdata);
- if (carry) {
-if (_mpw_debug)
-fprintf(stderr, "sub -+: carry\n");
- *zdata = 1;
- }
- }
- } else {
- zsign = 0;
- if (m->ob_size < 0) {
- carry = mpaddx(zsize-1, zdata+1, msize, mdata);
- if (carry) {
-if (_mpw_debug)
-fprintf(stderr, "sub +-: carry\n");
- *zdata = 1;
- }
- } else {
- carry = mpsubx(zsize-1, zdata+1, msize, mdata);
- if (carry) {
-if (_mpw_debug)
-fprintf(stderr, "sub ++: borrow\n");
- *zdata = MP_ALLMASK;
- mpneg(zsize, zdata);
- zsign = 1;
- }
- }
- }
- z = mpw_FromMPW(zsize-1, zdata+1, 1);
- if (zsign)
- z->ob_size = -z->ob_size;
- break;
- case '*':
- zsize = xsize + msize;
- zdata = alloca(zsize * sizeof(*zdata));
- zsign = x->ob_size * m->ob_size;
- mpmul(zdata, xsize, xdata, msize, mdata);
- z = mpw_FromMPW(zsize, zdata, 1);
- if (zsign < 0)
- z->ob_size = -z->ob_size;
- break;
- case '/':
- asize = xsize+1;
- adata = alloca(asize * sizeof(*adata));
- mpsetx(asize, adata, xsize, xdata);
- bsize = msize;
- bdata = alloca(bsize * sizeof(*bdata));
- mpsetx(bsize, bdata, msize, mdata);
-
- zsize = asize + 1;
- zdata = alloca(zsize * sizeof(*zdata));
- zsign = x->ob_size * m->ob_size;
- wksp = alloca((bsize+1) * sizeof(*wksp));
-
- shift = mpnorm(bsize, bdata);
- mplshift(asize, adata, shift);
- mpndivmod(zdata, asize, adata, bsize, bdata, wksp);
-
- zsize -= bsize;
-
- if (zsign < 0)
- (void) mpaddw(zsize, zdata, (mpw)1);
-
- z = mpw_FromMPW(zsize, zdata, 1);
- if (zsign < 0)
- z->ob_size = -z->ob_size;
- break;
- case '%':
- asize = xsize+1;
- adata = alloca(asize * sizeof(*adata));
- mpsetx(asize, adata, xsize, xdata);
- bsize = msize;
- bdata = mdata;
-
- zsize = asize;
- zdata = alloca(zsize * sizeof(*zdata));
- zsign = x->ob_size * m->ob_size;
- wksp = alloca((bsize+1) * sizeof(*wksp));
-
- mpnmod(zdata, asize, adata, bsize, bdata, wksp);
-
- if (zsign < 0) {
- if (m->ob_size < 0) {
- (void) mpsubx(zsize, zdata, bsize, bdata);
- mpneg(zsize, zdata);
- } else {
- zsign = 0;
- mpneg(zsize, zdata);
- (void) mpaddx(zsize, zdata, bsize, bdata);
- }
- }
- z = mpw_FromMPW(zsize, zdata, 1);
- if (zsign < 0) {
- z->ob_size = -z->ob_size;
- } else if (zsign > 0) {
- if (x->ob_size < 0)
- z->ob_size = -z->ob_size;
- }
- break;
- case '<':
- /* XXX FIXME: enlarge? negative count? sign?. */
- shift = (size_t) (msize == 1 ? mdata[0] : 0);
- z = mpw_FromMPW(xsize, xdata, 0);
- if (shift > 0)
- mplshift(MPW_SIZE(z), MPW_DATA(z), shift);
- break;
- case '>':
- /* XXX FIXME: enlarge? negative count? sign?. */
- shift = (size_t) (msize == 1 ? mdata[0] : 0);
- z = mpw_FromMPW(xsize, xdata, 0);
- if (shift > 0)
- mprshift(MPW_SIZE(z), MPW_DATA(z), shift);
- break;
- case '&':
- /* XXX reset to original size for now. */
- msize = MPW_SIZE(m);
- mdata = MPW_DATA(m);
- if (xsize <= msize) {
- z = mpw_FromMPW(xsize, xdata, 0);
- mpand(MPW_SIZE(z), MPW_DATA(z), mdata + (msize - xsize));
- } else {
- z = mpw_FromMPW(msize, mdata, 0);
- mpand(MPW_SIZE(z), MPW_DATA(z), xdata + (xsize - msize));
- }
- break;
- case '|':
- /* XXX reset to original size for now. */
- msize = MPW_SIZE(m);
- mdata = MPW_DATA(m);
- if (xsize <= msize) {
- z = mpw_FromMPW(xsize, xdata, 0);
- mpor(MPW_SIZE(z), MPW_DATA(z), mdata + (msize - xsize));
- } else {
- z = mpw_FromMPW(msize, mdata, 0);
- mpor(MPW_SIZE(z), MPW_DATA(z), xdata + (xsize - msize));
- }
- break;
- case '^':
- /* XXX reset to original size for now. */
- msize = MPW_SIZE(m);
- mdata = MPW_DATA(m);
- if (xsize <= msize) {
- z = mpw_FromMPW(xsize, xdata, 0);
- mpxor(MPW_SIZE(z), MPW_DATA(z), mdata + (msize - xsize));
- } else {
- z = mpw_FromMPW(msize, mdata, 0);
- mpxor(MPW_SIZE(z), MPW_DATA(z), xdata + (xsize - msize));
- }
- break;
- case 'P':
- { mpnumber zn;
-
- mpnzero(&zn);
- if (msize == 0 || (msize == 1 && *mdata == 0))
- mpnsetw(&zn, 1);
- else if (mpz(xsize, xdata) || m->ob_size < 0)
- mpnsetw(&zn, 0);
- else {
- zsign = (x->ob_size > 0 || mpeven(msize, mdata)) ? 1 : -1;
- mpnpow_w(&zn, xsize, xdata, msize, mdata);
- }
- z = mpw_FromMPW(zn.size, zn.data, 1);
- mpnfree(&zn);
- if (zsign < 0)
- z->ob_size = -z->ob_size;
- } break;
- case 'G':
- wksp = alloca((xsize) * sizeof(*wksp));
- z = mpw_New(msize);
- mpgcd_w(xsize, xdata, mdata, MPW_DATA(z), wksp);
- break;
- case 'I':
- wksp = alloca((7*msize+6)*sizeof(*wksp));
- z = mpw_New(msize);
- (void) mpextgcd_w(msize, wksp, mdata, MPW_DATA(z), wksp+msize);
- break;
-#ifdef DYING
- case 'R':
- { rngObject * r = ((rngObject *)x);
-
- wksp = alloca(msize*sizeof(*wksp));
- mpbset(&b, msize, mdata);
- z = mpw_New(msize);
- mpbrnd_w(&b, &r->rngc, MPW_DATA(z), wksp);
- } break;
-#endif
- case 'S':
- wksp = alloca((4*msize+2)*sizeof(*wksp));
- mpbset(&b, msize, mdata);
- z = mpw_New(msize);
- mpbsqrmod_w(&b, xsize, xdata, MPW_DATA(z), wksp);
- break;
- }
-
-if (_mpw_debug)
-fprintf(stderr, "*** mpw_%s %p[%d]\t", fname, MPW_DATA(z), MPW_SIZE(z)), mpfprintln(stderr, MPW_SIZE(z), MPW_DATA(z));
-
-exit:
- mpbfree(&b);
- Py_XDECREF(x);
- Py_XDECREF(m);
- return (PyObject *)z;
-}
-
-/** \ingroup py_c
- * Compute 3 argument operations.
- */
-static PyObject *
-mpw_ops3(const char *fname, char op,
- mpwObject *x, mpwObject *y, mpwObject *m)
- /*@*/
-{
- mpwObject * z = NULL;
- size_t xsize;
- mpw* xdata;
- size_t ysize;
- mpw* ydata;
- size_t msize;
- mpw* mdata;
- size_t zsize;
- mpw* zdata;
- mpbarrett b;
- mpw* wksp;
-
- mpbzero(&b);
- if (x == NULL || y == NULL || m == NULL)
- goto exit;
-
-if (_mpw_debug < 0) {
-prtmpw("a", x);
-prtmpw("b", y);
-prtmpw("c", m);
-}
-
- xsize = MPW_SIZE(x);
- xdata = MPW_DATA(x);
- ysize = MPW_SIZE(y);
- ydata = MPW_DATA(y);
- msize = MPW_SIZE(m);
- mdata = MPW_DATA(m);
-
- mpbset(&b, msize, mdata);
-
- zsize = b.size;
- zdata = alloca(zsize * sizeof(*zdata));
- wksp = alloca((4*zsize+2)*sizeof(*wksp));
-
- switch (op) {
- case '/':
- case '%':
- default:
- goto exit;
- /*@notreached@*/ break;
- case '+':
- fname = "Addm";
- mpbaddmod_w(&b, xsize, xdata, ysize, ydata, zdata, wksp);
- break;
- case '-':
- fname = "Subm";
- mpbsubmod_w(&b, xsize, xdata, ysize, ydata, zdata, wksp);
- break;
- case '*':
- fname = "Mulm";
- mpbmulmod_w(&b, xsize, xdata, ysize, ydata, zdata, wksp);
- break;
- case 'P':
- fname = "Powm";
- mpbpowmod_w(&b, xsize, xdata, ysize, ydata, zdata, wksp);
- break;
- }
-
- z = mpw_FromMPW(zsize, zdata, 1);
-
-if (_mpw_debug < 0)
-fprintf(stderr, "*** mpw_%s %p[%d]\t", fname, MPW_DATA(z), MPW_SIZE(z)), mpfprintln(stderr, MPW_SIZE(z), MPW_DATA(z));
-
-exit:
- mpbfree(&b);
- Py_XDECREF(x);
- Py_XDECREF(y);
- Py_XDECREF(m);
- return (PyObject *)z;
-}
-
-/* ---------- */
-
-/** \ingroup py_c
- */
-static PyObject *
-mpw_Debug(/*@unused@*/ mpwObject * s, PyObject * args)
- /*@globals _Py_NoneStruct @*/
- /*@modifies _Py_NoneStruct @*/
-{
- if (!PyArg_ParseTuple(args, "i:Debug", &_mpw_debug)) return NULL;
- Py_INCREF(Py_None);
- return Py_None;
-}
-
-/** \ingroup py_c
- * Compute gcd(x, y).
- */
-static PyObject *
-mpw_Gcd(mpwObject * s, PyObject * args)
- /*@*/
-{
- PyObject * xo, * mo;
-
- if (!PyArg_ParseTuple(args, "OO:Gcd", &xo, &mo)) return NULL;
- return mpw_ops2("Gcd", 'G', mpw_i2mpw(xo), mpw_i2mpw(mo));
-}
-
-/** \ingroup py_c
- * Compute inverse (modulo m) of x.
- */
-static PyObject *
-mpw_Invm(/*@unused@*/ mpwObject * s, PyObject * args)
- /*@*/
-{
- PyObject * xo, * mo;
-
- if (!PyArg_ParseTuple(args, "OO:Invm", &xo, &mo)) return NULL;
- return mpw_ops2("Invm", 'I', mpw_i2mpw(xo), mpw_i2mpw(mo));
-}
-
-/** \ingroup py_c
- * Compute x*x (modulo m).
- */
-static PyObject *
-mpw_Sqrm(mpwObject * s, PyObject * args)
- /*@*/
-{
- PyObject * xo, * mo;
-
- if (!PyArg_ParseTuple(args, "OO:Sqrm", &xo, &mo)) return NULL;
- return mpw_ops2("Sqrm", 'S', mpw_i2mpw(xo), mpw_i2mpw(mo));
-}
-
-/** \ingroup py_c
- * Compute x+y (modulo m).
- */
-static PyObject *
-mpw_Addm(mpwObject * s, PyObject * args)
- /*@*/
-{
- PyObject * xo, * yo, * mo;
-
- if (!PyArg_ParseTuple(args, "OOO:Addm", &xo, &yo, &mo)) return NULL;
- return mpw_ops3("Addm", '+',
- mpw_i2mpw(xo), mpw_i2mpw(yo), mpw_i2mpw(mo));
-}
-
-/** \ingroup py_c
- * Compute x-y (modulo m).
- */
-static PyObject *
-mpw_Subm(mpwObject * s, PyObject * args)
- /*@*/
-{
- PyObject * xo, * yo, * mo;
-
- if (!PyArg_ParseTuple(args, "OOO:Subm", &xo, &yo, &mo)) return NULL;
- return mpw_ops3("Subm", '-',
- mpw_i2mpw(xo), mpw_i2mpw(yo), mpw_i2mpw(mo));
-}
-
-/** \ingroup py_c
- * Compute x*y (modulo m).
- */
-static PyObject *
-mpw_Mulm(mpwObject * s, PyObject * args)
- /*@*/
-{
- PyObject * xo, * yo, * mo;
-
- if (!PyArg_ParseTuple(args, "OOO:Mulm", &xo, &yo, &mo)) return NULL;
- return mpw_ops3("Mulm", '*',
- mpw_i2mpw(xo), mpw_i2mpw(yo), mpw_i2mpw(mo));
-}
-
-/** \ingroup py_c
- * Compute x**y (modulo m).
- */
-static PyObject *
-mpw_Powm(mpwObject * s, PyObject * args)
- /*@*/
-{
- PyObject * xo, * yo, * mo;
-
- if (!PyArg_ParseTuple(args, "OOO:Powm", &xo, &yo, &mo)) return NULL;
- return mpw_ops3("Powm", 'P',
- mpw_i2mpw(xo), mpw_i2mpw(yo), mpw_i2mpw(mo));
-}
-
-#ifdef DYNING
-/** \ingroup py_c
- * Return random number 1 < r < b-1.
- */
-static PyObject *
-mpw_Rndm(mpwObject * s, PyObject * args)
- /*@*/
-{
- PyObject * xo, * mo;
-
- if (!PyArg_ParseTuple(args, "OO:Rndm", &mo, &xo)) return NULL;
- if (!is_rng(xo)) {
- PyErr_SetString(PyExc_TypeError, "mpw.rndm() requires rng_Type argument");
- return NULL;
- }
- return mpw_ops2("Rndm", 'R', (mpwObject*)xo, mpw_i2mpw(mo));
-}
-#endif
-
-/*@-fullinitblock@*/
-/*@unchecked@*/ /*@observer@*/
-static struct PyMethodDef mpw_methods[] = {
- {"Debug", (PyCFunction)mpw_Debug, METH_VARARGS,
- NULL},
- {"gcd", (PyCFunction)mpw_Gcd, METH_VARARGS,
- NULL},
- {"invm", (PyCFunction)mpw_Invm, METH_VARARGS,
- NULL},
- {"sqrm", (PyCFunction)mpw_Sqrm, METH_VARARGS,
- NULL},
- {"addm", (PyCFunction)mpw_Addm, METH_VARARGS,
- NULL},
- {"subm", (PyCFunction)mpw_Subm, METH_VARARGS,
- NULL},
- {"mulm", (PyCFunction)mpw_Mulm, METH_VARARGS,
- NULL},
- {"powm", (PyCFunction)mpw_Powm, METH_VARARGS,
- NULL},
-#ifdef DYING
- {"rndm", (PyCFunction)mpw_Rndm, METH_VARARGS,
- NULL},
-#endif
- {NULL, NULL} /* sentinel */
-};
-/*@=fullinitblock@*/
-
-static PyObject * mpw_getattro(PyObject * o, PyObject * n)
- /*@*/
-{
- return PyObject_GenericGetAttr(o, n);
-}
-
-static int mpw_setattro(PyObject * o, PyObject * n, PyObject * v)
- /*@*/
-{
- return PyObject_GenericSetAttr(o, n, v);
-}
-
-/* ---------- */
-
-static PyObject *
-mpw_add(PyObject * a, PyObject * b)
- /*@*/
-{
- return mpw_ops2("add", '+', mpw_i2mpw(a), mpw_i2mpw(b));
-}
-
-static PyObject *
-mpw_sub(PyObject * a, PyObject * b)
- /*@*/
-{
- return mpw_ops2("sub", '-', mpw_i2mpw(a), mpw_i2mpw(b));
-}
-
-static PyObject *
-mpw_mul(PyObject * a, PyObject * b)
- /*@*/
-{
- return mpw_ops2("mul", '*', mpw_i2mpw(a), mpw_i2mpw(b));
-}
-
-static PyObject *
-mpw_div(PyObject * a, PyObject * w)
- /*@*/
-{
- mpwObject * b = mpw_i2mpw(w);
-
- if (mpz(MPW_SIZE(b), MPW_DATA(b))) {
- Py_DECREF(b);
- PyErr_SetString(PyExc_ZeroDivisionError, "mpw_divide by zero");
- return NULL;
- }
- return mpw_ops2("div", '/', mpw_i2mpw(a), b);
-}
-
-static PyObject *
-mpw_classic_div(PyObject * a, PyObject * b)
- /*@*/
-{
- if (Py_DivisionWarningFlag &&
- PyErr_Warn(PyExc_DeprecationWarning, "classic long division") < 0)
- return NULL;
- return mpw_div(a, b);
-}
-
-static PyObject *
-mpw_mod(PyObject * a, PyObject * b)
- /*@*/
-{
- return mpw_ops2("rem", '%', mpw_i2mpw(a), mpw_i2mpw(b));
-}
-
-static PyObject *
-mpw_divmod(PyObject * v, PyObject * w)
- /*@*/
-{
- PyObject * z = NULL;
- mpwObject * q = NULL;
- mpwObject * r = NULL;
- mpwObject * a = mpw_i2mpw(v);
- size_t asize;
- mpw* adata;
- size_t anorm;
- mpwObject * b = mpw_i2mpw(w);
- size_t bsize;
- mpw* bdata;
- size_t bnorm;
- size_t zsize;
- mpw* zdata;
- mpw* wksp;
- int qsign = 0;
-
- if (a == NULL || b == NULL)
- goto exit;
-
- asize = MPW_SIZE(a);
- adata = MPW_DATA(a);
- anorm = mpsize(asize, adata);
- bsize = MPW_SIZE(b);
- bdata = MPW_DATA(b);
- bnorm = mpsize(bsize, bdata);
-
- if (mpz(bsize, bdata)) {
- PyErr_SetString(PyExc_ZeroDivisionError, "mpw_divmod by zero");
- goto exit;
- }
-
- if (anorm < asize) {
- asize -= anorm;
- adata += anorm;
- }
- zsize = asize + 1;
- zdata = alloca(zsize * sizeof(*zdata));
- if (bnorm < bsize) {
- bsize -= bnorm;
- bdata += bnorm;
- }
- qsign = a->ob_size * b->ob_size;
- wksp = alloca((bsize+1) * sizeof(*wksp));
-
- mpndivmod(zdata, asize, adata, bsize, bdata, wksp);
-
-if (_mpw_debug < 0) {
-fprintf(stderr, " a %p[%d]:\t", adata, asize), mpfprintln(stderr, asize, adata);
-fprintf(stderr, " b %p[%d]:\t", bdata, bsize), mpfprintln(stderr, bsize, bdata);
-fprintf(stderr, " z %p[%d]:\t", zdata, zsize), mpfprintln(stderr, zsize, zdata);
-}
-
- zsize -= bsize;
- r = mpw_FromMPW(bsize, zdata+zsize, 1);
- if (r == NULL)
- goto exit;
- if (qsign < 0) {
- if (b->ob_size < 0) {
- (void) mpsubx(MPW_SIZE(r), MPW_DATA(r), bsize, bdata);
- mpneg(MPW_SIZE(r), MPW_DATA(r));
- } else {
- mpneg(MPW_SIZE(r), MPW_DATA(r));
- (void) mpaddx(MPW_SIZE(r), MPW_DATA(r), bsize, bdata);
- }
- (void) mpaddw(zsize, zdata, (mpw)1);
- }
- if (b->ob_size < 0)
- r->ob_size = -r->ob_size;
-
- q = mpw_FromMPW(zsize, zdata, 1);
- if (q == NULL) {
- Py_DECREF(r);
- goto exit;
- }
- if (qsign < 0)
- q->ob_size = -q->ob_size;
-
-if (_mpw_debug) {
-prtmpw("q", q);
-prtmpw("r", r);
-fprintf(stderr, "*** mpw_divmod(%p,%p)\n", a, b);
-}
- if ((z = PyTuple_New(2)) == NULL) {
- Py_DECREF(q);
- Py_DECREF(r);
- goto exit;
- }
-
- (void) PyTuple_SetItem(z, 0, (PyObject *)q);
- (void) PyTuple_SetItem(z, 1, (PyObject *)r);
-
-exit:
- Py_XDECREF(a);
- Py_XDECREF(b);
- return (PyObject *)z;
-}
-
-static PyObject *
-mpw_pow(PyObject * a, PyObject * b, PyObject * c)
- /*@*/
-{
- if (c != Py_None)
- return mpw_ops3("Powm", 'P', mpw_i2mpw(a), mpw_i2mpw(b), mpw_i2mpw(c));
- else
- return mpw_ops2("pow", 'P', mpw_i2mpw(a), mpw_i2mpw(b));
-}
-
-static PyObject *
-mpw_neg(mpwObject * a)
- /*@*/
-{
- mpwObject *z;
-
- if (a->ob_size == 0 && mpw_CheckExact(a)) {
- /* -0 == 0 */
- Py_INCREF(a);
- z = a;
- } else {
- z = mpw_Copy(a);
- if (z != NULL)
- z->ob_size = -(a->ob_size);
- }
-
-if (z != NULL && _mpw_debug)
-fprintf(stderr, "*** mpw_neg %p[%d]\t", MPW_DATA(z), MPW_SIZE(z)), mpfprintln(stderr, MPW_SIZE(z), MPW_DATA(z));
-
- return (PyObject *)z;
-}
-
-static PyObject *
-mpw_pos(mpwObject * a)
- /*@*/
-{
- mpwObject *z;
-
- if (mpw_CheckExact(a)) {
- Py_INCREF(a);
- z = a;
- } else
- z = mpw_Copy(a);
-
-if (z != NULL && _mpw_debug)
-fprintf(stderr, "*** mpw_pos %p[%d]\t", MPW_DATA(z), MPW_SIZE(z)), mpfprintln(stderr, MPW_SIZE(z), MPW_DATA(z));
-
- return (PyObject *)z;
-}
-
-static PyObject *
-mpw_abs(mpwObject * a)
- /*@*/
-{
- mpwObject * z;
-
- if (a->ob_size < 0)
- z = (mpwObject *)mpw_neg(a);
- else
- z = (mpwObject *)mpw_pos(a);
-
-if (z != NULL && _mpw_debug)
-fprintf(stderr, "*** mpw_abs %p[%d]\t", MPW_DATA(z), MPW_SIZE(z)), mpfprintln(stderr, MPW_SIZE(z), MPW_DATA(z));
-
- return (PyObject *)z;
-}
-
-static int
-mpw_nonzero(mpwObject * a)
- /*@*/
-{
- return ABS(a->ob_size) != 0;
-}
-
-static PyObject *
-mpw_invert(mpwObject * a)
- /*@*/
-{
- /* Implement ~z as -(z+1) */
- mpwObject * z = mpw_Copy(a);
-
- if (z != NULL) {
- mpw val = 1;
- int carry;
-
- carry = mpaddx(MPW_SIZE(z), MPW_DATA(z), 1, &val);
- z->ob_size = -(a->ob_size);
- }
- return (PyObject *)z;
-}
-
-static PyObject *
-mpw_lshift(PyObject * a, PyObject * b)
- /*@*/
-{
- return mpw_ops2("lshift", '<', mpw_i2mpw(a), mpw_i2mpw(b));
-}
-
-static PyObject *
-mpw_rshift(PyObject * a, PyObject * b)
- /*@*/
-{
- return mpw_ops2("rshift", '>', mpw_i2mpw(a), mpw_i2mpw(b));
-}
-
-static PyObject *
-mpw_and(PyObject * a, PyObject * b)
- /*@*/
-{
- return mpw_ops2("and", '&', mpw_i2mpw(a), mpw_i2mpw(b));
-}
-
-static PyObject *
-mpw_xor(PyObject * a, PyObject * b)
- /*@*/
-{
- return mpw_ops2("xor", '^', mpw_i2mpw(a), mpw_i2mpw(b));
-}
-
-static PyObject *
-mpw_or(PyObject * a, PyObject * b)
- /*@*/
-{
- return mpw_ops2("or", '|', mpw_i2mpw(a), mpw_i2mpw(b));
-}
-
-static int
-mpw_coerce(PyObject ** pv, PyObject ** pw)
- /*@modifies *pv, *pw @*/
-{
-
-if (_mpw_debug)
-fprintf(stderr, "*** mpw_coerce(%p[%s],%p[%s])\n", pv, lbl(*pv), pw, lbl(*pw));
-
- if (mpw_Check(*pw))
- Py_INCREF(*pw);
- else if (PyInt_Check(*pw))
- *pw = (PyObject *) mpw_FromLong(PyInt_AsLong(*pw));
- else if (PyLong_Check(*pw))
- *pw = (PyObject *) mpw_FromLongObject((PyLongObject *)(*pw));
- else if (PyFloat_Check(*pw))
- *pw = (PyObject *) mpw_FromDouble(PyFloat_AsDouble(*pw));
- else if (PyString_Check(*pw))
- *pw = (PyObject *) mpw_FromHEX(PyString_AS_STRING(*pw));
- else {
- PyErr_SetString(PyExc_TypeError, "non-numeric coercion failed (mpw_coerce)");
- return 1;
- }
-
- Py_INCREF(*pv);
- return 0;
-}
-
-static PyObject *
-mpw_int(mpwObject * a)
- /*@*/
-{
- size_t anorm = MPW_SIZE(a) - MP_ROUND_B2W(MPBITCNT(MPW_SIZE(a), MPW_DATA(a)));
- size_t asize = MPW_SIZE(a) - anorm;
- mpw* adata = MPW_DATA(a) + anorm;
- long ival = 0;
-
- if (asize > 1) {
- PyErr_SetString(PyExc_ValueError, "mpw_int: arg too long to convert");
- return NULL;
- }
- if (asize == 1)
- ival = adata[0];
- if (a->ob_size < 0)
- ival = -ival;
-
- return Py_BuildValue("i", ival);
-}
-
-static PyObject *
-mpw_long(mpwObject * a)
- /*@*/
-{
- size_t abits = MPBITCNT(MPW_SIZE(a), MPW_DATA(a));
- size_t anorm = MPW_SIZE(a) - MP_ROUND_B2W(abits);
- size_t asize = MPW_SIZE(a) - anorm;
- mpw* adata = MPW_DATA(a) + anorm;
- size_t zsize = asize;
- mpw* zdata = alloca(zsize * sizeof(*zdata));
- int lsize = BITS_TO_DIGITS(abits);
- PyLongObject *lo = _PyLong_New(lsize);
- int digx;
-
- if (lo == NULL)
- return NULL;
-
- mpcopy(asize, zdata, adata);
-
- for (digx = 0; digx < lsize; digx++) {
- lo->ob_digit[digx] = zdata[zsize - 1] & MASK;
- mprshift(zsize, zdata, SHIFT);
- }
-
- while (digx > 0 && lo->ob_digit[digx-1] == 0)
- digx--;
- lo->ob_size = (a->ob_size >= 0 ? digx : -digx);
-
- return (PyObject *)lo;
-}
-
-static PyObject *
-mpw_float(mpwObject * a)
- /*@*/
-{
- PyObject * so = mpw_format(a, 10, 0);
- char * s, * se;
- double d;
-
- if (so == NULL)
- return NULL;
- s = PyString_AS_STRING(so);
- se = NULL;
- d = strtod(s, &se);
-
-if (_mpw_debug)
-fprintf(stderr, "*** mpw_float(%p): s %p \"%s\" se %p d %g\n", a, s, s, se, d);
- Py_DECREF(so);
-
- return Py_BuildValue("d", d);
-}
-
-static PyObject *
-mpw_oct(mpwObject * a)
- /*@*/
-{
- return mpw_format(a, 8, 1);
-}
-
-static PyObject *
-mpw_hex(mpwObject * a)
- /*@*/
-{
- return mpw_format(a, 16, 1);
-}
-
-static PyNumberMethods mpw_as_number = {
- (binaryfunc) mpw_add, /* nb_add */
- (binaryfunc) mpw_sub, /* nb_subtract */
- (binaryfunc) mpw_mul, /* nb_multiply */
- (binaryfunc) mpw_classic_div, /* nb_divide */
- (binaryfunc) mpw_mod, /* nb_remainder */
- (binaryfunc) mpw_divmod, /* nb_divmod */
- (ternaryfunc) mpw_pow, /* nb_power */
- (unaryfunc) mpw_neg, /* nb_negative */
- (unaryfunc) mpw_pos, /* nb_positive */
- (unaryfunc) mpw_abs, /* nb_absolute */
- (inquiry) mpw_nonzero, /* nb_nonzero */
- (unaryfunc) mpw_invert, /* nb_invert */
- (binaryfunc) mpw_lshift, /* nb_lshift */
- (binaryfunc) mpw_rshift, /* nb_rshift */
- (binaryfunc) mpw_and, /* nb_and */
- (binaryfunc) mpw_xor, /* nb_xor */
- (binaryfunc) mpw_or, /* nb_or */
- (coercion) mpw_coerce, /* nb_coerce */
-
- (unaryfunc) mpw_int, /* nb_int */
- (unaryfunc) mpw_long, /* nb_long */
- (unaryfunc) mpw_float, /* nb_float */
- (unaryfunc) mpw_oct, /* nb_oct */
- (unaryfunc) mpw_hex, /* nb_hex */
-
- /* Added in release 2.0 */
- (binaryfunc) 0, /* nb_inplace_add */
- (binaryfunc) 0, /* nb_inplace_subtract */
- (binaryfunc) 0, /* nb_inplace_multiply */
- (binaryfunc) 0, /* nb_inplace_divide */
- (binaryfunc) 0, /* nb_inplace_remainder */
- (ternaryfunc)0, /* nb_inplace_power */
- (binaryfunc) 0, /* nb_inplace_lshift */
- (binaryfunc) 0, /* nb_inplace_rshift */
- (binaryfunc) 0, /* nb_inplace_and */
- (binaryfunc) 0, /* nb_inplace_xor */
- (binaryfunc) 0, /* nb_inplace_or */
-
- /* Added in release 2.2 */
- /* The following require the Py_TPFLAGS_HAVE_CLASS flag */
- (binaryfunc) mpw_div, /* nb_floor_divide */
- (binaryfunc) 0, /* nb_true_divide */
- (binaryfunc) 0, /* nb_inplace_floor_divide */
- (binaryfunc) 0 /* nb_inplace_true_divide */
-
-};
-
-/* ---------- */
-
-/**
- */
-/*@unchecked@*/ /*@observer@*/
-static char mpw_doc[] =
-"";
-
-/*@-fullinitblock@*/
-PyTypeObject mpw_Type = {
- PyObject_HEAD_INIT(&PyType_Type)
- 0, /* ob_size */
- "rpm.mpw", /* tp_name */
- sizeof(mpwObject) - sizeof(mpw),/* tp_basicsize */
- sizeof(mpw), /* tp_itemsize */
- /* methods */
- (destructor) mpw_dealloc, /* tp_dealloc */
- 0, /* tp_print */
- 0, /* tp_getattr */
- 0, /* tp_setattr */
- (cmpfunc) mpw_compare, /* tp_compare */
- (reprfunc) mpw_repr, /* tp_repr */
- &mpw_as_number, /* tp_as_number */
- 0, /* tp_as_sequence */
- 0, /* tp_as_mapping */
- (hashfunc)0, /* tp_hash */
- 0, /* tp_call */
- (reprfunc) mpw_str, /* tp_str */
- (getattrofunc) mpw_getattro, /* tp_getattro */
- (setattrofunc) mpw_setattro, /* tp_setattro */
- 0, /* tp_as_buffer */
- Py_TPFLAGS_DEFAULT | Py_TPFLAGS_CHECKTYPES |
- Py_TPFLAGS_BASETYPE, /* tp_flags */
- mpw_doc, /* tp_doc */
- 0, /* tp_traverse */
- 0, /* tp_clear */
- 0, /* tp_richcompare */
- 0, /* tp_weaklistoffset */
- 0, /* tp_iter */
- 0, /* tp_iternext */
- mpw_methods, /* tp_methods */
- 0, /* tp_members */
- 0, /* tp_getset */
- 0, /* tp_base */
- 0, /* tp_dict */
- 0, /* tp_descr_get */
- 0, /* tp_descr_set */
- 0, /* tp_dictoffset */
- 0, /* tp_init */
- 0, /* tp_alloc */
- (newfunc) mpw_new, /* tp_new */
- (destructor) mpw_free, /* tp_free */
- 0, /* tp_is_gc */
-};
-/*@=fullinitblock@*/
-
-/* ---------- */
diff --git a/python/rpmmpw-py.h b/python/rpmmpw-py.h
index 2b31043f8..2ad1da47f 100644
--- a/python/rpmmpw-py.h
+++ b/python/rpmmpw-py.h
@@ -3,7 +3,7 @@
#include "rpmio_internal.h"
-/** \ingroup py_c
+/** \ingroup py_c
* \file python/rpmmpw-py.h
*/
diff --git a/python/rpmrc-py.c b/python/rpmrc-py.c
index a896ca38d..43fb1051f 100644
--- a/python/rpmrc-py.c
+++ b/python/rpmrc-py.c
@@ -1,4 +1,4 @@
-/** \ingroup py_c
+/** \ingroup py_c
* \file python/rpmrc-py.c
*/
@@ -249,7 +249,7 @@ fprintf(stderr, "*** rpmrc_next(%p[%s],%p)\n", s, lbl(s), args);
return NULL;
}
-/** \ingroup py_c
+/** \ingroup py_c
*/
static int rpmrc_init(PyObject * s, PyObject *args, PyObject *kwds)
/*@*/
@@ -261,7 +261,7 @@ fprintf(stderr, "*** rpmrc_init(%p[%s],%p,%p)\n", s, lbl(s), args, kwds);
return 0;
}
-/** \ingroup py_c
+/** \ingroup py_c
*/
static void rpmrc_free(PyObject * s)
/*@*/
@@ -271,7 +271,7 @@ fprintf(stderr, "*** rpmrc_free(%p[%s])\n", s, lbl(s));
_PyObject_GC_Del(s);
}
-/** \ingroup py_c
+/** \ingroup py_c
*/
static PyObject * rpmrc_alloc(PyTypeObject * subtype, int nitems)
/*@*/
@@ -283,7 +283,7 @@ fprintf(stderr, "*** rpmrc_alloc(%p[%s},%d) ret %p[%s]\n", subtype, lbl(subtype)
return (PyObject *) ns;
}
-/** \ingroup py_c
+/** \ingroup py_c
*/
static PyObject * rpmrc_new(PyTypeObject * subtype, PyObject *args, PyObject *kwds)
/*@*/
@@ -322,7 +322,7 @@ static struct PyMethodDef rpmrc_methods[] = {
};
/*@=fullinitblock@*/
-/** \ingroup py_c
+/** \ingroup py_c
*/
/*@-fullinitblock@*/
#if Py_TPFLAGS_HAVE_ITER
diff --git a/python/rpmrc-py.h b/python/rpmrc-py.h
index 788ba3b1b..ccac3b689 100644
--- a/python/rpmrc-py.h
+++ b/python/rpmrc-py.h
@@ -1,15 +1,15 @@
#ifndef H_RPMRC_PY
#define H_RPMRC_PY
-/** \ingroup py_c
+/** \ingroup py_c
* \file python/rpmrc-py.h
*/
-/** \ingroup py_c
+/** \ingroup py_c
*/
typedef struct rpmrcObject_s rpmrcObject;
-/** \ingroup py_c
+/** \ingroup py_c
*/
struct rpmrcObject_s {
#if Py_TPFLAGS_HAVE_ITER /* XXX backport to python-1.5.2 */
diff --git a/python/rpmrng-py.c b/python/rpmrng-py.c
deleted file mode 100644
index 69561ea05..000000000
--- a/python/rpmrng-py.c
+++ /dev/null
@@ -1,330 +0,0 @@
-/** \ingroup py_c
- * \file python/rpmrng-py.c
- */
-
-#include "system.h"
-
-#include "Python.h"
-#ifdef __LCLINT__
-#undef PyObject_HEAD
-#define PyObject_HEAD int _PyObjectHead;
-#endif
-
-#include "rpmrng-py.h"
-#include "mpprime.h"
-
-#include "rpmdebug-py.c"
-
-#include "debug.h"
-
-/*@unchecked@*/
-static int _rng_debug = 0;
-
-/*@unchecked@*/ /*@observer@*/
-static const char initialiser_name[] = "rpm.rng";
-
-/* ---------- */
-
-static void
-rng_dealloc(rngObject * s)
- /*@modifies s @*/
-{
-if (_rng_debug < -1)
-fprintf(stderr, "*** rng_dealloc(%p)\n", s);
-
-/*@-modobserver@*/
- randomGeneratorContextFree(&s->rngc);
-/*@=modobserver@*/
- mpbfree(&s->b);
- PyObject_Del(s);
-}
-
-static int
-rng_print(rngObject * s, FILE * fp, /*@unused@*/ int flags)
- /*@globals fileSystem @*/
- /*@modifies fileSystem @*/
-{
-if (_rng_debug < -1)
-fprintf(stderr, "*** rng_print(%p)\n", s);
- return 0;
-}
-
-/** \ingroup py_c
- */
-static int rng_init(rngObject * s, PyObject *args, PyObject *kwds)
- /*@modifies s @*/
-{
- PyObject * o = NULL;
- const randomGenerator* rng = NULL;
-
- if (!PyArg_ParseTuple(args, "|O:Cvt", &o)) return -1;
-
- if (o) {
- /* XXX "FIPS 186" or "Mersenne Twister" */
- if (PyString_Check(o))
- rng = randomGeneratorFind(PyString_AsString(o));
- }
-
- if (rng == NULL)
- rng = randomGeneratorDefault();
-
-/*@-modobserver@*/
- if (randomGeneratorContextInit(&s->rngc, rng) != 0)
- return -1;
-/*@=modobserver@*/
- mpbzero(&s->b);
-
-if (_rng_debug)
-fprintf(stderr, "*** rng_init(%p[%s],%p[%s],%p[%s])\n", s, lbl(s), args, lbl(args), kwds, lbl(kwds));
-
- return 0;
-}
-
-/** \ingroup py_c
- */
-static void rng_free(/*@only@*/ rngObject * s)
- /*@modifies s @*/
-{
-if (_rng_debug)
-fprintf(stderr, "*** rng_free(%p[%s])\n", s, lbl(s));
-/*@-modobserver@*/
- randomGeneratorContextFree(&s->rngc);
-/*@=modobserver@*/
- mpbfree(&s->b);
- PyObject_Del(s);
-}
-
-/** \ingroup py_c
- */
-static PyObject * rng_alloc(PyTypeObject * subtype, int nitems)
- /*@*/
-{
- PyObject * ns = PyType_GenericAlloc(subtype, nitems);
-
-if (_rng_debug)
-fprintf(stderr, "*** rng_alloc(%p[%s},%d) ret %p[%s]\n", subtype, lbl(subtype), nitems, ns, lbl(ns));
- return (PyObject *) ns;
-}
-
-static PyObject *
-rng_new(PyTypeObject * subtype, PyObject *args, PyObject *kwds)
- /*@*/
-{
- PyObject * ns = (PyObject *) PyObject_New(rngObject, &rng_Type);
-
-if (_rng_debug < -1)
-fprintf(stderr, "*** rng_new(%p[%s],%p[%s],%p[%s]) ret %p[%s]\n", subtype, lbl(subtype), args, lbl(args), kwds, lbl(kwds), ns, lbl(ns));
- return ns;
-}
-
-static rngObject *
-rng_New(void)
-{
- rngObject * ns = PyObject_New(rngObject, &rng_Type);
-
- return ns;
-}
-
-/* ---------- */
-
-/** \ingroup py_c
- */
-static PyObject *
-rng_Debug(/*@unused@*/ rngObject * s, PyObject * args)
- /*@globals _Py_NoneStruct @*/
- /*@modifies _Py_NoneStruct @*/
-{
- if (!PyArg_ParseTuple(args, "i:Debug", &_rng_debug)) return NULL;
-
-if (_rng_debug < 0)
-fprintf(stderr, "*** rng_Debug(%p)\n", s);
-
- Py_INCREF(Py_None);
- return Py_None;
-}
-
-/** \ingroup py_c
- */
-static PyObject *
-rng_Seed(rngObject * s, PyObject * args)
- /*@globals _Py_NoneStruct @*/
- /*@modifies _Py_NoneStruct @*/
-{
- PyObject * o;
- randomGeneratorContext* rc = &s->rngc;
- mpwObject *z;
-
- if (!PyArg_ParseTuple(args, "O:Seed", &o)) return NULL;
-
- if (!mpw_Check(o) || MPW_SIZE(z = (mpwObject*)o) > 0)
- return NULL;
-
- rc->rng->seed(rc->param, (byte*) MPW_DATA(z), MPW_SIZE(z));
-
-if (_rng_debug < 0)
-fprintf(stderr, "*** rng_Seed(%p)\n", s);
-
- Py_INCREF(Py_None);
- return Py_None;
-}
-
-/** \ingroup py_c
- */
-static PyObject *
-rng_Next(rngObject * s, PyObject * args)
- /*@*/
-{
- PyObject * o = NULL;
- randomGeneratorContext* rc = &s->rngc;
- mpbarrett* b = &s->b;
- mpwObject *z;
-
- if (!PyArg_ParseTuple(args, "|O:Next", &o)) return NULL;
-
- if (o) {
- if (mpw_Check(o) && MPW_SIZE(z = (mpwObject*)o) > 0) {
- b = alloca(sizeof(*b));
- mpbzero(b);
- /* XXX z probably needs normalization here. */
- mpbset(b, MPW_SIZE(z), MPW_DATA(z));
- } else
- ; /* XXX error? */
- }
-
- if (b == NULL || b->size == 0 || b->modl == NULL) {
- z = mpw_New(1);
- rc->rng->next(rc->param, (byte*) MPW_DATA(z), sizeof(*MPW_DATA(z)));
- } else {
- mpw* wksp = alloca(b->size * sizeof(*wksp));
- z = mpw_New(b->size);
- mpbrnd_w(b, rc, MPW_DATA(z), wksp);
- }
-
-if (_rng_debug)
-fprintf(stderr, "*** rng_Next(%p) %p[%d]\t", s, MPW_DATA(z), MPW_SIZE(z)), mpfprintln(stderr, MPW_SIZE(z), MPW_DATA(z));
-
- return (PyObject *)z;
-}
-
-/** \ingroup py_c
- */
-static PyObject *
-rng_Prime(rngObject * s, PyObject * args)
- /*@*/
-{
- randomGeneratorContext* rc = &s->rngc;
- unsigned pbits = 160;
- int trials = -1;
- size_t psize;
- mpbarrett* b;
- mpw *temp;
- mpwObject *z;
-
- if (!PyArg_ParseTuple(args, "|ii:Prime", &pbits, &trials)) return NULL;
-
- psize = MP_ROUND_B2W(pbits);
- temp = alloca((8*psize+2) * sizeof(*temp));
-
- b = alloca(sizeof(*b));
- mpbzero(b);
-
- if (trials <= 2)
- trials = mpptrials(pbits);
-#if 1
- mpprnd_w(b, rc, pbits, trials, (const mpnumber*) 0, temp);
-#else
- mpprndsafe_w(b, rc, pbits, trials, temp);
-#endif
-
- z = mpw_FromMPW(b->size, b->modl, 1);
-if (z != NULL && _rng_debug)
-fprintf(stderr, "*** rng_Prime(%p) %p[%d]\t", s, MPW_DATA(z), MPW_SIZE(z)), mpfprintln(stderr, MPW_SIZE(z), MPW_DATA(z));
-
- return (PyObject *)z;
-}
-
-/*@-fullinitblock@*/
-/*@unchecked@*/ /*@observer@*/
-static struct PyMethodDef rng_methods[] = {
- {"Debug", (PyCFunction)rng_Debug, METH_VARARGS,
- NULL},
- {"seed", (PyCFunction)rng_Seed, METH_VARARGS,
- NULL},
- {"next", (PyCFunction)rng_Next, METH_VARARGS,
- NULL},
- {"prime", (PyCFunction)rng_Prime, METH_VARARGS,
- NULL},
- {NULL, NULL} /* sentinel */
-};
-/*@=fullinitblock@*/
-
-static PyObject * rng_getattro(PyObject * o, PyObject * n)
- /*@*/
-{
- return PyObject_GenericGetAttr(o, n);
-}
-
-static int rng_setattro(PyObject * o, PyObject * n, PyObject * v)
- /*@*/
-{
- return PyObject_GenericSetAttr(o, n, v);
-}
-
-/* ---------- */
-
-/**
- */
-/*@unchecked@*/ /*@observer@*/
-static char rng_doc[] =
-"";
-
-/*@-fullinitblock@*/
-PyTypeObject rng_Type = {
- PyObject_HEAD_INIT(&PyType_Type)
- 0, /* ob_size */
- "rpm.rng", /* tp_name */
- sizeof(rngObject), /* tp_basicsize */
- 0, /* tp_itemsize */
- /* methods */
- (destructor) rng_dealloc, /* tp_dealloc */
- (printfunc) rng_print, /* tp_print */
- (getattrfunc)0, /* tp_getattr */
- (setattrfunc)0, /* tp_setattr */
- (cmpfunc)0, /* tp_compare */
- (reprfunc)0, /* tp_repr */
- 0, /* tp_as_number */
- 0, /* tp_as_sequence */
- 0, /* tp_as_mapping */
- (hashfunc)0, /* tp_hash */
- (ternaryfunc)0, /* tp_call */
- (reprfunc)0, /* tp_str */
- (getattrofunc) rng_getattro, /* tp_getattro */
- (setattrofunc) rng_setattro, /* tp_setattro */
- 0, /* tp_as_buffer */
- Py_TPFLAGS_DEFAULT, /* tp_flags */
- rng_doc, /* tp_doc */
-#if Py_TPFLAGS_HAVE_ITER
- 0, /* tp_traverse */
- 0, /* tp_clear */
- 0, /* tp_richcompare */
- 0, /* tp_weaklistoffset */
- (getiterfunc)0, /* tp_iter */
- (iternextfunc)0, /* tp_iternext */
- rng_methods, /* tp_methods */
- 0, /* tp_members */
- 0, /* tp_getset */
- 0, /* tp_base */
- 0, /* tp_dict */
- 0, /* tp_descr_get */
- 0, /* tp_descr_set */
- 0, /* tp_dictoffset */
- (initproc) rng_init, /* tp_init */
- (allocfunc) rng_alloc, /* tp_alloc */
- (newfunc) rng_new, /* tp_new */
- (destructor) rng_free, /* tp_free */
- 0, /* tp_is_gc */
-#endif
-};
-/*@=fullinitblock@*/
-
-/* ---------- */
diff --git a/python/rpmrng-py.h b/python/rpmrng-py.h
index 317d53af3..14c60e6b1 100644
--- a/python/rpmrng-py.h
+++ b/python/rpmrng-py.h
@@ -3,7 +3,7 @@
#include "rpmio_internal.h"
-/** \ingroup py_c
+/** \ingroup py_c
* \file python/rpmrng-py.h
*/
diff --git a/python/rpmte-py.c b/python/rpmte-py.c
index 1f15102ea..e1e1ff60c 100644
--- a/python/rpmte-py.c
+++ b/python/rpmte-py.c
@@ -1,4 +1,4 @@
-/** \ingroup py_c
+/** \ingroup py_c
* \file python/rpmte-py.c
*/
@@ -289,7 +289,7 @@ rpmte_FI(rpmteObject * s, PyObject * args)
return (PyObject *) rpmfi_Wrap(rpmfiLink(fi, "rpmte_FI"));
}
-/** \ingroup py_c
+/** \ingroup py_c
*/
/*@-fullinitblock@*/
/*@unchecked@*/ /*@observer@*/
@@ -390,7 +390,7 @@ static int rpmte_setattro(PyObject * o, PyObject * n, PyObject * v)
static char rpmte_doc[] =
"";
-/** \ingroup py_c
+/** \ingroup py_c
*/
/*@-fullinitblock@*/
PyTypeObject rpmte_Type = {
diff --git a/python/rpmte-py.h b/python/rpmte-py.h
index 54aa7c5c4..504cc5ee2 100644
--- a/python/rpmte-py.h
+++ b/python/rpmte-py.h
@@ -3,7 +3,7 @@
#include "rpmte.h"
-/** \ingroup py_c
+/** \ingroup py_c
* \file python/rpmte-py.h
*/
diff --git a/python/rpmts-py.c b/python/rpmts-py.c
index eaa80d008..1b81a96cc 100644
--- a/python/rpmts-py.c
+++ b/python/rpmts-py.c
@@ -1,4 +1,4 @@
-/** \ingroup py_c
+/** \ingroup py_c
* \file python/rpmts-py.c
*/
@@ -43,7 +43,7 @@ static int _rpmts_debug = 0;
* \name Class: Rpmts
* \class Rpmts
* \brief A python rpm.ts object represents an RPM transaction set.
- *
+ *
* The transaction set is the workhorse of RPM. It performs the
* installation and upgrade of packages. The rpm.ts object is
* instantiated by the TransactionSet function in the rpm module.
@@ -141,14 +141,14 @@ static int _rpmts_debug = 0;
* - ts.setProbFilter(ignoreSet) Set transaction set problem filter.
* @param problemSetFilter - control bit(s) to ignore classes of problems,
* a logical or of one or more of the following bit(s):
- * - rpm.RPMPROB_FILTER_IGNOREOS -
- * - rpm.RPMPROB_FILTER_IGNOREARCH -
- * - rpm.RPMPROB_FILTER_REPLACEPKG -
- * - rpm.RPMPROB_FILTER_FORCERELOCATE -
- * - rpm.RPMPROB_FILTER_REPLACENEWFILES -
- * - rpm.RPMPROB_FILTER_REPLACEOLDFILES -
- * - rpm.RPMPROB_FILTER_OLDPACKAGE -
- * - rpm.RPMPROB_FILTER_DISKSPACE -
+ * - rpm.RPMPROB_FILTER_IGNOREOS -
+ * - rpm.RPMPROB_FILTER_IGNOREARCH -
+ * - rpm.RPMPROB_FILTER_REPLACEPKG -
+ * - rpm.RPMPROB_FILTER_FORCERELOCATE -
+ * - rpm.RPMPROB_FILTER_REPLACENEWFILES -
+ * - rpm.RPMPROB_FILTER_REPLACEOLDFILES -
+ * - rpm.RPMPROB_FILTER_OLDPACKAGE -
+ * - rpm.RPMPROB_FILTER_DISKSPACE -
* @return previous ignoreSet
*
* - ts.run(callback,data) Attempt to execute a transaction set.
@@ -157,7 +157,7 @@ static int _rpmts_debug = 0;
* the ts.run() method.
*/
-/** \ingroup py_c
+/** \ingroup py_c
*/
struct rpmtsCallbackType_s {
PyObject * cb;
@@ -167,7 +167,7 @@ struct rpmtsCallbackType_s {
PyThreadState *_save;
};
-/** \ingroup py_c
+/** \ingroup py_c
*/
static PyObject *
rpmts_Debug(/*@unused@*/ rpmtsObject * s, PyObject * args)
@@ -183,7 +183,7 @@ fprintf(stderr, "*** rpmts_Debug(%p) ts %p\n", s, s->ts);
return Py_None;
}
-/** \ingroup py_c
+/** \ingroup py_c
* Add package to universe of possible packages to install in transaction set.
* @param ts transaction set
* @param h header
@@ -208,7 +208,7 @@ fprintf(stderr, "\tAddAvailable(%p) list %p\n", ts, ts->availablePackages);
}
-/** \ingroup py_c
+/** \ingroup py_c
*/
static PyObject *
rpmts_AddInstall(rpmtsObject * s, PyObject * args)
@@ -252,7 +252,7 @@ fprintf(stderr, "*** rpmts_AddInstall(%p,%p,%p,%s) ts %p\n", s, h, key, how, s->
return Py_None;
}
-/** \ingroup py_c
+/** \ingroup py_c
* @todo Permit finer control (i.e. not just --allmatches) of deleted elments.
*/
static PyObject *
@@ -263,7 +263,7 @@ rpmts_AddErase(rpmtsObject * s, PyObject * args)
PyObject * o;
int count;
rpmdbMatchIterator mi;
-
+
if (_rpmts_debug)
fprintf(stderr, "*** rpmts_AddErase(%p) ts %p\n", s, s->ts);
@@ -313,7 +313,7 @@ fprintf(stderr, "*** rpmts_AddErase(%p) ts %p\n", s, s->ts);
return Py_None;
}
-/** \ingroup py_c
+/** \ingroup py_c
*/
static int
rpmts_SolveCallback(rpmts ts, rpmds ds, const void * data)
@@ -350,7 +350,7 @@ fprintf(stderr, "*** rpmts_SolveCallback(%p,%p,%p) \"%s\"\n", ts, ds, data, rpmd
return res;
}
-/** \ingroup py_c
+/** \ingroup py_c
*/
static PyObject *
rpmts_Check(rpmtsObject * s, PyObject * args)
@@ -415,7 +415,7 @@ fprintf(stderr, "*** rpmts_Check(%p) ts %p cb %p\n", s, s->ts, cbInfo.cb);
char * needsName, * needsOP, * needsVersion;
int needsFlags, sense;
fnpyKey key;
-
+
p = ps->probs + i;
byName = p->pkgNEVR;
@@ -444,7 +444,7 @@ fprintf(stderr, "*** rpmts_Check(%p) ts %p cb %p\n", s, s->ts, cbInfo.cb);
else if (*needsOP == '=') needsFlags |= RPMSENSE_EQUAL;
}
}
-
+
cf = Py_BuildValue("((sss)(ss)iOi)", byName, byVersion, byRelease,
needsName, needsVersion, needsFlags,
(key != NULL ? key : Py_None),
@@ -463,7 +463,7 @@ fprintf(stderr, "*** rpmts_Check(%p) ts %p cb %p\n", s, s->ts, cbInfo.cb);
return Py_None;
}
-/** \ingroup py_c
+/** \ingroup py_c
*/
static PyObject *
rpmts_Order(rpmtsObject * s, PyObject * args)
@@ -484,7 +484,7 @@ fprintf(stderr, "*** rpmts_Order(%p) ts %p\n", s, s->ts);
return Py_BuildValue("i", rc);
}
-/** \ingroup py_c
+/** \ingroup py_c
*/
static PyObject *
rpmts_Clean(rpmtsObject * s, PyObject * args)
@@ -502,7 +502,7 @@ fprintf(stderr, "*** rpmts_Clean(%p) ts %p\n", s, s->ts);
return Py_None;
}
-/** \ingroup py_c
+/** \ingroup py_c
*/
static PyObject *
rpmts_IDTXload(rpmtsObject * s, PyObject * args)
@@ -546,7 +546,7 @@ fprintf(stderr, "*** rpmts_IDTXload(%p) ts %p\n", s, s->ts);
return result;
}
-/** \ingroup py_c
+/** \ingroup py_c
*/
static PyObject *
rpmts_IDTXglob(rpmtsObject * s, PyObject * args)
@@ -593,7 +593,7 @@ fprintf(stderr, "*** rpmts_IDTXglob(%p) ts %p\n", s, s->ts);
return result;
}
-/** \ingroup py_c
+/** \ingroup py_c
*/
static PyObject *
rpmts_Rollback(rpmtsObject * s, PyObject * args)
@@ -629,7 +629,7 @@ fprintf(stderr, "*** rpmts_Rollback(%p) ts %p\n", s, s->ts);
return Py_BuildValue("i", rc);
}
-/** \ingroup py_c
+/** \ingroup py_c
*/
static PyObject *
rpmts_OpenDB(rpmtsObject * s, PyObject * args)
@@ -648,7 +648,7 @@ fprintf(stderr, "*** rpmts_OpenDB(%p) ts %p\n", s, s->ts);
return Py_BuildValue("i", rpmtsOpenDB(s->ts, s->ts->dbmode));
}
-/** \ingroup py_c
+/** \ingroup py_c
*/
static PyObject *
rpmts_CloseDB(rpmtsObject * s, PyObject * args)
@@ -667,7 +667,7 @@ fprintf(stderr, "*** rpmts_CloseDB(%p) ts %p\n", s, s->ts);
return Py_BuildValue("i", rc);
}
-/** \ingroup py_c
+/** \ingroup py_c
*/
static PyObject *
rpmts_InitDB(rpmtsObject * s, PyObject * args)
@@ -688,7 +688,7 @@ fprintf(stderr, "*** rpmts_InitDB(%p) ts %p\n", s, s->ts);
return Py_BuildValue("i", rc);
}
-/** \ingroup py_c
+/** \ingroup py_c
*/
static PyObject *
rpmts_RebuildDB(rpmtsObject * s, PyObject * args)
@@ -709,7 +709,7 @@ fprintf(stderr, "*** rpmts_RebuildDB(%p) ts %p\n", s, s->ts);
return Py_BuildValue("i", rc);
}
-/** \ingroup py_c
+/** \ingroup py_c
*/
static PyObject *
rpmts_VerifyDB(rpmtsObject * s, PyObject * args)
@@ -730,7 +730,7 @@ fprintf(stderr, "*** rpmts_VerifyDB(%p) ts %p\n", s, s->ts);
return Py_BuildValue("i", rc);
}
-/** \ingroup py_c
+/** \ingroup py_c
*/
static PyObject *
rpmts_HdrFromFdno(rpmtsObject * s, PyObject * args)
@@ -777,7 +777,7 @@ fprintf(stderr, "*** rpmts_HdrFromFdno(%p) ts %p rc %d\n", s, s->ts, rpmrc);
return result;
}
-/** \ingroup py_c
+/** \ingroup py_c
*/
static PyObject *
rpmts_HdrCheck(rpmtsObject * s, PyObject * args)
@@ -832,7 +832,7 @@ fprintf(stderr, "*** rpmts_HdrCheck(%p) ts %p\n", s, s->ts);
return result;
}
-/** \ingroup py_c
+/** \ingroup py_c
*/
static PyObject *
rpmts_SetVSFlags(rpmtsObject * s, PyObject * args)
@@ -850,7 +850,7 @@ fprintf(stderr, "*** rpmts_SetVSFlags(%p) ts %p\n", s, s->ts);
return Py_BuildValue("i", rpmtsSetVSFlags(s->ts, vsflags));
}
-/** \ingroup py_c
+/** \ingroup py_c
*/
static PyObject *
rpmts_SetColor(rpmtsObject * s, PyObject * args)
@@ -868,7 +868,7 @@ fprintf(stderr, "*** rpmts_SetColor(%p) ts %p\n", s, s->ts);
return Py_BuildValue("i", rpmtsSetColor(s->ts, tscolor));
}
-/** \ingroup py_c
+/** \ingroup py_c
*/
static PyObject *
rpmts_PgpPrtPkts(rpmtsObject * s, PyObject * args)
@@ -900,7 +900,7 @@ fprintf(stderr, "*** rpmts_PgpPrtPkts(%p) ts %p\n", s, s->ts);
return Py_BuildValue("i", rc);
}
-/** \ingroup py_c
+/** \ingroup py_c
*/
static PyObject *
rpmts_PgpImportPubkey(rpmtsObject * s, PyObject * args)
@@ -932,7 +932,7 @@ fprintf(stderr, "*** rpmts_PgpImportPubkey(%p) ts %p\n", s, s->ts);
return Py_BuildValue("i", rc);
}
-/** \ingroup py_c
+/** \ingroup py_c
*/
static PyObject *
rpmts_GetKeys(rpmtsObject * s, PyObject * args)
@@ -969,7 +969,7 @@ fprintf(stderr, "*** rpmts_GetKeys(%p) ts %p\n", s, s->ts);
return tuple;
}
-/** \ingroup py_c
+/** \ingroup py_c
*/
static void *
rpmtsCallback(/*@unused@*/ const void * hd, const rpmCallbackType what,
@@ -1029,7 +1029,7 @@ rpmtsCallback(/*@unused@*/ const void * hd, const rpmCallbackType what,
fd = fdDup(fdno);
if (_rpmts_debug)
fprintf(stderr, "\t%p = fdDup(%d)\n", fd, fdno);
-
+
return fd;
} else
if (what == RPMCALLBACK_INST_CLOSE_FILE) {
@@ -1047,7 +1047,7 @@ fprintf(stderr, "\t%ld:%ld key %p\n", amount, total, pkgKey);
return NULL;
}
-/** \ingroup py_c
+/** \ingroup py_c
*/
static PyObject * rpmts_SetFlags(rpmtsObject * s, PyObject * args)
/*@modifies s @*/
@@ -1063,7 +1063,7 @@ fprintf(stderr, "*** rpmts_SetFlags(%p) ts %p transFlags %x\n", s, s->ts, transF
return Py_BuildValue("i", rpmtsSetFlags(s->ts, transFlags));
}
-/** \ingroup py_c
+/** \ingroup py_c
*/
static PyObject * rpmts_SetProbFilter(rpmtsObject * s, PyObject * args)
/*@modifies s @*/
@@ -1083,7 +1083,7 @@ fprintf(stderr, "*** rpmts_SetProbFilter(%p) ts %p ignoreSet %x\n", s, s->ts, ig
return Py_BuildValue("i", oignoreSet);
}
-/** \ingroup py_c
+/** \ingroup py_c
*/
static PyObject * rpmts_Run(rpmtsObject * s, PyObject * args)
/*@globals rpmGlobalMacroContext, _Py_NoneStruct @*/
@@ -1229,7 +1229,7 @@ rpmts_Match(rpmtsObject * s, PyObject * args)
char *key = NULL;
int len = 0;
int tag = RPMDBI_PACKAGES;
-
+
if (_rpmts_debug)
fprintf(stderr, "*** rpmts_Match(%p) ts %p\n", s, s->ts);
@@ -1253,7 +1253,7 @@ fprintf(stderr, "*** rpmts_Match(%p) ts %p\n", s, s->ts);
return rpmmi_Wrap( rpmtsInitIterator(s->ts, tag, key, len) );
}
-/** \ingroup py_c
+/** \ingroup py_c
*/
/*@-fullinitblock@*/
/*@unchecked@*/ /*@observer@*/
@@ -1344,7 +1344,7 @@ static struct PyMethodDef rpmts_methods[] = {
};
/*@=fullinitblock@*/
-/** \ingroup py_c
+/** \ingroup py_c
*/
static void rpmts_dealloc(/*@only@*/ rpmtsObject * s)
/*@modifies *s @*/
@@ -1367,7 +1367,7 @@ static PyObject * rpmts_getattro(PyObject * o, PyObject * n)
return PyObject_GenericGetAttr(o, n);
}
-/** \ingroup py_c
+/** \ingroup py_c
*/
static int rpmts_setattro(PyObject * o, PyObject * n, PyObject * v)
/*@modifies o @*/
@@ -1393,7 +1393,7 @@ static int rpmts_setattro(PyObject * o, PyObject * n, PyObject * v)
return 0;
}
-/** \ingroup py_c
+/** \ingroup py_c
*/
static int rpmts_init(rpmtsObject * s, PyObject *args, PyObject *kwds)
/*@globals rpmGlobalMacroContext @*/
@@ -1411,15 +1411,15 @@ fprintf(stderr, "*** rpmts_init(%p,%p,%p)\n", s, args, kwds);
s->ts = rpmtsCreate();
(void) rpmtsSetRootDir(s->ts, rootDir);
(void) rpmtsSetVSFlags(s->ts, vsflags);
- s->keyList = PyList_New(0);
- s->scriptFd = NULL;
+ s->keyList = PyList_New(0);
+ s->scriptFd = NULL;
s->tsi = NULL;
s->tsiFilter = 0;
return 0;
}
-/** \ingroup py_c
+/** \ingroup py_c
*/
static void rpmts_free(/*@only@*/ rpmtsObject * s)
/*@modifies s @*/
@@ -1438,7 +1438,7 @@ fprintf(stderr, "%p -- ts %p db %p\n", s, s->ts, s->ts->rdb);
PyObject_Del((PyObject *)s);
}
-/** \ingroup py_c
+/** \ingroup py_c
*/
static PyObject * rpmts_alloc(PyTypeObject * subtype, int nitems)
/*@*/
@@ -1450,7 +1450,7 @@ fprintf(stderr, "*** rpmts_alloc(%p,%d) ret %p\n", subtype, nitems, s);
return s;
}
-/** \ingroup py_c
+/** \ingroup py_c
*/
static PyObject * rpmts_new(PyTypeObject * subtype, PyObject *args, PyObject *kwds)
/*@globals rpmGlobalMacroContext @*/
@@ -1476,7 +1476,7 @@ fprintf(stderr, "%p ++ ts %p db %p\n", s, s->ts, s->ts->rdb);
static char rpmts_doc[] =
"";
-/** \ingroup py_c
+/** \ingroup py_c
*/
/*@-fullinitblock@*/
PyTypeObject rpmts_Type = {
diff --git a/python/rpmts-py.h b/python/rpmts-py.h
index a84e03775..049976d67 100644
--- a/python/rpmts-py.h
+++ b/python/rpmts-py.h
@@ -3,7 +3,7 @@
#include "rpmts.h"
-/** \ingroup py_c
+/** \ingroup py_c
* \file python/rpmts-py.h
*/