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

Potential to break libchewing compatibility when adding new keyboard layout #412

Closed
mlouielu opened this issue Nov 28, 2023 · 3 comments
Closed

Comments

@mlouielu
Copy link
Contributor

Current keyboard layout enum in bopomofo-private.h is the following:

enum {
KB_DEFAULT,
KB_HSU,
KB_IBM,
KB_GIN_YIEH,
KB_ET,
KB_ET26,
KB_DVORAK,
KB_DVORAK_HSU,
KB_DACHEN_CP26,
KB_HANYU_PINYIN,
KB_THL_PINYIN,
KB_MPS2_PINYIN,
KB_CARPALX,
KB_TYPE_NUM
};

And some of the code in bopomofo.c use this to distinguish bopomofo and pinyin input method:

if (pBopomofo->kbtype >= KB_HANYU_PINYIN) {

It has the potential to break compatibility when adding new keyboard layout (insert before KB_HANYU_PINYIN), which let adding new keyboard layout difficult. It also affect KB_CARPALX which is not a pinyin keyboard.

Adding a new function to distinguish this may be a way to solve this problem.

@kanru
Copy link
Member

kanru commented Nov 30, 2023

Good point. It seems current code assumes everything after KB_HANYU_PINYIN is a pinyin keyboard.

@kanru
Copy link
Member

kanru commented Dec 31, 2023

On second thought this is not breaking any ABI.

The enum values are part of the API/ABI so they should never change once added. To add new keyboard type, append them to the end of the enum list.

In bopomofo.c we know exactly what kbtype they are. The check at

if (pBopomofo->kbtype >= KB_HANYU_PINYIN) {
is a bug.

@mlouielu
Copy link
Contributor Author

Closed by #441, further new keyboard layout needs to take care of BopomofoKbIsPinyin().

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants