aboutsummaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authorXavier Leroy <xavierleroy@users.noreply.github.com>2016-03-21 10:18:51 +0100
committerXavier Leroy <xavierleroy@users.noreply.github.com>2016-03-21 10:18:51 +0100
commit20eef936dce1ef98b5b422c90cc9e072fb0d75ab (patch)
tree2690be164dc36fad63fc0f42e943d0fcb0735532 /lib
parentfdf4cac2439a7168bd005efbde4a1f76a00ada66 (diff)
parent01e32a075023ce7b037d42d048b1904ba3d9a82b (diff)
downloadcompcert-20eef936dce1ef98b5b422c90cc9e072fb0d75ab.tar.gz
compcert-20eef936dce1ef98b5b422c90cc9e072fb0d75ab.zip
Merge pull request #92 from AbsInt/cleanup
This PR activates more OCaml warnings and turns all warnings into errors. Also some unused functions, variables and types are removed.
Diffstat (limited to 'lib')
-rw-r--r--lib/Camlcoq.ml6
-rw-r--r--lib/Json.ml12
-rw-r--r--lib/Printlines.ml6
-rw-r--r--lib/Printlines.mli2
4 files changed, 18 insertions, 8 deletions
diff --git a/lib/Camlcoq.ml b/lib/Camlcoq.ml
index c5fb2e55..90c3ab3f 100644
--- a/lib/Camlcoq.ml
+++ b/lib/Camlcoq.ml
@@ -307,11 +307,11 @@ let first_unused_ident () = !next_atom
(* Strings *)
let camlstring_of_coqstring (s: char list) =
- let r = String.create (List.length s) in
+ let r = Bytes.create (List.length s) in
let rec fill pos = function
| [] -> r
- | c :: s -> r.[pos] <- c; fill (pos + 1) s
- in fill 0 s
+ | c :: s -> Bytes.set r pos c; fill (pos + 1) s
+ in Bytes.to_string (fill 0 s)
let coqstring_of_camlstring s =
let rec cstring accu pos =
diff --git a/lib/Json.ml b/lib/Json.ml
index 4aa91e95..22b50a9e 100644
--- a/lib/Json.ml
+++ b/lib/Json.ml
@@ -15,7 +15,8 @@ open Printf
(* Simple functions for JSON printing *)
(* Print a string as json string *)
-let p_jstring oc s = fprintf oc "\"%s\"" s
+let p_jstring oc s =
+ fprintf oc "\"%s\"" s
(* Print a list as json array *)
let p_jarray elem oc l =
@@ -29,13 +30,20 @@ let p_jarray elem oc l =
(* Print a bool as json bool *)
let p_jbool oc = fprintf oc "%B"
-(* Print a int as json int *)
+(* Print an int as json int *)
let p_jint oc = fprintf oc "%d"
+(* Print an int32 as json int *)
+let p_jint32 oc = fprintf oc "%ld"
+
(* Print a member *)
let p_jmember oc name p_mem mem =
fprintf oc "\n%a:%a" p_jstring name p_mem mem
+(* Print singleton object *)
+let p_jsingle_object oc name p_mem mem =
+ fprintf oc "{%a:%a}" p_jstring name p_mem mem
+
(* Print optional value *)
let p_jopt p_elem oc = function
| None -> output_string oc "null"
diff --git a/lib/Printlines.ml b/lib/Printlines.ml
index e0805f15..453096bc 100644
--- a/lib/Printlines.ml
+++ b/lib/Printlines.ml
@@ -48,7 +48,7 @@ let forward b dest =
(* Position [b] to the beginning of line [dest], which must be less than
the current line. *)
-let backward_buf = lazy (String.create 65536)
+let backward_buf = lazy (Bytes.create 65536)
(* 65536 to match [IO_BUFFER_SIZE] in the OCaml runtime.
lazy to allocate on demand. *)
@@ -65,13 +65,13 @@ let backward b dest =
seek_in b.chan 0;
b.lineno <- 1
end else begin
- let pos' = max 0 (pos - String.length buf) in
+ let pos' = max 0 (pos - Bytes.length buf) in
let len = pos - pos' in
seek_in b.chan pos';
really_input b.chan buf 0 len;
backward pos' (pos - pos')
end
- end else if buf.[idx-1] = '\n' then begin
+ end else if Bytes.get buf (idx-1) = '\n' then begin
(* Reached beginning of current line *)
if b.lineno = dest then begin
(* Found line number dest *)
diff --git a/lib/Printlines.mli b/lib/Printlines.mli
index 79201f86..545eb033 100644
--- a/lib/Printlines.mli
+++ b/lib/Printlines.mli
@@ -20,8 +20,10 @@ type filebuf
val openfile: string -> filebuf
(** Open the file with the given name. *)
+
val close: filebuf -> unit
(** Close the file underlying the given buffer. *)
+
val copy: out_channel -> string -> filebuf -> int -> int -> unit
(** [copy oc pref buf first last] copies lines number [first]
to [last], included, to the channel [oc]. Each line is