aboutsummaryrefslogtreecommitdiffstats
path: root/lib/stdlib
diff options
context:
space:
mode:
Diffstat (limited to 'lib/stdlib')
-rw-r--r--lib/stdlib/doc/src/epp.xml2
-rw-r--r--lib/stdlib/doc/src/unicode_usage.xml8
-rw-r--r--lib/stdlib/src/epp.erl44
-rw-r--r--lib/stdlib/src/erl_scan.erl2
-rw-r--r--lib/stdlib/src/filename.erl2
-rw-r--r--lib/stdlib/test/filename_SUITE.erl15
6 files changed, 32 insertions, 41 deletions
diff --git a/lib/stdlib/doc/src/epp.xml b/lib/stdlib/doc/src/epp.xml
index a57c7084fa..488499581f 100644
--- a/lib/stdlib/doc/src/epp.xml
+++ b/lib/stdlib/doc/src/epp.xml
@@ -51,7 +51,6 @@
<func>
<name name="open" arity="2"/>
<name name="open" arity="3"/>
- <name name="open" arity="4"/>
<fsummary>Open a file for preprocessing</fsummary>
<desc>
<p>Opens a file for preprocessing.</p>
@@ -76,7 +75,6 @@
</func>
<func>
<name name="parse_file" arity="3"/>
- <name name="parse_file" arity="4"/>
<fsummary>Preprocess and parse an Erlang source file</fsummary>
<desc>
<p>Preprocesses and parses an Erlang source file.
diff --git a/lib/stdlib/doc/src/unicode_usage.xml b/lib/stdlib/doc/src/unicode_usage.xml
index a7e010a05f..b7b5d497d0 100644
--- a/lib/stdlib/doc/src/unicode_usage.xml
+++ b/lib/stdlib/doc/src/unicode_usage.xml
@@ -53,7 +53,7 @@
<item>Basically the same as UTF-32, but without some Unicode semantics, defined by IEEE and has little use as a separate encoding standard. For all normal (and possibly abnormal) usages, UTF-32 and UCS-4 are interchangeable.</item>
</taglist>
<p>Certain ranges of characters are left unused and certain ranges are even deemed invalid. The most notable invalid range is 16#D800 - 16#DFFF, as the UTF-16 encoding does not allow for encoding of these numbers. It can be speculated that the UTF-16 encoding standard was, from the beginning, expected to be able to hold all Unicode characters in one 16-bit entity, but then had to be extended, leaving a hole in the Unicode range to cope with backward compatibility.</p>
-<p>Additionally, the codepoint 16#FEFF is used for byte order marks (BOM's) and use of that character is not encouraged in other contexts than that. It actually is valid though, as the character "ZWNBS" (Zero Width Non Breaking Space). BOM's are used to identify encodings and byte order for programs where such parameters are not known in advance. Byte order marks are more seldom used than one could expect, put their use is becoming more widely spread as they provide the means for programs to make educated guesses about the Unicode format of a certain file.</p>
+<p>Additionally, the codepoint 16#FEFF is used for byte order marks (BOM's) and use of that character is not encouraged in other contexts than that. It actually is valid though, as the character "ZWNBS" (Zero Width Non Breaking Space). BOM's are used to identify encodings and byte order for programs where such parameters are not known in advance. Byte order marks are more seldom used than one could expect, but their use is becoming more widely spread as they provide the means for programs to make educated guesses about the Unicode format of a certain file.</p>
</section>
<section>
<title>Standard Unicode representation in Erlang</title>
@@ -210,6 +210,12 @@ Eshell V5.7 (abort with ^G)
</section>
</section>
<section>
+<title>Unicode in environment variables and parameters</title>
+<p>Environment variables and their interpretation is handled much in the same way as file names. If Unicode file names are enabled, environment variables as well as parameters to the Erlang VM are expected to be in Unicode.</p>
+<p>If Unicode file names are enabled, the calls to <seealso marker="kernel:os#os_getenv/0"><c>os:getenv/0</c></seealso>, <seealso marker="kernel:os#os_getenv/1"><c>os:getenv/1</c></seealso> and <seealso marker="kernel:os#os_putenv/2"><c>os:putenv/2</c></seealso> will handle Unicode strings. On Unix-like platforms, the built-in functions will translate environment variables in UTF-8 to/from Unicode strings, possibly with codepoints > 255. On Windows the Unicode versions of the environment system API will be used, also allowing for codepoints > 255.</p>
+<p>On Unix-like operating systems, parameters are expected to be UTF-8 without translation if Unicode file names are enabled.</p>
+</section>
+<section>
<title>Unicode-aware modules</title>
<p>Most of the modules in Erlang/OTP are of course Unicode-unaware in the sense that they have no notion of Unicode and really shouldn't have. Typically they handle non-textual or byte-oriented data (like <c>gen_tcp</c> etc).</p>
<p>Modules that actually handle textual data (like <c>io_lib</c>, <c>string</c> etc) are sometimes subject to conversion or extension to be able to handle Unicode characters.</p>
diff --git a/lib/stdlib/src/epp.erl b/lib/stdlib/src/epp.erl
index d958b0af2a..ccc14610d7 100644
--- a/lib/stdlib/src/epp.erl
+++ b/lib/stdlib/src/epp.erl
@@ -20,9 +20,9 @@
%% An Erlang code preprocessor.
--export([open/2,open/3,open/4, open/5,close/1,format_error/1]).
+-export([open/2,open/3,open/5,close/1,format_error/1]).
-export([scan_erl_form/1,parse_erl_form/1,macro_defs/1]).
--export([parse_file/1, parse_file/3, parse_file/4]).
+-export([parse_file/1, parse_file/3]).
-export([interpret_file_attribute/1]).
-export([normalize_typed_record_fields/1,restore_typed_record_fields/1]).
@@ -54,14 +54,12 @@
%% open(FileName, IncludePath)
%% open(FileName, IncludePath, PreDefMacros)
-%% open(FileName, StartLocation, IncludePath, PredefMacros)
%% open(FileName, IoDevice, StartLocation, IncludePath, PreDefMacros)
%% close(Epp)
%% scan_erl_form(Epp)
%% parse_erl_form(Epp)
%% parse_file(Epp)
%% parse_file(FileName, IncludePath, PreDefMacros)
-%% parse_file(FileName, StartLocation, IncludePath, PreDefMacros)
%% macro_defs(Epp)
-spec open(FileName, IncludePath) ->
@@ -83,20 +81,8 @@ open(Name, Path) ->
ErrorDescriptor :: term().
open(Name, Path, Pdm) ->
- open(Name, 1, Path, Pdm).
-
--spec open(FileName, StartLocation, IncludePath, PredefMacros) ->
- {'ok', Epp} | {'error', ErrorDescriptor} when
- FileName :: file:name(),
- StartLocation :: erl_scan:location(),
- IncludePath :: [DirectoryName :: file:name()],
- PredefMacros :: macros(),
- Epp :: epp_handle(),
- ErrorDescriptor :: term().
-
-open(Name, StartLocation, Path, Pdm) ->
Self = self(),
- Epp = spawn(fun() -> server(Self, Name, StartLocation, Path, Pdm) end),
+ Epp = spawn(fun() -> server(Self, Name, Path, Pdm) end),
epp_request(Epp).
open(Name, File, StartLocation, Path, Pdm) ->
@@ -192,21 +178,7 @@ format_error(E) -> file:format_error(E).
OpenError :: file:posix() | badarg | system_limit.
parse_file(Ifile, Path, Predefs) ->
- parse_file(Ifile, 1, Path, Predefs).
-
--spec parse_file(FileName, StartLocation, IncludePath, PredefMacros) ->
- {'ok', [Form]} | {error, OpenError} when
- FileName :: file:name(),
- StartLocation :: erl_scan:location(),
- IncludePath :: [DirectoryName :: file:name()],
- Form :: erl_parse:abstract_form() | {'error', ErrorInfo} | {'eof',Line},
- PredefMacros :: macros(),
- Line :: erl_scan:line(),
- ErrorInfo :: erl_scan:error_info() | erl_parse:error_info(),
- OpenError :: file:posix() | badarg | system_limit.
-
-parse_file(Ifile, StartLocation, Path, Predefs) ->
- case open(Ifile, StartLocation, Path, Predefs) of
+ case open(Ifile, Path, Predefs) of
{ok,Epp} ->
Forms = parse_file(Epp),
close(Epp),
@@ -273,12 +245,14 @@ restore_typed_record_fields([{attribute,La,type,{{record,Record},Fields,[]}}|
restore_typed_record_fields([Form|Forms]) ->
[Form|restore_typed_record_fields(Forms)].
-%% server(StarterPid, FileName, Location, Path, PreDefMacros)
-server(Pid, Name, AtLocation, Path, Pdm) ->
+%% server(StarterPid, FileName, Path, PreDefMacros)
+
+server(Pid, Name, Path, Pdm) ->
process_flag(trap_exit, true),
case file:open(Name, [read]) of
{ok,File} ->
- init_server(Pid, Name, File, AtLocation, Path, Pdm, false);
+ Location = 1,
+ init_server(Pid, Name, File, Location, Path, Pdm, false);
{error,E} ->
epp_reply(Pid, {error,E})
end.
diff --git a/lib/stdlib/src/erl_scan.erl b/lib/stdlib/src/erl_scan.erl
index be64b428b1..10b2ed2e49 100644
--- a/lib/stdlib/src/erl_scan.erl
+++ b/lib/stdlib/src/erl_scan.erl
@@ -55,7 +55,7 @@
token_info/1,token_info/2,
attributes_info/1,attributes_info/2,set_attribute/3]).
--export_type([error_info/0, line/0, location/0, tokens_result/0]).
+-export_type([error_info/0, line/0, tokens_result/0]).
%%%
%%% Defines and type definitions
diff --git a/lib/stdlib/src/filename.erl b/lib/stdlib/src/filename.erl
index dbfcbea4f7..870af4e95f 100644
--- a/lib/stdlib/src/filename.erl
+++ b/lib/stdlib/src/filename.erl
@@ -726,6 +726,8 @@ nativename(Name0) ->
_ -> Name
end.
+win32_nativename(Name) when is_binary(Name) ->
+ binary:replace(Name, <<"/">>, <<"\\">>, [global]);
win32_nativename([$/|Rest]) ->
[$\\|win32_nativename(Rest)];
win32_nativename([C|Rest]) ->
diff --git a/lib/stdlib/test/filename_SUITE.erl b/lib/stdlib/test/filename_SUITE.erl
index 4cfa589660..99516c0c04 100644
--- a/lib/stdlib/test/filename_SUITE.erl
+++ b/lib/stdlib/test/filename_SUITE.erl
@@ -25,7 +25,7 @@
-export([pathtype/1,rootname/1,split/1,find_src/1]).
-export([absname_bin/1, absname_bin_2/1,
basename_bin_1/1, basename_bin_2/1,
- dirname_bin/1, extension_bin/1, join_bin/1]).
+ dirname_bin/1, extension_bin/1, join_bin/1, t_nativename_bin/1]).
-export([pathtype_bin/1,rootname_bin/1,split_bin/1]).
-include_lib("test_server/include/test_server.hrl").
@@ -38,7 +38,7 @@ all() ->
join, pathtype, rootname, split, t_nativename, find_src,
absname_bin, absname_bin_2, basename_bin_1, basename_bin_2, dirname_bin,
extension_bin,
- join_bin, pathtype_bin, rootname_bin, split_bin].
+ join_bin, pathtype_bin, rootname_bin, split_bin, t_nativename_bin].
groups() ->
[].
@@ -804,3 +804,14 @@ split_bin(Config) when is_list(Config) ->
ok
end.
+t_nativename_bin(Config) when is_list(Config) ->
+ ?line <<"abcedf">> = filename:nativename(<<"abcedf">>),
+ case os:type() of
+ {win32, _} ->
+ ?line <<"a:\\temp\\arne.exe">> =
+ filename:nativename(<<"A:/temp//arne.exe/">>);
+ _ ->
+ ?line <<"/usr/tmp/arne">> =
+ filename:nativename(<<"/usr/tmp//arne/">>)
+ end.
+