@@ -1660,6 +1660,40 @@ diff_equal_entry(diff_T *dp, int idx1, int idx2)
16601660 return TRUE;
16611661}
16621662
1663+ /*
1664+ * Compare the characters at "p1" and "p2". If they are equal (possibly
1665+ * ignoring case) return TRUE and set "len" to the number of bytes.
1666+ */
1667+ static int
1668+ diff_equal_char (char_u * p1 , char_u * p2 , int * len )
1669+ {
1670+ #ifdef FEAT_MBYTE
1671+ int l = (* mb_ptr2len )(p1 );
1672+
1673+ if (l != (* mb_ptr2len )(p2 ))
1674+ return FALSE;
1675+ if (l > 1 )
1676+ {
1677+ if (STRNCMP (p1 , p2 , l ) != 0
1678+ && (!enc_utf8
1679+ || !(diff_flags & DIFF_ICASE )
1680+ || utf_fold (utf_ptr2char (p1 ))
1681+ != utf_fold (utf_ptr2char (p2 ))))
1682+ return FALSE;
1683+ * len = l ;
1684+ }
1685+ else
1686+ #endif
1687+ {
1688+ if ((* p1 != * p2 )
1689+ && (!(diff_flags & DIFF_ICASE )
1690+ || TOLOWER_LOC (* p1 ) != TOLOWER_LOC (* p2 )))
1691+ return FALSE;
1692+ * len = 1 ;
1693+ }
1694+ return TRUE;
1695+ }
1696+
16631697/*
16641698 * Compare strings "s1" and "s2" according to 'diffopt'.
16651699 * Return non-zero when they are different.
@@ -1689,30 +1723,10 @@ diff_cmp(char_u *s1, char_u *s2)
16891723 }
16901724 else
16911725 {
1692- #ifdef FEAT_MBYTE
1693- l = (* mb_ptr2len )(p1 );
1694- if (l != (* mb_ptr2len )(p2 ))
1726+ if (!diff_equal_char (p1 , p2 , & l ))
16951727 break ;
1696- if (l > 1 )
1697- {
1698- if (STRNCMP (p1 , p2 , l ) != 0
1699- && (!enc_utf8
1700- || !(diff_flags & DIFF_ICASE )
1701- || utf_fold (utf_ptr2char (p1 ))
1702- != utf_fold (utf_ptr2char (p2 ))))
1703- break ;
1704- p1 += l ;
1705- p2 += l ;
1706- }
1707- else
1708- #endif
1709- {
1710- if (* p1 != * p2 && (!(diff_flags & DIFF_ICASE )
1711- || TOLOWER_LOC (* p1 ) != TOLOWER_LOC (* p2 )))
1712- break ;
1713- ++ p1 ;
1714- ++ p2 ;
1715- }
1728+ p1 += l ;
1729+ p2 += l ;
17161730 }
17171731 }
17181732
@@ -1949,40 +1963,6 @@ diffopt_horizontal(void)
19491963 return (diff_flags & DIFF_HORIZONTAL ) != 0 ;
19501964}
19511965
1952- /*
1953- * Compare the characters at "p1" and "p2". If they are equal (possibly
1954- * ignoring case) return TRUE and set "len" to the number of bytes.
1955- */
1956- static int
1957- diff_equal_char (char_u * p1 , char_u * p2 , int * len )
1958- {
1959- #ifdef FEAT_MBYTE
1960- int l = (* mb_ptr2len )(p1 );
1961-
1962- if (l != (* mb_ptr2len )(p2 ))
1963- return FALSE;
1964- if (l > 1 )
1965- {
1966- if (STRNCMP (p1 , p2 , l ) != 0
1967- && (!enc_utf8
1968- || !(diff_flags & DIFF_ICASE )
1969- || utf_fold (utf_ptr2char (p1 ))
1970- != utf_fold (utf_ptr2char (p2 ))))
1971- return FALSE;
1972- * len = l ;
1973- }
1974- else
1975- #endif
1976- {
1977- if ((* p1 != * p2 )
1978- && (!(diff_flags & DIFF_ICASE )
1979- || TOLOWER_LOC (* p1 ) != TOLOWER_LOC (* p2 )))
1980- return FALSE;
1981- * len = 1 ;
1982- }
1983- return TRUE;
1984- }
1985-
19861966/*
19871967 * Find the difference within a changed line.
19881968 * Returns TRUE if the line was added, no other buffer has it.
0 commit comments