summaryrefslogtreecommitdiff
path: root/src/printer/printer.h
diff options
context:
space:
mode:
authorMorgan Deters <mdeters@cs.nyu.edu>2013-12-24 13:24:56 -0500
committerMorgan Deters <mdeters@cs.nyu.edu>2013-12-24 13:24:56 -0500
commite23a40c0d121209afecff21ce5c6ed6e644bfb0e (patch)
tree03752744a3388bd716c83c1dd3a4ba29556bb062 /src/printer/printer.h
parentf42dcea977ed9180481cc842531e2c5372acbbe1 (diff)
Better automatic handling of output language setting.
Diffstat (limited to 'src/printer/printer.h')
-rw-r--r--src/printer/printer.h16
1 files changed, 15 insertions, 1 deletions
diff --git a/src/printer/printer.h b/src/printer/printer.h
index a7ae8c447..9ddac096d 100644
--- a/src/printer/printer.h
+++ b/src/printer/printer.h
@@ -54,7 +54,21 @@ public:
/** Get the Printer for a given OutputLanguage */
static Printer* getPrinter(OutputLanguage lang) throw() {
if(lang == language::output::LANG_AUTO) {
- lang = language::output::LANG_CVC4; // default
+ // Infer the language to use for output.
+ //
+ // Options can be null in certain circumstances (e.g., when printing
+ // the singleton "null" expr. So we guard against segfault
+ if(&Options::current() != NULL) {
+ if(options::outputLanguage.wasSetByUser()) {
+ lang = options::outputLanguage();
+ }
+ if(lang == language::output::LANG_AUTO && options::inputLanguage.wasSetByUser()) {
+ lang = language::toOutputLanguage(options::inputLanguage());
+ }
+ }
+ if(lang == language::output::LANG_AUTO) {
+ lang = language::output::LANG_CVC4; // default
+ }
}
if(d_printers[lang] == NULL) {
d_printers[lang] = makePrinter(lang);
generated by cgit on debian on lair
contact matthew@masot.net with questions or feedback