File 5016-Give-generic-function-a-generic-name.patch of Package erlang
From f8b27d4425100f3767e6196e711a12e108240518 Mon Sep 17 00:00:00 2001
From: Raimo Niskanen <raimo@erlang.org>
Date: Mon, 28 Aug 2023 15:30:56 +0200
Subject: [PATCH 6/8] Give generic function a generic name
---
lib/stdlib/src/erl_scan.erl | 21 ++++++++-------------
1 file changed, 8 insertions(+), 13 deletions(-)
diff --git a/lib/stdlib/src/erl_scan.erl b/lib/stdlib/src/erl_scan.erl
index 4ac59478a9..d03579d87b 100644
--- a/lib/stdlib/src/erl_scan.erl
+++ b/lib/stdlib/src/erl_scan.erl
@@ -945,7 +945,7 @@ scan_tqstring_line(Cs, St, Line, Col, Toks, Qs, Tqs, Acc) ->
fun scan_tqstring_line/6}};
eof ->
ContentR = [Acc|Tqs#tqs.content_r],
- Estr = string:slice(tqstring_chars_r(ContentR), 0, 16),
+ Estr = string:slice(lists_foldl_reverse(ContentR, ""), 0, 16),
scan_error(
{string,{$",Tqs#tqs.qs},Estr},%"
Tqs#tqs.line, Tqs#tqs.col, Line, Col, eof)
@@ -973,8 +973,8 @@ scan_tqstring_finish(Cs, St, Line, Col, Toks, Tqs, IndentR) ->
string, St, Chars,
lists_duplicate(
Qs, $",%"
- tqstring_chars_r(
- ContentR, lists:duplicate(Qs, $"))))),%"
+ lists_foldl_reverse(
+ ContentR, lists_duplicate(Qs, $", []))))),%"
scan1(Cs, St, Line, Col, [{string,Anno,Content}|Toks]);
{Tag=indentation, ErrorLine, ErrorCol} ->
scan_error(
@@ -986,15 +986,6 @@ scan_tqstring_finish(Cs, St, Line, Col, Toks, Tqs, IndentR) ->
Line, Col, Cs)
end.
-%% Reconstruct the scanned triple-quoted string from content lines
-%%
-tqstring_chars_r(ContentR) ->
- tqstring_chars_r(ContentR, "").
-%%
-tqstring_chars_r([], Chars) -> Chars;
-tqstring_chars_r([StringR|StringsR], Chars) ->
- tqstring_chars_r(StringsR, lists:reverse(StringR, Chars)).
-
%% Strip newline from the last line, but not if it is the only line
%%
strip_last_line_newline_r(ContentR=[_]) ->
@@ -1563,10 +1554,14 @@ new_column(no_col=Col, _Ncol) ->
new_column(Col, Ncol) when is_integer(Col) ->
Ncol.
-%% lists:duplicate/3
+%% lists:duplicate/3 (not exported)
lists_duplicate(0, _, L) -> L;
lists_duplicate(N, X, L) -> lists_duplicate(N-1, X, [X|L]).
+%% lists:foldl/3 over lists:reverse/2
+lists_foldl_reverse(Lists, Acc) ->
+ lists:foldl(fun lists:reverse/2, Acc, Lists).
+
nl_spcs(2) -> "\n ";
nl_spcs(3) -> "\n ";
nl_spcs(4) -> "\n ";
--
2.35.3