History

Add hint charset error reporting

malc committed 6 years ago

Commit abfaec31 parent 6ee08bd3 files · +22 −23Browse files

Unified · Split

3 files
  1. config.ml +14 −21
  2. main.ml +7 −1
  3. todo.org +1 −1
config.ml+14−21
@@ -709,26 +709,19 @@ let keys_of_string s = · 708 unmodified lines
709 List.map (key_of_string (Str.regexp "-")) elems709 List.map (key_of_string (Str.regexp "-")) elems
710;;710;;
711 711
712let validatehcs d v =712let validatehcs v =
713 if String.length v > 1 &&713 let l = String.length v in
714 let module S = Set.Make (714 if l < 2 then failwith "set is too small, must be greater than one char";
715 struct type t = char715 let module S = Set.Make (struct type t = char let compare = compare end) in
716 let compare a b = Char.code a - Char.code b716 let rec check s i =
717 end)717 if i < l
718 in718 then
719 let l = String.length v in719 let e = String.get v i in
720 let rec fold s i =720 if S.mem e s
721 if i = l721 then failwith "has duplicates"
722 then true722 else check (S.add e s) (i+1)
723 else723 in
724 let e = String.get v i in724 check (S.singleton (String.get v 0)) 1
725 if S.mem e s
726 then false
727 else fold (S.add e s) (i+1)
728 in
729 fold (S.singleton (String.get v 0)) 1
730 then v
731 else (Format.eprintf "invalid hint charset %S@." v; d)
732;;725;;
733 726
734let config_of c attrs =727let config_of c attrs =
@@ -825,7 +818,7 @@ let config_of c attrs = · 90 unmodified lines
825 | "coarse-presentation-positioning" ->818 | "coarse-presentation-positioning" ->
826 { c with coarseprespos = bool_of_string v }819 { c with coarseprespos = bool_of_string v }
827 | "use-document-css" -> { c with usedoccss = bool_of_string v }820 | "use-document-css" -> { c with usedoccss = bool_of_string v }
828 | "hint-charset" -> { c with hcs = validatehcs c.hcs v }821 | "hint-charset" -> validatehcs v; { c with hcs = v }
829 | _ -> c822 | _ -> c
830 with exn ->823 with exn ->
831 dolog "error processing attribute (`%S' = `%S'): %s" k v @@ exntos exn;824 dolog "error processing attribute (`%S' = `%S'): %s" k v @@ exntos exn;
main.ml+7−1
@@ -2533,7 +2533,13 @@ let enterinfomode = · 2532 unmodified lines
2533 (fun v -> conf.hfsize <- bound v 5 100);2533 (fun v -> conf.hfsize <- bound v 5 100);
2534 src#string "hint chars"2534 src#string "hint chars"
2535 (fun () -> conf.hcs)2535 (fun () -> conf.hcs)
2536 (fun v -> conf.hcs <- Config.validatehcs conf.hcs v);2536 (fun v ->
2537 try
2538 validatehcs v;
2539 conf.hcs <- v
2540 with exn ->
2541 state.text <- Printf.sprintf
2542 "invalid hint charset %S: %s\n" v (exntos exn));
2537 src#string "trim fuzz"2543 src#string "trim fuzz"
2538 (fun () -> irect_to_string conf.trimfuzz)2544 (fun () -> irect_to_string conf.trimfuzz)
2539 (fun v ->2545 (fun v ->
todo.org+1−1
@@ -28,4 +28,4 @@ · 27 unmodified lines
28 28
29 it takes an error in utils making deps dirty and then another...29 it takes an error in utils making deps dirty and then another...
30 (IOW i need to get some sleep before trying to wrap my head around it)30 (IOW i need to get some sleep before trying to wrap my head around it)
31* TODO hintchars validation should report errors differently (how?)31* TODO audit dologs, where possible turn them into adderr... and suchlike

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t