Skip to content
Snippets Groups Projects
Commit f985ef63 authored by Virgile Prevosto's avatar Virgile Prevosto
Browse files

[helpers] check_newline and isutf8 assume the names they are given aren't quoted

parent 2d763b68
No related branches found
No related tags found
No related merge requests found
......@@ -2151,9 +2151,9 @@ CHECK_NEWLINES:=./bin/check_newlines$(EXE)
$(CHECK_NEWLINES): bin/check_newlines.ml
$(PRINT_MAKING) $@
ifeq ($(OCAMLBEST),opt)
$(OCAMLOPT) str.cmxa unix.cmxa $< -o $@
$(OCAMLOPT) unix.cmxa $< -o $@
else
$(OCAMLC) str.cma unix.cma $< -o $@
$(OCAMLC) unix.cma $< -o $@
endif
check-newlines-clean:
......@@ -2166,9 +2166,9 @@ ISUTF8:=./bin/isutf8$(EXE)
$(ISUTF8): bin/isutf8.ml
$(PRINT_MAKING) $@
ifeq ($(OCAMLBEST),opt)
$(OCAMLOPT) str.cmxa $< -o $@
$(OCAMLOPT) $< -o $@
else
$(OCAMLC) str.cma $< -o $@
$(OCAMLC) $< -o $@
endif
isutf8-clean:
......
module StringSet = Set.Make(String)
let unquote_filename filename =
let n = String.length filename in
let r =
if n > 1 && String.get filename 0 = '"' &&
String.get filename (n - 1) = '"'
then
String.sub filename 1 (n-2)
else
filename
in
Str.global_replace (Str.regexp "\\\\") "" r
(* returns true for empty files *)
let is_last_byte_newline filename =
try
......@@ -51,13 +39,6 @@ let () =
try
while true; do
let filename = input_line file_list_ic in
let filename =
(* assume no empty filenames *)
if String.get filename 0 = '"' then
unquote_filename filename
else
filename
in
if not (StringSet.mem filename to_ignore) &&
not (is_last_byte_newline filename) then begin
incr errors;
......
module StringSet = Set.Make(String)
let unquote_filename filename =
let n = String.length filename in
let r =
if n > 1 && String.get filename 0 = '"' &&
String.get filename (n - 1) = '"'
then
String.sub filename 1 (n-2)
else
filename
in
Str.global_replace (Str.regexp "\\\\") "" r
exception False
let is_valid_utf8 filename =
......@@ -71,13 +59,6 @@ let () =
try
while true; do
let filename = input_line file_list_ic in
let filename =
(* assume no empty filenames *)
if String.get filename 0 = '"' then
unquote_filename filename
else
filename
in
if not (StringSet.mem filename to_ignore)
&& not (is_valid_utf8 filename) then begin
incr errors;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment