diff options
author | Hye-Shik Chang <hyeshik@gmail.com> | 2004-07-18 15:02:45 +0000 |
---|---|---|
committer | Hye-Shik Chang <hyeshik@gmail.com> | 2004-07-18 15:02:45 +0000 |
commit | 7d2da3c0c2e2e4ee7df9eaf8442bfb0fe1caca4a (patch) | |
tree | 71591d38b461738ca9245fa0b6a961cc4d6b8fa6 /Modules/cjkcodecs/cjkcodecs.h | |
parent | 488f541ee191a37d3ac811404dbcfb61920d0d6c (diff) | |
download | cpython-7d2da3c0c2e2e4ee7df9eaf8442bfb0fe1caca4a.tar.gz |
Replace an extern magic to assigning declared pointer from array's.
And unifdef(1) compatibility blocks.
Diffstat (limited to 'Modules/cjkcodecs/cjkcodecs.h')
-rw-r--r-- | Modules/cjkcodecs/cjkcodecs.h | 38 |
1 files changed, 12 insertions, 26 deletions
diff --git a/Modules/cjkcodecs/cjkcodecs.h b/Modules/cjkcodecs/cjkcodecs.h index bf08e588fd..7d7ad8154f 100644 --- a/Modules/cjkcodecs/cjkcodecs.h +++ b/Modules/cjkcodecs/cjkcodecs.h @@ -57,14 +57,8 @@ struct pair_encodemap { DBCHAR code; }; -/* There are really static, and (re)declared so later by the expansions - * of the BEGIN_MAPPINGS_LIST and BEGIN_CODECS_LIST macros, but it's - * 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[]; +static const MultibyteCodec *codec_list; +static const struct dbcs_map *mapping_list; #define CODEC_INIT(encoding) \ static int encoding##_codec_init(const void *config) @@ -201,13 +195,16 @@ extern const struct dbcs_map mapping_list[]; #define GET_INSIZE(c) 1 #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_DECONLY(enc) {#enc, NULL, (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) \ enc##_encode, \ enc##_encode_init, \ @@ -231,7 +228,10 @@ extern const struct dbcs_map mapping_list[]; enc##_codec_init, \ _STATELESS_METHODS(enc) \ }, -#define END_CODECS_LIST {"", NULL,} }; +#define END_CODECS_LIST \ + {"", NULL,} }; \ + static const MultibyteCodec *codec_list = \ + (const MultibyteCodec *)_codec_list; static PyObject * getmultibytecodec(void) @@ -254,12 +254,6 @@ getcodec(PyObject *self, PyObject *encoding) PyObject *codecobj, *r, *cofunc; const MultibyteCodec *codec; const char *enc; -#ifdef NO_METH_O - PyObject *args = encoding; - - if (!PyArg_ParseTuple(args, "O:getcodec", &encoding)) - return NULL; -#endif if (!PyString_Check(encoding)) { PyErr_SetString(PyExc_TypeError, @@ -286,22 +280,14 @@ getcodec(PyObject *self, PyObject *encoding) if (codecobj == NULL) return NULL; -#if PY_VERSION_HEX >= 0x02020000 r = PyObject_CallFunctionObjArgs(cofunc, codecobj, NULL); -#else - r = PyObject_CallFunction(cofunc, "O", codecobj); -#endif Py_DECREF(codecobj); return r; } static struct PyMethodDef __methods[] = { -#ifndef NO_METH_O {"getcodec", (PyCFunction)getcodec, METH_O, ""}, -#else - {"getcodec", (PyCFunction)getcodec, METH_VARARGS, ""}, -#endif {NULL, NULL}, }; |