mirror of
https://github.com/ProgramSnail/Lama.git
synced 2025-12-06 06:48:48 +00:00
Fix escaping
This commit is contained in:
parent
97a47f403f
commit
475ce90e9b
1 changed files with 25 additions and 5 deletions
|
|
@ -1284,13 +1284,33 @@ class env prg mode =
|
|||
let n = String.length x in
|
||||
let buf = Buffer.create (n * 2) in
|
||||
let rec iterate i =
|
||||
if i < n then (
|
||||
(match x.[i] with
|
||||
if i < n then
|
||||
match x.[i] with
|
||||
| '"' ->
|
||||
Buffer.add_char buf '\\';
|
||||
Buffer.add_char buf '"'
|
||||
| c -> Buffer.add_char buf c);
|
||||
Buffer.add_char buf '"';
|
||||
iterate (i + 1)
|
||||
| '\\' -> (
|
||||
if i + 1 >= n then (
|
||||
Buffer.add_char buf '\\';
|
||||
Buffer.add_char buf '\\')
|
||||
else
|
||||
match x.[i + 1] with
|
||||
| 'n' ->
|
||||
Buffer.add_char buf '\\';
|
||||
Buffer.add_char buf 'n';
|
||||
iterate (i + 2)
|
||||
| 't' ->
|
||||
Buffer.add_char buf '\\';
|
||||
Buffer.add_char buf 't';
|
||||
iterate (i + 2)
|
||||
| _ ->
|
||||
Buffer.add_char buf '\\';
|
||||
Buffer.add_char buf '\\';
|
||||
iterate (i + 1))
|
||||
| c ->
|
||||
Buffer.add_char buf c;
|
||||
iterate (i + 1)
|
||||
in
|
||||
iterate 0;
|
||||
Buffer.contents buf
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue