[Python-checkins] python/dist/src/Modules pwdmodule.c,1.35,1.36
loewis@users.sourceforge.net
loewis@users.sourceforge.net
2002年9月17日 02:34:08 -0700
Update of /cvsroot/python/python/dist/src/Modules
In directory usw-pr-cvs1:/tmp/cvs-serv3322
Modified Files:
pwdmodule.c
Log Message:
Deal with NULL fields in mkpwent.
Index: pwdmodule.c
===================================================================
RCS file: /cvsroot/python/python/dist/src/Modules/pwdmodule.c,v
retrieving revision 1.35
retrieving revision 1.36
diff -C2 -d -r1.35 -r1.36
*** pwdmodule.c 2 Aug 2002 02:27:13 -0000 1.35
--- pwdmodule.c 17 Sep 2002 09:34:06 -0000 1.36
***************
*** 45,48 ****
--- 45,59 ----
static PyTypeObject StructPwdType;
+ static void
+ sets(PyObject *v, int i, char* val)
+ {
+ if (val)
+ PyStructSequence_SET_ITEM(v, i, PyString_FromString(val));
+ else {
+ PyStructSequence_SET_ITEM(v, i, Py_None);
+ Py_INCREF(Py_None);
+ }
+ }
+
static PyObject *
mkpwent(struct passwd *p)
***************
*** 54,58 ****
#define SETI(i,val) PyStructSequence_SET_ITEM(v, i, PyInt_FromLong((long) val))
! #define SETS(i,val) PyStructSequence_SET_ITEM(v, i, PyString_FromString(val))
SETS(setIndex++, p->pw_name);
--- 65,69 ----
#define SETI(i,val) PyStructSequence_SET_ITEM(v, i, PyInt_FromLong((long) val))
! #define SETS(i,val) sets(v, i, val)
SETS(setIndex++, p->pw_name);