From 230a9175a5edb1b1a47fb09af2f4341eab93b1b0 Mon Sep 17 00:00:00 2001
From: Benoit Chesneau <bchesneau@gmail.com>
Date: Sat, 5 Dec 2020 11:31:24 +0100
Subject: [PATCH] remove unicode_util_compat library

remove unicode_util_compat library and support only Erlang >= 20. This
change simplify the stack and prepare future change to support specific
features of Erlang 23 and sup.
---
 .travis.yml          |  1 -
 CHANGELOG            |  4 ++++
 rebar.config         |  2 +-
 rebar.lock           |  9 +--------
 src/idna.app.src     |  4 ++--
 src/idna.erl         | 10 +++++-----
 src/idna_context.erl |  4 ++--
 7 files changed, 15 insertions(+), 19 deletions(-)

diff --git a/.travis.yml b/.travis.yml
index 7f16c91..3f1a419 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -1,6 +1,5 @@
 language: erlang
 otp_release:
-  - 19.3
   - 20.0
   - 20.1.7
   - 20.3.8.22
diff --git a/CHANGELOG b/CHANGELOG
index d21de4c..bc61c3b 100644
--- a/CHANGELOG
+++ b/CHANGELOG
@@ -1,5 +1,9 @@
 # CHANGELOG
 
+== 7.0.0 - unreleased
+
+- remove unicode_compat. only support Erlang >= 20
+
 == 6.1.1 - 2020-12-06
 
 - fix license information
diff --git a/rebar.config b/rebar.config
index 3af59e3..cd02013 100644
--- a/rebar.config
+++ b/rebar.config
@@ -1,3 +1,3 @@
 {erl_opts, []}.
 
-{deps, [{unicode_util_compat, "~>0.7.0"}]}.
+{deps, []}.
diff --git a/rebar.lock b/rebar.lock
index 8813028..57afcca 100644
--- a/rebar.lock
+++ b/rebar.lock
@@ -1,8 +1 @@
-{"1.2.0",
-[{<<"unicode_util_compat">>,{pkg,<<"unicode_util_compat">>,<<"0.7.0">>},0}]}.
-[
-{pkg_hash,[
- {<<"unicode_util_compat">>, <<"BC84380C9AB48177092F43AC89E4DFA2C6D62B40B8BD132B1059ECC7232F9A78">>}]},
-{pkg_hash_ext,[
- {<<"unicode_util_compat">>, <<"25EEE6D67DF61960CF6A794239566599B09E17E668D3700247BC498638152521">>}]}
-].
+[].
diff --git a/src/idna.app.src b/src/idna.app.src
index ddf767c..fd0b0d9 100644
--- a/src/idna.app.src
+++ b/src/idna.app.src
@@ -1,9 +1,9 @@
 {application, idna, [
   {description, "A pure Erlang IDNA implementation"},
-  {vsn, "6.1.1"},
+  {vsn, "7.0.0"},
   {modules, []},
   {registered, []},
-  {applications, [kernel, stdlib, unicode_util_compat]},
+  {applications, [kernel, stdlib]},
 
   {licenses, ["MIT"]},
   {links, [{"Github", "https://github.com/benoitc/erlang-idna"}]}
diff --git a/src/idna.erl b/src/idna.erl
index 61c115a..e58cc86 100644
--- a/src/idna.erl
+++ b/src/idna.erl
@@ -337,7 +337,7 @@ lowercase_list([], true) ->
 lowercase_list([], false) ->
   throw(unchanged);
 lowercase_list(CPs0, Changed) ->
-  case unicode_util_compat:lowercase(CPs0) of
+  case unicode_util:lowercase(CPs0) of
     [Char|CPs] when Char =:= hd(CPs0) -> [Char|lowercase_list(CPs, Changed)];
     [Char|CPs] -> append(Char,lowercase_list(CPs, true));
     [] -> lowercase_list([], Changed)
@@ -350,9 +350,9 @@ lowercase_bin(CP1, <<CP2/utf8, Bin/binary>>, Changed)
   when CP1 < 128, CP2 < 256 ->
   [CP1|lowercase_bin(CP2, Bin, Changed)];
 lowercase_bin(CP1, Bin, Changed) ->
-  case unicode_util_compat:lowercase([CP1|Bin]) of
+  case unicode_util:lowercase([CP1|Bin]) of
     [CP1|CPs] ->
-      case unicode_util_compat:cp(CPs) of
+      case unicode_util:cp(CPs) of
         [Next|Rest] ->
           [CP1|lowercase_bin(Next, Rest, Changed)];
         [] when Changed ->
@@ -361,7 +361,7 @@ lowercase_bin(CP1, Bin, Changed) ->
           throw(unchanged)
       end;
     [Char|CPs] ->
-      case unicode_util_compat:cp(CPs) of
+      case unicode_util:cp(CPs) of
         [Next|Rest] ->
           [Char|lowercase_bin(Next, Rest, true)];
         [] ->
@@ -378,7 +378,7 @@ append(GC, Str) when is_list(GC) -> GC ++ Str.
 
 
 characters_to_nfc_list(CD) ->
-  case unicode_util_compat:nfc(CD) of
+  case unicode_util:nfc(CD) of
     [CPs|Str] when is_list(CPs) -> CPs ++ characters_to_nfc_list(Str);
     [CP|Str] -> [CP|characters_to_nfc_list(Str)];
     [] -> []
diff --git a/src/idna_context.erl b/src/idna_context.erl
index faab65e..eecc432 100644
--- a/src/idna_context.erl
+++ b/src/idna_context.erl
@@ -25,7 +25,7 @@ valid_contextj(Label, Pos) ->
 valid_contextj(16#200c, Label, Pos) ->
   if
      Pos > 0 ->
-       case unicode_util_compat:lookup(lists:nth(Pos, Label)) of
+       case unicode_util:lookup(lists:nth(Pos, Label)) of
          #{ ccc := ?virama_combining_class } -> true;
          _ ->
            valid_contextj_1(Label, Pos)
@@ -35,7 +35,7 @@ valid_contextj(16#200c, Label, Pos) ->
   end;
 
 valid_contextj(16#200d, Label, Pos) when Pos > 0 ->
-  case unicode_util_compat:lookup(lists:nth(Pos, Label)) of
+  case unicode_util:lookup(lists:nth(Pos, Label)) of
     #{ ccc := ?virama_combining_class } -> true;
     _ -> false
   end;
