X-Git-Url: https://ncurses.scripts.mit.edu/?p=ncurses.git;a=blobdiff_plain;f=ncurses%2Ftinfo%2Fcaptoinfo.c;fp=ncurses%2Ftinfo%2Fcaptoinfo.c;h=eec8a133bbdeb8a8bd3c1c1da93cdc58fc96324c;hp=0d7944f36fa7003851b2f391dcd4f2b0558d1a5d;hb=614f0d6711aad3f1a99c149cc533e74f8af3c444;hpb=10539f5afe94d8ff488516ca7f9861af7c800bfb diff --git a/ncurses/tinfo/captoinfo.c b/ncurses/tinfo/captoinfo.c index 0d7944f3..eec8a133 100644 --- a/ncurses/tinfo/captoinfo.c +++ b/ncurses/tinfo/captoinfo.c @@ -93,7 +93,7 @@ #include #include -MODULE_ID("$Id: captoinfo.c,v 1.54 2010/01/16 17:12:19 tom Exp $") +MODULE_ID("$Id: captoinfo.c,v 1.57 2010/04/18 00:14:49 tom Exp $") #define MAX_PUSHED 16 /* max # args we can push onto the stack */ @@ -666,8 +666,27 @@ _nc_infotocap(const char *cap GCC_UNUSED, const char *str, int const parameteriz int c1, c2; char *cp = 0; - if (str[0] == '\\' && (str[1] == '^' || str[1] == ',')) { - bufptr = save_char(bufptr, *++str); + if (str[0] == '^') { + if (str[1] == '\0' || (str + 1) == trimmed) { + bufptr = save_string(bufptr, "\\136"); + ++str; + } else { + bufptr = save_char(bufptr, *str++); + bufptr = save_char(bufptr, *str); + } + } else if (str[0] == '\\') { + if (str[1] == '\0' || (str + 1) == trimmed) { + bufptr = save_string(bufptr, "\\134"); + ++str; + } else if (str[1] == '^') { + bufptr = save_string(bufptr, "\\136"); + ++str; + } else if (str[1] == ',') { + bufptr = save_char(bufptr, *++str); + } else { + bufptr = save_char(bufptr, *str++); + bufptr = save_char(bufptr, *str); + } } else if (str[0] == '$' && str[1] == '<') { /* discard padding */ str += 2; while (isdigit(UChar(*str))