Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
locale.c: Create S_get_category_index()
libc locale categories, like LC_NUMERIC, are opaque integers. This makes it inconvenient to have table-driven code. Instead, we have tables that are indexed by small positive integers, which are a compile-time mapping from the libc values. This commit creates a run-time function to also do that mapping. It will first be used in the next commit. The function does a loop through the available categories, looking for a match. It could be replaced by some sort of quick hash lookup, but the largest arrays in the field have a max of 12 elements, with almost all searches finding their quarry in the first 6. It doesn't seem worthwhile to me to replace a linear search of 6 elements by something more complicated. The design intent is this search will be used only at the edges of the locale-handling code; once found the index is used in future bits of the current operation.
- Loading branch information
1 parent
013af96
commit b70ece7
Showing
4 changed files
with
60 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters