- Added colour output, with --monochrome switch to disable this.

This commit is contained in:
ccremers 2005-12-28 15:27:22 +00:00
parent e19f8bddd1
commit ab75acea62
3 changed files with 77 additions and 16 deletions

View File

@ -60,6 +60,7 @@ enum exittypes
#include "binding.h" #include "binding.h"
#include "switches.h" #include "switches.h"
#include "specialterm.h" #include "specialterm.h"
#include "color.h"
// The global system state // The global system state
System sys; System sys;
@ -103,6 +104,9 @@ main (int argc, char **argv)
/* process any command-line switches */ /* process any command-line switches */
switchesInit (argc, argv); switchesInit (argc, argv);
/* process colors */
colorInit ();
/* start system */ /* start system */
sys = systemInit (); sys = systemInit ();
@ -267,6 +271,7 @@ main (int argc, char **argv)
} }
knowledgeDestroy (sys->know); knowledgeDestroy (sys->know);
systemDone (sys); systemDone (sys);
colorDone ();
compilerDone (); compilerDone ();
/* done symbols */ /* done symbols */
@ -285,6 +290,37 @@ exit:
return exitcode; return exitcode;
} }
//! Print something bad
void
printBad (char *s)
{
eprintf ("%s%s%s", COLOR_Red, s, COLOR_Reset);
}
//! Print something good
void
printGood (char *s)
{
eprintf ("%s%s%s", COLOR_Green, s, COLOR_Reset);
}
//! Print state (existState, isAttack)
/**
* Fail == ( existState xor isAttack )
*/
void
printOkFail (int existState, int isAttack)
{
if (existState != isAttack)
{
printGood ("Ok");
}
else
{
printBad ("Fail");
}
}
//! Display time and state space size information using ASCII. //! Display time and state space size information using ASCII.
/** /**
* Displays also whether an attack was found or not. * Displays also whether an attack was found or not.
@ -379,7 +415,17 @@ timersPrint (const System sys)
Term pname; Term pname;
Term rname; Term rname;
Termlist labellist; Termlist labellist;
int isAttack; // stores whether this claim failure constitutes an attack or not
if (isTermEqual (cl_scan->type, CLAIM_Reachable))
{
// An attack on reachable is not really an attack, we're just generating the state space
isAttack = false;
}
else
{
isAttack = true;
}
anyclaims = true; anyclaims = true;
eprintf ("claim\t"); eprintf ("claim\t");
@ -452,20 +498,10 @@ timersPrint (const System sys)
/* now report the status */ /* now report the status */
eprintf ("\t"); eprintf ("\t");
eprintf ("attacks: ");
if (cl_scan->count > 0 && cl_scan->failed > 0) if (cl_scan->count > 0 && cl_scan->failed > 0)
{ {
/* there is an attack */ /* there is a state */
if (!isTermEqual (cl_scan->type, CLAIM_Reachable)) printOkFail (true, isAttack);
{
/* a normal claim */
eprintf ("yes");
}
else
{
/* Reachable is not an attack */
eprintf ("no");
}
eprintf ("\t"); eprintf ("\t");
/* are these all attacks? */ /* are these all attacks? */
@ -478,7 +514,15 @@ timersPrint (const System sys)
{ {
eprintf ("at least"); eprintf ("at least");
} }
eprintf (" %i variant", cl_scan->failed); eprintf (" %i ", cl_scan->failed);
if (isAttack)
{
eprintf ("attack");
}
else
{
eprintf ("variant");
}
if (cl_scan->failed != 1) if (cl_scan->failed != 1)
{ {
eprintf ("s"); eprintf ("s");
@ -487,8 +531,9 @@ timersPrint (const System sys)
} }
else else
{ {
/* no attack */ /* no state */
eprintf ("no\t"); printOkFail (false, isAttack);
eprintf ("\t");
/* subcases */ /* subcases */
if (cl_scan->count == 0) if (cl_scan->count == 0)
@ -502,7 +547,8 @@ timersPrint (const System sys)
if (cl_scan->complete) if (cl_scan->complete)
{ {
/* complete proof */ /* complete proof */
eprintf ("[proof of correctness]"); eprintf ("[%sproof of correctness%s]", COLOR_Bold,
COLOR_Reset);
} }
else else
{ {

View File

@ -89,6 +89,7 @@ switchesInit (int argc, char **argv)
switches.reportStates = 0; switches.reportStates = 0;
switches.extendNonReads = 0; // default off switches.extendNonReads = 0; // default off
switches.extendTrivial = 0; // default off switches.extendTrivial = 0; // default off
switches.monochrome = false; // default colors
// Obsolete // Obsolete
switches.latex = 0; // latex output? switches.latex = 0; // latex output?
@ -898,6 +899,19 @@ switcher (const int process, int index)
} }
} }
if (detect (' ', "monochrome", 0))
{
if (!process)
{
helptext ("--monochrome", "disable color terminal output");
}
else
{
switches.monochrome = true;
return index;
}
}
#ifdef DEBUG #ifdef DEBUG
if (detect ('D', "debug", 1)) if (detect ('D', "debug", 1))
{ {

View File

@ -68,6 +68,7 @@ struct switchdata
int reportStates; //!< Progress display switch. (traversed states) int reportStates; //!< Progress display switch. (traversed states)
int extendNonReads; //!< Show further events in arachne xml output. int extendNonReads; //!< Show further events in arachne xml output.
int extendTrivial; //!< Show further events in arachne xml output, based on knowledge underapproximation. (Includes at least the events of the nonreads extension) int extendTrivial; //!< Show further events in arachne xml output, based on knowledge underapproximation. (Includes at least the events of the nonreads extension)
int monochrome; //!< Disable color output
//! Latex output switch. //! Latex output switch.
/** /**