From 7eb5f3d81a38ce09d174c6835784a99ab25b03d5 Mon Sep 17 00:00:00 2001 From: Alexandre Duret-Lutz Date: Tue, 25 May 2004 11:05:07 +0000 Subject: [PATCH] * src/sanity/style.test: Catch {.*{ and }.*}. * src/sanity/80columns.test: Untabify files. * iface/gspn/ltlgspn.cc, src/ltlvisit/basereduc.cc: Fix long lines. --- ChangeLog | 4 + iface/gspn/ltlgspn.cc | 3 +- src/ltlvisit/basereduc.cc | 208 +++++++++++++++++++------------------- src/sanity/80columns.test | 16 ++- src/sanity/style.test | 6 ++ 5 files changed, 131 insertions(+), 106 deletions(-) diff --git a/ChangeLog b/ChangeLog index 955a7c801..4b461d577 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,9 @@ 2004-05-25 Alexandre Duret-Lutz + * src/sanity/style.test: Catch {.*{ and }.*}. + * src/sanity/80columns.test: Untabify files. + * iface/gspn/ltlgspn.cc, src/ltlvisit/basereduc.cc: Fix long lines. + * src/ltlvisit/basereduc.cc, src/ltlvisit/reducform.cc, src/ltlvisit/forminf.cc: Remove superfluous spot::ltl:: prefixes. diff --git a/iface/gspn/ltlgspn.cc b/iface/gspn/ltlgspn.cc index 01a5e55cd..75a6cb0dd 100644 --- a/iface/gspn/ltlgspn.cc +++ b/iface/gspn/ltlgspn.cc @@ -63,7 +63,8 @@ syntax(char* prog) #ifdef SSP << " -e3 use semi-d. incl. Couvreur's emptiness-check" << std::endl - << " -e4 use semi-d. incl. Couvreur's emptiness-check's shy variant" + << " -e4 use semi-d. incl. Couvreur's emptiness-check's " + << "shy variant" << std::endl << " -e5 use d. incl. Couvreur's emptiness-check's shy variant" << std::endl diff --git a/src/ltlvisit/basereduc.cc b/src/ltlvisit/basereduc.cc index 738a6cb3e..04f1f7fe7 100644 --- a/src/ltlvisit/basereduc.cc +++ b/src/ltlvisit/basereduc.cc @@ -80,25 +80,28 @@ namespace spot return; case unop::X: - /* X(true) = true - X(false) = false */ + // X(true) = true + // X(false) = false if (node_type(result_) == (node_type_form_visitor::Const)) return; - /* XGF(f) = GF(f) */ + // XGF(f) = GF(f) if (is_GF(result_)) return; - /* X(f1 & GF(f2)) = X(f1) & GF(F2) */ - /* X(f1 | GF(f2)) = X(f1) | GF(F2) */ + // X(f1 & GF(f2)) = X(f1) & GF(F2) + // X(f1 | GF(f2)) = X(f1) | GF(F2) mo = dynamic_cast(result_); if (mo && mo->size() == 2) { + // FIXME: This is incomplete. It should be done for + // multops of any size. if (is_GF(mo->nth(0))) { multop::vec* res = new multop::vec; - res->push_back(unop::instance(unop::F, - basic_reduce_form(mo->nth(1)))); + res->push_back + (unop::instance(unop::F, + basic_reduce_form(mo->nth(1)))); res->push_back(basic_reduce_form(mo->nth(0))); result_ = multop::instance(mo->op(), res); destroy(mo); @@ -107,8 +110,9 @@ namespace spot if (is_GF(mo->nth(1))) { multop::vec* res = new multop::vec; - res->push_back(unop::instance(unop::F, - basic_reduce_form(mo->nth(0)))); + res->push_back + (unop::instance(unop::F, + basic_reduce_form(mo->nth(0)))); res->push_back(basic_reduce_form(mo->nth(1))); result_ = multop::instance(mo->op(), res); destroy(mo); @@ -116,18 +120,17 @@ namespace spot } } - result_ = unop::instance(unop::X, result_); return; case unop::F: - /* F(true) = true - F(false) = false */ + // F(true) = true + // F(false) = false if (node_type(result_) == (node_type_form_visitor::Const)) return; - /* FX(a) = XF(a) */ + // FX(a) = XF(a) u = dynamic_cast(result_); if (u && u->op() == unop::X) { @@ -139,32 +142,34 @@ namespace spot return; } - /* F(f1 & GF(f2)) = F(f1) & GF(F2) */ + // F(f1 & GF(f2)) = F(f1) & GF(F2) mo = dynamic_cast(result_); - if (mo && mo->op() == multop::And) + if (mo && mo->op() == multop::And + // FIXME: This is incomplete. It should be done for + // "And"s of any size. + && mo->size() == 2) { - if (mo->size() == 2) + if (is_GF(mo->nth(0))) { - if (is_GF(mo->nth(0))) - { - multop::vec* res = new multop::vec; - res->push_back(unop::instance(unop::F, - basic_reduce_form(mo->nth(1)))); - res->push_back(basic_reduce_form(mo->nth(0))); - result_ = multop::instance(mo->op(), res); - destroy(mo); - return; - } - if (is_GF(mo->nth(1))) - { - multop::vec* res = new multop::vec; - res->push_back(unop::instance(unop::F, - basic_reduce_form(mo->nth(0)))); - res->push_back(basic_reduce_form(mo->nth(1))); - result_ = multop::instance(mo->op(), res); - destroy(mo); - return; - } + multop::vec* res = new multop::vec; + res->push_back + (unop::instance(unop::F, + basic_reduce_form(mo->nth(1)))); + res->push_back(basic_reduce_form(mo->nth(0))); + result_ = multop::instance(mo->op(), res); + destroy(mo); + return; + } + if (is_GF(mo->nth(1))) + { + multop::vec* res = new multop::vec; + res->push_back + (unop::instance(unop::F, + basic_reduce_form(mo->nth(0)))); + res->push_back(basic_reduce_form(mo->nth(1))); + result_ = multop::instance(mo->op(), res); + destroy(mo); + return; } } @@ -174,12 +179,12 @@ namespace spot case unop::G: - /* G(true) = true - G(false) = false */ + // G(true) = true + // G(false) = false if (node_type(result_) == (node_type_form_visitor::Const)) return; - /* G(a R b) = G(b) */ + // G(a R b) = G(b) bo = dynamic_cast(result_); if (bo && bo->op() == binop::R) { @@ -189,7 +194,7 @@ namespace spot return; } - /* GX(a) = XG(a) */ + // GX(a) = XG(a) u = dynamic_cast(result_); if (u && u->op() == unop::X) { @@ -201,36 +206,37 @@ namespace spot return; } - /* G(f1 | GF(f2)) = G(f1) | GF(F2) */ + // G(f1 | GF(f2)) = G(f1) | GF(F2) mo = dynamic_cast(result_); - if (mo && mo->op() == multop::Or) + if (mo && mo->op() == multop::Or + // FIXME: This is incomplete. It should be done for + // "Or"s of any size. + && mo->size() == 2) { - if (mo->size() == 2) + if (is_GF(mo->nth(0))) { - if (is_GF(mo->nth(0))) - { - multop::vec* res = new multop::vec; - res->push_back(unop::instance(unop::F, - basic_reduce_form(mo->nth(1)))); - res->push_back(basic_reduce_form(mo->nth(0))); - result_ = multop::instance(mo->op(), res); - destroy(mo); - return; - } - if (is_GF(mo->nth(1))) - { - multop::vec* res = new multop::vec; - res->push_back(unop::instance(unop::F, - basic_reduce_form(mo->nth(0)))); - res->push_back(basic_reduce_form(mo->nth(1))); - result_ = multop::instance(mo->op(), res); - destroy(mo); - return; - } + multop::vec* res = new multop::vec; + res->push_back + (unop::instance(unop::F, + basic_reduce_form(mo->nth(1)))); + res->push_back(basic_reduce_form(mo->nth(0))); + result_ = multop::instance(mo->op(), res); + destroy(mo); + return; + } + if (is_GF(mo->nth(1))) + { + multop::vec* res = new multop::vec; + res->push_back + (unop::instance(unop::F, + basic_reduce_form(mo->nth(0)))); + res->push_back(basic_reduce_form(mo->nth(1))); + result_ = multop::instance(mo->op(), res); + destroy(mo); + return; } } - result_ = unop::instance(unop::G, result_); return; } @@ -268,8 +274,8 @@ namespace spot case binop::U: f2 = basic_reduce_form(f2); - /* a U false = false - a U true = true */ + // a U false = false + // a U true = true if (node_type(f2) == (node_type_form_visitor::Const)) { result_ = f2; @@ -278,7 +284,7 @@ namespace spot f1 = basic_reduce_form(f1); - /* X(a) U X(b) = X(a U b) */ + // X(a) U X(b) = X(a U b) fu1 = dynamic_cast(f1); fu2 = dynamic_cast(f2); if ((fu1 && fu2) && @@ -301,8 +307,8 @@ namespace spot case binop::R: f2 = basic_reduce_form(f2); - /* a R false = false - a R true = true */ + // a R false = false + // a R true = true if (node_type(f2) == (node_type_form_visitor::Const)) { result_ = f2; @@ -311,7 +317,7 @@ namespace spot f1 = basic_reduce_form(f1); - /* X(a) R X(b) = X(a R b) */ + // X(a) R X(b) = X(a R b) fu1 = dynamic_cast(f1); fu2 = dynamic_cast(f2); if ((fu1 && fu2) && @@ -375,7 +381,7 @@ namespace spot case node_type_form_visitor::Unop: - /* Xa & Xb = X(a & b)*/ + // Xa & Xb = X(a & b) uo = dynamic_cast(*i); if (uo && uo->op() == unop::X) { @@ -383,7 +389,7 @@ namespace spot break; } - /* FG(a) & FG(b) = FG(a & b)*/ + // FG(a) & FG(b) = FG(a & b) if (is_FG(*i)) { uo2 = dynamic_cast(uo->child()); @@ -395,19 +401,18 @@ namespace spot case node_type_form_visitor::Binop: - /* (a U b) & (c U b) = (a & c) U b */ + // (a U b) & (c U b) = (a & c) U b if (dynamic_cast(*i)->op() == binop::U) { ftmp = dynamic_cast(*i)->second(); tmpUright = new multop::vec; for (multop::vec::iterator j = i; j != res->end(); j++) { - if (*j == NULL) + if (!*j) continue; - if ((node_type(*j) == node_type_form_visitor::Binop) - && - (dynamic_cast(*j)->op() == binop::U) && - (ftmp == dynamic_cast(*j)->second())) + if (node_type(*j) == node_type_form_visitor::Binop + && dynamic_cast(*j)->op() == binop::U + && ftmp == dynamic_cast(*j)->second()) { bo = dynamic_cast(*j); tmpUright @@ -415,7 +420,7 @@ namespace spot if (j != i) { destroy(*j); - *j = NULL; + *j = 0; } } } @@ -429,19 +434,18 @@ namespace spot break; } - /* (a R b) & (a R c) = a R (b & c) */ + // (a R b) & (a R c) = a R (b & c) if (dynamic_cast(*i)->op() == binop::R) { ftmp = dynamic_cast(*i)->first(); tmpRright = new multop::vec; for (multop::vec::iterator j = i; j != res->end(); j++) { - if (*j == NULL) + if (!*j) continue; - if ((node_type(*j) == node_type_form_visitor::Binop) - && - (dynamic_cast(*j)->op() == binop::R) && - (ftmp == dynamic_cast(*j)->first())) + if (node_type(*j) == node_type_form_visitor::Binop + && dynamic_cast(*j)->op() == binop::R + && ftmp == dynamic_cast(*j)->first()) { bo = dynamic_cast(*j); tmpRright @@ -449,7 +453,7 @@ namespace spot if (j != i) { destroy(*j); - *j = NULL; + *j = 0; } } } @@ -479,14 +483,14 @@ namespace spot for (multop::vec::iterator i = res->begin(); i != res->end(); i++) { - if (*i == NULL) + if (!*i) continue; switch (node_type(*i)) { case node_type_form_visitor::Unop: - /* Xa | Xb = X(a | b)*/ + // Xa | Xb = X(a | b) uo = dynamic_cast(*i); if (uo && uo->op() == unop::X) { @@ -494,7 +498,7 @@ namespace spot break; } - /* GF(a) | GF(b) = GF(a | b)*/ + // GF(a) | GF(b) = GF(a | b) if (is_GF(*i)) { uo2 = dynamic_cast(uo->child()); @@ -506,19 +510,18 @@ namespace spot case node_type_form_visitor::Binop: - /* (a U b) | (a U c) = a U (b | c) */ + // (a U b) | (a U c) = a U (b | c) if (dynamic_cast(*i)->op() == binop::U) { ftmp = dynamic_cast(*i)->first(); tmpUright = new multop::vec; for (multop::vec::iterator j = i; j != res->end(); j++) { - if (*j == NULL) + if (!*j) continue; - if ((node_type(*j) == node_type_form_visitor::Binop) - && - (dynamic_cast(*j)->op() == binop::U) && - (ftmp == dynamic_cast(*j)->first())) + if (node_type(*j) == node_type_form_visitor::Binop + && dynamic_cast(*j)->op() == binop::U + && ftmp == dynamic_cast(*j)->first()) { bo = dynamic_cast(*j); tmpUright @@ -526,7 +529,7 @@ namespace spot if (j != i) { destroy(*j); - *j = NULL; + *j = 0; } } } @@ -538,19 +541,18 @@ namespace spot break; } - /* (a R b) | (c R b) = (a | c) R b */ + // (a R b) | (c R b) = (a | c) R b if (dynamic_cast(*i)->op() == binop::R) { ftmp = dynamic_cast(*i)->second(); tmpRright = new multop::vec; for (multop::vec::iterator j = i; j != res->end(); j++) { - if (*j == NULL) + if (!*j) continue; - if ((node_type(*j) == node_type_form_visitor::Binop) - && - (dynamic_cast(*j)->op() == binop::R) && - (ftmp == dynamic_cast(*j)->second())) + if (node_type(*j) == node_type_form_visitor::Binop + && dynamic_cast(*j)->op() == binop::R + && ftmp == dynamic_cast(*j)->second()) { bo = dynamic_cast(*j); tmpRright @@ -558,7 +560,7 @@ namespace spot if (j != i) { destroy(*j); - *j = NULL; + *j = 0; } } } diff --git a/src/sanity/80columns.test b/src/sanity/80columns.test index 31231d12b..1028d84c0 100755 --- a/src/sanity/80columns.test +++ b/src/sanity/80columns.test @@ -4,6 +4,18 @@ set -e +untabify() +{ + perl -pe 's/^((.{8})*)\t/$1 /g; + s/^(.(.{8})*)\t/$1 /g; + s/^(..(.{8})*)\t/$1 /g; + s/^(...(.{8})*)\t/$1 /g; + s/^(....(.{8})*)\t/$1 /g; + s/^(.....(.{8})*)\t/$1 /g; + s/^(......(.{8})*)\t/$1 /g; + s/^(.......(.{8})*)\t/$1 /g;' $1 +} + rm -f failures for dir in "${INCDIR-..}" "${INCDIR-..}"/../iface; do @@ -11,8 +23,8 @@ for dir in "${INCDIR-..}" "${INCDIR-..}"/../iface; do find "$dir" \( -name "${1-*}.hh" -o -name "${1-*}.cc" \ -o -name "${1-*}.test" \) -a -type f -a -print | while read file; do - x='.........................................' - if grep -q $x$x "$file"; then + x='........................................' + if (untabify $file | grep -q $x.$x) 2>/dev/null; then if grep 'GNU Bison' "$file" >/dev/null || grep 'generated by flex' "$file" >/dev/null ; then : diff --git a/src/sanity/style.test b/src/sanity/style.test index 0d44afe33..5a57c53ce 100755 --- a/src/sanity/style.test +++ b/src/sanity/style.test @@ -98,6 +98,12 @@ for dir in "${INCDIR-..}" "${INCDIR-..}"/../iface; do grep -v 'for (;;)' $tmp | grep ';[^ ")]' && diag 'Must have space or newline after semicolon.' + grep '}.*}' $tmp && + diag 'No two } on the same line.' + + grep '{.*{' $tmp && + diag 'No two { on the same line.' + $fail && echo "$file" >>failures done done