Changeset View
Changeset View
Standalone View
Standalone View
head/lib/libc/locale/collate.c
Show First 20 Lines • Show All 78 Lines • ▼ Show 20 Lines | if (table->map && (table->maplen > 0)) { | ||||
(void) munmap(table->map, table->maplen); | (void) munmap(table->map, table->maplen); | ||||
} | } | ||||
free(t); | free(t); | ||||
} | } | ||||
void * | void * | ||||
__collate_load(const char *encoding, __unused locale_t unused) | __collate_load(const char *encoding, __unused locale_t unused) | ||||
{ | { | ||||
if (strcmp(encoding, "C") == 0 || strcmp(encoding, "POSIX") == 0) { | if (strcmp(encoding, "C") == 0 || strcmp(encoding, "POSIX") == 0 || | ||||
strncmp(encoding, "C.", 2) == 0) { | |||||
return &__xlocale_C_collate; | return &__xlocale_C_collate; | ||||
} | } | ||||
struct xlocale_collate *table = calloc(sizeof(struct xlocale_collate), 1); | struct xlocale_collate *table = calloc(sizeof(struct xlocale_collate), 1); | ||||
table->header.header.destructor = destruct_collate; | table->header.header.destructor = destruct_collate; | ||||
// FIXME: Make sure that _LDP_CACHE is never returned. We should be doing | // FIXME: Make sure that _LDP_CACHE is never returned. We should be doing | ||||
// the caching outside of this section | // the caching outside of this section | ||||
if (__collate_load_tables_l(encoding, table) != _LDP_LOADED) { | if (__collate_load_tables_l(encoding, table) != _LDP_LOADED) { | ||||
xlocale_release(table); | xlocale_release(table); | ||||
Show All 21 Lines | __collate_load_tables_l(const char *encoding, struct xlocale_collate *table) | ||||
char *map; | char *map; | ||||
collate_info_t *info; | collate_info_t *info; | ||||
struct stat sbuf; | struct stat sbuf; | ||||
int fd; | int fd; | ||||
table->__collate_load_error = 1; | table->__collate_load_error = 1; | ||||
/* 'encoding' must be already checked. */ | /* 'encoding' must be already checked. */ | ||||
if (strcmp(encoding, "C") == 0 || strcmp(encoding, "POSIX") == 0) { | if (strcmp(encoding, "C") == 0 || strcmp(encoding, "POSIX") == 0 || | ||||
strncmp(encoding, "C.", 2) == 0) { | |||||
return (_LDP_CACHE); | return (_LDP_CACHE); | ||||
} | } | ||||
if (asprintf(&buf, "%s/%s/LC_COLLATE", _PathLocale, encoding) == -1) | if (asprintf(&buf, "%s/%s/LC_COLLATE", _PathLocale, encoding) == -1) | ||||
return (_LDP_ERROR); | return (_LDP_ERROR); | ||||
if ((fd = _open(buf, O_RDONLY)) < 0) { | if ((fd = _open(buf, O_RDONLY)) < 0) { | ||||
free(buf); | free(buf); | ||||
▲ Show 20 Lines • Show All 576 Lines • Show Last 20 Lines |