aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorFredrik Gustafsson <[email protected]>2013-09-11 09:34:50 +0200
committerFredrik Gustafsson <[email protected]>2013-09-11 09:34:50 +0200
commitf13bf23b904fc155e41da4d00a2a8387ef27b1fd (patch)
tree565a23e921ae751f7852a270ff5fa7ec83e95788
parentad4d72a4b1c89761416f0dbe61920718507d915a (diff)
parentde29dde83bc3aa6328e3db6876ddf929a5141e75 (diff)
downloadotp-f13bf23b904fc155e41da4d00a2a8387ef27b1fd.tar.gz
otp-f13bf23b904fc155e41da4d00a2a8387ef27b1fd.tar.bz2
otp-f13bf23b904fc155e41da4d00a2a8387ef27b1fd.zip
Merge branch 'maint'
-rw-r--r--lib/parsetools/src/leex.erl6
-rw-r--r--lib/parsetools/test/leex_SUITE.erl24
2 files changed, 24 insertions, 6 deletions
diff --git a/lib/parsetools/src/leex.erl b/lib/parsetools/src/leex.erl
index 7039aea1ae..03f864ff03 100644
--- a/lib/parsetools/src/leex.erl
+++ b/lib/parsetools/src/leex.erl
@@ -436,7 +436,7 @@ parse_defs(_, {eof,L}, St) ->
parse_defs(Ifile, {ok,Chars,L}=Line, Ms, St) ->
%% This little beauty matches out a macro definition, RE's are so clear.
MS = "^[ \t]*([A-Z_][A-Za-z0-9_]*)[ \t]*=[ \t]*([^ \t\r\n]*)[ \t\r\n]*\$",
- case re:run(Chars, MS, [{capture,all_but_first,list}]) of
+ case re:run(Chars, MS, [{capture,all_but_first,list},unicode]) of
{match,[Name,Def]} ->
%%io:fwrite("~p = ~p\n", [Name,Def]),
parse_defs(Ifile, nextline(Ifile, L, St), [{Name,Def}|Ms], St);
@@ -491,7 +491,7 @@ parse_rules_end(_, NextLine, REAs, As, St) ->
collect_rule(Ifile, Chars, L0) ->
%% Erlang strings are 1 based, but re 0 :-(
- {match,[{St0,Len}|_]} = re:run(Chars, "[^ \t\r\n]+"),
+ {match,[{St0,Len}|_]} = re:run(Chars, "[^ \t\r\n]+", [unicode]),
St = St0 + 1,
%%io:fwrite("RE = ~p~n", [substr(Chars, St, Len)]),
case collect_action(Ifile, substr(Chars, St+Len), L0, []) of
@@ -548,7 +548,7 @@ var_used(Name, Toks) ->
%% here as it uses info in replace string (&).
parse_rule_regexp(RE0, [{M,Exp}|Ms], St) ->
- Split= re:split(RE0, "\\{" ++ M ++ "\\}", [{return,list}]),
+ Split= re:split(RE0, "\\{" ++ M ++ "\\}", [{return,list},unicode]),
RE1 = string:join(Split, Exp),
parse_rule_regexp(RE1, Ms, St);
parse_rule_regexp(RE, [], St) ->
diff --git a/lib/parsetools/test/leex_SUITE.erl b/lib/parsetools/test/leex_SUITE.erl
index fba73e3859..eb15bebf63 100644
--- a/lib/parsetools/test/leex_SUITE.erl
+++ b/lib/parsetools/test/leex_SUITE.erl
@@ -44,7 +44,7 @@
pt/1, man/1, ex/1, ex2/1, not_yet/1,
- otp_10302/1, otp_11286/1]).
+ otp_10302/1, otp_11286/1, unicode/1]).
% Default timetrap timeout (set in init_per_testcase).
-define(default_timeout, ?t:minutes(1)).
@@ -65,7 +65,7 @@ all() ->
groups() ->
[{checks, [], [file, compile, syntax]},
- {examples, [], [pt, man, ex, ex2, not_yet]},
+ {examples, [], [pt, man, ex, ex2, not_yet, unicode]},
{tickets, [], [otp_10302, otp_11286]}].
init_per_suite(Config) ->
@@ -400,6 +400,24 @@ pt(Config) when is_list(Config) ->
?line run(Config, Ts),
ok.
+unicode(suite) ->
+ [];
+unicode(Config) when is_list(Config) ->
+ Ts = [{unicode_1,
+ <<"%% -*- coding: utf-8 -*-\n"
+ "Definitions.\n"
+ "RTLarrow = (←)\n"
+ "Rules.\n"
+ "{RTLarrow} : {token,{'<-',TokenLine}}.\n"
+ "Erlang code.\n"
+ "-export([t/0]).\n"
+ "t() -> {ok, [{'<-', 1}], 1} = string(\"←\"), ok.">>,
+ default,
+ ok}],
+
+ ?line run(Config, Ts),
+ ok.
+
man(doc) ->
"Examples from the manpage.";
man(suite) -> [];
@@ -1075,7 +1093,7 @@ run_test(Config, Def, Pre) ->
XrlFile = filename:join(DataDir, DefFile),
ErlFile = filename:join(DataDir, Filename),
Opts = [return, warn_unused_vars,{outdir,DataDir}],
- ok = file:write_file(XrlFile, Def),
+ ok = file:write_file(XrlFile, Def, [{encoding, unicode}]),
LOpts = [return, {report, false} |
case Pre of
default ->