parent
9707b23258
commit
56de4c81b2
3 changed files with 19 additions and 10 deletions
|
|
@ -131,7 +131,10 @@ proc splitSwitch(conf: ConfigRef; switch: string, cmd, arg: var string, pass: TC
|
||||||
else: break
|
else: break
|
||||||
inc(i)
|
inc(i)
|
||||||
if i >= len(switch): arg = ""
|
if i >= len(switch): arg = ""
|
||||||
elif switch[i] in {':', '=', '['}: arg = substr(switch, i + 1)
|
# cmd:arg => (cmd,arg)
|
||||||
|
elif switch[i] in {':', '='}: arg = substr(switch, i + 1)
|
||||||
|
# cmd[sub]:rest => (cmd,[sub]:rest)
|
||||||
|
elif switch[i] == '[': arg = substr(switch, i)
|
||||||
else: invalidCmdLineOption(conf, pass, switch, info)
|
else: invalidCmdLineOption(conf, pass, switch, info)
|
||||||
|
|
||||||
proc processOnOffSwitch(conf: ConfigRef; op: TOptions, arg: string, pass: TCmdLinePass,
|
proc processOnOffSwitch(conf: ConfigRef; op: TOptions, arg: string, pass: TCmdLinePass,
|
||||||
|
|
@ -167,14 +170,20 @@ proc expectNoArg(conf: ConfigRef; switch, arg: string, pass: TCmdLinePass, info:
|
||||||
|
|
||||||
proc processSpecificNote*(arg: string, state: TSpecialWord, pass: TCmdLinePass,
|
proc processSpecificNote*(arg: string, state: TSpecialWord, pass: TCmdLinePass,
|
||||||
info: TLineInfo; orig: string; conf: ConfigRef) =
|
info: TLineInfo; orig: string; conf: ConfigRef) =
|
||||||
var id = "" # arg = "X]:on|off"
|
var id = "" # arg = key:val or [key]:val; with val=on|off
|
||||||
var i = 0
|
var i = 0
|
||||||
var n = hintMin
|
var n = hintMin
|
||||||
while i < len(arg) and (arg[i] != ']'):
|
var isBracket = false
|
||||||
|
if i < len(arg) and arg[i] == '[':
|
||||||
|
isBracket = true
|
||||||
|
inc(i)
|
||||||
|
while i < len(arg) and (arg[i] notin {':', '=', ']'}):
|
||||||
add(id, arg[i])
|
add(id, arg[i])
|
||||||
inc(i)
|
inc(i)
|
||||||
if i < len(arg) and (arg[i] == ']'): inc(i)
|
if isBracket:
|
||||||
else: invalidCmdLineOption(conf, pass, orig, info)
|
if i < len(arg) and arg[i] == ']': inc(i)
|
||||||
|
else: invalidCmdLineOption(conf, pass, orig, info)
|
||||||
|
|
||||||
if i < len(arg) and (arg[i] in {':', '='}): inc(i)
|
if i < len(arg) and (arg[i] in {':', '='}): inc(i)
|
||||||
else: invalidCmdLineOption(conf, pass, orig, info)
|
else: invalidCmdLineOption(conf, pass, orig, info)
|
||||||
if state == wHint:
|
if state == wHint:
|
||||||
|
|
@ -743,11 +752,11 @@ proc processCommand*(switch: string, pass: TCmdLinePass; config: ConfigRef) =
|
||||||
|
|
||||||
proc processSwitch*(pass: TCmdLinePass; p: OptParser; config: ConfigRef) =
|
proc processSwitch*(pass: TCmdLinePass; p: OptParser; config: ConfigRef) =
|
||||||
# hint[X]:off is parsed as (p.key = "hint[X]", p.val = "off")
|
# hint[X]:off is parsed as (p.key = "hint[X]", p.val = "off")
|
||||||
# we fix this here
|
# we transform it to (key = hint, val = [X]:off)
|
||||||
var bracketLe = strutils.find(p.key, '[')
|
var bracketLe = strutils.find(p.key, '[')
|
||||||
if bracketLe >= 0:
|
if bracketLe >= 0:
|
||||||
var key = substr(p.key, 0, bracketLe - 1)
|
var key = substr(p.key, 0, bracketLe - 1)
|
||||||
var val = substr(p.key, bracketLe + 1) & ':' & p.val
|
var val = substr(p.key, bracketLe) & ':' & p.val
|
||||||
processSwitch(key, val, pass, gCmdLineInfo, config)
|
processSwitch(key, val, pass, gCmdLineInfo, config)
|
||||||
else:
|
else:
|
||||||
processSwitch(p.key, p.val, pass, gCmdLineInfo, config)
|
processSwitch(p.key, p.val, pass, gCmdLineInfo, config)
|
||||||
|
|
|
||||||
|
|
@ -175,9 +175,9 @@ proc parseAssignment(L: var TLexer, tok: var TToken;
|
||||||
confTok(L, tok, config, condStack)
|
confTok(L, tok, config, condStack)
|
||||||
if tok.tokType == tkBracketLe:
|
if tok.tokType == tkBracketLe:
|
||||||
# BUGFIX: val, not s!
|
# BUGFIX: val, not s!
|
||||||
# BUGFIX: do not copy '['!
|
|
||||||
confTok(L, tok, config, condStack)
|
confTok(L, tok, config, condStack)
|
||||||
checkSymbol(L, tok)
|
checkSymbol(L, tok)
|
||||||
|
add(val, '[')
|
||||||
add(val, tokToStr(tok))
|
add(val, tokToStr(tok))
|
||||||
confTok(L, tok, config, condStack)
|
confTok(L, tok, config, condStack)
|
||||||
if tok.tokType == tkBracketRi: confTok(L, tok, config, condStack)
|
if tok.tokType == tkBracketRi: confTok(L, tok, config, condStack)
|
||||||
|
|
|
||||||
|
|
@ -73,12 +73,12 @@ proc switch*(key: string, val="") =
|
||||||
proc warning*(name: string; val: bool) =
|
proc warning*(name: string; val: bool) =
|
||||||
## Disables or enables a specific warning.
|
## Disables or enables a specific warning.
|
||||||
let v = if val: "on" else: "off"
|
let v = if val: "on" else: "off"
|
||||||
warningImpl(name & "]:" & v, "warning[" & name & "]:" & v)
|
warningImpl(name & ":" & v, "warning:" & name & ":" & v)
|
||||||
|
|
||||||
proc hint*(name: string; val: bool) =
|
proc hint*(name: string; val: bool) =
|
||||||
## Disables or enables a specific hint.
|
## Disables or enables a specific hint.
|
||||||
let v = if val: "on" else: "off"
|
let v = if val: "on" else: "off"
|
||||||
hintImpl(name & "]:" & v, "hint[" & name & "]:" & v)
|
hintImpl(name & ":" & v, "hint:" & name & ":" & v)
|
||||||
|
|
||||||
proc patchFile*(package, filename, replacement: string) =
|
proc patchFile*(package, filename, replacement: string) =
|
||||||
## Overrides the location of a given file belonging to the
|
## Overrides the location of a given file belonging to the
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue