diff options
author | scuri <scuri> | 2009-10-20 18:12:26 +0000 |
---|---|---|
committer | scuri <scuri> | 2009-10-20 18:12:26 +0000 |
commit | a972dbb9bd731a439d009bd51e36981c41a06232 (patch) | |
tree | e4e5d0aaf23706083dfb1fe4180e18f0907a90c9 /src/pdflib/pdcore/pc_chartabs.c | |
parent | 27a4f9c4ac45ff65f941964f7351b64b1e6a9f35 (diff) |
*** empty log message ***
Diffstat (limited to 'src/pdflib/pdcore/pc_chartabs.c')
-rw-r--r-- | src/pdflib/pdcore/pc_chartabs.c | 85 |
1 files changed, 71 insertions, 14 deletions
diff --git a/src/pdflib/pdcore/pc_chartabs.c b/src/pdflib/pdcore/pc_chartabs.c index 3799d45..9e33bcb 100644 --- a/src/pdflib/pdcore/pc_chartabs.c +++ b/src/pdflib/pdcore/pc_chartabs.c @@ -10,7 +10,7 @@ | | *---------------------------------------------------------------------------*/ -/* $Id: pc_chartabs.c,v 1.1 2008/10/17 06:10:43 scuri Exp $ +/* $Id: pc_chartabs.c,v 1.2 2009/10/20 18:12:26 scuri Exp $ * * PDFlib routines for converting glyph or character names to Unicode * and vice versa @@ -33,26 +33,53 @@ int pdc_glyphname2codelist(const char *glyphname, const pdc_glyph_tab *glyphtab, int tabsize, pdc_ushort *codelist) { + const char *s1, *s2; int lo = 0; int hi = glyphname ? tabsize : lo; - int nv = 0; + int i, j, cmp, nv = 0; while (lo < hi) { - int i = (lo + hi) / 2; - int cmp = strcmp(glyphname, glyphtab[i].name); + i = (lo + hi) / 2; + + s1 = glyphname; + s2 = glyphtab[i].name; + for (; *s1; ++s1, ++s2) + { + if (*s1 != *s2) + break; + } + cmp = (*s1 - *s2); if (cmp == 0) { + j = i; for (; i >= 1; i--) { - if (strcmp(glyphname, glyphtab[i-1].name)) + s1 = glyphname; + s2 = glyphtab[i-1].name; + for (; *s1; ++s1, ++s2) + { + if (*s1 != *s2) + break; + } + if (*s1 != *s2) break; } for (; i < tabsize; i++) { - if (strcmp(glyphname, glyphtab[i].name)) - break; + if (i > j) + { + s1 = glyphname; + s2 = glyphtab[i].name; + for (; *s1; ++s1, ++s2) + { + if (*s1 != *s2) + break; + } + if (*s1 != *s2) + break; + } codelist[nv] = glyphtab[i].code; nv++; } @@ -75,13 +102,23 @@ int pdc_glyphname2code(const char *glyphname, const pdc_glyph_tab *glyphtab, int tabsize) { + const char *s1, *s2; int lo = 0; int hi = glyphname ? tabsize : lo; + int i, cmp; while (lo < hi) { - int i = (lo + hi) / 2; - int cmp = strcmp(glyphname, glyphtab[i].name); + i = (lo + hi) / 2; + + s1 = glyphname; + s2 = glyphtab[i].name; + for (; *s1; ++s1, ++s2) + { + if (*s1 != *s2) + break; + } + cmp = (*s1 - *s2); if (cmp == 0) return (int) glyphtab[i].code; @@ -175,13 +212,23 @@ const char * pdc_glyphname2glyphname(const char *glyphname, const pdc_glyph_tab *glyphtab, int tabsize) { + const char *s1, *s2; int lo = 0; int hi = tabsize; + int cmp, i; while (lo < hi) { - int i = (lo + hi) / 2; - int cmp = strcmp(glyphname, glyphtab[i].name); + i = (lo + hi) / 2; + + s1 = glyphname; + s2 = glyphtab[i].name; + for (; *s1; ++s1, ++s2) + { + if (*s1 != *s2) + break; + } + cmp = (*s1 - *s2); if (cmp == 0) return glyphtab[i].name; @@ -332,15 +379,25 @@ pdc_glyphname2altunicode(const char *glyphname) pdc_bool pdc_is_std_charname(const char *glyphname) { + const char *s1, *s2; int lo = 0; int hi = ((sizeof pc_standard_latin_charset) / (sizeof (char *))); + int cmp, i; if (glyphname) { while (lo < hi) { - int i = (lo + hi) / 2; - int cmp = strcmp(glyphname, pc_standard_latin_charset[i]); + i = (lo + hi) / 2; + + s1 = glyphname; + s2 = pc_standard_latin_charset[i]; + for (; *s1; ++s1, ++s2) + { + if (*s1 != *s2) + break; + } + cmp = (*s1 - *s2); if (cmp == 0) return pdc_true; @@ -578,7 +635,7 @@ pdc_string2unicode(pdc_core *pdc, const char *text, int i_flags, if (seterr) { - pdc_set_errmsg(pdc, PDC_E_CONV_ILLUTF32, &text[i], 0, 0, 0); + pdc_set_errmsg(pdc, PDC_E_CONV_ILLUTF32CHAR, &text[i], 0, 0, 0); if (verbose) pdc_error(pdc, -1, 0, 0, 0, 0); } |