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

Portable Alphabetical Checking #133

Open
cadaniluk opened this issue May 15, 2018 · 2 comments
Open

Portable Alphabetical Checking #133

cadaniluk opened this issue May 15, 2018 · 2 comments

Comments

@cadaniluk
Copy link

cadaniluk commented May 15, 2018

Skimming through the code, I noticed some checks to determine if a character is alphabetical by doing something like if (a >= 'A' && a <= 'Z'), notably src/segwit_addr.c and src/utils.c.
C does not guarantee that the alphabetical characters are consecutive, so technically, this is not entirely portable. ASCII does have all alphabetical characters laid out consecutively, though, so because of ASCII's ubiquity, this is a non-issue on virtually every system.

I am only fussing about this because the README reads "Libbtc is a very portable C library." isalpha from the C standard header <ctype.h> is portable and more concise. Possibly slower, but speed should be negligible here.

Is this something worth fixing?

@jonasschnelli
Copy link

Since this is upstream, I think you should address it here https://github.com/sipa/bech32 or ask at least @sipa. Not sure if its worth fixing... but probably no.

@sipa
Copy link

sipa commented May 15, 2018

The reason for not using isalpha is that it's locale-dependent, which would possibly result in violating the spec if you're not on the "C" locale. If you really want to support non-ASCII systems (just checked: ASCII is indeed not mandated by POSIX, nor that the alphabetic characters are in order), you'll need a switch/case I guess.

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

3 participants