on master help sign in
Fix another bug

--HG-- extra : convert_revision : 79a7f28fda89159e58e339b26b1b645a60ceaa5e

commita97092b6cd6a127656f4b64f7bf883cf38944e1d authorBryan O'Sullivan <bos@serpentine.com> dateTue 3 Feb 2009, 08:02 (18 years ago) parentb4329af
1 file changed+11−9
Data/Text.hs+11−9
Data/Text.hs+11−9
@@ -658,15 +658,17 @@ words :: Text -> [Text]
658658words (Text arr off len) = loop0 off off
659659 where
660660 loop0 start n
661− | isSpace (unsafeChr c) = if start == n
662− then loop0 (start+1) (start+1)
663− else (Text arr start (n-start)):loop0 (n+1) (n+1)
664− | n < (off+len) = loop0 start (n+1)
665− | otherwise = if start == n
666− then []
667− else [(Text arr start (n-start))]
668− where
669− c = arr `A.unsafeIndex` n
661+ | n >= len = if start == n
662+ then []
663+ else [Text arr (start+off) (n-start)]
664+ | isSpace (unsafeChr c) =
665+ if start == n
666+ then loop0 (start+1) (start+1)
667+ else Text arr (start+off) (n-start) : loop0 (n+1) (n+1)
668+ | otherwise = if c < 0xD800 || c > 0xDBFF
669+ then loop0 start (n+1)
670+ else loop0 start (n+2)
671+ where c = arr `A.unsafeIndex` n
670672{-# INLINE words #-}
671673
672674-- | /O(n)/ Breaks a 'Text' up into a list of 'Text's at