Skip to content

Commit

Permalink
Add support for OCaml 5.00
Browse files Browse the repository at this point in the history
  • Loading branch information
kit-ty-kate committed Feb 16, 2022
1 parent fc7f1d1 commit 31d7998
Show file tree
Hide file tree
Showing 6 changed files with 14 additions and 28 deletions.
2 changes: 1 addition & 1 deletion markup-lwt.opam
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ depends: [
"dune" {>= "2.7.0"}
"lwt"
"markup"
"ocaml"
"ocaml" {>= "4.03"}
]

build: [
Expand Down
13 changes: 0 additions & 13 deletions src/common.ml
Original file line number Diff line number Diff line change
@@ -1,19 +1,6 @@
(* This file is part of Markup.ml, released under the MIT license. See
LICENSE.md for details, or visit https://github.com/aantron/markup.ml. *)

(* Aliases for reducing the number of deprecation warnings. *)
module String =
struct
include String
let lowercase = lowercase [@ocaml.warning "-3"]
end

module Char =
struct
include Char
let lowercase = lowercase [@ocaml.warning "-3"]
end

type 'a cont = 'a -> unit
type 'a cps = exn cont -> 'a cont -> unit

Expand Down
12 changes: 6 additions & 6 deletions src/detect.ml
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ let guess_family_xml source throw k =

(* 5.2 in the Encoding Candidate Recommendation. *)
let normalize_name for_html s =
match String.lowercase (trim_string s) with
match String.lowercase_ascii (trim_string s) with
| "unicode-1-1-utf-8" | "utf-8" | "utf8" ->
"utf-8"

Expand Down Expand Up @@ -223,7 +223,7 @@ let meta_tag_prescan =
let rec iterate () =
next source throw (fun () -> k "") (function
| c when c = quote -> k (Buffer.contents buffer)
| c -> add_utf_8 buffer (Char.code (Char.lowercase c)); iterate ())
| c -> add_utf_8 buffer (Char.code (Char.lowercase_ascii c)); iterate ())
in
iterate ()
in
Expand All @@ -237,7 +237,7 @@ let meta_tag_prescan =
push source c;
k (Buffer.contents buffer)
| c ->
add_utf_8 buffer (Char.code (Char.lowercase c));
add_utf_8 buffer (Char.code (Char.lowercase_ascii c));
iterate ())
in
iterate ()
Expand All @@ -249,7 +249,7 @@ let meta_tag_prescan =
next source throw (fun () -> k None) begin function
| 'c' ->
next_n 6 source throw begin fun l ->
match List.map Char.lowercase l with
match List.map Char.lowercase_ascii l with
| ['h'; 'a'; 'r'; 's'; 'e'; 't'] ->
skip_whitespace source throw (fun () ->
next source throw (fun () -> k None) begin function
Expand Down Expand Up @@ -316,7 +316,7 @@ let meta_tag_prescan =
k (Buffer.contents buffer)

| Some c ->
add_utf_8 buffer (Char.code (Char.lowercase c));
add_utf_8 buffer (Char.code (Char.lowercase_ascii c));
iterate ()
end
in
Expand Down Expand Up @@ -463,7 +463,7 @@ let meta_tag_prescan =

| 'm' ->
peek_n 5 source throw (fun l ->
match List.map Char.lowercase l with
match List.map Char.lowercase_ascii l with
| ['m'; 'e'; 't'; 'a'; c] when is_whitespace c || c = '/' ->
next_n 4 source throw (fun _ ->
process_meta_tag scan)
Expand Down
6 changes: 3 additions & 3 deletions src/html_parser.ml
Original file line number Diff line number Diff line change
Expand Up @@ -240,7 +240,7 @@ struct
Lowercase the element name given by the user before analysis by the
parser, to match this convention. [String.lowercase] is acceptable
here because the API assumes the string [element] is in UTF-8. *)
k (`Fragment (String.lowercase element), None)
k (`Fragment (String.lowercase_ascii element), None)
| Some (`Document as c) -> k (c, None)
| None -> detect tokens throw k)
(fun (detected_context, deciding_token) ->
Expand Down Expand Up @@ -2825,7 +2825,7 @@ let parse requested_context report (tokens, set_tokenizer_state, set_foreign) =
| l, `End {name} ->
(fun mode' ->
match Stack.current_element open_elements with
| Some {element_name = _, name'} when String.lowercase name' = name ->
| Some {element_name = _, name'} when String.lowercase_ascii name' = name ->
mode' ()
| _ ->
report l (`Unmatched_end_tag name) !throw (fun () ->
Expand All @@ -2834,7 +2834,7 @@ let parse requested_context report (tokens, set_tokenizer_state, set_foreign) =
let rec scan = function
| [] -> mode ()
| {element_name = ns, name'}::_
when String.lowercase name' = name ->
when String.lowercase_ascii name' = name ->
close_element ~ns l name mode
| {element_name = `HTML, _}::_ -> force_html ()
| _::rest -> scan rest
Expand Down
1 change: 0 additions & 1 deletion src/stream_io.ml
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
(* This file is part of Markup.ml, released under the MIT license. See
LICENSE.md for details, or visit https://github.com/aantron/markup.ml. *)

open Common
open Kstream

let state_fold f initial =
Expand Down
8 changes: 4 additions & 4 deletions src/xml_tokenizer.ml
Original file line number Diff line number Diff line change
Expand Up @@ -382,7 +382,7 @@ let tokenize report resolve_reference (input, get_location) =
and target_state () =
next' pi finish_pi begin function
| _, c when is_whitespace c ->
if String.lowercase (Buffer.contents target_buffer) = "xml" then
if String.lowercase_ascii (Buffer.contents target_buffer) = "xml" then
xml_declaration_state ()
else
text_state ()
Expand Down Expand Up @@ -422,7 +422,7 @@ let tokenize report resolve_reference (input, get_location) =
report l (`Bad_token ("<?...", pi, "empty")) !throw (fun () ->
k None)
else
if String.lowercase (Buffer.contents target_buffer) = "xml" then
if String.lowercase_ascii (Buffer.contents target_buffer) = "xml" then
finish_xml ()
else
k (Some
Expand All @@ -438,7 +438,7 @@ let tokenize report resolve_reference (input, get_location) =
scan [] l
in

let matches s (_, name, _) = String.lowercase name = s in
let matches s (_, name, _) = String.lowercase_ascii name = s in

let version_valid s =
String.length s = 3 &&
Expand Down Expand Up @@ -498,7 +498,7 @@ let tokenize report resolve_reference (input, get_location) =
report l
(`Bad_token (value, xml, "must be 'yes' or 'no'")) !throw
(fun () ->
match String.lowercase value with
match String.lowercase_ascii value with
| "yes" -> k (Some true)
| "no" -> k (Some false)
| _ -> k None))
Expand Down

0 comments on commit 31d7998

Please sign in to comment.