Source

planck / lib / sstring.ml

open Spotlib.Spot

include Pstream.Make(struct
  module Pos = Position.None
  module Attr = struct
    type t = Pos.t
    let position x = x
  end
  module Elem = struct
    type t = string
    let show = Printf.sprintf "%S"
    let format ppf = Format.fprintf ppf "%S"
    include Mtypes.Make_comparable(struct
      type t = string
      let compare (x : string) y = compare x y
    end)
  end
end)

let attr_default = ()

let the_null_desc = null_desc attr_default
let the_null = null attr_default

let from_string str = Lazy.lazy_from_val (cons_desc str attr_default the_null)

let from_chan ic =
  let len = 1024 in
  let rec read () = lazy begin
    let buf = String.create len in
    let read_bytes = input ic buf 0 len in
    if read_bytes = 0 then null_desc attr_default
    else
      let str = String.sub buf 0 read_bytes in
      cons_desc str attr_default (read ())
  end
  in
  read ()
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.