Changeset 1687
- Timestamp:
- 2008-03-10 03:33:25 (2 years ago)
- Files:
-
- 1 modified
-
FCKeditor/trunk/editor/dialog/fck_replace.html (modified) (5 diffs)
Legend:
- Unmodified
- Added
- Removed
-
FCKeditor/trunk/editor/dialog/fck_replace.html
r1565 r1687 232 232 // Knuth-Morris-Pratt Algorithm for stream input 233 233 KMP_NOMATCH = 0 ; 234 KMP_STARTED = 1 ; 235 KMP_ADVANCED = 2 ; 236 KMP_MATCHED = 3 ; 234 KMP_ADVANCED = 1 ; 235 KMP_MATCHED = 2 ; 237 236 function KmpMatch( pattern, ignoreCase ) 238 237 { … … 269 268 return KMP_MATCHED; 270 269 } 271 return this._State > 1 ? KMP_ADVANCED : KMP_STARTED ;270 return KMP_ADVANCED ; 272 271 } 273 272 else if ( this._State == 0 ) … … 292 291 var matchState = KMP_NOMATCH ; 293 292 var matchBookmark = null ; 293 var matchBookmarkStart = [] ; 294 294 295 295 // Match finding. … … 306 306 { 307 307 matcher.Reset(); 308 matchBookmark = null;308 matchBookmarkStart = [] ; 309 309 } 310 310 } … … 316 316 // So delete any positional information. 317 317 if ( matchState == KMP_NOMATCH ) 318 matchBookmark = null ; 319 // The currently scanned character is a possible start, so mark down the starting position. 320 else if ( matchState == KMP_STARTED ) 321 matchBookmark = { Start : cursor.concat( [] ) } ; 318 matchBookmarkStart = [] ; 319 // We've matched something, but it's not a complete match, so let's just mark down the position for backtracking later. 320 else if ( matchState == KMP_ADVANCED ) 321 { 322 matchBookmarkStart.push( cursor.concat( [] ) ) ; 323 if ( matchBookmarkStart.length > matcher._State ) 324 matchBookmarkStart.shift() ; 325 } 322 326 // Found a complete match! Mark down the ending position as well. 323 327 else if ( matchState == KMP_MATCHED ) 324 328 { 325 // It is possible to get a KMP_MATCHED without KMP_ STARTED when the match pattern is only 1 character.329 // It is possible to get a KMP_MATCHED without KMP_ADVANCED when the match pattern is only 1 character. 326 330 // So need to check and mark down the starting position as well. 327 if ( matchBookmark == null)328 matchBookmark = { Start : cursor.concat( [] ) };329 330 matchBookmark .End = cursor.concat( [] );331 if ( matchBookmarkStart.length == 0 ) 332 matchBookmarkStart = [cursor.concat( [] )] ; 333 334 matchBookmark = { 'Start' : matchBookmarkStart.shift(), 'End' : cursor.concat( [] ) } ; 331 335 matchBookmark.End[ matchBookmark.End.length - 1 ]++; 332 336