annotate lib/ur/string.ur @ 912:771449d8b411

Fix inconsistency in bool URLification between C and JavaScript
author Adam Chlipala <adamc@hcoop.net>
date Tue, 25 Aug 2009 15:19:00 -0400
parents 5e1a4b12c83a
children e46227efcbba
rev   line source
adamc@821 1 type t = Basis.string
adamc@821 2
adamc@828 3 val length = Basis.strlen
adamc@828 4 val append = Basis.strcat
adamc@828 5
adamc@821 6 val sub = Basis.strsub
adamc@821 7 val suffix = Basis.strsuffix
adamc@829 8
adamc@829 9 val index = Basis.strindex
adamc@829 10 val atFirst = Basis.strchr
adamc@829 11
adamc@831 12 fun mindex {Haystack = s, Needle = chs} = Basis.strcspn s chs
adamc@831 13
adamc@829 14 fun substring s {Start = start, Len = len} = Basis.substring s start len
adamc@829 15
adamc@829 16 fun split s ch =
adamc@829 17 case index s ch of
adamc@829 18 None => None
adamc@829 19 | Some i => Some (substring s {Start = 0, Len = i},
adamc@829 20 substring s {Start = i + 1, Len = length s - i - 1})
adamc@831 21 fun msplit {Haystack = s, Needle = chs} =
adamc@831 22 case mindex {Haystack = s, Needle = chs} of
adamc@831 23 None => None
adamc@831 24 | Some i => Some (substring s {Start = 0, Len = i},
adamc@831 25 sub s i,
adamc@831 26 substring s {Start = i + 1, Len = length s - i - 1})