Skip to content

Commit 9c7ca89

Browse files
committed
Mapscript python: fix 'ISO C90 forbids mixed declarations and code' warning, and convert line endings to Unix style
1 parent 95ddad7 commit 9c7ca89

File tree

1 file changed

+34
-35
lines changed

1 file changed

+34
-35
lines changed

Diff for: mapscript/python/pymodule.i

+34-35
Original file line numberDiff line numberDiff line change
@@ -95,41 +95,40 @@ CreateTupleFromDoubleArray( double *first, unsigned int size ) {
9595
* Typemap to turn a Python dict into two sequences and
9696
* an item count. Used for msApplySubstitutions
9797
*/
98-
%typemap(in) (char **names, char **values, int npairs) {
99-
/* Check if is a dict */
100-
if (PyDict_Check($input)) {
101-
102-
int size = PyDict_Size($input);
103-
$3 = size;
104-
$1 = (char **) malloc((size+1)*sizeof(char *));
105-
$2 = (char **) malloc((size+1)*sizeof(char *));
106-
int i = 0;
107-
108-
PyObject* keys = PyDict_Keys($input);
109-
PyObject* values = PyDict_Values($input);
110-
PyObject *key;
111-
PyObject *val;
112-
113-
for (i = 0; i < size; i++) {
114-
key = PyList_GetItem(keys, i);
115-
val = PyList_GetItem(values, i);
116-
117-
$1[i] = PyString_AsString(key);
118-
$2[i] = PyString_AsString(val);
119-
}
120-
121-
$1[i] = 0;
122-
$2[i] = 0;
123-
124-
} else {
125-
PyErr_SetString(PyExc_TypeError, "Input not a dictionary");
126-
SWIG_fail;
127-
}
128-
}
129-
130-
%typemap(freearg) (char **names, char **values, int npairs) {
131-
free((char *) $1);
132-
free((char *) $2);
98+
%typemap(in) (char **names, char **values, int npairs) {
99+
/* Check if is a dict */
100+
if (PyDict_Check($input)) {
101+
102+
int i = 0;
103+
int size = PyDict_Size($input);
104+
105+
PyObject* keys = PyDict_Keys($input);
106+
PyObject* values = PyDict_Values($input);
107+
108+
$3 = size;
109+
$1 = (char **) malloc((size+1)*sizeof(char *));
110+
$2 = (char **) malloc((size+1)*sizeof(char *));
111+
112+
for (i = 0; i < size; i++) {
113+
PyObject* key = PyList_GetItem(keys, i);
114+
PyObject* val = PyList_GetItem(values, i);
115+
116+
$1[i] = PyString_AsString(key);
117+
$2[i] = PyString_AsString(val);
118+
}
119+
120+
$1[i] = 0;
121+
$2[i] = 0;
122+
123+
} else {
124+
PyErr_SetString(PyExc_TypeError, "Input not a dictionary");
125+
SWIG_fail;
126+
}
127+
}
128+
129+
%typemap(freearg) (char **names, char **values, int npairs) {
130+
free((char *) $1);
131+
free((char *) $2);
133132
}
134133

135134
/**************************************************************************

0 commit comments

Comments
 (0)