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

Bug #1005737, #1007249: Fix several build problems and warnings

found on legacy C compilers of HP-UX, IRIX and Tru64.  (Reported
by roadkill, Richard Townsend, Maik Hertha and Minsik Kim)
üst 026f8dc1
...@@ -2,7 +2,7 @@ Notes on cjkcodecs ...@@ -2,7 +2,7 @@ Notes on cjkcodecs
------------------- -------------------
This directory contains source files for cjkcodecs extension modules. This directory contains source files for cjkcodecs extension modules.
They are based on CJKCodecs (http://cjkpython.i18n.org/#CJKCodecs) They are based on CJKCodecs (http://cjkpython.i18n.org/#CJKCodecs)
as of Jul 18 2004 currently. as of Aug 20 2004 currently.
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
* _codecs_hk.c: Codecs collection for encodings from Hong Kong * _codecs_hk.c: Codecs collection for encodings from Hong Kong
* *
* Written by Hye-Shik Chang <perky@FreeBSD.org> * Written by Hye-Shik Chang <perky@FreeBSD.org>
* $CJKCodecs: _codecs_hk.c,v 1.3 2004/07/07 14:59:26 perky Exp $ * $CJKCodecs: _codecs_hk.c,v 1.4 2004/07/18 04:44:27 perky Exp $
*/ */
#define USING_IMPORTED_MAPS #define USING_IMPORTED_MAPS
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
* _codecs_iso2022.c: Codecs collection for ISO-2022 encodings. * _codecs_iso2022.c: Codecs collection for ISO-2022 encodings.
* *
* Written by Hye-Shik Chang <perky@FreeBSD.org> * Written by Hye-Shik Chang <perky@FreeBSD.org>
* $CJKCodecs: _codecs_iso2022.c,v 1.18 2004/07/07 18:30:17 perky Exp $ * $CJKCodecs: _codecs_iso2022.c,v 1.22 2004/08/19 17:08:13 perky Exp $
*/ */
#define USING_IMPORTED_MAPS #define USING_IMPORTED_MAPS
...@@ -117,7 +117,7 @@ struct iso2022_designation { ...@@ -117,7 +117,7 @@ struct iso2022_designation {
struct iso2022_config { struct iso2022_config {
int flags; int flags;
const struct iso2022_designation designations[]; /* non-ascii desigs */ const struct iso2022_designation *designations; /* non-ascii desigs */
}; };
/*-*- iso-2022 codec implementation -*-*/ /*-*- iso-2022 codec implementation -*-*/
...@@ -197,7 +197,9 @@ ENCODER(iso2022) ...@@ -197,7 +197,9 @@ ENCODER(iso2022)
length = 2; length = 2;
#if Py_UNICODE_SIZE == 2 #if Py_UNICODE_SIZE == 2
if (length == 2) { if (length == 2) {
ucs4_t u4in[2] = {IN1, IN2}; ucs4_t u4in[2];
u4in[0] = (ucs4_t)IN1;
u4in[1] = (ucs4_t)IN2;
encoded = dsg->encoder(u4in, &length); encoded = dsg->encoder(u4in, &length);
} else } else
encoded = dsg->encoder(&c, &length); encoded = dsg->encoder(&c, &length);
...@@ -420,7 +422,7 @@ iso2022processg2(const void *config, MultibyteCodec_State *state, ...@@ -420,7 +422,7 @@ iso2022processg2(const void *config, MultibyteCodec_State *state,
DECODER(iso2022) DECODER(iso2022)
{ {
const struct iso2022_designation *dsgcache = NULL; const struct iso2022_designation *dsgcache = NULL;
while (inleft > 0) { while (inleft > 0) {
unsigned char c = IN1; unsigned char c = IN1;
int err; int err;
...@@ -1047,50 +1049,52 @@ dummy_encoder(const ucs4_t *data, int *length) ...@@ -1047,50 +1049,52 @@ dummy_encoder(const ucs4_t *data, int *length)
#define REGISTRY_ISO8859_7 { CHARSET_ISO8859_7, 2, 1, \ #define REGISTRY_ISO8859_7 { CHARSET_ISO8859_7, 2, 1, \
NULL, dummy_decoder, dummy_encoder } NULL, dummy_decoder, dummy_encoder }
#define REGISTRY_SENTINEL { 0, } #define REGISTRY_SENTINEL { 0, }
#define CONFIGDEF(var, attrs) \
static const struct iso2022_config iso2022_##var##_config = { \
attrs, iso2022_##var##_designations \
};
static const struct iso2022_config iso2022_kr_config = { static const struct iso2022_designation iso2022_kr_designations[] = {
0, REGISTRY_KSX1001, REGISTRY_SENTINEL
{ REGISTRY_KSX1001, REGISTRY_SENTINEL },
}; };
CONFIGDEF(kr, 0)
static const struct iso2022_config iso2022_jp_config = { static const struct iso2022_designation iso2022_jp_designations[] = {
NO_SHIFT | USE_JISX0208_EXT, REGISTRY_JISX0208, REGISTRY_JISX0201_R, REGISTRY_JISX0208_O,
{ REGISTRY_JISX0208, REGISTRY_JISX0201_R, REGISTRY_JISX0208_O, REGISTRY_SENTINEL
REGISTRY_SENTINEL },
}; };
CONFIGDEF(jp, NO_SHIFT | USE_JISX0208_EXT)
static const struct iso2022_config iso2022_jp_1_config = { static const struct iso2022_designation iso2022_jp_1_designations[] = {
NO_SHIFT | USE_JISX0208_EXT, REGISTRY_JISX0208, REGISTRY_JISX0212, REGISTRY_JISX0201_R,
{ REGISTRY_JISX0208, REGISTRY_JISX0212, REGISTRY_JISX0201_R, REGISTRY_JISX0208_O, REGISTRY_SENTINEL
REGISTRY_JISX0208_O, REGISTRY_SENTINEL },
}; };
CONFIGDEF(jp_1, NO_SHIFT | USE_JISX0208_EXT)
static const struct iso2022_config iso2022_jp_2_config = { static const struct iso2022_designation iso2022_jp_2_designations[] = {
NO_SHIFT | USE_G2 | USE_JISX0208_EXT, REGISTRY_JISX0208, REGISTRY_JISX0212, REGISTRY_KSX1001,
{ REGISTRY_JISX0208, REGISTRY_JISX0212, REGISTRY_KSX1001, REGISTRY_GB2312, REGISTRY_JISX0201_R, REGISTRY_JISX0208_O,
REGISTRY_GB2312, REGISTRY_JISX0201_R, REGISTRY_JISX0208_O, REGISTRY_ISO8859_1, REGISTRY_ISO8859_7, REGISTRY_SENTINEL
REGISTRY_ISO8859_1, REGISTRY_ISO8859_7, REGISTRY_SENTINEL },
}; };
CONFIGDEF(jp_2, NO_SHIFT | USE_G2 | USE_JISX0208_EXT)
static const struct iso2022_config iso2022_jp_2004_config = { static const struct iso2022_designation iso2022_jp_2004_designations[] = {
NO_SHIFT | USE_G2 | USE_JISX0208_EXT, REGISTRY_JISX0213_2004_1_PAIRONLY, REGISTRY_JISX0208,
{ REGISTRY_JISX0213_2004_1_PAIRONLY, REGISTRY_JISX0208, REGISTRY_JISX0213_2004_1, REGISTRY_JISX0213_2004_2, REGISTRY_SENTINEL
REGISTRY_JISX0213_2004_1, REGISTRY_JISX0213_2004_2,
REGISTRY_SENTINEL },
}; };
CONFIGDEF(jp_2004, NO_SHIFT | USE_JISX0208_EXT)
static const struct iso2022_config iso2022_jp_3_config = { static const struct iso2022_designation iso2022_jp_3_designations[] = {
NO_SHIFT | USE_JISX0208_EXT, REGISTRY_JISX0213_2000_1_PAIRONLY, REGISTRY_JISX0208,
{ REGISTRY_JISX0213_2000_1_PAIRONLY, REGISTRY_JISX0208, REGISTRY_JISX0213_2000_1, REGISTRY_JISX0213_2000_2, REGISTRY_SENTINEL
REGISTRY_JISX0213_2000_1, REGISTRY_JISX0213_2000_2,
REGISTRY_SENTINEL },
}; };
CONFIGDEF(jp_3, NO_SHIFT | USE_JISX0208_EXT)
static const struct iso2022_config iso2022_jp_ext_config = { static const struct iso2022_designation iso2022_jp_ext_designations[] = {
NO_SHIFT | USE_JISX0208_EXT, REGISTRY_JISX0208, REGISTRY_JISX0212, REGISTRY_JISX0201_R,
{ REGISTRY_JISX0208, REGISTRY_JISX0212, REGISTRY_JISX0201_R, REGISTRY_JISX0201_K, REGISTRY_JISX0208_O, REGISTRY_SENTINEL
REGISTRY_JISX0201_K, REGISTRY_JISX0208_O, REGISTRY_SENTINEL },
}; };
CONFIGDEF(jp_ext, NO_SHIFT | USE_JISX0208_EXT)
BEGIN_MAPPINGS_LIST BEGIN_MAPPINGS_LIST
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
* cjkcodecs.h: common header for cjkcodecs * cjkcodecs.h: common header for cjkcodecs
* *
* Written by Hye-Shik Chang <perky@FreeBSD.org> * Written by Hye-Shik Chang <perky@FreeBSD.org>
* $CJKCodecs: cjkcodecs.h,v 1.5 2004/07/06 17:05:24 perky Exp $ * $CJKCodecs: cjkcodecs.h,v 1.6 2004/07/18 15:22:31 perky Exp $
*/ */
#ifndef _CJKCODECS_H_ #ifndef _CJKCODECS_H_
...@@ -230,7 +230,7 @@ static const struct dbcs_map *mapping_list; ...@@ -230,7 +230,7 @@ static const struct dbcs_map *mapping_list;
}, },
#define END_CODECS_LIST \ #define END_CODECS_LIST \
{"", NULL,} }; \ {"", NULL,} }; \
static const MultibyteCodec *codec_list = \ static const MultibyteCodec *codec_list = \
(const MultibyteCodec *)_codec_list; (const MultibyteCodec *)_codec_list;
static PyObject * static PyObject *
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
* multibytecodec.c: Common Multibyte Codec Implementation * multibytecodec.c: Common Multibyte Codec Implementation
* *
* Written by Hye-Shik Chang <perky@FreeBSD.org> * Written by Hye-Shik Chang <perky@FreeBSD.org>
* $CJKCodecs: multibytecodec.c,v 1.12 2004/06/27 19:24:13 perky Exp $ * $CJKCodecs: multibytecodec.c,v 1.13 2004/08/19 16:57:19 perky Exp $
*/ */
#include "Python.h" #include "Python.h"
...@@ -338,7 +338,7 @@ multibytecodec_decerror(MultibyteCodec *codec, ...@@ -338,7 +338,7 @@ multibytecodec_decerror(MultibyteCodec *codec,
/* use cached exception object if available */ /* use cached exception object if available */
if (buf->excobj == NULL) { if (buf->excobj == NULL) {
buf->excobj = PyUnicodeDecodeError_Create(codec->encoding, buf->excobj = PyUnicodeDecodeError_Create(codec->encoding,
buf->inbuf_top, (const char *)buf->inbuf_top,
(int)(buf->inbuf_end - buf->inbuf_top), (int)(buf->inbuf_end - buf->inbuf_top),
start, end, reason); start, end, reason);
if (buf->excobj == NULL) if (buf->excobj == NULL)
...@@ -965,7 +965,7 @@ mbstreamwriter_iwrite(MultibyteStreamWriterObject *self, ...@@ -965,7 +965,7 @@ mbstreamwriter_iwrite(MultibyteStreamWriterObject *self,
PyObject *unistr) PyObject *unistr)
{ {
PyObject *wr, *ucvt, *r = NULL; PyObject *wr, *ucvt, *r = NULL;
Py_UNICODE *inbuf, *inbuf_end, *data, *inbuf_tmp = NULL; Py_UNICODE *inbuf, *inbuf_end, *inbuf_tmp = NULL;
int datalen; int datalen;
if (PyUnicode_Check(unistr)) if (PyUnicode_Check(unistr))
...@@ -982,7 +982,6 @@ mbstreamwriter_iwrite(MultibyteStreamWriterObject *self, ...@@ -982,7 +982,6 @@ mbstreamwriter_iwrite(MultibyteStreamWriterObject *self,
} }
} }
data = PyUnicode_AS_UNICODE(unistr);
datalen = PyUnicode_GET_SIZE(unistr); datalen = PyUnicode_GET_SIZE(unistr);
if (datalen == 0) { if (datalen == 0) {
Py_XDECREF(ucvt); Py_XDECREF(ucvt);
......
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