Quellcode durchsuchen

Revert "add encoding support for template."

This reverts commit 025a96b143.
pull/2233/head
Takuya Shiozaki vor 5 Jahren
Ursprung
Commit
b27442f720
3 geänderte Dateien mit 6 neuen und 18 gelöschten Zeilen
  1. +1
    -1
      src/rebar_prv_shell.erl
  2. +3
    -11
      src/rebar_string.erl
  3. +2
    -6
      src/rebar_templater.erl

+ 1
- 1
src/rebar_prv_shell.erl Datei anzeigen

@ -571,7 +571,7 @@ consult_env_config(State, Filename) ->
{ok, Bin} -> unicode:characters_to_list(Bin)
end,
ReplacedStr = replace_env_vars(RawString),
case rebar_string:consult(ReplacedStr, utf8) of
case rebar_string:consult(unicode:characters_to_list(ReplacedStr)) of
{error, Reason} ->
throw(?PRV_ERROR({bad_term_file, Filename, Reason}));
[Terms] ->

+ 3
- 11
src/rebar_string.erl Datei anzeigen

@ -6,7 +6,7 @@
%% Compatibility exports
-export([join/2, split/2, lexemes/2, trim/1, trim/3, uppercase/1, lowercase/1, chr/2]).
%% Util exports
-export([consult/1, consult/2]).
-export([consult/1]).
-ifdef(unicode_str).
@ -55,17 +55,9 @@ chr(Str, Char) -> string:chr(Str, Char).
%% @doc
%% Given a string or binary, parse it into a list of terms, ala file:consult/1
-spec consult(unicode:chardata(), epp:source_encoding() | none) -> {error, term()} | [term()].
consult(Str, none) ->
consult(Str, epp:default_encoding());
consult(Bin, latin1) when is_binary(Bin) ->
consult([], binary_to_list(Bin), []);
consult(Str, _) ->
consult([], unicode:characters_to_list(Str), []).
%% Backward compatibility for plugins.
-spec consult(unicode:chardata()) -> {error, term()} | [term()].
consult(Str) -> consult(Str, utf8).
consult(Str) ->
consult([], unicode:characters_to_list(Str), []).
consult(Cont, Str, Acc) ->
case erl_scan:tokens(Cont, Str, 0) of

+ 2
- 6
src/rebar_templater.erl Datei anzeigen

@ -59,7 +59,7 @@ list_templates(State) ->
%% Expand a single template's value
list_template(Files, {Name, Type, File}, State) ->
case consult_template(Files, Type, File) of
case rebar_string:consult(binary_to_list(load_file(Files, Type, File))) of
{error, Reason} ->
{error, {consult, File, Reason}};
TemplateTerms ->
@ -158,7 +158,7 @@ drop_var_docs([{K,V}|Rest]) -> [{K,V} | drop_var_docs(Rest)].
%% Load the template index, resolve all variables, and then execute
%% the template.
create({Template, Type, File}, Files, UserVars, Force, State) ->
TemplateTerms = consult_template(Files, Type, File),
TemplateTerms = rebar_string:consult(binary_to_list(load_file(Files, Type, File))),
Vars = drop_var_docs(override_vars(UserVars, get_template_vars(TemplateTerms, State))),
maybe_warn_about_name(Vars),
TemplateCwd = filename:dirname(File),
@ -439,7 +439,3 @@ render(Bin, Context) ->
[{key_type, atom},
{escape_fun, fun(X) -> X end}] % disable HTML-style escaping
).
consult_template(Files, Type, File) ->
TemplateBin = load_file(Files, Type, File),
rebar_string:consult(TemplateBin, epp:read_encoding_from_binary(TemplateBin)).

Laden…
Abbrechen
Speichern