Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
M
menhir
Project overview
Project overview
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
10
Issues
10
List
Boards
Labels
Milestones
Merge Requests
3
Merge Requests
3
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Packages
Packages
Container Registry
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
POTTIER Francois
menhir
Commits
7e5c7c06
Commit
7e5c7c06
authored
Jun 19, 2019
by
POTTIER Francois
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Work around in bug in [String.escaped] in OCaml 4.02.3. Closes issue
#24
.
parent
6cefed83
Pipeline
#83294
passed with stages
in 25 seconds
Changes
4
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
85 additions
and
1 deletion
+85
-1
CHANGES.md
CHANGES.md
+6
-0
src/Compatibility.ml
src/Compatibility.ml
+61
-0
src/Compatibility.mli
src/Compatibility.mli
+17
-0
src/printer.ml
src/printer.ml
+1
-1
No files found.
CHANGES.md
View file @
7e5c7c06
# Changes
## 2019/06/20
*
When compiled with OCaml 4.02.3, Menhir could produce OCaml code
containing invalid string literals. This was due to a problem in
`String.escaped`
. Fixed. (Reported by ELLIOTCABLE.)
## 2019/06/13
*
Relax the syntax of point-free actions to allow
`< >`
(with arbitrary
...
...
src/Compatibility.ml
0 → 100644
View file @
7e5c7c06
module
Bytes
=
struct
include
Bytes
let
escaped
s
=
let
n
=
ref
0
in
for
i
=
0
to
length
s
-
1
do
n
:=
!
n
+
(
match
unsafe_get
s
i
with
|
'\"'
|
'\\'
|
'\n'
|
'\t'
|
'\r'
|
'\b'
->
2
|
'
'
..
'
~
'
->
1
|
_
->
4
)
done
;
if
!
n
=
length
s
then
copy
s
else
begin
let
s'
=
create
!
n
in
n
:=
0
;
for
i
=
0
to
length
s
-
1
do
begin
match
unsafe_get
s
i
with
|
(
'\"'
|
'\\'
)
as
c
->
unsafe_set
s'
!
n
'\\'
;
incr
n
;
unsafe_set
s'
!
n
c
|
'\n'
->
unsafe_set
s'
!
n
'\\'
;
incr
n
;
unsafe_set
s'
!
n
'
n'
|
'\t'
->
unsafe_set
s'
!
n
'\\'
;
incr
n
;
unsafe_set
s'
!
n
'
t'
|
'\r'
->
unsafe_set
s'
!
n
'\\'
;
incr
n
;
unsafe_set
s'
!
n
'
r'
|
'\b'
->
unsafe_set
s'
!
n
'\\'
;
incr
n
;
unsafe_set
s'
!
n
'
b'
|
(
'
'
..
'
~
'
)
as
c
->
unsafe_set
s'
!
n
c
|
c
->
let
a
=
Char
.
code
c
in
unsafe_set
s'
!
n
'\\'
;
incr
n
;
unsafe_set
s'
!
n
(
Char
.
chr
(
48
+
a
/
100
));
incr
n
;
unsafe_set
s'
!
n
(
Char
.
chr
(
48
+
(
a
/
10
)
mod
10
));
incr
n
;
unsafe_set
s'
!
n
(
Char
.
chr
(
48
+
a
mod
10
));
end
;
incr
n
done
;
s'
end
end
module
String
=
struct
open
String
let
escaped
s
=
let
rec
escape_if_needed
s
n
i
=
if
i
>=
n
then
s
else
match
unsafe_get
s
i
with
|
'\"'
|
'\\'
|
'\000'
..
'\031'
|
'\127'
..
'\255'
->
Bytes
.
unsafe_to_string
(
Bytes
.
escaped
(
Bytes
.
unsafe_of_string
s
))
|
_
->
escape_if_needed
s
n
(
i
+
1
)
in
escape_if_needed
s
(
length
s
)
0
end
src/Compatibility.mli
0 → 100644
View file @
7e5c7c06
(* The standard library function [String.escaped] in OCaml 4.02.3 depends
on the operating system function [isprint] and therefore can have OS-
dependent, locale-dependent behavior. This issue has been fixed in OCaml
4.03. We use a copy of the code found in OCaml 4.03 and higher, so as to
avoid this issue. *)
module
Bytes
:
sig
val
escaped
:
bytes
->
bytes
end
module
String
:
sig
val
escaped
:
string
->
string
end
src/printer.ml
View file @
7e5c7c06
...
...
@@ -398,7 +398,7 @@ and exprk k f e =
else
fprintf
f
"(%d)"
k
|
EStringConst
s
->
fprintf
f
"
\"
%s
\"
"
(
String
.
escaped
s
)
fprintf
f
"
\"
%s
\"
"
(
Compatibility
.
String
.
escaped
s
)
|
ETuple
[]
->
assert
false
|
ETuple
[
e
]
->
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment