Mercurial > urweb
view lib/ur/string.ur @ 1739:c414850f206f
Add support for -boot flag, which allows in-tree execution of Ur/Web
The boot flag rewrites most hardcoded paths to point to the build
directory, and also forces static compilation. This is convenient
for developing Ur/Web, or if you cannot 'sudo make install' Ur/Web.
The following changes were made:
* Header files were moved to include/urweb instead of include;
this lets FFI users point their C_INCLUDE_PATH at this directory
at write <urweb/urweb.h>. For internal Ur/Web executables,
we simply pass -I$PATH/include/urweb as normal.
* Differentiate between LIB and SRCLIB; SRCLIB is Ur and JavaScript
source files, while LIB is compiled products from libtool. For
in-tree compilation these live in different places.
* No longer reference Config for paths; instead use Settings; these
settings can be changed dynamically by Compiler.enableBoot ()
(TODO: add a disableBoot function.)
* config.h is now generated directly in include/urweb/config.h,
for consistency's sake (especially since it gets installed
along with the rest of the headers!)
* All of the autotools build products got updated.
* The linkStatic field in protocols now only contains the name of the
build product, and not the absolute path.
Future users have to be careful not to reference the Settings files
to early, lest they get an old version (this was the source of two
bugs during development of this patch.)
author | Edward Z. Yang <ezyang@mit.edu> |
---|---|
date | Wed, 02 May 2012 17:17:57 -0400 |
parents | 65fbb250b875 |
children | 2da693675de9 |
line wrap: on
line source
type t = Basis.string val str = Basis.str1 val length = Basis.strlen val lengthGe = Basis.strlenGe val append = Basis.strcat val sub = Basis.strsub val suffix = Basis.strsuffix val index = Basis.strindex fun sindex r = Basis.strsindex r.Haystack r.Needle val atFirst = Basis.strchr fun mindex {Haystack = s, Needle = chs} = let val n = Basis.strcspn s chs in if n >= length s then None else Some n end fun substring s {Start = start, Len = len} = Basis.substring s start len fun seek s ch = case index s ch of None => None | Some i => Some (suffix s (i + 1)) fun mseek {Haystack = s, Needle = chs} = case mindex {Haystack = s, Needle = chs} of None => None | Some i => Some (sub s i, suffix s (i + 1)) fun split s ch = case index s ch of None => None | Some i => Some (substring s {Start = 0, Len = i}, suffix s (i + 1)) fun split' s ch = case index s ch of None => None | Some i => Some (substring s {Start = 0, Len = i}, suffix s i) fun msplit {Haystack = s, Needle = chs} = case mindex {Haystack = s, Needle = chs} of None => None | Some i => Some (substring s {Start = 0, Len = i}, sub s i, suffix s (i + 1)) fun ssplit r = case sindex r of None => None | Some i => Some (substring r.Haystack {Start = 0, Len = i}, suffix r.Haystack (i + length r.Needle)) fun all f s = let val len = length s fun al i = i >= len || (f (sub s i) && al (i + 1)) in al 0 end fun mp f s = let fun mp' i acc = if i < 0 then acc else mp' (i - 1) (str (f (sub s i)) ^ acc) in mp' (length s - 1) "" end fun newlines [ctx] [[Body] ~ ctx] (s : string) : xml ([Body] ++ ctx) [] [] = case split s #"\n" of None => cdata s | Some (s1, s2) => <xml>{[s1]}<br/>{newlines s2}</xml> fun isPrefix {Full = f, Prefix = p} = length f >= length p && substring f {Start = 0, Len = length p} = p