File long64.diff of Package python-gdchart
--- python-gdchart-0.6.1.orig/gdc_py.c
+++ python-gdchart-0.6.1/gdc_py.c
@@ -1149,9 +1149,21 @@
break;
}
- case opt_int:
case opt_long:
{
+ long *p = (opt->chartvar != NULL) ? opt->chartvar : opt->pievar;
+ if (p != NULL) {
+ key = PyString_FromString(opt->keyword);
+ value = Py_BuildValue("l", *p);
+ PyDict_SetItem(dict, key, value);
+ Py_DECREF(key);
+ Py_DECREF(value);
+ }
+ break;
+ }
+
+ case opt_int:
+ {
int *p = (opt->chartvar != NULL) ? opt->chartvar : opt->pievar;
if (p != NULL) {
key = PyString_FromString(opt->keyword);
@@ -1164,7 +1176,6 @@
}
case opt_int_a:
- case opt_long_a:
{
int **p = (opt->chartvar != NULL) ? opt->chartvar : opt->pievar;
if (p != NULL) {
@@ -1181,6 +1192,23 @@
break;
}
+ case opt_long_a:
+ {
+ long **p = (opt->chartvar != NULL) ? opt->chartvar : opt->pievar;
+ if (p != NULL) {
+ int i;
+ key = PyString_FromString(opt->keyword);
+ value = PyTuple_New(opt->size);
+ for (i = 0; i < opt->size; i++) {
+ PyTuple_SetItem(value, i, Py_BuildValue("l", (*p)[i]));
+ }
+ PyDict_SetItem(dict, key, value);
+ Py_DECREF(key);
+ Py_DECREF(value);
+ }
+ break;
+ }
+
case opt_bool_a:
{
char **p = (opt->chartvar != NULL) ? opt->chartvar : opt->pievar;
@@ -1449,7 +1478,6 @@
}
case opt_int:
- case opt_long: assert(sizeof(int) == sizeof(long));
{
int x = (int) PyInt_AsLong(value);
if (PyErr_Occurred()) {
@@ -1466,8 +1494,24 @@
break;
}
+ case opt_long:
+ {
+ long x = PyInt_AsLong(value);
+ if (PyErr_Occurred()) {
+ SetTypeError("option", keyword);
+ return NULL;
+ }
+
+ if (opt->chartvar != NULL) {
+ *((long *) opt->chartvar) = x;
+ }
+ if (opt->pievar != NULL) {
+ *((long *) opt->pievar) = x;
+ }
+ break;
+ }
+
case opt_int_a:
- case opt_long_a: assert(sizeof(int) == sizeof(long));
{
int size;
int *vals = NULL;
@@ -1516,6 +1560,55 @@
break;
}
+ case opt_long_a:
+ {
+ int size;
+ long *vals = NULL;
+
+ if (value == Py_None) {
+ size = 0;
+ }
+ else {
+ if (!PySequence_Check(value)) {
+ SetTypeError("option", keyword);
+ return NULL;
+ }
+ size = PyObject_Length(value);
+ }
+
+ if (size > 0) {
+ int i;
+ vals = PyMem_Malloc(size * sizeof(long));
+ if (vals == NULL) {
+ PyErr_NoMemory();
+ return NULL;
+ }
+
+ for (i = 0; i < size; i++) {
+ PyObject *element = PySequence_GetItem(value, i);
+ long x = PyInt_AsLong(element);
+ Py_DECREF(element);
+ vals[i] = x;
+ }
+ if (PyErr_Occurred()) {
+ SetTypeError("option", keyword);
+ return NULL;
+ }
+ }
+ if (opt->chartvar != NULL) {
+ *((long **) opt->chartvar) = vals;
+ }
+ if (opt->pievar != NULL) {
+ *((long **) opt->pievar) = vals;
+ }
+ if (*opt->cache != NULL) {
+ PyMem_Free(*opt->cache);
+ }
+ *opt->cache = vals;
+ opt->size = size;
+ break;
+ }
+
case opt_bool_a:
{
int size;
@@ -1552,10 +1645,10 @@
}
}
if (opt->chartvar != NULL) {
- *((int **) opt->chartvar) = vals;
+ *((char **) opt->chartvar) = vals;
}
if (opt->pievar != NULL) {
- *((int **) opt->pievar) = vals;
+ *((char **) opt->pievar) = vals;
}
if (*opt->cache != NULL) {
PyMem_Free(*opt->cache);