Skip to content

Commit

Permalink
Add otpbp_erl_anno
Browse files Browse the repository at this point in the history
- add set_end_location/2
  • Loading branch information
Ledest committed Nov 12, 2024
1 parent 9263acf commit f463ceb
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 0 deletions.
1 change: 1 addition & 0 deletions rebar.config.script
Original file line number Diff line number Diff line change
Expand Up @@ -151,6 +151,7 @@ Funs = [{application, get_supervisor, 1},
{eldap, paged_result_control, 1},
{eldap, paged_result_control, 2},
{eldap, paged_result_cookie, 1},
{erl_anno, set_end_location, 2},
{erl_epmd, listen_port_please, 2},
{erl_epmd, port_please, 2},
{erl_epmd, port_please, 3},
Expand Down
21 changes: 21 additions & 0 deletions src/otpbp_erl_anno.erl
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
-module(otpbp_erl_anno).

-ifndef(HAVE_erl_anno__set_end_location_2).
% OTP 27.2
-export([set_end_location/2]).
-endif.

-ifndef(HAVE_erl_anno__set_end_location_2).
set_end_location(Location, {L, C} = Anno) when is_integer(L), L >= 0, is_integer(C), C >= 1 ->
set_end_location1(Location, [{location, Anno}]);
set_end_location(Location, Anno) when is_integer(Anno), Anno >= 0 -> set_end_location1(Location, [{location, Anno}]);
set_end_location(Location, [_|_] = Anno) -> set_end_location1(Location, Anno);
set_end_location(Location, Anno) -> error(badarg, [Location, Anno]).

set_end_location1({L, C} = Location, Anno) when is_integer(L), L >= 0, is_integer(C), C >= 1 ->
set_end_location2(Location, Anno);
set_end_location1(Location, Anno) when is_integer(Location), Location >= 0 -> set_end_location2(Location, Anno);
set_end_location1(Location, Anno) -> error(badarg, [Location, Anno]).

set_end_location2(Location, Anno) -> lists:keystore(end_location, 1, Anno, {end_location, Location}).
-endif.
1 change: 1 addition & 0 deletions src/otpbp_pt.erl
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,7 @@
{{eldap, paged_result_cookie, 1}, otpbp_eldap},
{{edlin, keymap, 0}, otpbp_edlin},
{{epp, scan_file, [1, 2]}, otpbp_epp},
{{erl_anno, set_end_location, 2}, otpbp_erl_anno},
{{erl_epmd, listen_port_please, 2}, otpbp_erl_epmd},
{{erl_epmd, port_please, [2, 3]}, otpbp_erl_epmd},
{{erl_error, format_fun, [1, 2]}, lib},
Expand Down

0 comments on commit f463ceb

Please sign in to comment.