[Python-checkins] CVS: python/dist/src/Modules pyexpat.c,2.44,2.45
Fred L. Drake
fdrake@users.sourceforge.net
Sat, 24 Mar 2001 11:58:28 -0800
Update of /cvsroot/python/python/dist/src/Modules
In directory usw-pr-cvs1:/tmp/cvs-serv11703
Modified Files:
pyexpat.c
Log Message:
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).
Index: pyexpat.c
===================================================================
RCS file: /cvsroot/python/python/dist/src/Modules/pyexpat.c,v
retrieving revision 2.44
retrieving revision 2.45
diff -C2 -r2.44 -r2.45
*** pyexpat.c 2001/03/13 01:58:22 2.44
--- pyexpat.c 2001/03/24 19:58:26 2.45
***************
*** 1,2 ****
--- 1,4 ----
+ #include <ctype.h>
+
#include "Python.h"
#include "compile.h"
***************
*** 1464,1472 ****
#endif
DL_EXPORT(void)
initpyexpat(void)
{
PyObject *m, *d;
- char *rev = "$Revision$";
PyObject *errmod_name = PyString_FromString("pyexpat.errors");
PyObject *errors_module;
--- 1466,1494 ----
#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)
initpyexpat(void)
{
PyObject *m, *d;
PyObject *errmod_name = PyString_FromString("pyexpat.errors");
PyObject *errors_module;
***************
*** 1501,1506 ****
PyModule_AddObject(m, "XMLParserType", (PyObject *) &Xmlparsetype);
! PyModule_AddObject(m, "__version__",
! PyString_FromStringAndSize(rev+11, strlen(rev+11)-2));
#if EXPAT_VERSION >= 0x015f02
PyModule_AddStringConstant(m, "EXPAT_VERSION",
--- 1523,1527 ----
PyModule_AddObject(m, "XMLParserType", (PyObject *) &Xmlparsetype);
! PyModule_AddObject(m, "__version__", get_version_string());
#if EXPAT_VERSION >= 0x015f02
PyModule_AddStringConstant(m, "EXPAT_VERSION",