RosettaCodeData/Task/Update-a-configuration-file/TXR/update-a-configuration-file.txr
Ingy döt Net 68f8f3e56b all tasks
2013-04-11 01:07:29 -07:00

76 lines
1.2 KiB
Text

@(next :args)
@configfile
@(maybe)
@ (next configfile)
@ (collect :vars (config))
@config
@ (end)
@(end)
@(collect)
@ (cases)
@option=
@ (output :into new_opt_line :filter :upcase)
; @option
@ (end)
@ (or)
@option=@val
@ (output :into new_opt_line :filter :upcase)
@option @val
@ (end)
@ (or)
@option
@ (output :into new_opt_line :filter :upcase)
@option
@ (end)
@ (end)
@ (next :var config)
@ (local new_config)
@ (bind new_config ())
@ (collect :vars ((opt_there "")))
@ (block)
@ (cases)
@ (cases)
@{line /[ \t]*/}
@ (or)
@{line /#.*/}
@ (end)
@ (output :append :into new_config)
@line
@ (end)
@ (accept)
@ (or)
@ (maybe)
; @opt_there
@ (or)
@opt_there @(skip)
@ (or)
@opt_there
@ (or)
@original_line
@ (end)
@ (end)
@ (cases)
@ (bind opt_there option :filter :upcase)
@ (output :append :into new_config)
@new_opt_line
@ (end)
@ (or)
@ (output :append :into new_config)
@original_line
@ (end)
@ (end)
@ (end)
@ (cases)
@ (bind opt_there option :filter :upcase)
@ (or)
@ (output :append :into new_config)
@new_opt_line
@ (end)
@ (end)
@ (set config new_config)
@(end)
@(output)
@ (repeat)
@config
@ (end)
@(end)