Created
November 2, 2021 08:34
-
-
Save jubnzv/c2c8b2edd4d739a28f32107905235795 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env ocaml | |
let startswith s1 s2 = | |
let len1 = String.length s1 and len2 = String.length s2 in | |
if len1 < len2 then false | |
else | |
let sub = String.sub s1 0 len2 in | |
String.equal sub s2 | |
let check filepath = | |
let f = open_in filepath in | |
let rec loop () = | |
try | |
let next = input_line f in | |
if String.length next > 80 && startswith next "(*" then | |
Printf.printf "%s:\n '%s'\n" filepath next; | |
loop () | |
with End_of_file -> | |
close_in f; | |
() | |
in loop () | |
let endswith s1 s2 = | |
let len1 = String.length s1 and len2 = String.length s2 in | |
if len1 < len2 then false | |
else | |
let sub = String.sub s1 (len1 - len2) len2 in | |
String.equal sub s2 | |
let rec walk = function | |
| f::fs when (Sys.file_exists f && Sys.is_directory f) -> begin | |
Sys.readdir f | |
|> Array.to_list | |
|> List.map (Filename.concat f) | |
|> List.iter | |
(fun fp -> begin | |
if Sys.is_directory fp then | |
walk [fp] | |
else if endswith fp ".ml" then | |
check fp | |
else () | |
end) | |
end | |
| f::fs -> walk fs | |
| _ -> () | |
let () = | |
walk ["./src/content/"] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment