File tree Expand file tree Collapse file tree 1 file changed +11
-11
lines changed Expand file tree Collapse file tree 1 file changed +11
-11
lines changed Original file line number Diff line number Diff line change @@ -147,6 +147,16 @@ let rec format_sexp f s =
147147 Format. pp_print_string f " ;;" ;
148148 Format. pp_print_string f s
149149
150+ let escape_string s =
151+ let b = Buffer. create (String. length s + 2 ) in
152+ for i = 0 to String. length s - 1 do
153+ let c = s.[i] in
154+ if Char. (c > = ' ' && c < = '~' && c <> '"' && c <> '\\' )
155+ then Buffer. add_char b c
156+ else Printf. bprintf b " \\ %02x" (Char. code c)
157+ done ;
158+ Buffer. contents b
159+
150160let index tbl x = Atom (" $" ^ Code.Var.Hashtbl. find tbl x)
151161
152162let heap_type st (ty : heap_type ) =
@@ -215,7 +225,7 @@ let str_type st typ =
215225
216226let block_type = func_type
217227
218- let quoted_name name = Atom (" \" " ^ name ^ " \" " )
228+ let quoted_name name = Atom (" \" " ^ escape_string name ^ " \" " )
219229
220230let export name =
221231 match name with
@@ -613,16 +623,6 @@ let import st f =
613623 ]
614624 ]
615625
616- let escape_string s =
617- let b = Buffer. create (String. length s + 2 ) in
618- for i = 0 to String. length s - 1 do
619- let c = s.[i] in
620- if Char. (c > = ' ' && c < = '~' && c <> '"' && c <> '\\' )
621- then Buffer. add_char b c
622- else Printf. bprintf b " \\ %02x" (Char. code c)
623- done ;
624- Buffer. contents b
625-
626626let type_field st { name; typ; supertype; final } =
627627 if final && Option. is_none supertype
628628 then List [ Atom " type" ; index st.type_names name; str_type st typ ]
You can’t perform that action at this time.
0 commit comments