Provide SRFI-6

This commit is contained in:
Neale Pickett 2009-03-03 17:46:27 -06:00
parent e3eae3bb19
commit 6dd5c6fd54
3 changed files with 12 additions and 5 deletions

View File

@ -117,9 +117,15 @@ let open_output_port name =
with Sys_error err ->
raise (Error ("unable to open '" ^ name ^ "' for output: " ^ err))
let string_input_port s =
let open_input_string s =
{ ungot = ref None; impl = Input_string (s, ref 0) }
let string_output_port () =
let open_output_string () =
{ ungot = ref None; impl = Output_string (Buffer.create 256) }
let get_output_string p =
match p.impl with
| Output_string buf ->
Buffer.contents buf
| _ ->
""

View File

@ -6,8 +6,9 @@ val input_port : in_channel -> port
val output_port : out_channel -> port
val open_input_port : string -> port
val open_output_port : string -> port
val string_input_port : string -> port
val string_output_port : unit -> port
val open_input_string : string -> port
val open_output_string : unit -> port
val get_output_string : port -> string
val is_input : port -> bool
val is_output : port -> bool

View File

@ -83,5 +83,5 @@ let read_from_port p =
;;
let read_from_string s =
read_from_port (Ocs_port.string_input_port s)
read_from_port (Ocs_port.open_input_string s)
;;