MCPcopy Create free account
hub / github.com/FirebirdSQL/firebird / keymacro__decode_str

Function keymacro__decode_str

extern/editline/src/keymacro.c:636–671  ·  view source on GitHub ↗

keymacro__decode_str(): * Make a printable version of the ey */

Source from the content-addressed store, hash-verified

634 * Make a printable version of the ey
635 */
636protected size_t
637keymacro__decode_str(const Char *str, char *buf, size_t len, const char *sep)
638{
639 char *b = buf, *eb = b + len;
640 const Char *p;
641
642 b = buf;
643 if (sep[0] != '\0') {
644 ADDC(sep[0]);
645 }
646 if (*str == '\0') {
647 ADDC('^');
648 ADDC('@');
649 goto add_endsep;
650 }
651 for (p = str; *p != 0; p++) {
652 Char dbuf[VISUAL_WIDTH_MAX];
653 Char *p2 = dbuf;
654 ssize_t l = ct_visual_char(dbuf, VISUAL_WIDTH_MAX, *p);
655 while (l-- > 0) {
656 ssize_t n = ct_encode_char(b, (size_t)(eb - b), *p2++);
657 if (n == -1) /* ran out of space */
658 goto add_endsep;
659 else
660 b += n;
661 }
662 }
663add_endsep:
664 if (sep[0] != '\0' && sep[1] != '\0') {
665 ADDC(sep[1]);
666 }
667 ADDC('\0');
668 if ((size_t)(b - buf) >= len)
669 buf[len - 1] = '\0';
670 return (size_t)(b - buf);
671}

Callers 3

map_print_keyFunction · 0.85
map_print_some_keysFunction · 0.85
keymacro_kprintFunction · 0.85

Calls 2

ct_visual_charFunction · 0.85
ct_encode_charFunction · 0.85

Tested by

no test coverage detected