From f463cebab916f55b5879fa6a95baeb10766ce003 Mon Sep 17 00:00:00 2001 From: Led Date: Tue, 12 Nov 2024 15:32:06 +0200 Subject: [PATCH] Add otpbp_erl_anno - add set_end_location/2 --- rebar.config.script | 1 + src/otpbp_erl_anno.erl | 21 +++++++++++++++++++++ src/otpbp_pt.erl | 1 + 3 files changed, 23 insertions(+) create mode 100644 src/otpbp_erl_anno.erl diff --git a/rebar.config.script b/rebar.config.script index 32a9233..ebf7769 100644 --- a/rebar.config.script +++ b/rebar.config.script @@ -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}, diff --git a/src/otpbp_erl_anno.erl b/src/otpbp_erl_anno.erl new file mode 100644 index 0000000..d3faba8 --- /dev/null +++ b/src/otpbp_erl_anno.erl @@ -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. diff --git a/src/otpbp_pt.erl b/src/otpbp_pt.erl index 06f4e74..185eaf6 100644 --- a/src/otpbp_pt.erl +++ b/src/otpbp_pt.erl @@ -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},