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
a47d0eb5
Commit
a47d0eb5
authored
2 years ago
by
Patrick Baudin
Browse files
Options
Downloads
Patches
Plain Diff
[Lint] no more needs of 'bin/isutf8.ml'
parent
ab91b9dc
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
.gitignore
+0
-2
0 additions, 2 deletions
.gitignore
bin/isutf8.ml
+0
-97
0 additions, 97 deletions
bin/isutf8.ml
with
0 additions
and
99 deletions
.gitignore
+
0
−
2
View file @
a47d0eb5
...
@@ -61,8 +61,6 @@ autom4te.cache
...
@@ -61,8 +61,6 @@ autom4te.cache
/devel_tools/fc-time
/devel_tools/fc-time
/devel_tools/fc-memuse
/devel_tools/fc-memuse
/bin/ocamldep_transitive_closure
/bin/ocamldep_transitive_closure
/bin/isutf8
/bin/isutf8.exe
#share
#share
/share/Makefile.config
/share/Makefile.config
...
...
This diff is collapsed.
Click to expand it.
bin/isutf8.ml
deleted
100644 → 0
+
0
−
97
View file @
ab91b9dc
(**************************************************************************)
(* *)
(* This file is part of Frama-C. *)
(* *)
(* Copyright (C) 2007-2022 *)
(* CEA (Commissariat à l'énergie atomique et aux énergies *)
(* alternatives) *)
(* *)
(* you can redistribute it and/or modify it under the terms of the GNU *)
(* Lesser General Public License as published by the Free Software *)
(* Foundation, version 2.1. *)
(* *)
(* It is distributed in the hope that it will be useful, *)
(* but WITHOUT ANY WARRANTY; without even the implied warranty of *)
(* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *)
(* GNU Lesser General Public License for more details. *)
(* *)
(* See the GNU Lesser General Public License version 2.1 *)
(* for more details (enclosed in the file licenses/LGPLv2.1). *)
(* *)
(**************************************************************************)
module
StringSet
=
Set
.
Make
(
String
)
exception
False
let
is_valid_utf8
filename
=
let
buf
=
Bytes
.
create
1024
in
try
let
ic
=
open_in_bin
filename
in
let
extra
=
ref
0
in
try
while
true
do
let
n_bytes_read
=
input
ic
buf
0
1024
in
if
n_bytes_read
=
0
then
raise
End_of_file
;
for
i
=
0
to
n_bytes_read
-
1
do
let
c
=
Bytes
.
get_uint8
buf
i
in
(*Format.printf "extra: %d, read byte: %d (0x%x, char %c)@."
!extra c c (Char.chr c);*)
if
!
extra
>
0
then
begin
decr
extra
;
if
c
lsr
6
<>
2
then
raise
False
end
else
if
c
>
127
then
begin
if
c
lsr
5
=
6
then
extra
:=
1
else
if
c
lsr
4
=
14
then
extra
:=
2
else
if
c
lsr
3
=
30
then
extra
:=
3
else
raise
False
end
;
done
;
done
;
close_in
ic
;
!
extra
=
0
with
|
End_of_file
->
close_in
ic
;
!
extra
=
0
|
False
->
close_in
ic
;
false
with
|
Sys_error
msg
->
(* possibly a non-existing file (e.g. with spaces); ignoring *)
Format
.
printf
"isutf8: cannot open, ignoring file: %s (%s)@."
filename
msg
;
true
(* usage: first argument is a file name containing a list of files
(one per line) to be checked; the remaining arguments are filenames
to be ignored during checking. *)
let
()
=
if
Array
.
length
Sys
.
argv
<
2
then
begin
Format
.
printf
"usage: %s file_list.txt [ignore1 ignore2 ...]@."
Sys
.
argv
.
(
0
);
exit
0
end
;
let
errors
=
ref
0
in
let
file_list_ic
=
open_in
Sys
.
argv
.
(
1
)
in
let
to_ignore
=
StringSet
.
of_list
(
List
.
tl
(
Array
.
to_list
Sys
.
argv
))
in
begin
try
while
true
;
do
let
filename
=
input_line
file_list_ic
in
if
not
(
StringSet
.
mem
filename
to_ignore
)
&&
not
(
is_valid_utf8
filename
)
then
begin
incr
errors
;
Format
.
printf
"error: invalid UTF-8 in file: %s@."
filename
end
done
with
End_of_file
->
close_in
file_list_ic
end
;
if
!
errors
>
0
then
begin
Format
.
printf
"Found %d file(s) with errors.@."
!
errors
;
exit
1
end
else
exit
0
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