From 2b6def26f41457eba8f2056432cd1af68a5b58b0 Mon Sep 17 00:00:00 2001 From: Simon Tatham Date: Tue, 20 Apr 2004 17:50:41 +0000 Subject: Infrastructure changes for character set support. ustrtoa, ustrfroma, utoa_dup and ufroma_dup now take a charset parameter, and also have a variety of subtly distinct forms. Also, when a \cfg directive is seen in the input file, the precise octet strings for each parameter are kept in their original form as well as being translated into Unicode, so that when they represent filenames they can be used verbatim. [originally from svn r4097] --- bk_whlp.c | 31 ++++--------------------------- 1 file changed, 4 insertions(+), 27 deletions(-) (limited to 'bk_whlp.c') diff --git a/bk_whlp.c b/bk_whlp.c index 7738c71..c8a6524 100644 --- a/bk_whlp.c +++ b/bk_whlp.c @@ -45,30 +45,7 @@ static void whlp_contents_write(struct bk_whlp_state *state, paragraph *whlp_config_filename(char *filename) { - paragraph *p; - wchar_t *ufilename, *up; - int len; - - p = mknew(paragraph); - memset(p, 0, sizeof(*p)); - p->type = para_Config; - p->next = NULL; - p->fpos.filename = ""; - p->fpos.line = p->fpos.col = -1; - - ufilename = ufroma_dup(filename); - len = ustrlen(ufilename) + 2 + lenof(L"winhelp-filename"); - p->keyword = mknewa(wchar_t, len); - up = p->keyword; - ustrcpy(up, L"winhelp-filename"); - up = uadv(up); - ustrcpy(up, ufilename); - up = uadv(up); - *up = L'\0'; - assert(up - p->keyword < len); - sfree(ufilename); - - return p; + return cmdline_cfg_simple("winhelp-filename", filename, NULL); } void whlp_backend(paragraph *sourceform, keywordlist *keywords, @@ -129,7 +106,7 @@ void whlp_backend(paragraph *sourceform, keywordlist *keywords, p->parent->private_data = topicname; } else if (!ustricmp(p->keyword, L"winhelp-filename")) { sfree(filename); - filename = utoa_dup(uadv(p->keyword)); + filename = dupstr(adv(p->origkeyword)); } } } @@ -152,7 +129,7 @@ void whlp_backend(paragraph *sourceform, keywordlist *keywords, filename = newf; len = strlen(newf); } - cntname = mknewa(char, len); + cntname = mknewa(char, len+1); sprintf(cntname, "%.*s.cnt", len-4, filename); } @@ -671,7 +648,7 @@ static void whlp_rdaddwc(rdstringc *rs, word *text) { assert(text->type != word_CodeQuote && text->type != word_WkCodeQuote); if (removeattr(text->type) == word_Normal) { - if (whlp_convert(text->text, 0, &c, FALSE)) + if (whlp_convert(text->text, 0, &c, FALSE) || !text->alt) rdaddsc(rs, c); else whlp_rdaddwc(rs, text->alt); -- cgit v1.1