File 0667-dialyzer-Fix-ordinal-for-numbers-over-twenty.patch of Package erlang

From c20033f4d198858a8fbc11ca7cd4775544cf8fd7 Mon Sep 17 00:00:00 2001
From: Tom <TD5@users.noreply.github.com>
Date: Tue, 7 Feb 2023 21:31:20 +0000
Subject: [PATCH] dialyzer: Fix ordinal for numbers over twenty

---
 lib/dialyzer/src/dialyzer.erl | 16 ++++++++++++----
 1 file changed, 12 insertions(+), 4 deletions(-)

diff --git a/lib/dialyzer/src/dialyzer.erl b/lib/dialyzer/src/dialyzer.erl
index f4f323daeb..a502f7107d 100644
--- a/lib/dialyzer/src/dialyzer.erl
+++ b/lib/dialyzer/src/dialyzer.erl
@@ -727,10 +727,18 @@ form_position_string(ArgNs) ->
       Head ++ " and " ++ ordinal(Last)
   end.
 
-ordinal(1) -> "1st";
-ordinal(2) -> "2nd";
-ordinal(3) -> "3rd";
-ordinal(N) when is_integer(N) -> io_lib:format("~wth", [N]).
+ordinal(N) when is_integer(N),
+                ((N rem 100) =:= 11) orelse
+                ((N rem 100) =:= 12) orelse
+                ((N rem 100) =:= 13) ->
+  io_lib:format("~Bth", [N]);
+ordinal(N) when is_integer(N) ->
+  case min(N rem 10, 4) of
+    1 -> io_lib:format("~Bst", [N]);
+    2 -> io_lib:format("~Bnd", [N]);
+    3 -> io_lib:format("~Brd", [N]);
+    _ -> io_lib:format("~Bth", [N])
+  end.
 
 %% Functions that parse type strings, literal strings, and contract
 %% strings. Return strings formatted by erl_pp.
-- 
2.35.3

openSUSE Build Service is sponsored by