From: NeilBrown Date: Wed, 2 Dec 2015 03:40:23 +0000 (+1100) Subject: render-format: allow '<' characters in format fields. X-Git-Tag: lca2016~136 X-Git-Url: http://git.neil.brown.name/?a=commitdiff_plain;h=2ae020fa2bf2a716176886f4dc49832a5c5f22b9;p=edlib.git render-format: allow '<' characters in format fields. These need to be quoted. Signed-off-by: NeilBrown --- diff --git a/core-misc.c b/core-misc.c index ff3d3a41..3372dc77 100644 --- a/core-misc.c +++ b/core-misc.c @@ -50,3 +50,8 @@ void buf_append(struct buf *b, wchar_t wch) l = wcrtomb(t, wch, &ps); buf_concat_len(b, t, l); } + +void buf_append_byte(struct buf *b, char c) +{ + buf_concat_len(b, &c, 1); +} diff --git a/misc.h b/misc.h index f031a94d..3b0ce198 100644 --- a/misc.h +++ b/misc.h @@ -16,6 +16,7 @@ void buf_init(struct buf *b); void buf_concat(struct buf *b, char *s); void buf_concat_len(struct buf *b, char *s, int l); void buf_append(struct buf *b, wchar_t wch); +void buf_append_byte(struct buf *b, char c); static inline char *buf_final(struct buf *b) { if (b->b) diff --git a/mode-emacs.c b/mode-emacs.c index 38eb9cbb..aa307df0 100644 --- a/mode-emacs.c +++ b/mode-emacs.c @@ -437,7 +437,9 @@ DEF_CMD(emacs_doc_complete) struct pane *par, *pop; struct cmd_info ci2 = {0}; - pop = pane_attach(ci->focus, "popup", ed->docs->home, "DM1"); + pop = pane_attach(ci->focus, "popup", ed->docs->home, "DM1r"); + if (!pop) + return -1; par = pane_final_child(pop); attr_set_str(&par->attrs, "line-format", "%+name", -1); diff --git a/render-format.c b/render-format.c index fd598513..3df04bcc 100644 --- a/render-format.c +++ b/render-format.c @@ -62,7 +62,7 @@ DEF_CMD(render_line) int w, adjust, l; if (*n != '%' || n[1] == '%') { - buf_append(&ret, *n); + buf_append_byte(&ret, *n); if (*n == '%') n += 1; n += 1; @@ -100,7 +100,12 @@ DEF_CMD(render_line) if (!val) val = "-"; if (*n != ':') { - buf_concat(&ret, val); + while (*val) { + if (*val == '<') + buf_append_byte(&ret, '<'); + buf_append_byte(&ret, *val); + val += 1; + } continue; } w = 0; @@ -121,7 +126,9 @@ DEF_CMD(render_line) } while (*val && w > 0 ) { - buf_append(&ret, *val); + if (*val == '<') + buf_append_byte(&ret, '<'); + buf_append_byte(&ret, *val); w -= 1; val += 1; }