Kaydet (Commit) 64a9e38f authored tarafından Hye-Shik Chang's avatar Hye-Shik Chang

Replace an extern magic to assigning declared pointer from array's.

And unifdef(1) compatibility blocks.
üst 22118bc0
...@@ -57,14 +57,8 @@ struct pair_encodemap { ...@@ -57,14 +57,8 @@ struct pair_encodemap {
DBCHAR code; DBCHAR code;
}; };
/* There are really static, and (re)declared so later by the expansions static const MultibyteCodec *codec_list;
* of the BEGIN_MAPPINGS_LIST and BEGIN_CODECS_LIST macros, but it's static const struct dbcs_map *mapping_list;
* not legal C to declare a static array of unknown size. It would be
* better if the code were rearranged so as to not require declaration
* of these names before the macros define them.
*/
extern const MultibyteCodec codec_list[];
extern const struct dbcs_map mapping_list[];
#define CODEC_INIT(encoding) \ #define CODEC_INIT(encoding) \
static int encoding##_codec_init(const void *config) static int encoding##_codec_init(const void *config)
...@@ -201,13 +195,16 @@ extern const struct dbcs_map mapping_list[]; ...@@ -201,13 +195,16 @@ extern const struct dbcs_map mapping_list[];
#define GET_INSIZE(c) 1 #define GET_INSIZE(c) 1
#endif #endif
#define BEGIN_MAPPINGS_LIST static const struct dbcs_map mapping_list[] = { #define BEGIN_MAPPINGS_LIST static const struct dbcs_map _mapping_list[] = {
#define MAPPING_ENCONLY(enc) {#enc, (void*)enc##_encmap, NULL}, #define MAPPING_ENCONLY(enc) {#enc, (void*)enc##_encmap, NULL},
#define MAPPING_DECONLY(enc) {#enc, NULL, (void*)enc##_decmap}, #define MAPPING_DECONLY(enc) {#enc, NULL, (void*)enc##_decmap},
#define MAPPING_ENCDEC(enc) {#enc, (void*)enc##_encmap, (void*)enc##_decmap}, #define MAPPING_ENCDEC(enc) {#enc, (void*)enc##_encmap, (void*)enc##_decmap},
#define END_MAPPINGS_LIST {"", NULL, NULL} }; #define END_MAPPINGS_LIST \
{"", NULL, NULL} }; \
static const struct dbcs_map *mapping_list = \
(const struct dbcs_map *)_mapping_list;
#define BEGIN_CODECS_LIST static const MultibyteCodec codec_list[] = { #define BEGIN_CODECS_LIST static const MultibyteCodec _codec_list[] = {
#define _STATEFUL_METHODS(enc) \ #define _STATEFUL_METHODS(enc) \
enc##_encode, \ enc##_encode, \
enc##_encode_init, \ enc##_encode_init, \
...@@ -231,7 +228,10 @@ extern const struct dbcs_map mapping_list[]; ...@@ -231,7 +228,10 @@ extern const struct dbcs_map mapping_list[];
enc##_codec_init, \ enc##_codec_init, \
_STATELESS_METHODS(enc) \ _STATELESS_METHODS(enc) \
}, },
#define END_CODECS_LIST {"", NULL,} }; #define END_CODECS_LIST \
{"", NULL,} }; \
static const MultibyteCodec *codec_list = \
(const MultibyteCodec *)_codec_list;
static PyObject * static PyObject *
getmultibytecodec(void) getmultibytecodec(void)
...@@ -254,12 +254,6 @@ getcodec(PyObject *self, PyObject *encoding) ...@@ -254,12 +254,6 @@ getcodec(PyObject *self, PyObject *encoding)
PyObject *codecobj, *r, *cofunc; PyObject *codecobj, *r, *cofunc;
const MultibyteCodec *codec; const MultibyteCodec *codec;
const char *enc; const char *enc;
#ifdef NO_METH_O
PyObject *args = encoding;
if (!PyArg_ParseTuple(args, "O:getcodec", &encoding))
return NULL;
#endif
if (!PyString_Check(encoding)) { if (!PyString_Check(encoding)) {
PyErr_SetString(PyExc_TypeError, PyErr_SetString(PyExc_TypeError,
...@@ -286,22 +280,14 @@ getcodec(PyObject *self, PyObject *encoding) ...@@ -286,22 +280,14 @@ getcodec(PyObject *self, PyObject *encoding)
if (codecobj == NULL) if (codecobj == NULL)
return NULL; return NULL;
#if PY_VERSION_HEX >= 0x02020000
r = PyObject_CallFunctionObjArgs(cofunc, codecobj, NULL); r = PyObject_CallFunctionObjArgs(cofunc, codecobj, NULL);
#else
r = PyObject_CallFunction(cofunc, "O", codecobj);
#endif
Py_DECREF(codecobj); Py_DECREF(codecobj);
return r; return r;
} }
static struct PyMethodDef __methods[] = { static struct PyMethodDef __methods[] = {
#ifndef NO_METH_O
{"getcodec", (PyCFunction)getcodec, METH_O, ""}, {"getcodec", (PyCFunction)getcodec, METH_O, ""},
#else
{"getcodec", (PyCFunction)getcodec, METH_VARARGS, ""},
#endif
{NULL, NULL}, {NULL, NULL},
}; };
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment