• R/O
  • HTTP
  • SSH
  • HTTPS

Commit

Tags
No Tags

Frequently used words (click to add to your profile)

javac++androidlinuxc#windowsobjective-ccocoa誰得qtpythonphprubygameguibathyscaphec計画中(planning stage)翻訳omegatframeworktwitterdomtestvb.netdirectxゲームエンジンbtronarduinopreviewer

Commit MetaInfo

Revision8d004ca33cdf55bc7e4afb6cb8cf27e9d9bf176c (tree)
Time2009-04-12 19:49:02
Authorhenoheno <henoheno>
Commiterhenoheno

Log Message

generate_trie_regex(): Modified, comments only

Change Summary

Incremental Difference

--- a/lib/func.php
+++ b/lib/func.php
@@ -1,6 +1,6 @@
11 <?php
22 // PukiWiki - Yet another WikiWikiWeb clone.
3-// $Id: func.php,v 1.100 2009/03/29 15:08:00 henoheno Exp $
3+// $Id: func.php,v 1.101 2009/04/12 10:49:02 henoheno Exp $
44 // Copyright (C)
55 // 2002-2007,2009 PukiWiki Developers Team
66 // 2001-2002 Originally written by yu-ji
@@ -617,9 +617,16 @@ function preg_quote_extended($string, $delimiter = NULL)
617617 // Generate one compact regex for quick reTRIEval,
618618 // that just matches with all $array-values.
619619 //
620-// USAGE:
620+// USAGE (PHP >= 4.4.0, PHP >= 5.0.2):
621621 // $array = array(7 => 'fooa', 5 => 'foob');
622-// sort($array, SORT_STRING); // Keys are replaced, as we had expected
622+// $array = array_unique($array);
623+// sort($array, SORT_LOCALE_STRING); // Keys will be replaced
624+// echo generate_trie_regex($array); // 'foo(?:a|b)'
625+//
626+// USAGE (PHP >= 5.2.9):
627+// $array = array(7 => 'fooa', 5 => 'foob');
628+// $array = array_unique($array, SORT_LOCALE_STRING);
629+// $array = array_values($array);
623630 // echo generate_trie_regex($array); // 'foo(?:a|b)'
624631 //
625632 // ARGUMENTS:
@@ -636,10 +643,10 @@ function preg_quote_extended($string, $delimiter = NULL)
636643 //
637644 function generate_trie_regex(& $array, $_offset = 0, $_sentry = NULL, $_pos = 0)
638645 {
639- if (empty($array)) return '(?!)'; // Zero
646+ if (empty($array)) return '(?!)'; // Match with nothing
640647 if ($_sentry === NULL) $_sentry = count($array);
641648
642- // Too short. Skip this
649+ // Question mark: array('', 'something') => '(?:something)?'
643650 $skip = ($_pos >= mb_strlen($array[$_offset]));
644651 if ($skip) ++$_offset;
645652