Mercurial > vim
comparison src/mbyte.c @ 12716:351cf7c67bbe v8.0.1236
patch 8.0.1236: Mac features are confusing
commit https://github.com/vim/vim/commit/d057301b1f28736f094affa17b190244ad56e8d9
Author: Bram Moolenaar <Bram@vim.org>
Date: Sat Oct 28 21:11:06 2017 +0200
patch 8.0.1236: Mac features are confusing
Problem: Mac features are confusing.
Solution: Make feature names more consistent, add "osxdarwin". Rename
feature flags, cleanup Mac code. (Kazunobu Kuriyama, closes #2178)
author | Christian Brabandt <cb@256bit.org> |
---|---|
date | Sat, 28 Oct 2017 21:15:35 +0200 |
parents | f58755eb453e |
children | 327e1264b9bf |
comparison
equal
deleted
inserted
replaced
12715:279ec0abb4ac | 12716:351cf7c67bbe |
---|---|
103 | 103 |
104 #ifdef FEAT_GUI_X11 | 104 #ifdef FEAT_GUI_X11 |
105 # include <X11/Intrinsic.h> | 105 # include <X11/Intrinsic.h> |
106 #endif | 106 #endif |
107 #ifdef X_LOCALE | 107 #ifdef X_LOCALE |
108 #include <X11/Xlocale.h> | 108 # include <X11/Xlocale.h> |
109 # if !defined(HAVE_MBLEN) && !defined(mblen) | |
110 # define mblen _Xmblen | |
111 # endif | |
109 #endif | 112 #endif |
110 | 113 |
111 #if defined(FEAT_GUI_GTK) && defined(FEAT_XIM) | 114 #if defined(FEAT_GUI_GTK) && defined(FEAT_XIM) |
112 # if GTK_CHECK_VERSION(3,0,0) | 115 # if GTK_CHECK_VERSION(3,0,0) |
113 # include <gdk/gdkkeysyms-compat.h> | 116 # include <gdk/gdkkeysyms-compat.h> |
413 {"euckr", IDX_EUC_KR}, | 416 {"euckr", IDX_EUC_KR}, |
414 {"5601", IDX_EUC_KR}, /* Sun: KS C 5601 */ | 417 {"5601", IDX_EUC_KR}, /* Sun: KS C 5601 */ |
415 {"euccn", IDX_EUC_CN}, | 418 {"euccn", IDX_EUC_CN}, |
416 {"gb2312", IDX_EUC_CN}, | 419 {"gb2312", IDX_EUC_CN}, |
417 {"euctw", IDX_EUC_TW}, | 420 {"euctw", IDX_EUC_TW}, |
418 #if defined(WIN3264) || defined(WIN32UNIX) || defined(MACOS) | 421 #if defined(WIN3264) || defined(WIN32UNIX) || defined(MACOS_X) |
419 {"japan", IDX_CP932}, | 422 {"japan", IDX_CP932}, |
420 {"korea", IDX_CP949}, | 423 {"korea", IDX_CP949}, |
421 {"prc", IDX_CP936}, | 424 {"prc", IDX_CP936}, |
422 {"chinese", IDX_CP936}, | 425 {"chinese", IDX_CP936}, |
423 {"taiwan", IDX_CP950}, | 426 {"taiwan", IDX_CP950}, |
514 int i; | 517 int i; |
515 int idx; | 518 int idx; |
516 int n; | 519 int n; |
517 int enc_dbcs_new = 0; | 520 int enc_dbcs_new = 0; |
518 #if defined(USE_ICONV) && !defined(WIN3264) && !defined(WIN32UNIX) \ | 521 #if defined(USE_ICONV) && !defined(WIN3264) && !defined(WIN32UNIX) \ |
519 && !defined(MACOS) | 522 && !defined(MACOS_CONVERT) |
520 # define LEN_FROM_CONV | 523 # define LEN_FROM_CONV |
521 vimconv_T vimconv; | 524 vimconv_T vimconv; |
522 char_u *p; | 525 char_u *p; |
523 #endif | 526 #endif |
524 | 527 |
709 /* enc_dbcs is set by setting 'fileencoding'. It becomes a Windows | 712 /* enc_dbcs is set by setting 'fileencoding'. It becomes a Windows |
710 * CodePage identifier, which we can pass directly in to Windows | 713 * CodePage identifier, which we can pass directly in to Windows |
711 * API */ | 714 * API */ |
712 n = IsDBCSLeadByteEx(enc_dbcs, (WINBYTE)i) ? 2 : 1; | 715 n = IsDBCSLeadByteEx(enc_dbcs, (WINBYTE)i) ? 2 : 1; |
713 #else | 716 #else |
714 # if defined(MACOS) || defined(__amigaos4__) || defined(__ANDROID__) | 717 # if defined(__amigaos4__) || defined(__ANDROID__) || \ |
718 !(defined(HAVE_MBLEN) || defined(X_LOCALE)) | |
715 /* | 719 /* |
716 * if mblen() is not available, character which MSB is turned on | 720 * if mblen() is not available, character which MSB is turned on |
717 * are treated as leading byte character. (note : This assumption | 721 * are treated as leading byte character. (note : This assumption |
718 * is not always true.) | 722 * is not always true.) |
719 */ | 723 */ |
720 n = (i & 0x80) ? 2 : 1; | 724 n = (i & 0x80) ? 2 : 1; |
721 # else | 725 # else |
722 char buf[MB_MAXBYTES + 1]; | 726 char buf[MB_MAXBYTES + 1]; |
723 # ifdef X_LOCALE | 727 |
724 # ifndef mblen | |
725 # define mblen _Xmblen | |
726 # endif | |
727 # endif | |
728 if (i == NUL) /* just in case mblen() can't handle "" */ | 728 if (i == NUL) /* just in case mblen() can't handle "" */ |
729 n = 1; | 729 n = 1; |
730 else | 730 else |
731 { | 731 { |
732 buf[0] = i; | 732 buf[0] = i; |
733 buf[1] = 0; | 733 buf[1] = 0; |
734 #ifdef LEN_FROM_CONV | 734 # ifdef LEN_FROM_CONV |
735 if (vimconv.vc_type != CONV_NONE) | 735 if (vimconv.vc_type != CONV_NONE) |
736 { | 736 { |
737 /* | 737 /* |
738 * string_convert() should fail when converting the first | 738 * string_convert() should fail when converting the first |
739 * byte of a double-byte character. | 739 * byte of a double-byte character. |
746 } | 746 } |
747 else | 747 else |
748 n = 2; | 748 n = 2; |
749 } | 749 } |
750 else | 750 else |
751 #endif | 751 # endif |
752 { | 752 { |
753 /* | 753 /* |
754 * mblen() should return -1 for invalid (means the leading | 754 * mblen() should return -1 for invalid (means the leading |
755 * multibyte) character. However there are some platforms | 755 * multibyte) character. However there are some platforms |
756 * where mblen() returns 0 for invalid character. | 756 * where mblen() returns 0 for invalid character. |
916 /* JIS code classification */ | 916 /* JIS code classification */ |
917 unsigned char lb = lead; | 917 unsigned char lb = lead; |
918 unsigned char tb = trail; | 918 unsigned char tb = trail; |
919 | 919 |
920 /* convert process code to JIS */ | 920 /* convert process code to JIS */ |
921 # if defined(WIN3264) || defined(WIN32UNIX) || defined(MACOS) | 921 # if defined(WIN3264) || defined(WIN32UNIX) || defined(MACOS_X) |
922 /* process code is SJIS */ | 922 /* process code is SJIS */ |
923 if (lb <= 0x9f) | 923 if (lb <= 0x9f) |
924 lb = (lb - 0x81) * 2 + 0x21; | 924 lb = (lb - 0x81) * 2 + 0x21; |
925 else | 925 else |
926 lb = (lb - 0xc1) * 2 + 0x21; | 926 lb = (lb - 0xc1) * 2 + 0x21; |
6534 vcp->vc_factor = 2; /* up to twice as long */ | 6534 vcp->vc_factor = 2; /* up to twice as long */ |
6535 vcp->vc_cpfrom = from_is_utf8 ? 0 : encname2codepage(from); | 6535 vcp->vc_cpfrom = from_is_utf8 ? 0 : encname2codepage(from); |
6536 vcp->vc_cpto = to_is_utf8 ? 0 : encname2codepage(to); | 6536 vcp->vc_cpto = to_is_utf8 ? 0 : encname2codepage(to); |
6537 } | 6537 } |
6538 #endif | 6538 #endif |
6539 #ifdef MACOS_X | 6539 #ifdef MACOS_CONVERT |
6540 else if ((from_prop & ENC_MACROMAN) && (to_prop & ENC_LATIN1)) | 6540 else if ((from_prop & ENC_MACROMAN) && (to_prop & ENC_LATIN1)) |
6541 { | 6541 { |
6542 vcp->vc_type = CONV_MAC_LATIN1; | 6542 vcp->vc_type = CONV_MAC_LATIN1; |
6543 } | 6543 } |
6544 else if ((from_prop & ENC_MACROMAN) && to_is_utf8) | 6544 else if ((from_prop & ENC_MACROMAN) && to_is_utf8) |