From f3cee0e9f409c5850709f11ba15cec22d7387401 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bj=C3=B6rn=20Gustavsson?= Date: Mon, 3 Mar 2014 13:50:23 +0100 Subject: epp: Make it possible to specify a default encoding In the next commit, we will need a way to tell epp which the default encoding should be for files that have no encoding comment. We could add new open() and parse_file() functions with one extra argument for the encoding, but there are already too many variants. To avoid having to add an additional argument to epp:open() and epp:parse_file() each time new options are needed, introduce epp:open/1 and epp:parse_file/2 that takes a property list with options. Also support the new 'default_encoding' option for specifying the default encoding for source files. Thanks to Richard Carlsson for the idea and the implementation of the new functionality in epp.erl. --- lib/stdlib/doc/src/epp.xml | 56 +++++++++++++++++++++++++++++++++++++++++----- 1 file changed, 51 insertions(+), 5 deletions(-) (limited to 'lib/stdlib/doc/src/epp.xml') diff --git a/lib/stdlib/doc/src/epp.xml b/lib/stdlib/doc/src/epp.xml index cf33530395..50baad04a9 100644 --- a/lib/stdlib/doc/src/epp.xml +++ b/lib/stdlib/doc/src/epp.xml @@ -63,12 +63,30 @@ + + + Open a file for preprocessing + +

Opens a file for preprocessing.

+

If extra is given in + Options, the return value will be + {ok, Epp, Extra} instead + of {ok, Epp}.

+
+
+ Open a file for preprocessing + +

Equivalent to epp:open([{name, FileName}, {includes, IncludePath}]).

+
+
+ Open a file for preprocessing -

Opens a file for preprocessing.

+

Equivalent to epp:open([{name, FileName}, {includes, IncludePath}, + {macros, PredefMacros}]).

@@ -89,12 +107,24 @@ - + Preprocess and parse an Erlang source file

Preprocesses and parses an Erlang source file. - Note that the tuple {eof, Line} returned at end-of-file is - included as a "form".

+ Note that the tuple {eof, Line} returned + at end-of-file is included as a "form".

+

If extra is given in + Options, the return value will be + {ok, [Form], Extra} instead + of {ok, [Form]}.

+
+
+ + + Preprocess and parse an Erlang source file + +

Equivalent to epp:parse_file(FileName, [{includes, IncludePath}, + {macros, PredefMacros}]).

@@ -111,7 +141,7 @@

Returns a string representation of an encoding. The string is recognized by read_encoding/1,2, read_encoding_from_binary/1,2, and - set_encoding/1 as a valid encoding.

+ set_encoding/1,2 as a valid encoding.

@@ -156,6 +186,22 @@ encoding was found.

+ + + Read and set the encoding of an IO device + +

Reads the encoding from + an IO device and sets the encoding of the device + accordingly. The position of the IO device referenced by + File is not affected. If no valid + encoding can be read from the IO device the encoding of the + IO device is set to the + encoding given by + Default.

+

Returns the read encoding, or none if no valid + encoding was found.

+
+
Format an error descriptor -- cgit v1.2.3