From dbd94f89b2dbadbb5557748c8b2cc94efafaf8c1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Francesco=20Munafo=CC=80?= Date: Sat, 1 Jun 2019 13:25:28 +0200 Subject: [PATCH] Incapsulated definitions of mb_ord and mb_chr into a if(!function_exists('...')) {...} to avoid error when they are already defined (termux latest) --- lib/diff_match_patch.php | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/lib/diff_match_patch.php b/lib/diff_match_patch.php index cdeb11f..ab4ab6d 100644 --- a/lib/diff_match_patch.php +++ b/lib/diff_match_patch.php @@ -2071,14 +2071,18 @@ define('Match_MaxBits', PHP_INT_SIZE * 8); function charCodeAt($str, $pos) { return mb_ord(mb_substr($str, $pos, 1)); } -function mb_ord($v) { - $k = mb_convert_encoding($v, 'UCS-2LE', 'UTF-8'); - $k1 = ord(substr($k, 0, 1)); - $k2 = ord(substr($k, 1, 1)); - return $k2 * 256 + $k1; +if(!function_exists('mb_ord')) { + function mb_ord($v) { + $k = mb_convert_encoding($v, 'UCS-2LE', 'UTF-8'); + $k1 = ord(substr($k, 0, 1)); + $k2 = ord(substr($k, 1, 1)); + return $k2 * 256 + $k1; + } } -function mb_chr($num){ - return mb_convert_encoding('&#'.intval($num).';', 'UTF-8', 'HTML-ENTITIES'); +if(!function_exists('mb_chr')) { + function mb_chr($num){ + return mb_convert_encoding('&#'.intval($num).';', 'UTF-8', 'HTML-ENTITIES'); + } } /**