Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

gh-103583: Isolate CJK codec modules #103869

Merged
merged 7 commits into from
Apr 27, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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