From 98dac5cb19fb7264e220db9782755ee3688b498e Mon Sep 17 00:00:00 2001 From: Thomas Roessler Date: Mon, 23 Aug 1999 14:53:44 +0000 Subject: [PATCH] Don't delete symbol -> character code mappings. Character sets may define multiple symbols. :-( --- charset.c | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) diff --git a/charset.c b/charset.c index 40df1021..393c240a 100644 --- a/charset.c +++ b/charset.c @@ -431,12 +431,8 @@ static int load_charset (const char *filename, CHARSET ** csp, short multbyte) hash_delete (cs->symb_to_repr, cd->symbol, NULL, NULL); hash_insert (cs->symb_to_repr, cd->symbol, cd, 0); - if (cs->description[cd->repr]) - { - hash_delete (cs->symb_to_repr, cs->description[cd->repr]->symbol, cs->description[cd->repr], NULL); - chardesc_free (&cs->description[cd->repr]); - } - else + /* note: we intentionally leak some memory here. */ + if (!cs->description[cd->repr]) cs->u_symb++; cs->description[cd->repr] = cd; @@ -455,12 +451,15 @@ static int load_charset (const char *filename, CHARSET ** csp, short multbyte) cs->description[i] = NULL; cs->n_symb = new_size; } + hash_delete (cs->symb_to_repr, cd->symbol, NULL, NULL); hash_insert (cs->symb_to_repr, cd->symbol, cd, 0); + cs->description[cs->u_symb++] = cd; cd = NULL; } } + if (cd) { dprint (5, (debugfile, "load_charset: character description still present: <%s>->%x\n", @@ -503,9 +502,9 @@ static CHARDESC *repr2descr (int repr, CHARSET * cs) key = safe_malloc (sizeof(CHARDESC)); key->repr = repr; key->symbol = ""; /* otherwise, the - * debug code may - * segfault. ouch. - */ + * debug code may + * segfault. ouch. + */ r = bsearch (&key, cs->description, cs->u_symb, sizeof (CHARDESC *), _cd_compar); -- 2.40.0