Mercurial > vim
comparison src/getchar.c @ 15605:62b3805506b3 v8.1.0810
patch 8.1.0810: too many #ifdefs
commit https://github.com/vim/vim/commit/264b74fa545edfb92c0d7d08a02c26331cc5b168
Author: Bram Moolenaar <Bram@vim.org>
Date: Thu Jan 24 17:18:42 2019 +0100
patch 8.1.0810: too many #ifdefs
Problem: Too many #ifdefs.
Solution: Graduate FEAT_MBYTE, part 4.
author | Bram Moolenaar <Bram@vim.org> |
---|---|
date | Thu, 24 Jan 2019 17:30:08 +0100 |
parents | d89c5b339c2a |
children | dd2e0b83a660 |
comparison
equal
deleted
inserted
replaced
15604:5d64befd4ab4 | 15605:62b3805506b3 |
---|---|
289 * Translates special keys, NUL, CSI, K_SPECIAL and multibyte characters. | 289 * Translates special keys, NUL, CSI, K_SPECIAL and multibyte characters. |
290 */ | 290 */ |
291 static void | 291 static void |
292 add_char_buff(buffheader_T *buf, int c) | 292 add_char_buff(buffheader_T *buf, int c) |
293 { | 293 { |
294 #ifdef FEAT_MBYTE | |
295 char_u bytes[MB_MAXBYTES + 1]; | 294 char_u bytes[MB_MAXBYTES + 1]; |
296 int len; | 295 int len; |
297 int i; | 296 int i; |
298 #endif | |
299 char_u temp[4]; | 297 char_u temp[4]; |
300 | 298 |
301 #ifdef FEAT_MBYTE | |
302 if (IS_SPECIAL(c)) | 299 if (IS_SPECIAL(c)) |
303 len = 1; | 300 len = 1; |
304 else | 301 else |
305 len = (*mb_char2bytes)(c, bytes); | 302 len = (*mb_char2bytes)(c, bytes); |
306 for (i = 0; i < len; ++i) | 303 for (i = 0; i < len; ++i) |
307 { | 304 { |
308 if (!IS_SPECIAL(c)) | 305 if (!IS_SPECIAL(c)) |
309 c = bytes[i]; | 306 c = bytes[i]; |
310 #endif | |
311 | 307 |
312 if (IS_SPECIAL(c) || c == K_SPECIAL || c == NUL) | 308 if (IS_SPECIAL(c) || c == K_SPECIAL || c == NUL) |
313 { | 309 { |
314 /* translate special key code into three byte sequence */ | 310 /* translate special key code into three byte sequence */ |
315 temp[0] = K_SPECIAL; | 311 temp[0] = K_SPECIAL; |
331 { | 327 { |
332 temp[0] = c; | 328 temp[0] = c; |
333 temp[1] = NUL; | 329 temp[1] = NUL; |
334 } | 330 } |
335 add_buff(buf, temp, -1L); | 331 add_buff(buf, temp, -1L); |
336 #ifdef FEAT_MBYTE | 332 } |
337 } | |
338 #endif | |
339 } | 333 } |
340 | 334 |
341 /* First read ahead buffer. Used for translated commands. */ | 335 /* First read ahead buffer. Used for translated commands. */ |
342 static buffheader_T readbuf1 = {{NULL, {NUL}}, NULL, 0, 0}; | 336 static buffheader_T readbuf1 = {{NULL, {NUL}}, NULL, 0, 0}; |
343 | 337 |
594 | 588 |
595 if (*s == NUL || (len >= 0 && s - str >= len)) | 589 if (*s == NUL || (len >= 0 && s - str >= len)) |
596 break; | 590 break; |
597 | 591 |
598 /* Handle a special or multibyte character. */ | 592 /* Handle a special or multibyte character. */ |
599 #ifdef FEAT_MBYTE | |
600 if (has_mbyte) | 593 if (has_mbyte) |
601 /* Handle composing chars separately. */ | 594 /* Handle composing chars separately. */ |
602 c = mb_cptr2char_adv(&s); | 595 c = mb_cptr2char_adv(&s); |
603 else | 596 else |
604 #endif | |
605 c = *s++; | 597 c = *s++; |
606 if (c < ' ' || c == DEL || (*s == NUL && (c == '0' || c == '^'))) | 598 if (c < ' ' || c == DEL || (*s == NUL && (c == '0' || c == '^'))) |
607 add_char_buff(&redobuff, Ctrl_V); | 599 add_char_buff(&redobuff, Ctrl_V); |
608 | 600 |
609 /* CTRL-V '0' must be inserted as CTRL-V 048 (EBCDIC: xf0) */ | 601 /* CTRL-V '0' must be inserted as CTRL-V 048 (EBCDIC: xf0) */ |
684 stuffReadbuffLen(s, 3L); | 676 stuffReadbuffLen(s, 3L); |
685 s += 3; | 677 s += 3; |
686 } | 678 } |
687 else | 679 else |
688 { | 680 { |
689 #ifdef FEAT_MBYTE | |
690 c = mb_ptr2char_adv(&s); | 681 c = mb_ptr2char_adv(&s); |
691 #else | |
692 c = *s++; | |
693 #endif | |
694 if (c == CAR || c == NL || c == ESC) | 682 if (c == CAR || c == NL || c == ESC) |
695 c = ' '; | 683 c = ' '; |
696 stuffcharReadbuff(c); | 684 stuffcharReadbuff(c); |
697 } | 685 } |
698 } | 686 } |
730 read_redo(int init, int old_redo) | 718 read_redo(int init, int old_redo) |
731 { | 719 { |
732 static buffblock_T *bp; | 720 static buffblock_T *bp; |
733 static char_u *p; | 721 static char_u *p; |
734 int c; | 722 int c; |
735 #ifdef FEAT_MBYTE | |
736 int n; | 723 int n; |
737 char_u buf[MB_MAXBYTES + 1]; | 724 char_u buf[MB_MAXBYTES + 1]; |
738 int i; | 725 int i; |
739 #endif | |
740 | 726 |
741 if (init) | 727 if (init) |
742 { | 728 { |
743 if (old_redo) | 729 if (old_redo) |
744 bp = old_redobuff.bh_first.b_next; | 730 bp = old_redobuff.bh_first.b_next; |
750 return OK; | 736 return OK; |
751 } | 737 } |
752 if ((c = *p) != NUL) | 738 if ((c = *p) != NUL) |
753 { | 739 { |
754 /* Reverse the conversion done by add_char_buff() */ | 740 /* Reverse the conversion done by add_char_buff() */ |
755 #ifdef FEAT_MBYTE | |
756 /* For a multi-byte character get all the bytes and return the | 741 /* For a multi-byte character get all the bytes and return the |
757 * converted character. */ | 742 * converted character. */ |
758 if (has_mbyte && (c != K_SPECIAL || p[1] == KS_SPECIAL)) | 743 if (has_mbyte && (c != K_SPECIAL || p[1] == KS_SPECIAL)) |
759 n = MB_BYTE2LEN_CHECK(c); | 744 n = MB_BYTE2LEN_CHECK(c); |
760 else | 745 else |
761 n = 1; | 746 n = 1; |
762 for (i = 0; ; ++i) | 747 for (i = 0; ; ++i) |
763 #endif | |
764 { | 748 { |
765 if (c == K_SPECIAL) /* special key or escaped K_SPECIAL */ | 749 if (c == K_SPECIAL) /* special key or escaped K_SPECIAL */ |
766 { | 750 { |
767 c = TO_SPECIAL(p[1], p[2]); | 751 c = TO_SPECIAL(p[1], p[2]); |
768 p += 2; | 752 p += 2; |
774 if (*++p == NUL && bp->b_next != NULL) | 758 if (*++p == NUL && bp->b_next != NULL) |
775 { | 759 { |
776 bp = bp->b_next; | 760 bp = bp->b_next; |
777 p = bp->b_str; | 761 p = bp->b_str; |
778 } | 762 } |
779 #ifdef FEAT_MBYTE | |
780 buf[i] = c; | 763 buf[i] = c; |
781 if (i == n - 1) /* last byte of a character */ | 764 if (i == n - 1) /* last byte of a character */ |
782 { | 765 { |
783 if (n != 1) | 766 if (n != 1) |
784 c = (*mb_ptr2char)(buf); | 767 c = (*mb_ptr2char)(buf); |
785 break; | 768 break; |
786 } | 769 } |
787 c = *p; | 770 c = *p; |
788 if (c == NUL) /* cannot happen? */ | 771 if (c == NUL) /* cannot happen? */ |
789 break; | 772 break; |
790 #endif | |
791 } | 773 } |
792 } | 774 } |
793 | 775 |
794 return c; | 776 return c; |
795 } | 777 } |
1091 * the char. | 1073 * the char. |
1092 */ | 1074 */ |
1093 void | 1075 void |
1094 ins_char_typebuf(int c) | 1076 ins_char_typebuf(int c) |
1095 { | 1077 { |
1096 #ifdef FEAT_MBYTE | |
1097 char_u buf[MB_MAXBYTES + 1]; | 1078 char_u buf[MB_MAXBYTES + 1]; |
1098 #else | |
1099 char_u buf[4]; | |
1100 #endif | |
1101 if (IS_SPECIAL(c)) | 1079 if (IS_SPECIAL(c)) |
1102 { | 1080 { |
1103 buf[0] = K_SPECIAL; | 1081 buf[0] = K_SPECIAL; |
1104 buf[1] = K_SECOND(c); | 1082 buf[1] = K_SECOND(c); |
1105 buf[2] = K_THIRD(c); | 1083 buf[2] = K_THIRD(c); |
1106 buf[3] = NUL; | 1084 buf[3] = NUL; |
1107 } | 1085 } |
1108 else | 1086 else |
1109 { | |
1110 #ifdef FEAT_MBYTE | |
1111 buf[(*mb_char2bytes)(c, buf)] = NUL; | 1087 buf[(*mb_char2bytes)(c, buf)] = NUL; |
1112 #else | |
1113 buf[0] = c; | |
1114 buf[1] = NUL; | |
1115 #endif | |
1116 } | |
1117 (void)ins_typebuf(buf, KeyNoremap, 0, !KeyTyped, cmd_silent); | 1088 (void)ins_typebuf(buf, KeyNoremap, 0, !KeyTyped, cmd_silent); |
1118 } | 1089 } |
1119 | 1090 |
1120 /* | 1091 /* |
1121 * Return TRUE if the typeahead buffer was changed (while waiting for a | 1092 * Return TRUE if the typeahead buffer was changed (while waiting for a |
1577 */ | 1548 */ |
1578 int | 1549 int |
1579 vgetc(void) | 1550 vgetc(void) |
1580 { | 1551 { |
1581 int c, c2; | 1552 int c, c2; |
1582 #ifdef FEAT_MBYTE | |
1583 int n; | 1553 int n; |
1584 char_u buf[MB_MAXBYTES + 1]; | 1554 char_u buf[MB_MAXBYTES + 1]; |
1585 int i; | 1555 int i; |
1586 #endif | |
1587 | 1556 |
1588 #ifdef FEAT_EVAL | 1557 #ifdef FEAT_EVAL |
1589 /* Do garbage collection when garbagecollect() was called previously and | 1558 /* Do garbage collection when garbagecollect() was called previously and |
1590 * we are now at the toplevel. */ | 1559 * we are now at the toplevel. */ |
1591 if (may_garbage_collect && want_garbage_collect) | 1560 if (may_garbage_collect && want_garbage_collect) |
1761 case K_XDOWN: c = K_DOWN; break; | 1730 case K_XDOWN: c = K_DOWN; break; |
1762 case K_XLEFT: c = K_LEFT; break; | 1731 case K_XLEFT: c = K_LEFT; break; |
1763 case K_XRIGHT: c = K_RIGHT; break; | 1732 case K_XRIGHT: c = K_RIGHT; break; |
1764 } | 1733 } |
1765 | 1734 |
1766 #ifdef FEAT_MBYTE | |
1767 /* For a multi-byte character get all the bytes and return the | 1735 /* For a multi-byte character get all the bytes and return the |
1768 * converted character. | 1736 * converted character. |
1769 * Note: This will loop until enough bytes are received! | 1737 * Note: This will loop until enough bytes are received! |
1770 */ | 1738 */ |
1771 if (has_mbyte && (n = MB_BYTE2LEN_CHECK(c)) > 1) | 1739 if (has_mbyte && (n = MB_BYTE2LEN_CHECK(c)) > 1) |
1792 } | 1760 } |
1793 } | 1761 } |
1794 --no_mapping; | 1762 --no_mapping; |
1795 c = (*mb_ptr2char)(buf); | 1763 c = (*mb_ptr2char)(buf); |
1796 } | 1764 } |
1797 #endif | |
1798 | 1765 |
1799 break; | 1766 break; |
1800 } | 1767 } |
1801 } | 1768 } |
1802 | 1769 |
2210 typebuf.tb_buf[typebuf.tb_off + mlen]) | 2177 typebuf.tb_buf[typebuf.tb_off + mlen]) |
2211 #endif | 2178 #endif |
2212 break; | 2179 break; |
2213 } | 2180 } |
2214 | 2181 |
2215 #ifdef FEAT_MBYTE | |
2216 /* Don't allow mapping the first byte(s) of a | 2182 /* Don't allow mapping the first byte(s) of a |
2217 * multi-byte char. Happens when mapping | 2183 * multi-byte char. Happens when mapping |
2218 * <M-a> and then changing 'encoding'. Beware | 2184 * <M-a> and then changing 'encoding'. Beware |
2219 * that 0x80 is escaped. */ | 2185 * that 0x80 is escaped. */ |
2220 { | 2186 { |
2223 | 2189 |
2224 if (has_mbyte && p2 != NULL | 2190 if (has_mbyte && p2 != NULL |
2225 && MB_BYTE2LEN(c1) > MB_PTR2LEN(p2)) | 2191 && MB_BYTE2LEN(c1) > MB_PTR2LEN(p2)) |
2226 mlen = 0; | 2192 mlen = 0; |
2227 } | 2193 } |
2228 #endif | |
2229 /* | 2194 /* |
2230 * Check an entry whether it matches. | 2195 * Check an entry whether it matches. |
2231 * - Full match: mlen == keylen | 2196 * - Full match: mlen == keylen |
2232 * - Partly match: mlen == typebuf.tb_len | 2197 * - Partly match: mlen == typebuf.tb_len |
2233 */ | 2198 */ |
2683 { | 2648 { |
2684 if (!VIM_ISWHITE(ptr[col])) | 2649 if (!VIM_ISWHITE(ptr[col])) |
2685 curwin->w_wcol = vcol; | 2650 curwin->w_wcol = vcol; |
2686 vcol += lbr_chartabsize(ptr, ptr + col, | 2651 vcol += lbr_chartabsize(ptr, ptr + col, |
2687 (colnr_T)vcol); | 2652 (colnr_T)vcol); |
2688 #ifdef FEAT_MBYTE | |
2689 if (has_mbyte) | 2653 if (has_mbyte) |
2690 col += (*mb_ptr2len)(ptr + col); | 2654 col += (*mb_ptr2len)(ptr + col); |
2691 else | 2655 else |
2692 #endif | |
2693 ++col; | 2656 ++col; |
2694 } | 2657 } |
2695 curwin->w_wrow = curwin->w_cline_row | 2658 curwin->w_wrow = curwin->w_cline_row |
2696 + curwin->w_wcol / curwin->w_width; | 2659 + curwin->w_wcol / curwin->w_width; |
2697 curwin->w_wcol %= curwin->w_width; | 2660 curwin->w_wcol %= curwin->w_width; |
2698 curwin->w_wcol += curwin_col_off(); | 2661 curwin->w_wcol += curwin_col_off(); |
2699 #ifdef FEAT_MBYTE | |
2700 col = 0; /* no correction needed */ | 2662 col = 0; /* no correction needed */ |
2701 #endif | |
2702 } | 2663 } |
2703 else | 2664 else |
2704 { | 2665 { |
2705 --curwin->w_wcol; | 2666 --curwin->w_wcol; |
2706 #ifdef FEAT_MBYTE | |
2707 col = curwin->w_cursor.col - 1; | 2667 col = curwin->w_cursor.col - 1; |
2708 #endif | |
2709 } | 2668 } |
2710 } | 2669 } |
2711 else if (curwin->w_p_wrap && curwin->w_wrow) | 2670 else if (curwin->w_p_wrap && curwin->w_wrow) |
2712 { | 2671 { |
2713 --curwin->w_wrow; | 2672 --curwin->w_wrow; |
2714 curwin->w_wcol = curwin->w_width - 1; | 2673 curwin->w_wcol = curwin->w_width - 1; |
2715 #ifdef FEAT_MBYTE | |
2716 col = curwin->w_cursor.col - 1; | 2674 col = curwin->w_cursor.col - 1; |
2717 #endif | |
2718 } | 2675 } |
2719 #ifdef FEAT_MBYTE | |
2720 if (has_mbyte && col > 0 && curwin->w_wcol > 0) | 2676 if (has_mbyte && col > 0 && curwin->w_wcol > 0) |
2721 { | 2677 { |
2722 /* Correct when the cursor is on the right halve | 2678 /* Correct when the cursor is on the right halve |
2723 * of a double-wide character. */ | 2679 * of a double-wide character. */ |
2724 ptr = ml_get_curline(); | 2680 ptr = ml_get_curline(); |
2725 col -= (*mb_head_off)(ptr, ptr + col); | 2681 col -= (*mb_head_off)(ptr, ptr + col); |
2726 if ((*mb_ptr2cells)(ptr + col) > 1) | 2682 if ((*mb_ptr2cells)(ptr + col) > 1) |
2727 --curwin->w_wcol; | 2683 --curwin->w_wcol; |
2728 } | 2684 } |
2729 #endif | |
2730 } | 2685 } |
2731 setcursor(); | 2686 setcursor(); |
2732 out_flush(); | 2687 out_flush(); |
2733 #ifdef FEAT_CMDL_INFO | 2688 #ifdef FEAT_CMDL_INFO |
2734 new_wcol = curwin->w_wcol; | 2689 new_wcol = curwin->w_wcol; |
3432 * If an abbreviation ends in a keyword character, the | 3387 * If an abbreviation ends in a keyword character, the |
3433 * rest must be all keyword-char or all non-keyword-char. | 3388 * rest must be all keyword-char or all non-keyword-char. |
3434 * Otherwise we won't be able to find the start of it in a | 3389 * Otherwise we won't be able to find the start of it in a |
3435 * vi-compatible way. | 3390 * vi-compatible way. |
3436 */ | 3391 */ |
3437 #ifdef FEAT_MBYTE | |
3438 if (has_mbyte) | 3392 if (has_mbyte) |
3439 { | 3393 { |
3440 int first, last; | 3394 int first, last; |
3441 int same = -1; | 3395 int same = -1; |
3442 | 3396 |
3456 { | 3410 { |
3457 retval = 1; | 3411 retval = 1; |
3458 goto theend; | 3412 goto theend; |
3459 } | 3413 } |
3460 } | 3414 } |
3461 else | 3415 else if (vim_iswordc(keys[len - 1])) // ends in keyword char |
3462 #endif | |
3463 if (vim_iswordc(keys[len - 1])) /* ends in keyword char */ | |
3464 for (n = 0; n < len - 2; ++n) | 3416 for (n = 0; n < len - 2; ++n) |
3465 if (vim_iswordc(keys[n]) != vim_iswordc(keys[len - 2])) | 3417 if (vim_iswordc(keys[n]) != vim_iswordc(keys[len - 2])) |
3466 { | 3418 { |
3467 retval = 1; | 3419 retval = 1; |
3468 goto theend; | 3420 goto theend; |
4456 char_u tb[MB_MAXBYTES + 4]; | 4408 char_u tb[MB_MAXBYTES + 4]; |
4457 mapblock_T *mp; | 4409 mapblock_T *mp; |
4458 #ifdef FEAT_LOCALMAP | 4410 #ifdef FEAT_LOCALMAP |
4459 mapblock_T *mp2; | 4411 mapblock_T *mp2; |
4460 #endif | 4412 #endif |
4461 #ifdef FEAT_MBYTE | |
4462 int clen = 0; /* length in characters */ | 4413 int clen = 0; /* length in characters */ |
4463 #endif | |
4464 int is_id = TRUE; | 4414 int is_id = TRUE; |
4465 int vim_abbr; | 4415 int vim_abbr; |
4466 | 4416 |
4467 if (typebuf.tb_no_abbr_cnt) /* abbrev. are not recursive */ | 4417 if (typebuf.tb_no_abbr_cnt) /* abbrev. are not recursive */ |
4468 return FALSE; | 4418 return FALSE; |
4478 * before it except white space. | 4428 * before it except white space. |
4479 */ | 4429 */ |
4480 if (col == 0) /* cannot be an abbr. */ | 4430 if (col == 0) /* cannot be an abbr. */ |
4481 return FALSE; | 4431 return FALSE; |
4482 | 4432 |
4483 #ifdef FEAT_MBYTE | |
4484 if (has_mbyte) | 4433 if (has_mbyte) |
4485 { | 4434 { |
4486 char_u *p; | 4435 char_u *p; |
4487 | 4436 |
4488 p = mb_prevptr(ptr, ptr + col); | 4437 p = mb_prevptr(ptr, ptr + col); |
4506 ++clen; | 4455 ++clen; |
4507 } | 4456 } |
4508 scol = (int)(p - ptr); | 4457 scol = (int)(p - ptr); |
4509 } | 4458 } |
4510 else | 4459 else |
4511 #endif | |
4512 { | 4460 { |
4513 if (!vim_iswordc(ptr[col - 1])) | 4461 if (!vim_iswordc(ptr[col - 1])) |
4514 vim_abbr = TRUE; /* Vim added abbr. */ | 4462 vim_abbr = TRUE; /* Vim added abbr. */ |
4515 else | 4463 else |
4516 { | 4464 { |
4599 } | 4547 } |
4600 else | 4548 else |
4601 { | 4549 { |
4602 if (c < ABBR_OFF && (c < ' ' || c > '~')) | 4550 if (c < ABBR_OFF && (c < ' ' || c > '~')) |
4603 tb[j++] = Ctrl_V; /* special char needs CTRL-V */ | 4551 tb[j++] = Ctrl_V; /* special char needs CTRL-V */ |
4604 #ifdef FEAT_MBYTE | |
4605 if (has_mbyte) | 4552 if (has_mbyte) |
4606 { | 4553 { |
4607 /* if ABBR_OFF has been added, remove it here */ | 4554 /* if ABBR_OFF has been added, remove it here */ |
4608 if (c >= ABBR_OFF) | 4555 if (c >= ABBR_OFF) |
4609 c -= ABBR_OFF; | 4556 c -= ABBR_OFF; |
4610 j += (*mb_char2bytes)(c, tb + j); | 4557 j += (*mb_char2bytes)(c, tb + j); |
4611 } | 4558 } |
4612 else | 4559 else |
4613 #endif | |
4614 tb[j++] = c; | 4560 tb[j++] = c; |
4615 } | 4561 } |
4616 tb[j] = NUL; | 4562 tb[j] = NUL; |
4617 /* insert the last typed char */ | 4563 /* insert the last typed char */ |
4618 (void)ins_typebuf(tb, 1, 0, TRUE, mp->m_silent); | 4564 (void)ins_typebuf(tb, 1, 0, TRUE, mp->m_silent); |
4635 #endif | 4581 #endif |
4636 } | 4582 } |
4637 | 4583 |
4638 tb[0] = Ctrl_H; | 4584 tb[0] = Ctrl_H; |
4639 tb[1] = NUL; | 4585 tb[1] = NUL; |
4640 #ifdef FEAT_MBYTE | |
4641 if (has_mbyte) | 4586 if (has_mbyte) |
4642 len = clen; /* Delete characters instead of bytes */ | 4587 len = clen; /* Delete characters instead of bytes */ |
4643 #endif | |
4644 while (len-- > 0) /* delete the from string */ | 4588 while (len-- > 0) /* delete the from string */ |
4645 (void)ins_typebuf(tb, 1, 0, TRUE, mp->m_silent); | 4589 (void)ins_typebuf(tb, 1, 0, TRUE, mp->m_silent); |
4646 return TRUE; | 4590 return TRUE; |
4647 } | 4591 } |
4648 } | 4592 } |
4713 char_u *s, *d; | 4657 char_u *s, *d; |
4714 | 4658 |
4715 /* Need a buffer to hold up to three times as much. Four in case of an | 4659 /* Need a buffer to hold up to three times as much. Four in case of an |
4716 * illegal utf-8 byte: | 4660 * illegal utf-8 byte: |
4717 * 0xc0 -> 0xc3 0x80 -> 0xc3 K_SPECIAL KS_SPECIAL KE_FILLER */ | 4661 * 0xc0 -> 0xc3 0x80 -> 0xc3 K_SPECIAL KS_SPECIAL KE_FILLER */ |
4718 res = alloc((unsigned)(STRLEN(p) * | 4662 res = alloc((unsigned)(STRLEN(p) * 4) + 1); |
4719 #ifdef FEAT_MBYTE | |
4720 4 | |
4721 #else | |
4722 3 | |
4723 #endif | |
4724 ) + 1); | |
4725 if (res != NULL) | 4663 if (res != NULL) |
4726 { | 4664 { |
4727 d = res; | 4665 d = res; |
4728 for (s = p; *s != NUL; ) | 4666 for (s = p; *s != NUL; ) |
4729 { | 4667 { |
5010 return OK; | 4948 return OK; |
5011 } | 4949 } |
5012 | 4950 |
5013 for ( ; *str != NUL; ++str) | 4951 for ( ; *str != NUL; ++str) |
5014 { | 4952 { |
5015 #ifdef FEAT_MBYTE | |
5016 char_u *p; | 4953 char_u *p; |
5017 | 4954 |
5018 /* Check for a multi-byte character, which may contain escaped | 4955 /* Check for a multi-byte character, which may contain escaped |
5019 * K_SPECIAL and CSI bytes */ | 4956 * K_SPECIAL and CSI bytes */ |
5020 p = mb_unescape(&str); | 4957 p = mb_unescape(&str); |
5024 if (fputc(*p++, fd) < 0) | 4961 if (fputc(*p++, fd) < 0) |
5025 return FAIL; | 4962 return FAIL; |
5026 --str; | 4963 --str; |
5027 continue; | 4964 continue; |
5028 } | 4965 } |
5029 #endif | |
5030 | 4966 |
5031 c = *str; | 4967 c = *str; |
5032 /* | 4968 /* |
5033 * Special key codes have to be translated to be able to make sense | 4969 * Special key codes have to be translated to be able to make sense |
5034 * when they are read back. | 4970 * when they are read back. |