bin: --stats=%H --stats=%h

Part of #91.

* bin/common_aoutput.cc, bin/common_aoutput.hh: implement %H and %h.
* tests/core/readsave.test: Test them.
* NEWS: Mention it.
This commit is contained in:
Alexandre Duret-Lutz 2016-08-08 10:48:06 +02:00
parent 0d753048ce
commit f423c424eb
4 changed files with 57 additions and 1 deletions

View file

@ -152,6 +152,9 @@ static const argp_option io_options[] =
" minuscules for output):", 4 },
{ "%F", 0, nullptr, OPTION_DOC | OPTION_NO_USAGE, F_doc, 0 },
{ "%L", 0, nullptr, OPTION_DOC | OPTION_NO_USAGE, L_doc, 0 },
{ "%H, %h", 0, nullptr, OPTION_DOC | OPTION_NO_USAGE,
"the automaton in HOA format on a single line (use %[opt]H or %[opt]h "
"to specify additional options as in --hoa=opt)", 0 },
{ "%M, %m", 0, nullptr, OPTION_DOC | OPTION_NO_USAGE,
"name of the automaton", 0 },
{ "%S, %s", 0, nullptr, OPTION_DOC | OPTION_NO_USAGE,
@ -192,6 +195,9 @@ static const argp_option o_options[] =
"the following interpreted sequences:", 4 },
{ "%F", 0, nullptr, OPTION_DOC | OPTION_NO_USAGE, F_doc, 0 },
{ "%L", 0, nullptr, OPTION_DOC | OPTION_NO_USAGE, L_doc, 0 },
{ "%h", 0, nullptr, OPTION_DOC | OPTION_NO_USAGE,
"the automaton in HOA format on a single line (use %[opt]h "
"to specify additional options as in --hoa=opt)", 0 },
{ "%m", 0, nullptr, OPTION_DOC | OPTION_NO_USAGE,
"name of the automaton", 0 },
{ "%s", 0, nullptr, OPTION_DOC | OPTION_NO_USAGE,
@ -396,3 +402,17 @@ void automaton_printer::add_stat(char c, const spot::printable* p)
statistics.declare(c, p);
outputnamer.declare(c, p);
}
void printable_automaton::print(std::ostream& os, const char* pos) const
{
std::string options = "l";
if (*pos == '[')
{
++pos;
auto end = strchr(pos, ']');
options = std::string(pos, end - pos);
options += 'l';
pos = end + 1;
}
print_hoa(os, val_, options.c_str());
}