diff options
author | Araq <rumpf_a@web.de> | 2018-04-30 19:51:26 +0200 |
---|---|---|
committer | Araq <rumpf_a@web.de> | 2018-04-30 19:51:26 +0200 |
commit | 1a3b35603ce5eb3f6770e30fe930743edcfcbc68 (patch) | |
tree | 59dd58f350850dbc626321c0fbffea7f85bdb80b /compiler | |
parent | 85af8fb74cc06ea6044b8796791d7415d4a5f22f (diff) | |
parent | 0d2f8795ca7a6ce46e948f1dab1413872c4f688e (diff) | |
download | Nim-1a3b35603ce5eb3f6770e30fe930743edcfcbc68.tar.gz |
Merge branch 'araq-strings-v1' into devel
Diffstat (limited to 'compiler')
-rw-r--r-- | compiler/ccgexprs.nim | 11 | ||||
-rw-r--r-- | compiler/commands.nim | 4 | ||||
-rw-r--r-- | compiler/condsyms.nim | 1 | ||||
-rw-r--r-- | compiler/msgs.nim | 4 |
4 files changed, 15 insertions, 5 deletions
diff --git a/compiler/ccgexprs.nim b/compiler/ccgexprs.nim index eb67db2b3..a3a85a3dc 100644 --- a/compiler/ccgexprs.nim +++ b/compiler/ccgexprs.nim @@ -909,9 +909,14 @@ proc genSeqElem(p: BProc, n, x, y: PNode, d: var TLoc) = if ty.kind in {tyRef, tyPtr}: ty = skipTypes(ty.lastSon, abstractVarRange) # emit range check: if optBoundsCheck in p.options: - linefmt(p, cpsStmts, - "if (!$2 || (NU)($1) >= (NU)($2->$3)) #raiseIndexError();$n", - rdLoc(b), rdLoc(a), lenField(p)) + if ty.kind == tyString and not defined(nimNoZeroTerminator): + linefmt(p, cpsStmts, + "if (!$2 || (NU)($1) > (NU)($2->$3)) #raiseIndexError();$n", + rdLoc(b), rdLoc(a), lenField(p)) + else: + linefmt(p, cpsStmts, + "if (!$2 || (NU)($1) >= (NU)($2->$3)) #raiseIndexError();$n", + rdLoc(b), rdLoc(a), lenField(p)) if d.k == locNone: d.storage = OnHeap if skipTypes(a.t, abstractVar).kind in {tyRef, tyPtr}: a.r = rfmt(nil, "(*$1)", a.r) diff --git a/compiler/commands.nim b/compiler/commands.nim index 34debbc49..364b1c43a 100644 --- a/compiler/commands.nim +++ b/compiler/commands.nim @@ -188,11 +188,11 @@ proc processSpecificNote*(arg: string, state: TSpecialWord, pass: TCmdLinePass, if i < len(arg) and (arg[i] in {':', '='}): inc(i) else: invalidCmdLineOption(pass, orig, info) if state == wHint: - var x = findStr(msgs.HintsToStr, id) + let x = findStr(msgs.HintsToStr, id) if x >= 0: n = TNoteKind(x + ord(hintMin)) else: localError(info, "unknown hint: " & id) else: - var x = findStr(msgs.WarningsToStr, id) + let x = findStr(msgs.WarningsToStr, id) if x >= 0: n = TNoteKind(x + ord(warnMin)) else: localError(info, "unknown warning: " & id) case substr(arg, i).normalize diff --git a/compiler/condsyms.nim b/compiler/condsyms.nim index 08dda9b6a..b1d0ccc7a 100644 --- a/compiler/condsyms.nim +++ b/compiler/condsyms.nim @@ -115,3 +115,4 @@ proc initDefines*() = defineSymbol("nimSymKind") defineSymbol("nimVmEqIdent") defineSymbol("nimNoNil") + defineSymbol("nimNoZeroTerminator") diff --git a/compiler/msgs.nim b/compiler/msgs.nim index 5ae2c4970..838735753 100644 --- a/compiler/msgs.nim +++ b/compiler/msgs.nim @@ -474,6 +474,10 @@ const hintMin* = hintSuccess hintMax* = high(TMsgKind) +static: + doAssert HintsToStr.len == ord(hintMax) - ord(hintMin) + 1 + doAssert WarningsToStr.len == ord(warnMax) - ord(warnMin) + 1 + type TNoteKind* = range[warnMin..hintMax] # "notes" are warnings or hints TNoteKinds* = set[TNoteKind] |