This commit is contained in:
Andreas Rumpf
2018-01-24 20:08:17 +01:00
parent cd26d02882
commit 80caca15bd
6 changed files with 30 additions and 5 deletions

View File

@@ -223,3 +223,6 @@ styledEcho "Red on Green.", resetStyle
- ``writeStackTrace`` is now proclaimed to have no IO effect (even though it does)
so that it is more useful for debugging purposes.
- ``\n`` is now only the single line feed character like in most
other programming languages. The new platform specific newline escape sequence is
written as ``\p``. This change only affects the Windows platform.

View File

@@ -471,6 +471,16 @@ proc processSwitch(switch, arg: string, pass: TCmdLinePass, info: TLineInfo;
processOnOffSwitch({optMemTracker}, arg, pass, info)
if optMemTracker in gOptions: defineSymbol("memtracker")
else: undefSymbol("memtracker")
of "oldnewlines":
case arg.normalize
of "on":
options.gOldNewlines = true
defineSymbol("nimOldNewlines")
of "off":
options.gOldNewlines = false
undefSymbol("nimOldNewlines")
else:
localError(info, errOnOrOffExpectedButXFound, arg)
of "checks", "x": processOnOffSwitch(ChecksOptions, arg, pass, info)
of "floatchecks":
processOnOffSwitch({optNaNCheck, optInfCheck}, arg, pass, info)

View File

@@ -625,7 +625,15 @@ proc getEscapedChar(L: var TLexer, tok: var TToken) =
inc(L.bufpos) # skip '\'
case L.buf[L.bufpos]
of 'n', 'N':
if tok.tokType == tkCharLit: lexMessage(L, errNnotAllowedInCharacter)
if gOldNewlines:
if tok.tokType == tkCharLit: lexMessage(L, errNnotAllowedInCharacter)
add(tok.literal, tnl)
else:
add(tok.literal, '\L')
inc(L.bufpos)
of 'p', 'P':
if tok.tokType == tkCharLit:
lexMessage(L, errGenerated, "\\p not allowed in character literal")
add(tok.literal, tnl)
inc(L.bufpos)
of 'r', 'R', 'c', 'C':

View File

@@ -114,6 +114,7 @@ proc cppDefine*(c: ConfigRef; define: string) =
var
gIdeCmd*: IdeCmd
gOldNewlines*: bool
const
ChecksOptions* = {optObjCheck, optFieldCheck, optRangeCheck, optNilCheck,

View File

@@ -63,6 +63,7 @@ Advanced options:
--memTracker:on|off turn memory tracker on|off
--excessiveStackTrace:on|off
stack traces use full file paths
--oldNewlines:on|off turn on|off the old behaviour of "\n"
--skipCfg do not read the general configuration file
--skipUserCfg do not read the user's configuration file
--skipParentCfg do not read the parent dirs' configuration files

View File

@@ -163,9 +163,10 @@ contain the following `escape sequences`:idx:\ :
================== ===================================================
Escape sequence Meaning
================== ===================================================
``\n`` `newline`:idx:
``\p`` platform specific newline: CRLF on Windows,
LF on Unix
``\r``, ``\c`` `carriage return`:idx:
``\l`` `line feed`:idx:
``\n``, ``\l`` `line feed`:idx: (often called `newline`:idx:)
``\f`` `form feed`:idx:
``\t`` `tabulator`:idx:
``\v`` `vertical tabulator`:idx:
@@ -261,7 +262,8 @@ Character literals
------------------
Character literals are enclosed in single quotes ``''`` and can contain the
same escape sequences as strings - with one exception: `newline`:idx: (``\n``)
same escape sequences as strings - with one exception: the platform
dependent `newline`:idx: (``\p``)
is not allowed as it may be wider than one character (often it is the pair
CR/LF for example). Here are the valid `escape sequences`:idx: for character
literals:
@@ -270,7 +272,7 @@ literals:
Escape sequence Meaning
================== ===================================================
``\r``, ``\c`` `carriage return`:idx:
``\l`` `line feed`:idx:
``\n``, ``\l`` `line feed`:idx:
``\f`` `form feed`:idx:
``\t`` `tabulator`:idx:
``\v`` `vertical tabulator`:idx: