[Zope-Checkins] CVS: Products/DCOracle2/src - dco2.c:1.107

Matthew T. Kromer matt@zope.com
Fri, 12 Apr 2002 14:29:46 -0400


Update of /cvs-repository/Products/DCOracle2/src
In directory cvs.zope.org:/tmp/cvs-serv23006/src

Modified Files:
	dco2.c 
Log Message:
Add compare mechanism to OracleDates so you can sort them (Collector issue
# 36)


=== Products/DCOracle2/src/dco2.c 1.106 => 1.107 ===
 static PyObject *OracleDate_str(OracleDate *self);
 static PyObject *OracleDate_repr(OracleDate *self);
+static int OracleDate_cmp(OracleDate *left, OracleDate *right);
 static int OracleDate_coerce(PyObject **o1, PyObject **o2);
 static PyObject *OracleDate_int(OracleDate *self);
 static PyObject *OracleDate_long(OracleDate *self);
@@ -857,7 +858,7 @@
 	(printfunc) NULL,			/* tp_print		*/
 	(getattrfunc) OracleDate_getattr,	/* obsolete tp_getattr	*/
 	(setattrfunc) NULL,			/* obsolete tp_setattr	*/
-	(cmpfunc) NULL,				/* tp_compare		*/
+	(cmpfunc) OracleDate_cmp,		/* tp_compare		*/
 	(reprfunc) OracleDate_repr,		/* tp_repr		*/
 	&OracleDateNumberMethods,		/* tp_as_number		*/
 	NULL,					/* tp_as_sequence	*/
@@ -4936,6 +4937,24 @@
 
 	TRACE(T_EXIT,("sA", "OracleDate_repr", self->repr));
 	return self->repr;
+}
+
+/*
+** OracleDate_cmp
+**
+*/
+
+static int OracleDate_cmp(OracleDate *left, OracleDate *right) {
+
+	int result;
+
+	TRACE(T_ENTRY,("sAA", "OracleDate_cmp", left, right));
+
+	result = memcmp(left->ocidate, right->ocidate, sizeof(left->ocidate));
+	
+	TRACE(T_ENTRY,("sd", "OracleDate_cmp", result));
+
+	return result;
 }
 
 /*