Sign Up
Log In
Log In
or
Sign Up
Places
All Projects
Status Monitor
Collapse sidebar
home:Ledest:erlang:23
erlang
1200-dialyzer-Fix-ordinal-for-numbers-over-twen...
Overview
Repositories
Revisions
Requests
Users
Attributes
Meta
File 1200-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
Locations
Projects
Search
Status Monitor
Help
OpenBuildService.org
Documentation
API Documentation
Code of Conduct
Contact
Support
@OBShq
Terms
openSUSE Build Service is sponsored by
The Open Build Service is an
openSUSE project
.
Sign Up
Log In
Places
Places
All Projects
Status Monitor