Eliminate use of ctype.h routines.

That way, we don't do locale-sensitive case-insensitivity (yes, the
locale can affect case-mapping - in a Turkish locale, "I" isn't the
upper-case version of "i", for example).

Change-Id: I5f7663e85160558ff3769617f924e45049c9c384
Reviewed-on: https://code.wireshark.org/review/4843
Reviewed-by: Guy Harris <guy@alum.mit.edu>
This commit is contained in:
Guy Harris 2014-10-19 15:41:04 -07:00
parent ac55a6d2f5
commit 2b6c267a57
2 changed files with 6 additions and 4 deletions

View File

@ -24,7 +24,6 @@
#include "config.h"
#include <ctype.h>
#include <string.h>
#include <stdio.h>
#include <glib.h>
@ -479,8 +478,8 @@ pack_string(const gchar *key, guint32 *divx, guint32 flags)
ch = (unsigned char)key[i];
if (flags & WMEM_TREE_STRING_NOCASE) {
if (isupper(ch)) {
ch = tolower(ch);
if (g_ascii_isupper(ch)) {
ch = g_ascii_tolower(ch);
}
}
tmp <<= 8;

View File

@ -112,7 +112,10 @@ wmem_tree_lookup32_le(wmem_tree_t *tree, guint32 key);
/** Insert a new value under a string key. Like wmem_tree_insert32 but where the
* key is a null-terminated string instead of a guint32. You may pass
* WMEM_TREE_STRING_NOCASE to the flags argument in order to make it store the
* key in a case-insensitive way. */
* key in a case-insensitive way. (Note that "case-insensitive" refers
* only to the ASCII letters A-Z and a-z; it is locale-independent.
* Do not expect it to honor the rules of your language; for example, "I"
* will always be mapped to "i". */
WS_DLL_PUBLIC
void
wmem_tree_insert_string(wmem_tree_t *tree, const gchar* key, void *data,