Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
Iris
RefinedC
Commits
ed18827b
Commit
ed18827b
authored
Mar 02, 2021
by
Rodolphe Lepigre
Committed by
Michael Sammler
Mar 02, 2021
Browse files
Better error handling with [realpath] + bug fix.
parent
1943211d
Pipeline
#42822
passed with stage
in 18 minutes and 56 seconds
Changes
2
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
frontend/main.ml
View file @
ed18827b
...
...
@@ -114,13 +114,13 @@ let run : config -> string -> unit = fun cfg c_file ->
Coq_pp
.
print_stmt_locs
:=
false
end
;
(* Split the file path into a file name and absolute directory path. *)
let
c_file
=
try
Filename
.
realpath
c_file
with
Invalid_argument
(
_
)
->
panic
"File [%s] disappeared..."
c_file
in
let
c_file_name
=
Filename
.
basename
c_file
in
let
c_file_name_no_ext
=
Filename
.
remove_extension
c_file_name
in
let
c_file_dir
=
let
c_file_dir
=
Filename
.
dirname
c_file
in
try
Filename
.
realpath
c_file_dir
with
Invalid_argument
(
_
)
->
panic
"Directory [%s] disappeared..."
c_file_dir
in
let
c_file_dir
=
Filename
.
dirname
c_file
in
(* Locate the RefinedC project root and the relitive logical directory. *)
let
find_root_and_dir_path
dir
=
let
rec
find
acc
dir
=
...
...
frontend/stubs.c
View file @
ed18827b
#include <limits.h>
#include <stdlib.h>
#include <errno.h>
#include <caml/mlvalues.h>
#include <caml/alloc.h>
#include <caml/fail.h>
...
...
@@ -10,8 +11,29 @@ CAMLprim value c_realpath(value v) {
char
*
output_path
=
realpath
(
input_path
,
NULL
);
// Checking for error.
if
(
output_path
==
NULL
)
caml_invalid_argument
(
"Extra.Filename.realpath
\0
"
);
if
(
output_path
==
NULL
){
switch
(
errno
){
case
EACCES
:
caml_invalid_argument
(
"Extra.Filename.realpath (EACCESS)
\0
"
);
case
EINVAL
:
caml_invalid_argument
(
"Extra.Filename.realpath (EINVAL)
\0
"
);
case
EIO
:
caml_invalid_argument
(
"Extra.Filename.realpath (EIO)
\0
"
);
case
ELOOP
:
caml_invalid_argument
(
"Extra.Filename.realpath (ELOOP)
\0
"
);
case
ENAMETOOLONG
:
caml_invalid_argument
(
"Extra.Filename.realpath (ENAMETOOLONG)
\0
"
);
case
ENOENT
:
caml_invalid_argument
(
"Extra.Filename.realpath (ENOENT)
\0
"
);
case
ENOMEM
:
caml_invalid_argument
(
"Extra.Filename.realpath (ENOMEM)
\0
"
);
case
ENOTDIR
:
caml_invalid_argument
(
"Extra.Filename.realpath (ENOTDIR)
\0
"
);
default:
// Should not be reachable.
caml_invalid_argument
(
"Extra.Filename.realpath (unknown)
\0
"
);
}
}
// Preparing the result value.
value
res
=
caml_copy_string
(
output_path
);
...
...
Write
Preview
Supports
Markdown
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