Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
locale.c: Remove potential infinite recursive call
In Configurations where this #ifdef'd code is compiled, we recursively call my_langinfo(). Prior to this commit, the call asked for the UTFness of the returned string. Depending on the particular values involved, that could lead to this same code being executed to determine that UTF8ness of the locale. This would have proceeded ad infinitum except a previous commit had created flags so as to skip any call that would recurse infinitely. But that can lead to erroneous results, because when skipped, we may not know what the answer is. This commit avoids all that by not asking the recursed call to return the UTF8ness of the string, but instead use a heuristic to get its value here. This avoids needing to know the locale's UTF8ness (which is where the infinite recursion would come from). The heuristic is that if it is illegal UTF-8, it isn't UTF-8; if it is plain ASCII, we can't tell; and if it is legal UTF-8, it will be tentatively considered UTF-8. This is just one iteration of a loop through a bunch of strings, so that after all the accumulated evidence of all iterations, we have confidence that the total result is correct. There are other code sections that also have the potential for infinite recursion. The next commits handle these.
- Loading branch information