Skip to content

Commit

Permalink
gh-103583: Isolate CJK codec modules (#103869)
Browse files Browse the repository at this point in the history
  • Loading branch information
erlend-aasland authored Apr 27, 2023
1 parent e9c7772 commit 8a0c7f1
Show file tree
Hide file tree
Showing 9 changed files with 228 additions and 226 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
Isolate :mod:`!_multibytecodec` and codecs extension modules. Patches by
Erlend E. Aasland.
18 changes: 9 additions & 9 deletions Modules/cjkcodecs/_codecs_hk.c
Original file line number Diff line number Diff line change
Expand Up @@ -6,23 +6,23 @@

#define USING_IMPORTED_MAPS

#define CJK_MOD_SPECIFIC_STATE \
const encode_map *big5_encmap; \
const decode_map *big5_decmap;

#include "cjkcodecs.h"
#include "mappings_hk.h"

/*
* BIG5HKSCS codec
*/

static const encode_map *big5_encmap = NULL;
static const decode_map *big5_decmap = NULL;

CODEC_INIT(big5hkscs)
{
static int initialized = 0;

if (!initialized && IMPORT_MAP(tw, big5, &big5_encmap, &big5_decmap))
cjkcodecs_module_state *st = codec->modstate;
if (IMPORT_MAP(tw, big5, &st->big5_encmap, &st->big5_decmap)) {
return -1;
initialized = 1;
}
return 0;
}

Expand Down Expand Up @@ -81,7 +81,7 @@ ENCODER(big5hkscs)
}
}
}
else if (TRYMAP_ENC(big5, code, c))
else if (TRYMAP_ENC_ST(big5, code, c))
;
else
return 1;
Expand Down Expand Up @@ -122,7 +122,7 @@ DECODER(big5hkscs)
REQUIRE_INBUF(2);

if (0xc6 > c || c > 0xc8 || (c < 0xc7 && INBYTE2 < 0xa1)) {
if (TRYMAP_DEC(big5, decoded, c, INBYTE2)) {
if (TRYMAP_DEC_ST(big5, decoded, c, INBYTE2)) {
OUTCHAR(decoded);
NEXT_IN(2);
continue;
Expand Down
Loading

0 comments on commit 8a0c7f1

Please sign in to comment.