This commit is contained in:
Andreas Rumpf 2018-01-24 20:08:17 +01:00
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) - ``writeStackTrace`` is now proclaimed to have no IO effect (even though it does)
so that it is more useful for debugging purposes. 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) processOnOffSwitch({optMemTracker}, arg, pass, info)
if optMemTracker in gOptions: defineSymbol("memtracker") if optMemTracker in gOptions: defineSymbol("memtracker")
else: undefSymbol("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 "checks", "x": processOnOffSwitch(ChecksOptions, arg, pass, info)
of "floatchecks": of "floatchecks":
processOnOffSwitch({optNaNCheck, optInfCheck}, arg, pass, info) processOnOffSwitch({optNaNCheck, optInfCheck}, arg, pass, info)

View file

@ -625,7 +625,15 @@ proc getEscapedChar(L: var TLexer, tok: var TToken) =
inc(L.bufpos) # skip '\' inc(L.bufpos) # skip '\'
case L.buf[L.bufpos] case L.buf[L.bufpos]
of 'n', 'N': 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) add(tok.literal, tnl)
inc(L.bufpos) inc(L.bufpos)
of 'r', 'R', 'c', 'C': of 'r', 'R', 'c', 'C':

View file

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

View file

@ -63,6 +63,7 @@ Advanced options:
--memTracker:on|off turn memory tracker on|off --memTracker:on|off turn memory tracker on|off
--excessiveStackTrace:on|off --excessiveStackTrace:on|off
stack traces use full file paths 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 --skipCfg do not read the general configuration file
--skipUserCfg do not read the user's configuration file --skipUserCfg do not read the user's configuration file
--skipParentCfg do not read the parent dirs' configuration files --skipParentCfg do not read the parent dirs' configuration files

View file

@ -163,9 +163,10 @@ contain the following `escape sequences`:idx:\ :
================== =================================================== ================== ===================================================
Escape sequence Meaning Escape sequence Meaning
================== =================================================== ================== ===================================================
``\n`` `newline`:idx: ``\p`` platform specific newline: CRLF on Windows,
LF on Unix
``\r``, ``\c`` `carriage return`:idx: ``\r``, ``\c`` `carriage return`:idx:
``\l`` `line feed`:idx: ``\n``, ``\l`` `line feed`:idx: (often called `newline`:idx:)
``\f`` `form feed`:idx: ``\f`` `form feed`:idx:
``\t`` `tabulator`:idx: ``\t`` `tabulator`:idx:
``\v`` `vertical tabulator`:idx: ``\v`` `vertical tabulator`:idx:
@ -261,7 +262,8 @@ Character literals
------------------ ------------------
Character literals are enclosed in single quotes ``''`` and can contain the 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 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 CR/LF for example). Here are the valid `escape sequences`:idx: for character
literals: literals:
@ -270,7 +272,7 @@ literals:
Escape sequence Meaning Escape sequence Meaning
================== =================================================== ================== ===================================================
``\r``, ``\c`` `carriage return`:idx: ``\r``, ``\c`` `carriage return`:idx:
``\l`` `line feed`:idx: ``\n``, ``\l`` `line feed`:idx:
``\f`` `form feed`:idx: ``\f`` `form feed`:idx:
``\t`` `tabulator`:idx: ``\t`` `tabulator`:idx:
``\v`` `vertical tabulator`:idx: ``\v`` `vertical tabulator`:idx: