diff options
author | H. Peter Anvin <hpa@smyrno.hos.anvin.org> | 2005-12-04 22:01:56 -0800 |
---|---|---|
committer | H. Peter Anvin <hpa@smyrno.hos.anvin.org> | 2005-12-04 22:01:56 -0800 |
commit | 8986e43af73d8f8f8e93e169878ecd29d5592a3a (patch) | |
tree | a4351b92cf501bca1f03bda638c0241b2d13beec | |
parent | 12a407d6ebceeb1fc9b8ad8c7dda5049c75e1da8 (diff) | |
download | libucd-8986e43af73d8f8f8e93e169878ecd29d5592a3a.tar.gz |
Complete the handling of name-to-ucs lookups
-rw-r--r-- | nametoucs.c | 18 | ||||
-rw-r--r-- | ucd.h | 1 |
2 files changed, 16 insertions, 3 deletions
diff --git a/nametoucs.c b/nametoucs.c index 3e345f8..736af61 100644 --- a/nametoucs.c +++ b/nametoucs.c @@ -17,7 +17,7 @@ static uint32_t prehash(const char *str) } /* This returns a candidate UCS for a given name. */ -int32_t _libucd_name_to_ucs(const char *name) +static int32_t name_lookup(const char *name) { int32_t ucs; uint32_t hash; @@ -38,5 +38,17 @@ int32_t _libucd_name_to_ucs(const char *name) return ucs; } - - +struct unicode_character_data * +unicode_character_lookup(const char *name) +{ + int32_t ucs = name_lookup(name); + struct unicode_character_data *ucd = + unicode_character_data(ucs); + + if ( !ucd->name || strcmp(name, ucd->name) ) { + unicode_character_put(ucd); + return NULL; + } + + return ucd; +} @@ -582,5 +582,6 @@ struct unicode_character_data { struct unicode_character_data *unicode_character_data(int32_t); struct unicode_character_data *unicode_character_get(struct unicode_character_data *); void unicode_character_put(struct unicode_character_data *); +struct unicode_character_data *unicode_character_lookup(const char *); #endif /* UCD_H */ |