diff options
author | A. Wilcox <AWilcox@Wilcox-Tech.com> | 2020-11-16 14:26:16 -0600 |
---|---|---|
committer | A. Wilcox <AWilcox@Wilcox-Tech.com> | 2020-11-16 14:26:16 -0600 |
commit | f6138a72338559c3c2d3535b8a969f9d4124c021 (patch) | |
tree | 76199ae0406b72c0e0cac23f6c3259d9f8e51853 /libgcompat | |
parent | edd0373fa40c64b0d265ead7feeafc5e8cc6c4be (diff) | |
download | gcompat-f6138a72338559c3c2d3535b8a969f9d4124c021.tar.gz gcompat-f6138a72338559c3c2d3535b8a969f9d4124c021.tar.bz2 gcompat-f6138a72338559c3c2d3535b8a969f9d4124c021.tar.xz gcompat-f6138a72338559c3c2d3535b8a969f9d4124c021.zip |
locale: Fix two correctness issues
* Count size of list correctly
* Don't make __names const; it isn't.
Diffstat (limited to 'libgcompat')
-rw-r--r-- | libgcompat/locale.c | 5 |
1 files changed, 3 insertions, 2 deletions
diff --git a/libgcompat/locale.c b/libgcompat/locale.c index a7ac2c0..538ece7 100644 --- a/libgcompat/locale.c +++ b/libgcompat/locale.c @@ -15,7 +15,7 @@ struct glibc_locale { const int *__ctype_tolower; const int *__ctype_toupper; - const char *__names[13]; + char *__names[13]; }; const unsigned short **__ctype_b_loc(void); @@ -23,9 +23,10 @@ const int32_t **__ctype_tolower_loc(void); const int32_t **__ctype_toupper_loc(void); const char *__gcompat_valid_locales[] = {"C", "POSIX"}; +#define valid_locale_count sizeof __gcompat_valid_locales / sizeof *__gcompat_valid_locales bool _is_valid_locale(const char *candidate) { - for(int i = 0; i < sizeof __gcompat_valid_locales; i++) { + for(size_t i = 0; i < valid_locale_count; i++) { if(strcmp(candidate, __gcompat_valid_locales[i]) == 0) return true; } return false; |