Mercurial > vim
comparison src/fileio.c @ 474:a5fcf36ef512 v7.0127
updated for version 7.0127
author | vimboss |
---|---|
date | Wed, 10 Aug 2005 21:07:57 +0000 |
parents | f98374445f66 |
children | 4772a5e3f9fa |
comparison
equal
deleted
inserted
replaced
473:4a7320e53f32 | 474:a5fcf36ef512 |
---|---|
1400 * characters and check for trailing bytes. */ | 1400 * characters and check for trailing bytes. */ |
1401 needed = 0; | 1401 needed = 0; |
1402 p = ptr; | 1402 p = ptr; |
1403 for (flen = from_size; flen > 0; flen -= l) | 1403 for (flen = from_size; flen > 0; flen -= l) |
1404 { | 1404 { |
1405 l = utf_ptr2len_check_len(p, flen); | 1405 l = utf_ptr2len_len(p, flen); |
1406 if (l > flen) /* incomplete char */ | 1406 if (l > flen) /* incomplete char */ |
1407 { | 1407 { |
1408 if (l > CONV_RESTLEN) | 1408 if (l > CONV_RESTLEN) |
1409 /* weird overlong byte sequence */ | 1409 /* weird overlong byte sequence */ |
1410 goto rewind_retry; | 1410 goto rewind_retry; |
1465 /* Convert from utf-8 to ucs-2. */ | 1465 /* Convert from utf-8 to ucs-2. */ |
1466 needed = 0; | 1466 needed = 0; |
1467 p = ptr; | 1467 p = ptr; |
1468 for (flen = from_size; flen > 0; flen -= l) | 1468 for (flen = from_size; flen > 0; flen -= l) |
1469 { | 1469 { |
1470 l = utf_ptr2len_check_len(p, flen); | 1470 l = utf_ptr2len_len(p, flen); |
1471 u8c = utf_ptr2char(p); | 1471 u8c = utf_ptr2char(p); |
1472 ucsp[needed * 2] = (u8c & 0xff); | 1472 ucsp[needed * 2] = (u8c & 0xff); |
1473 ucsp[needed * 2 + 1] = (u8c >> 8); | 1473 ucsp[needed * 2 + 1] = (u8c >> 8); |
1474 ++needed; | 1474 ++needed; |
1475 p += l; | 1475 p += l; |
1724 * read in the previous read() call. */ | 1724 * read in the previous read() call. */ |
1725 for (p = ptr - utf_head_off(buffer, ptr); p < ptr + size; ++p) | 1725 for (p = ptr - utf_head_off(buffer, ptr); p < ptr + size; ++p) |
1726 { | 1726 { |
1727 if (*p >= 0x80) | 1727 if (*p >= 0x80) |
1728 { | 1728 { |
1729 len = utf_ptr2len_check(p); | 1729 len = utf_ptr2len(p); |
1730 /* A length of 1 means it's an illegal byte. Accept | 1730 /* A length of 1 means it's an illegal byte. Accept |
1731 * an incomplete character at the end though, the next | 1731 * an incomplete character at the end though, the next |
1732 * read() will get the next bytes, we'll check it | 1732 * read() will get the next bytes, we'll check it |
1733 * then. */ | 1733 * then. */ |
1734 if (len == 1) | 1734 if (len == 1) |
4612 * short! */ | 4612 * short! */ |
4613 l = CONV_RESTLEN - ip->bw_restlen; | 4613 l = CONV_RESTLEN - ip->bw_restlen; |
4614 if (l > len) | 4614 if (l > len) |
4615 l = len; | 4615 l = len; |
4616 mch_memmove(ip->bw_rest + ip->bw_restlen, buf, (size_t)l); | 4616 mch_memmove(ip->bw_rest + ip->bw_restlen, buf, (size_t)l); |
4617 n = utf_ptr2len_check_len(ip->bw_rest, ip->bw_restlen + l); | 4617 n = utf_ptr2len_len(ip->bw_rest, ip->bw_restlen + l); |
4618 if (n > ip->bw_restlen + len) | 4618 if (n > ip->bw_restlen + len) |
4619 { | 4619 { |
4620 /* We have an incomplete byte sequence at the end to | 4620 /* We have an incomplete byte sequence at the end to |
4621 * be written. We can't convert it without the | 4621 * be written. We can't convert it without the |
4622 * remaining bytes. Keep them for the next call. */ | 4622 * remaining bytes. Keep them for the next call. */ |
4642 n = 0; | 4642 n = 0; |
4643 } | 4643 } |
4644 } | 4644 } |
4645 else | 4645 else |
4646 { | 4646 { |
4647 n = utf_ptr2len_check_len(buf + wlen, len - wlen); | 4647 n = utf_ptr2len_len(buf + wlen, len - wlen); |
4648 if (n > len - wlen) | 4648 if (n > len - wlen) |
4649 { | 4649 { |
4650 /* We have an incomplete byte sequence at the end to | 4650 /* We have an incomplete byte sequence at the end to |
4651 * be written. We can't convert it without the | 4651 * be written. We can't convert it without the |
4652 * remaining bytes. Keep them for the next call. */ | 4652 * remaining bytes. Keep them for the next call. */ |
4709 { | 4709 { |
4710 /* Convert from UTF-8 to UCS-2, to the start of the buffer. | 4710 /* Convert from UTF-8 to UCS-2, to the start of the buffer. |
4711 * The buffer has been allocated to be big enough. */ | 4711 * The buffer has been allocated to be big enough. */ |
4712 while (fromlen > 0) | 4712 while (fromlen > 0) |
4713 { | 4713 { |
4714 n = utf_ptr2len_check_len(from, fromlen); | 4714 n = utf_ptr2len_len(from, fromlen); |
4715 if (n > (int)fromlen) /* incomplete byte sequence */ | 4715 if (n > (int)fromlen) /* incomplete byte sequence */ |
4716 break; | 4716 break; |
4717 u8c = utf_ptr2char(from); | 4717 u8c = utf_ptr2char(from); |
4718 *to++ = (u8c & 0xff); | 4718 *to++ = (u8c & 0xff); |
4719 *to++ = (u8c >> 8); | 4719 *to++ = (u8c >> 8); |
6597 char_u *p; | 6597 char_u *p; |
6598 | 6598 |
6599 for (p = fname; *p != NUL; ++p) | 6599 for (p = fname; *p != NUL; ++p) |
6600 # ifdef FEAT_MBYTE | 6600 # ifdef FEAT_MBYTE |
6601 /* The Big5 encoding can have '\' in the trail byte. */ | 6601 /* The Big5 encoding can have '\' in the trail byte. */ |
6602 if (enc_dbcs != 0 && (*mb_ptr2len_check)(p) > 1) | 6602 if (enc_dbcs != 0 && (*mb_ptr2len)(p) > 1) |
6603 ++p; | 6603 ++p; |
6604 else | 6604 else |
6605 # endif | 6605 # endif |
6606 if (*p == '\\') | 6606 if (*p == '\\') |
6607 *p = '/'; | 6607 *p = '/'; |
8906 break; | 8906 break; |
8907 #endif | 8907 #endif |
8908 default: | 8908 default: |
8909 size++; | 8909 size++; |
8910 # ifdef FEAT_MBYTE | 8910 # ifdef FEAT_MBYTE |
8911 if (enc_dbcs != 0 && (*mb_ptr2len_check)(p) > 1) | 8911 if (enc_dbcs != 0 && (*mb_ptr2len)(p) > 1) |
8912 { | 8912 { |
8913 ++p; | 8913 ++p; |
8914 ++size; | 8914 ++size; |
8915 } | 8915 } |
8916 # endif | 8916 # endif |
9043 else | 9043 else |
9044 reg_pat[i++] = ','; | 9044 reg_pat[i++] = ','; |
9045 break; | 9045 break; |
9046 default: | 9046 default: |
9047 # ifdef FEAT_MBYTE | 9047 # ifdef FEAT_MBYTE |
9048 if (enc_dbcs != 0 && (*mb_ptr2len_check)(p) > 1) | 9048 if (enc_dbcs != 0 && (*mb_ptr2len)(p) > 1) |
9049 reg_pat[i++] = *p++; | 9049 reg_pat[i++] = *p++; |
9050 else | 9050 else |
9051 # endif | 9051 # endif |
9052 if (allow_dirs != NULL && vim_ispathsep(*p)) | 9052 if (allow_dirs != NULL && vim_ispathsep(*p)) |
9053 *allow_dirs = TRUE; | 9053 *allow_dirs = TRUE; |