Skip to content

Commit

Permalink
missing fixes for 4.06
Browse files Browse the repository at this point in the history
how did opam this compile before?
  • Loading branch information
vogler committed Nov 29, 2017
1 parent b4db151 commit a1d4c69
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 17 deletions.
6 changes: 3 additions & 3 deletions src/cil.ml
Original file line number Diff line number Diff line change
Expand Up @@ -5080,7 +5080,7 @@ let loadBinaryFile (filename : string) : file =
(* Take the name of a file and make a valid symbol name out of it. There are
* a few characters that are not valid in symbols *)
let makeValidSymbolName (s: string) =
let s = String.copy s in (* So that we can update in place *)
let b = Bytes.copy (Bytes.of_string s) in (* So that we can update in place *)
let l = String.length s in
for i = 0 to l - 1 do
let c = String.get s i in
Expand All @@ -5090,9 +5090,9 @@ let makeValidSymbolName (s: string) =
| _ -> false
in
if isinvalid then
String.set s i '_';
Bytes.set b i '_';
done;
s
Bytes.to_string b

let rec addOffset (toadd: offset) (off: offset) : offset =
match off with
Expand Down
11 changes: 6 additions & 5 deletions src/ocamlutil/errormsg.ml
Original file line number Diff line number Diff line change
Expand Up @@ -211,16 +211,17 @@ let cleanFileName str =
if str <> "" && String.get str 0 = '"' (* '"' ( *)
then rem_quotes str else str in
let l = String.length str1 in
let str1 = Bytes.of_string str1 in
let rec loop (copyto: int) (i: int) =
if i >= l then
String.sub str1 0 copyto
Bytes.to_string (Bytes.sub str1 0 copyto)
else
let c = String.get str1 i in
let c = Bytes.get str1 i in
if c <> '\\' then begin
String.set str1 copyto c; loop (copyto + 1) (i + 1)
Bytes.set str1 copyto c; loop (copyto + 1) (i + 1)
end else begin
String.set str1 copyto '/';
if i < l - 2 && String.get str1 (i + 1) = '\\' then
Bytes.set str1 copyto '/';
if i < l - 2 && Bytes.get str1 (i + 1) = '\\' then
loop (copyto + 1) (i + 2)
else
loop (copyto + 1) (i + 1)
Expand Down
18 changes: 9 additions & 9 deletions src/ocamlutil/pretty.ml
Original file line number Diff line number Diff line change
Expand Up @@ -725,31 +725,31 @@ let gprintf (finish : doc -> 'b)
invalid_arg ("dprintf: unimplemented format "
^ (String.sub format i (j-i+1)));
let j' = succ j in (* eat the d,i,x etc. *)
let format_spec = "% " in
String.set format_spec 1 (fget j'); (* format_spec = "%x", etc. *)
let format_spec = Bytes.of_string "% " in
Bytes.set format_spec 1 (fget j'); (* format_spec = "%x", etc. *)
Obj.magic(fun n ->
collect (dctext1 acc
(Int64.format format_spec n))
(Int64.format (Bytes.to_string format_spec) n))
(succ j'))
| 'l' ->
if j != i + 1 then invalid_arg ("dprintf: unimplemented format "
^ (String.sub format i (j-i+1)));
let j' = succ j in (* eat the d,i,x etc. *)
let format_spec = "% " in
String.set format_spec 1 (fget j'); (* format_spec = "%x", etc. *)
let format_spec = Bytes.of_string "% " in
Bytes.set format_spec 1 (fget j'); (* format_spec = "%x", etc. *)
Obj.magic(fun n ->
collect (dctext1 acc
(Int32.format format_spec n))
(Int32.format (Bytes.to_string format_spec) n))
(succ j'))
| 'n' ->
if j != i + 1 then invalid_arg ("dprintf: unimplemented format "
^ (String.sub format i (j-i+1)));
let j' = succ j in (* eat the d,i,x etc. *)
let format_spec = "% " in
String.set format_spec 1 (fget j'); (* format_spec = "%x", etc. *)
let format_spec = Bytes.of_string "% " in
Bytes.set format_spec 1 (fget j'); (* format_spec = "%x", etc. *)
Obj.magic(fun n ->
collect (dctext1 acc
(Nativeint.format format_spec n))
(Nativeint.format (Bytes.to_string format_spec) n))
(succ j'))
| 'f' | 'e' | 'E' | 'g' | 'G' ->
Obj.magic(fun f ->
Expand Down

0 comments on commit a1d4c69

Please sign in to comment.