Do not use character class regexp
[llpp.git] / mkhelp.sh
blob4692b5ab597b6135ee5adafe239c16c1d7d6da82
1 #!/bin/sh
2 set -e
3 v=$(cd $(dirname $0) && git describe --tags --dirty 2>/dev/null || echo unknown)
4 ocaml str.cma -stdin "$1" "$v" <<EOF
5 let fixup = let open Str in
6 let dash = regexp "\\\\([^ ]*\\\\) +- +\\\\(.*\\\\)"
7 and head = regexp "-----\\\\(.*\\\\)-----" in
8 fun s -> global_replace dash "\\\\1\\t\\\\2" s |>
9 global_replace head "\\xc2\\xb7\\\\1";;
10 let rec iter ic = match input_line ic with
11 | s -> Printf.printf "%S;\\n" @@ fixup s; iter ic
12 | exception End_of_file -> ();;
13 Printf.printf "let keys = [\\n";
14 iter @@ open_in Sys.argv.(1);;
15 Printf.printf "];;\\nlet version = %S;;\\n" Sys.argv.(2);;
16 EOF