Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
F
frama-c
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Container Registry
Model registry
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
pub
frama-c
Commits
a6c650f9
Commit
a6c650f9
authored
4 years ago
by
Andre Maroneze
Committed by
David Bühler
4 years ago
Browse files
Options
Downloads
Patches
Plain Diff
[Kernel] Compress large contexts in error messages
parent
59b8573e
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/kernel_internals/parsing/errorloc.ml
+16
-2
16 additions, 2 deletions
src/kernel_internals/parsing/errorloc.ml
with
16 additions
and
2 deletions
src/kernel_internals/parsing/errorloc.ml
+
16
−
2
View file @
a6c650f9
...
@@ -126,8 +126,14 @@ let pp_context_from_file ?(ctx=2) ?start_line fmt pos =
...
@@ -126,8 +126,14 @@ let pp_context_from_file ?(ctx=2) ?start_line fmt pos =
|
None
->
pos
.
Filepath
.
pos_lnum
,
pos
.
Filepath
.
pos_lnum
|
None
->
pos
.
Filepath
.
pos_lnum
,
pos
.
Filepath
.
pos_lnum
|
Some
l
->
min
l
pos
.
Filepath
.
pos_lnum
,
max
l
pos
.
Filepath
.
pos_lnum
|
Some
l
->
min
l
pos
.
Filepath
.
pos_lnum
,
max
l
pos
.
Filepath
.
pos_lnum
in
in
(* The difference between the first and last error lines can be very
large; in this case, we print only the first and last [error_ctx]
lines, with "..." between them. *)
let
first_to_print
=
max
(
first_error_line
-
ctx
)
1
in
let
first_to_print
=
max
(
first_error_line
-
ctx
)
1
in
let
last_to_print
=
last_error_line
+
ctx
in
let
last_to_print
=
last_error_line
+
ctx
in
let
error_ctx
=
3
in
let
error_height
=
last_error_line
-
first_error_line
+
1
in
let
compress_error
=
error_height
>
2
*
error_ctx
+
1
+
2
in
let
i
=
ref
1
in
let
i
=
ref
1
in
let
error_line_len
=
ref
0
in
let
error_line_len
=
ref
0
in
try
try
...
@@ -148,8 +154,16 @@ let pp_context_from_file ?(ctx=2) ?start_line fmt pos =
...
@@ -148,8 +154,16 @@ let pp_context_from_file ?(ctx=2) ?start_line fmt pos =
(* print error lines *)
(* print error lines *)
while
!
i
<=
last_error_line
do
while
!
i
<=
last_error_line
do
let
line
=
input_line
in_ch
in
let
line
=
input_line
in_ch
in
error_line_len
:=
String
.
length
line
;
if
compress_error
&&
!
i
=
first_error_line
+
error_ctx
then
Format
.
fprintf
fmt
"%-6d%s
\n
"
!
i
line
;
Format
.
fprintf
fmt
"%d-%d [... omitted ...]
\n
"
(
first_error_line
+
error_ctx
)
(
last_error_line
-
error_ctx
)
else
if
compress_error
&&
!
i
>
first_error_line
+
error_ctx
&&
!
i
<=
last_error_line
-
error_ctx
then
()
(* ignore line *)
else
begin
error_line_len
:=
String
.
length
line
;
Format
.
fprintf
fmt
"%-6d%s
\n
"
!
i
line
;
end
;
incr
i
incr
i
done
;
done
;
(* if more than one line of context, print blank line,
(* if more than one line of context, print blank line,
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment