Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit f5a149a

Browse files
committed
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)
1 parent 026f8dc commit f5a149a

5 files changed

Lines changed: 45 additions & 42 deletions

File tree

Modules/cjkcodecs/README

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ Notes on cjkcodecs
22
-------------------
33
This directory contains source files for cjkcodecs extension modules.
44
They are based on CJKCodecs (http://cjkpython.i18n.org/#CJKCodecs)
5-
as of Jul 18 2004 currently.
5+
as of Aug 20 2004 currently.
66

77

88

Modules/cjkcodecs/_codecs_hk.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
* _codecs_hk.c: Codecs collection for encodings from Hong Kong
33
*
44
* Written by Hye-Shik Chang <[email protected]>
5-
* $CJKCodecs: _codecs_hk.c,v 1.3 2004/07/07 14:59:26 perky Exp $
5+
* $CJKCodecs: _codecs_hk.c,v 1.4 2004/07/18 04:44:27 perky Exp $
66
*/
77

88
#define USING_IMPORTED_MAPS

Modules/cjkcodecs/_codecs_iso2022.c

Lines changed: 38 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
* _codecs_iso2022.c: Codecs collection for ISO-2022 encodings.
33
*
44
* Written by Hye-Shik Chang <[email protected]>
5-
* $CJKCodecs: _codecs_iso2022.c,v 1.18 2004/07/07 18:30:17 perky Exp $
5+
* $CJKCodecs: _codecs_iso2022.c,v 1.22 2004/08/19 17:08:13 perky Exp $
66
*/
77

88
#define USING_IMPORTED_MAPS
@@ -117,7 +117,7 @@ struct iso2022_designation {
117117

118118
struct iso2022_config {
119119
int flags;
120-
const struct iso2022_designation designations[]; /* non-ascii desigs */
120+
const struct iso2022_designation *designations; /* non-ascii desigs */
121121
};
122122

123123
/*-*- iso-2022 codec implementation -*-*/
@@ -197,7 +197,9 @@ ENCODER(iso2022)
197197
length = 2;
198198
#if Py_UNICODE_SIZE == 2
199199
if (length == 2) {
200-
ucs4_t u4in[2] = {IN1, IN2};
200+
ucs4_t u4in[2];
201+
u4in[0] = (ucs4_t)IN1;
202+
u4in[1] = (ucs4_t)IN2;
201203
encoded = dsg->encoder(u4in, &length);
202204
} else
203205
encoded = dsg->encoder(&c, &length);
@@ -420,7 +422,7 @@ iso2022processg2(const void *config, MultibyteCodec_State *state,
420422
DECODER(iso2022)
421423
{
422424
const struct iso2022_designation *dsgcache = NULL;
423-
425+
424426
while (inleft > 0) {
425427
unsigned char c = IN1;
426428
int err;
@@ -1047,50 +1049,52 @@ dummy_encoder(const ucs4_t *data, int *length)
10471049
#define REGISTRY_ISO8859_7 { CHARSET_ISO8859_7, 2, 1, \
10481050
NULL, dummy_decoder, dummy_encoder }
10491051
#define REGISTRY_SENTINEL { 0, }
1052+
#define CONFIGDEF(var, attrs) \
1053+
static const struct iso2022_config iso2022_##var##_config = { \
1054+
attrs, iso2022_##var##_designations \
1055+
};
10501056

1051-
static const struct iso2022_config iso2022_kr_config = {
1052-
0,
1053-
{ REGISTRY_KSX1001, REGISTRY_SENTINEL },
1057+
static const struct iso2022_designation iso2022_kr_designations[] = {
1058+
REGISTRY_KSX1001, REGISTRY_SENTINEL
10541059
};
1060+
CONFIGDEF(kr, 0)
10551061

1056-
static const struct iso2022_config iso2022_jp_config = {
1057-
NO_SHIFT | USE_JISX0208_EXT,
1058-
{ REGISTRY_JISX0208, REGISTRY_JISX0201_R, REGISTRY_JISX0208_O,
1059-
REGISTRY_SENTINEL },
1062+
static const struct iso2022_designation iso2022_jp_designations[] = {
1063+
REGISTRY_JISX0208, REGISTRY_JISX0201_R, REGISTRY_JISX0208_O,
1064+
REGISTRY_SENTINEL
10601065
};
1066+
CONFIGDEF(jp, NO_SHIFT | USE_JISX0208_EXT)
10611067

1062-
static const struct iso2022_config iso2022_jp_1_config = {
1063-
NO_SHIFT | USE_JISX0208_EXT,
1064-
{ REGISTRY_JISX0208, REGISTRY_JISX0212, REGISTRY_JISX0201_R,
1065-
REGISTRY_JISX0208_O, REGISTRY_SENTINEL },
1068+
static const struct iso2022_designation iso2022_jp_1_designations[] = {
1069+
REGISTRY_JISX0208, REGISTRY_JISX0212, REGISTRY_JISX0201_R,
1070+
REGISTRY_JISX0208_O, REGISTRY_SENTINEL
10661071
};
1072+
CONFIGDEF(jp_1, NO_SHIFT | USE_JISX0208_EXT)
10671073

1068-
static const struct iso2022_config iso2022_jp_2_config = {
1069-
NO_SHIFT | USE_G2 | USE_JISX0208_EXT,
1070-
{ REGISTRY_JISX0208, REGISTRY_JISX0212, REGISTRY_KSX1001,
1071-
REGISTRY_GB2312, REGISTRY_JISX0201_R, REGISTRY_JISX0208_O,
1072-
REGISTRY_ISO8859_1, REGISTRY_ISO8859_7, REGISTRY_SENTINEL },
1074+
static const struct iso2022_designation iso2022_jp_2_designations[] = {
1075+
REGISTRY_JISX0208, REGISTRY_JISX0212, REGISTRY_KSX1001,
1076+
REGISTRY_GB2312, REGISTRY_JISX0201_R, REGISTRY_JISX0208_O,
1077+
REGISTRY_ISO8859_1, REGISTRY_ISO8859_7, REGISTRY_SENTINEL
10731078
};
1079+
CONFIGDEF(jp_2, NO_SHIFT | USE_G2 | USE_JISX0208_EXT)
10741080

1075-
static const struct iso2022_config iso2022_jp_2004_config = {
1076-
NO_SHIFT | USE_G2 | USE_JISX0208_EXT,
1077-
{ REGISTRY_JISX0213_2004_1_PAIRONLY, REGISTRY_JISX0208,
1078-
REGISTRY_JISX0213_2004_1, REGISTRY_JISX0213_2004_2,
1079-
REGISTRY_SENTINEL },
1081+
static const struct iso2022_designation iso2022_jp_2004_designations[] = {
1082+
REGISTRY_JISX0213_2004_1_PAIRONLY, REGISTRY_JISX0208,
1083+
REGISTRY_JISX0213_2004_1, REGISTRY_JISX0213_2004_2, REGISTRY_SENTINEL
10801084
};
1085+
CONFIGDEF(jp_2004, NO_SHIFT | USE_JISX0208_EXT)
10811086

1082-
static const struct iso2022_config iso2022_jp_3_config = {
1083-
NO_SHIFT | USE_JISX0208_EXT,
1084-
{ REGISTRY_JISX0213_2000_1_PAIRONLY, REGISTRY_JISX0208,
1085-
REGISTRY_JISX0213_2000_1, REGISTRY_JISX0213_2000_2,
1086-
REGISTRY_SENTINEL },
1087+
static const struct iso2022_designation iso2022_jp_3_designations[] = {
1088+
REGISTRY_JISX0213_2000_1_PAIRONLY, REGISTRY_JISX0208,
1089+
REGISTRY_JISX0213_2000_1, REGISTRY_JISX0213_2000_2, REGISTRY_SENTINEL
10871090
};
1091+
CONFIGDEF(jp_3, NO_SHIFT | USE_JISX0208_EXT)
10881092

1089-
static const struct iso2022_config iso2022_jp_ext_config = {
1090-
NO_SHIFT | USE_JISX0208_EXT,
1091-
{ REGISTRY_JISX0208, REGISTRY_JISX0212, REGISTRY_JISX0201_R,
1092-
REGISTRY_JISX0201_K, REGISTRY_JISX0208_O, REGISTRY_SENTINEL },
1093+
static const struct iso2022_designation iso2022_jp_ext_designations[] = {
1094+
REGISTRY_JISX0208, REGISTRY_JISX0212, REGISTRY_JISX0201_R,
1095+
REGISTRY_JISX0201_K, REGISTRY_JISX0208_O, REGISTRY_SENTINEL
10931096
};
1097+
CONFIGDEF(jp_ext, NO_SHIFT | USE_JISX0208_EXT)
10941098

10951099

10961100
BEGIN_MAPPINGS_LIST

Modules/cjkcodecs/cjkcodecs.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
* cjkcodecs.h: common header for cjkcodecs
33
*
44
* Written by Hye-Shik Chang <[email protected]>
5-
* $CJKCodecs: cjkcodecs.h,v 1.5 2004/07/06 17:05:24 perky Exp $
5+
* $CJKCodecs: cjkcodecs.h,v 1.6 2004/07/18 15:22:31 perky Exp $
66
*/
77

88
#ifndef _CJKCODECS_H_
@@ -230,7 +230,7 @@ static const struct dbcs_map *mapping_list;
230230
},
231231
#define END_CODECS_LIST \
232232
{"", NULL,} }; \
233-
static const MultibyteCodec *codec_list = \
233+
static const MultibyteCodec *codec_list = \
234234
(const MultibyteCodec *)_codec_list;
235235

236236
static PyObject *

Modules/cjkcodecs/multibytecodec.c

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
* multibytecodec.c: Common Multibyte Codec Implementation
33
*
44
* Written by Hye-Shik Chang <[email protected]>
5-
* $CJKCodecs: multibytecodec.c,v 1.12 2004/06/27 19:24:13 perky Exp $
5+
* $CJKCodecs: multibytecodec.c,v 1.13 2004/08/19 16:57:19 perky Exp $
66
*/
77

88
#include "Python.h"
@@ -338,7 +338,7 @@ multibytecodec_decerror(MultibyteCodec *codec,
338338
/* use cached exception object if available */
339339
if (buf->excobj == NULL) {
340340
buf->excobj = PyUnicodeDecodeError_Create(codec->encoding,
341-
buf->inbuf_top,
341+
(const char *)buf->inbuf_top,
342342
(int)(buf->inbuf_end - buf->inbuf_top),
343343
start, end, reason);
344344
if (buf->excobj == NULL)
@@ -965,7 +965,7 @@ mbstreamwriter_iwrite(MultibyteStreamWriterObject *self,
965965
PyObject *unistr)
966966
{
967967
PyObject *wr, *ucvt, *r = NULL;
968-
Py_UNICODE *inbuf, *inbuf_end, *data, *inbuf_tmp = NULL;
968+
Py_UNICODE *inbuf, *inbuf_end, *inbuf_tmp = NULL;
969969
int datalen;
970970

971971
if (PyUnicode_Check(unistr))
@@ -982,7 +982,6 @@ mbstreamwriter_iwrite(MultibyteStreamWriterObject *self,
982982
}
983983
}
984984

985-
data = PyUnicode_AS_UNICODE(unistr);
986985
datalen = PyUnicode_GET_SIZE(unistr);
987986
if (datalen == 0) {
988987
Py_XDECREF(ucvt);

0 commit comments

Comments
 (0)