diff options
| author | Jakob Kaivo <jkk@ung.org> | 2024-06-03 13:56:25 -0400 |
|---|---|---|
| committer | Jakob Kaivo <jkk@ung.org> | 2024-06-03 13:56:25 -0400 |
| commit | a686d047d79bdfc37c096a4fa350c37e4ccf3cf5 (patch) | |
| tree | ca631b9095454a239211b6f676bdd3e0cb102156 /src/locale | |
| parent | c575f269ed4a04f89d610b423cc43ce7bd6f008b (diff) | |
add LC_CTYPE epoch and use separate CT_ categories and CTM_ masks to support detecting change of LC_CTYPE between calls to wctype()/iswctype() and wctrans()/towctrans()
Diffstat (limited to 'src/locale')
| -rw-r--r-- | src/locale/__load_locale.c | 1 | ||||
| -rw-r--r-- | src/locale/_locale.h | 1 | ||||
| -rw-r--r-- | src/locale/setlocale.c | 11 |
3 files changed, 10 insertions, 3 deletions
diff --git a/src/locale/__load_locale.c b/src/locale/__load_locale.c index 89fbd8a9..1831f798 100644 --- a/src/locale/__load_locale.c +++ b/src/locale/__load_locale.c @@ -43,6 +43,7 @@ char * __load_locale(struct __locale_t *loc, int mask, const char *name) if (mask & LC_CTYPE_MASK) { strcpy(loc->ctype, name); + loc->ctype_epoch++; if (localefile == NULL) { char upper[] = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"; diff --git a/src/locale/_locale.h b/src/locale/_locale.h index 41441456..b7867731 100644 --- a/src/locale/_locale.h +++ b/src/locale/_locale.h @@ -36,6 +36,7 @@ struct __locale_t { char all[UCHAR_MAX]; char ctype[UCHAR_MAX]; + unsigned int ctype_epoch; struct { unsigned int ctattr[UCHAR_MAX + 1]; unsigned char ctoupper[UCHAR_MAX + 1]; diff --git a/src/locale/setlocale.c b/src/locale/setlocale.c index 86c44a5f..22779792 100644 --- a/src/locale/setlocale.c +++ b/src/locale/setlocale.c @@ -72,9 +72,14 @@ char * setlocale(int category, const char *locale) name_to_return = __load_locale(l, mask, locale); } - __readonly(RO_UNLOCK, retname); - strcpy(retname, name_to_return); - __readonly(RO_LOCK, retname); + if (name_to_return != NULL) { + __readonly(RO_UNLOCK, retname); + strcpy(retname, name_to_return); + __readonly(RO_LOCK, retname); + } else { + retname = NULL; + } + return retname; } |
