Skip to content

Commit 8a0c7f1

Browse files
gh-103583: Isolate CJK codec modules (#103869)
1 parent e9c7772 commit 8a0c7f1

9 files changed

+228
-226
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
Isolate :mod:`!_multibytecodec` and codecs extension modules. Patches by
2+
Erlend E. Aasland.

Modules/cjkcodecs/_codecs_hk.c

+9-9
Original file line numberDiff line numberDiff line change
@@ -6,23 +6,23 @@
66

77
#define USING_IMPORTED_MAPS
88

9+
#define CJK_MOD_SPECIFIC_STATE \
10+
const encode_map *big5_encmap; \
11+
const decode_map *big5_decmap;
12+
913
#include "cjkcodecs.h"
1014
#include "mappings_hk.h"
1115

1216
/*
1317
* BIG5HKSCS codec
1418
*/
1519

16-
static const encode_map *big5_encmap = NULL;
17-
static const decode_map *big5_decmap = NULL;
18-
1920
CODEC_INIT(big5hkscs)
2021
{
21-
static int initialized = 0;
22-
23-
if (!initialized && IMPORT_MAP(tw, big5, &big5_encmap, &big5_decmap))
22+
cjkcodecs_module_state *st = codec->modstate;
23+
if (IMPORT_MAP(tw, big5, &st->big5_encmap, &st->big5_decmap)) {
2424
return -1;
25-
initialized = 1;
25+
}
2626
return 0;
2727
}
2828

@@ -81,7 +81,7 @@ ENCODER(big5hkscs)
8181
}
8282
}
8383
}
84-
else if (TRYMAP_ENC(big5, code, c))
84+
else if (TRYMAP_ENC_ST(big5, code, c))
8585
;
8686
else
8787
return 1;
@@ -122,7 +122,7 @@ DECODER(big5hkscs)
122122
REQUIRE_INBUF(2);
123123

124124
if (0xc6 > c || c > 0xc8 || (c < 0xc7 && INBYTE2 < 0xa1)) {
125-
if (TRYMAP_DEC(big5, decoded, c, INBYTE2)) {
125+
if (TRYMAP_DEC_ST(big5, decoded, c, INBYTE2)) {
126126
OUTCHAR(decoded);
127127
NEXT_IN(2);
128128
continue;

0 commit comments

Comments
 (0)