X-Git-Url: https://git.distorted.org.uk/~mdw/sgt/halibut/blobdiff_plain/b921687e6593e2a473b12e5851a5ff145a6ac3d8..2223c2ddaa32c4979bb95188b87a70bc2abd8dda:/bk_info.c diff --git a/bk_info.c b/bk_info.c index 23f8628..fc1b292 100644 --- a/bk_info.c +++ b/bk_info.c @@ -80,7 +80,7 @@ static infoconfig info_configure(paragraph *source) { if (source->type == para_Config) { if (!ustricmp(source->keyword, L"info-filename")) { sfree(ret.filename); - ret.filename = utoa_dup(uadv(source->keyword)); + ret.filename = dupstr(adv(source->origkeyword)); } else if (!ustricmp(source->keyword, L"info-max-file-size")) { ret.maxfilesize = utoi(uadv(source->keyword)); } @@ -92,34 +92,11 @@ static infoconfig info_configure(paragraph *source) { paragraph *info_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"info-filename"); - p->keyword = mknewa(wchar_t, len); - up = p->keyword; - ustrcpy(up, L"info-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("info-filename", filename, NULL); } void info_backend(paragraph *sourceform, keywordlist *keywords, - indexdata *idx) { + indexdata *idx, void *unused) { paragraph *p; infoconfig conf; word *prefix, *body, *wp; @@ -140,8 +117,7 @@ void info_backend(paragraph *sourceform, keywordlist *keywords, int width = 70, listindentbefore = 1, listindentafter = 3; int indent_code = 2, index_width = 40; - IGNORE(keywords); /* we don't happen to need this */ - IGNORE(idx); /* or this */ + IGNORE(unused); conf = info_configure(sourceform); @@ -236,11 +212,11 @@ void info_backend(paragraph *sourceform, keywordlist *keywords, } rdaddsc(&intro_text, "INFO-DIR-SECTION "); - s = utoa_dup(section); + s = utoa_dup(section, CS_FIXME); rdaddsc(&intro_text, s); sfree(s); rdaddsc(&intro_text, "\nSTART-INFO-DIR-ENTRY\n* "); - s = utoa_dup(shortname); + s = utoa_dup(shortname, CS_FIXME); rdaddsc(&intro_text, s); sfree(s); rdaddsc(&intro_text, ": ("); @@ -258,7 +234,7 @@ void info_backend(paragraph *sourceform, keywordlist *keywords, } } rdaddsc(&intro_text, ". "); - s = utoa_dup(longname); + s = utoa_dup(longname, CS_FIXME); rdaddsc(&intro_text, s); sfree(s); rdaddsc(&intro_text, "\nEND-INFO-DIR-ENTRY\n\n"); @@ -748,7 +724,7 @@ static void info_rdaddwc(rdstringc *rs, word *words, word *end, int xrefs) { attraux(words->aux) == attr_Only)) rdaddc(rs, '`'); /* FIXME: configurability */ if (removeattr(words->type) == word_Normal) { - if (info_convert(words->text, &c)) + if (info_convert(words->text, &c) || !words->alt) rdaddsc(rs, c); else info_rdaddwc(rs, words->alt, NULL, FALSE); @@ -808,7 +784,7 @@ static int info_width_internal(word *words, int xrefs) { ? (attraux(words->aux) == attr_Only ? 2 : attraux(words->aux) == attr_Always ? 0 : 1) : 0) + - (info_convert(words->text, NULL) ? + (info_convert(words->text, NULL) || !words->alt ? ustrlen(words->text) : info_width_internal_list(words->alt, xrefs))); @@ -839,12 +815,14 @@ static int info_width_internal(word *words, int xrefs) { return 0; /* should never happen */ } -static int info_width_noxrefs(word *words) +static int info_width_noxrefs(void *ctx, word *words) { + IGNORE(ctx); return info_width_internal(words, FALSE); } -static int info_width_xrefs(word *words) +static int info_width_xrefs(void *ctx, word *words) { + IGNORE(ctx); return info_width_internal(words, TRUE); } @@ -866,7 +844,8 @@ static void info_heading(rdstringc *text, word *tprefix, firstlinewidth = width - length; wrapwidth = width; - wrapping = wrap_para(words, firstlinewidth, wrapwidth, info_width_noxrefs); + wrapping = wrap_para(words, firstlinewidth, wrapwidth, + info_width_noxrefs, NULL, 0); for (p = wrapping; p; p = p->next) { info_rdaddwc(&t, p->begin, p->end, FALSE); length = (t.text ? strlen(t.text) : 0); @@ -930,7 +909,8 @@ static void info_para(rdstringc *text, word *prefix, char *prefixextra, } else e = indent + extraindent; - wrapping = wrap_para(words, firstlinewidth, width, info_width_xrefs); + wrapping = wrap_para(words, firstlinewidth, width, info_width_xrefs, + NULL, 0); for (p = wrapping; p; p = p->next) { for (i = 0; i < e; i++) rdaddc(text, ' ');