diff options
author | Hans Bolinder <[email protected]> | 2017-06-21 09:41:52 +0200 |
---|---|---|
committer | Siri Hansen <[email protected]> | 2017-09-05 11:02:26 +0200 |
commit | 7c8b2a0d705ede4bc0ec1bfe8e0afe5a9942809b (patch) | |
tree | 3fa4a2f96f74a6891260526b3f37603c7e460e92 /lib/tools/src/xref_utils.erl | |
parent | 42afeb0c4af0625196c313b309add3a14a2bbb7c (diff) | |
download | otp-7c8b2a0d705ede4bc0ec1bfe8e0afe5a9942809b.tar.gz otp-7c8b2a0d705ede4bc0ec1bfe8e0afe5a9942809b.tar.bz2 otp-7c8b2a0d705ede4bc0ec1bfe8e0afe5a9942809b.zip |
xref: Improve handling of Unicode
The updates of xref_base:analysis() are cosmetic (the strings are
parsed by the Erlang scanner only).
Diffstat (limited to 'lib/tools/src/xref_utils.erl')
-rw-r--r-- | lib/tools/src/xref_utils.erl | 13 |
1 files changed, 9 insertions, 4 deletions
diff --git a/lib/tools/src/xref_utils.erl b/lib/tools/src/xref_utils.erl index b0c168e018..02e207d40c 100644 --- a/lib/tools/src/xref_utils.erl +++ b/lib/tools/src/xref_utils.erl @@ -1,7 +1,7 @@ %% %% %CopyrightBegin% %% -%% Copyright Ericsson AB 2000-2016. All Rights Reserved. +%% Copyright Ericsson AB 2000-2017. All Rights Reserved. %% %% Licensed under the Apache License, Version 2.0 (the "License"); %% you may not use this file except in compliance with the License. @@ -638,14 +638,14 @@ neighbours([], G, Fun, VT, L, _V, Vs) -> neighbours(Vs, G, Fun, VT, L). match_list(L, RExpr) -> - {ok, Expr} = re:compile(RExpr), + {ok, Expr} = re:compile(RExpr, [unicode]), filter(fun(E) -> match(E, Expr) end, L). match_one(VarL, Con, Col) -> select_each(VarL, fun(E) -> Con =:= element(Col, E) end). match_many(VarL, RExpr, Col) -> - {ok, Expr} = re:compile(RExpr), + {ok, Expr} = re:compile(RExpr, [unicode]), select_each(VarL, fun(E) -> match(element(Col, E), Expr) end). match(I, Expr) when is_integer(I) -> @@ -653,7 +653,12 @@ match(I, Expr) when is_integer(I) -> {match, [{0,length(S)}]} =:= re:run(S, Expr, [{capture, first}]); match(A, Expr) when is_atom(A) -> S = atom_to_list(A), - {match, [{0,length(S)}]} =:= re:run(S, Expr, [{capture, first}]). + case re:run(S, Expr, [{capture, first}]) of + {match, [{0,Size}]} -> + Size =:= byte_size(unicode:characters_to_binary(S)); + _ -> + false + end. select_each([{Mod,Funs} | L], Pred) -> case filter(Pred, Funs) of |