You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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?
The text was updated successfully, but these errors were encountered:
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.
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.
Skimming through the code, I noticed some checks to determine if a character is alphabetical by doing something like
if (a >= 'A' && a <= 'Z')
, notablysrc/segwit_addr.c
andsrc/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?
The text was updated successfully, but these errors were encountered: