summaryrefslogtreecommitdiffstats
path: root/Modules
diff options
context:
space:
mode:
authorHye-Shik Chang <hyeshik@gmail.com>2004-07-18 15:02:45 (GMT)
committerHye-Shik Chang <hyeshik@gmail.com>2004-07-18 15:02:45 (GMT)
commit64a9e38f35e2889ed1c076c820a808f827a5e334 (patch)
tree75f213a064504fd5e7b8bf380b93df244a550a92 /Modules
parent22118bc0b08942bbfc41218ea8ab3dff4e0d8c2f (diff)
downloadcpython-64a9e38f35e2889ed1c076c820a808f827a5e334.zip
cpython-64a9e38f35e2889ed1c076c820a808f827a5e334.tar.gz
cpython-64a9e38f35e2889ed1c076c820a808f827a5e334.tar.bz2
Replace an extern magic to assigning declared pointer from array's.
And unifdef(1) compatibility blocks.
Diffstat (limited to 'Modules')
-rw-r--r--Modules/cjkcodecs/cjkcodecs.h38
1 files changed, 12 insertions, 26 deletions
diff --git a/Modules/cjkcodecs/cjkcodecs.h b/Modules/cjkcodecs/cjkcodecs.h
index bf08e58..7d7ad81 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},
};