get_version_string(): New function -- returns a Python string object that
gives the CVS revision of this file even if it does not include the extra RCS "$Revision: " cruft. initpyexpat(): Use get_version_string() instead of hard-coding magic indexes into the RCS string (which may be affected by export options).
This commit is contained in:
parent
c8da0f966f
commit
4113b137cd
|
@ -1,3 +1,5 @@
|
||||||
|
#include <ctype.h>
|
||||||
|
|
||||||
#include "Python.h"
|
#include "Python.h"
|
||||||
#include "compile.h"
|
#include "compile.h"
|
||||||
#include "frameobject.h"
|
#include "frameobject.h"
|
||||||
|
@ -1463,11 +1465,31 @@ PyModule_AddStringConstant(PyObject *m, char *name, char *value)
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
/* Return a Python string that represents the version number without the
|
||||||
|
* extra cruft added by revision control, even if the right options were
|
||||||
|
* given to the "cvs export" command to make it not include the extra
|
||||||
|
* cruft.
|
||||||
|
*/
|
||||||
|
static PyObject *
|
||||||
|
get_version_string(void)
|
||||||
|
{
|
||||||
|
static char *rcsid = "$Revision$";
|
||||||
|
char *rev = rcsid;
|
||||||
|
int i = 0;
|
||||||
|
|
||||||
|
while (!isdigit(*rev))
|
||||||
|
++rev;
|
||||||
|
while (rev[i] != ' ' && rev[i] != '\0')
|
||||||
|
++i;
|
||||||
|
|
||||||
|
return PyString_FromStringAndSize(rev, i);
|
||||||
|
}
|
||||||
|
|
||||||
DL_EXPORT(void)
|
DL_EXPORT(void)
|
||||||
initpyexpat(void)
|
initpyexpat(void)
|
||||||
{
|
{
|
||||||
PyObject *m, *d;
|
PyObject *m, *d;
|
||||||
char *rev = "$Revision$";
|
|
||||||
PyObject *errmod_name = PyString_FromString("pyexpat.errors");
|
PyObject *errmod_name = PyString_FromString("pyexpat.errors");
|
||||||
PyObject *errors_module;
|
PyObject *errors_module;
|
||||||
PyObject *modelmod_name;
|
PyObject *modelmod_name;
|
||||||
|
@ -1500,8 +1522,7 @@ initpyexpat(void)
|
||||||
Py_INCREF(&Xmlparsetype);
|
Py_INCREF(&Xmlparsetype);
|
||||||
PyModule_AddObject(m, "XMLParserType", (PyObject *) &Xmlparsetype);
|
PyModule_AddObject(m, "XMLParserType", (PyObject *) &Xmlparsetype);
|
||||||
|
|
||||||
PyModule_AddObject(m, "__version__",
|
PyModule_AddObject(m, "__version__", get_version_string());
|
||||||
PyString_FromStringAndSize(rev+11, strlen(rev+11)-2));
|
|
||||||
#if EXPAT_VERSION >= 0x015f02
|
#if EXPAT_VERSION >= 0x015f02
|
||||||
PyModule_AddStringConstant(m, "EXPAT_VERSION",
|
PyModule_AddStringConstant(m, "EXPAT_VERSION",
|
||||||
(char *) XML_ExpatVersion());
|
(char *) XML_ExpatVersion());
|
||||||
|
|
Loading…
Reference in New Issue