/// Exception-safe version of sqlite3_open_v2. /// /// \param file The path to the database file to be opened. /// \param flags The flags to be passed to the open routine. /// /// \return The opened database. /// /// \throw std::bad_alloc If there is not enough memory to open the /// database. /// \throw api_error If there is any problem opening the database. static ::sqlite3* safe_open(const char* file, const int flags) { ::sqlite3* db; const int error = ::sqlite3_open_v2(file, &db, flags, NULL); if (error != SQLITE_OK) { if (db == NULL) throw std::bad_alloc(); else { sqlite::database error_db(db, true); throw sqlite::api_error::from_database(error_db, "sqlite3_open_v2"); } } INV(db != NULL); return db; }
static atf_error_t srcdir_strip_libtool(atf_fs_path_t *srcdir) { atf_error_t err; atf_fs_path_t parent; err = atf_fs_path_branch_path(srcdir, &parent); if (atf_is_error(err)) goto out; atf_fs_path_fini(srcdir); *srcdir = parent; INV(!atf_is_error(err)); out: return err; }
Word RMCONS(Word r, Word J) { Word J1,Jh,Jh1,Jp; Step1: /* Remove. */ Jp = NIL; Jh = J; while (Jh != NIL) { ADV(Jh,&J1,&Jh); Jh1 = LELTI(J1,PO_POLY); if (!PCONST(r,Jh1)) Jp = COMP(J1,Jp); } Jp = INV(Jp); goto Return; Return: /* Prepare for return. */ return(Jp); }
void impl::app::usage(std::ostream& os) { PRE(inited()); std::string args = specific_args(); if (!args.empty()) args = " " + args; os << ui::format_text_with_tag(std::string(m_prog_name) + " [options]" + args, "Usage: ", false) << "\n\n" << ui::format_text(m_description) << "\n\n"; options_set opts = options(); INV(!opts.empty()); os << "Available options:\n"; size_t coldesc = 0; for (options_set::const_iterator iter = opts.begin(); iter != opts.end(); iter++) { const option& opt = (*iter); if (opt.m_argument.length() + 1 > coldesc) coldesc = opt.m_argument.length() + 1; } for (options_set::const_iterator iter = opts.begin(); iter != opts.end(); iter++) { const option& opt = (*iter); std::string tag = std::string(" -") + opt.m_character; if (opt.m_argument.empty()) tag += " "; else tag += " " + opt.m_argument + " "; os << ui::format_text_with_tag(opt.m_description, tag, false, coldesc + 10) << "\n"; } os << "\n"; std::string gmp; if (!m_global_manpage.empty()) gmp = " and " + m_global_manpage; os << ui::format_text("For more details please see " + m_manpage + gmp + ".") << "\n"; }
/// Finds a column by name. /// /// \param name The name of the column to search for. /// /// \return The column identifier. /// /// \throw value_error If the name cannot be found. int sqlite::statement::column_id(const char* name) { std::map< std::string, int >& cache = _pimpl->column_cache; if (cache.empty()) { for (int i = 0; i < column_count(); i++) { const std::string aux_name = column_name(i); INV(cache.find(aux_name) == cache.end()); cache[aux_name] = i; } } const std::map< std::string, int >::const_iterator iter = cache.find(name); if (iter == cache.end()) throw invalid_column_error(_pimpl->db.db_filename(), name); else return (*iter).second; }
int CNAME(BLASLONG m, BLASLONG n, FLOAT *a, BLASLONG lda, BLASLONG offset, FLOAT *b){ BLASLONG i, ii, j, jj; #ifndef UNIT FLOAT data01; #endif FLOAT *a1; jj = offset; j = n; while (j > 0){ a1 = a + 0 * lda; i = m; ii = 0; while (i > 0) { if (ii == jj) { #ifndef UNIT data01 = *(a1 + 0); #endif *(b + 0) = INV(data01); } if (ii > jj) *(b + 0) = *(a1 + 0); a1 ++; b ++; i --; ii ++; } a += lda; jj ++; j --; } return 0; }
bool atf_user_is_member_of_group(gid_t gid) { static gid_t groups[NGROUPS_MAX]; static int ngroups = -1; bool found; int i; if (ngroups == -1) { ngroups = getgroups(NGROUPS_MAX, groups); INV(ngroups >= 0); } found = false; for (i = 0; !found && i < ngroups; i++) if (groups[i] == gid) found = true; return found; }
/// Checks if all the requirements specified by the test case are met. /// /// \param md The test metadata. /// \param cfg The engine configuration. /// \param test_suite Name of the test suite the test belongs to. /// \param work_directory Path to where the test case will be run. /// /// \return A string describing the reason for skipping the test, or empty if /// the test should be executed. std::string engine::check_reqs(const model::metadata& md, const config::tree& cfg, const std::string& test_suite, const fs::path& work_directory) { std::string reason; reason = check_required_configs(md.required_configs(), cfg, test_suite); if (!reason.empty()) return reason; reason = check_allowed_architectures(md.allowed_architectures(), cfg); if (!reason.empty()) return reason; reason = check_allowed_platforms(md.allowed_platforms(), cfg); if (!reason.empty()) return reason; reason = check_required_user(md.required_user(), cfg); if (!reason.empty()) return reason; reason = check_required_files(md.required_files()); if (!reason.empty()) return reason; reason = check_required_programs(md.required_programs()); if (!reason.empty()) return reason; reason = check_required_memory(md.required_memory()); if (!reason.empty()) return reason; reason = check_required_disk_space(md.required_disk_space(), work_directory); if (!reason.empty()) return reason; INV(reason.empty()); return reason; }
Word RMMPF(Word P, Word k) { Word P_k,P_k_j,Pp,Pp_k; Step1: /* Remove. */ P_k = LELTI(P,k); Pp_k = NIL; while (P_k != NIL) { ADV(P_k,&P_k_j,&P_k); if (LELTI(P_k_j,PO_STATUS) == PO_KEEP) Pp_k = COMP(P_k_j,Pp_k); } Pp_k = INV(Pp_k); SLELTI(P,k,Pp_k); Pp = P; Return: /* Prepare for return. */ return(Pp); }
void atf_list_fini(atf_list_t *l) { struct list_entry *le; size_t freed; le = (struct list_entry *)l->m_begin; freed = 0; while (le != NULL) { struct list_entry *lenext; lenext = le->m_next; delete_entry(le); le = lenext; freed++; } INV(freed == l->m_size + 2); }
Word NORMAETF(Word A) { Word X,T,j,P,r,I,s,c,L,Lr,Fs,Fa,L_i,e_i,P_i,rk_i,Pk_i,F; Step1: /* Get the components. */ FIRST6(A,&X,&T,&j,&P,&r,&I); Step2: /* Factor \v{P}. */ if (!ISLIST(FIRST(P))) IPFACDB(r,P,&s,&c,&L); else { Word Lp = NIL; for(; P != NIL; P = RED(P)) Lp = COMP(LIST2(1,FIRST(P)),Lp); L = CINV(Lp); } Step3: /* Sign of content is irrelevant in _root_ expressions! */ Step4: /* Simplify the representation of the polys in \v{L}. */ Lr = NIL; /* r-level factors */ Fs = NIL; /* factors of level less than r can't be zero! */ while (L != NIL) { ADV(L,&L_i,&L); FIRST2(L_i,&e_i,&P_i); PSIMREP(r,P_i,&rk_i,&Pk_i); if (rk_i < r) Fs = COMP(LIST4(NEOP,Pk_i,rk_i,NIL),Fs); else Lr = COMP(Pk_i,Lr); } Lr = INV(Lr); Step5: /* Create formula */ Fa = LIST6(IROOT,T,j,Lr,r,NIL); F = COMP(Fa,Fs); F = COMP(ANDOP,CINV(F)); Return: /* Prepare for return. */ return(F); }
Word SIGNL(Word c, Word L) { Word I,L1,Lp,Lt,M,s,s1; /* hide s1; */ Step1: /* Compute. */ s = LELTI(c,SAMPLE); FIRST2(s,&M,&I); Lp = L; Lt = NIL; while (Lp != NIL) { ADV(Lp,&L1,&Lp); s1 = AFSIGN(M,I,L1); Lt = COMP(s1,Lt); } Lt = INV(Lt); goto Return; Return: /* Prepare for return. */ return(Lt); }
/// Gets information about a user by its identifier. /// /// \param uid The identifier of the user to query. /// /// \return The information about the user. /// /// \throw std::runtime_error If the user does not exist. passwd_ns::user passwd_ns::find_user_by_uid(const unsigned int uid) { if (mock_users.empty()) { const struct ::passwd* pw = ::getpwuid(uid); if (pw == NULL) throw std::runtime_error(F("Failed to get information about the " "user with UID %s") % uid); INV(pw->pw_uid == uid); return user(pw->pw_name, pw->pw_uid, pw->pw_gid); } else { for (std::vector< user >::const_iterator iter = mock_users.begin(); iter != mock_users.end(); iter++) { if ((*iter).uid == uid) return *iter; } throw std::runtime_error(F("Failed to get information about the " "user with UID %s") % uid); } }
atf_error_t atf_fs_path_branch_path(const atf_fs_path_t *p, atf_fs_path_t *bp) { const size_t endpos = atf_dynstr_rfind_ch(&p->m_data, '/'); atf_error_t err; if (endpos == atf_dynstr_npos) err = atf_fs_path_init_fmt(bp, "."); else if (endpos == 0) err = atf_fs_path_init_fmt(bp, "/"); else err = atf_dynstr_init_substr(&bp->m_data, &p->m_data, 0, endpos); #if defined(HAVE_CONST_DIRNAME) INV(atf_equal_dynstr_cstring(&bp->m_data, dirname(atf_dynstr_cstring(&p->m_data)))); #endif /* defined(HAVE_CONST_DIRNAME) */ return err; }
atf_error_t atf_fs_path_leaf_name(const atf_fs_path_t *p, atf_dynstr_t *ln) { size_t begpos = atf_dynstr_rfind_ch(&p->m_data, '/'); atf_error_t err; if (begpos == atf_dynstr_npos) begpos = 0; else begpos++; err = atf_dynstr_init_substr(ln, &p->m_data, begpos, atf_dynstr_npos); #if defined(HAVE_CONST_BASENAME) INV(atf_equal_dynstr_cstring(ln, basename(atf_dynstr_cstring(&p->m_data)))); #endif /* defined(HAVE_CONST_BASENAME) */ return err; }
/// Gets information about a user by its name. /// /// \param name The name of the user to query. /// /// \return The information about the user. /// /// \throw std::runtime_error If the user does not exist. passwd_ns::user passwd_ns::find_user_by_name(const std::string& name) { if (mock_users.empty()) { const struct ::passwd* pw = ::getpwnam(name.c_str()); if (pw == NULL) throw std::runtime_error(F("Failed to get information about the " "user '%s'") % name); INV(pw->pw_name == name); return user(pw->pw_name, pw->pw_uid, pw->pw_gid); } else { for (std::vector< user >::const_iterator iter = mock_users.begin(); iter != mock_users.end(); iter++) { if ((*iter).name == name) return *iter; } throw std::runtime_error(F("Failed to get information about the " "user '%s'") % name); } }
static atf_error_t create_tmpdir(atf_fs_path_t *dir) { atf_error_t err; err = atf_fs_path_init_fmt(dir, "%s/check.XXXXXX", atf_env_get_with_default("TMPDIR", "/tmp")); if (atf_is_error(err)) goto out; err = atf_fs_mkdtemp(dir); if (atf_is_error(err)) { atf_fs_path_fini(dir); goto out; } INV(!atf_is_error(err)); out: return err; }
Word GROUPSAMEPJ(Word r, Word J) { Word J1,Jp,Js,t, Js1, Jt, J2, Jt2, i; Step1: /* Group. */ Jp = NIL; Js = J; i = 0; while (Js != NIL) { ADV(Js,&J1,&Js); Js1 = LELTI(J1,PO_POLY); Jt = Jp; t = 0; while (Jt != NIL) { ADV(Jt,&J2,&Jt); Jt2 = LELTI(J2,PO_POLY); if (LELTI(J1,PO_TYPE) == PO_POINT && LELTI(J2,PO_TYPE) == PO_POINT && PRJPNTEQUAL(Js1,Jt2) || LELTI(J1,PO_TYPE) != PO_POINT && LELTI(J2,PO_TYPE) != PO_POINT && EQUAL(Js1,Jt2)) { SLELTI(J2,PO_PARENT,CONC(LELTI(J2,PO_PARENT),LELTI(J1,PO_PARENT))); t = 1; break; } } if (t == 0) { i = i + 1; SLELTI(J1,PO_LABEL,LIST3(LFS("J"),r,i)); Jp = COMP(J1,Jp); } } Jp = INV(Jp); Return: /* Prepare for return. */ return(Jp); }
/// Converts the tree to a collection of key/value string pairs. /// /// \param dotted_key Subtree from which to start the export. /// \param strip_key If true, remove the dotted_key prefix from the resulting /// properties. /// /// \return A map of keys to values in their textual representation. /// /// \throw invalid_key_error If the provided key has an invalid format. /// \throw unknown_key_error If the provided key is unknown. /// \throw value_error If the provided key points to a leaf. config::properties_map config::tree::all_properties(const std::string& dotted_key, const bool strip_key) const { PRE(!strip_key || !dotted_key.empty()); properties_map properties; detail::tree_key key; const detail::base_node* raw_node; if (dotted_key.empty()) { raw_node = _root.get(); } else { key = detail::parse_key(dotted_key); raw_node = _root->lookup_ro(key, 0); } try { const detail::inner_node& child = dynamic_cast< const detail::inner_node& >(*raw_node); child.all_properties(properties, key); } catch (const std::bad_cast& unused_error) { INV(!dotted_key.empty()); throw value_error(F("Cannot export properties from a leaf node; " "'%s' given") % dotted_key); } if (strip_key) { properties_map stripped; for (properties_map::const_iterator iter = properties.begin(); iter != properties.end(); ++iter) { stripped[(*iter).first.substr(dotted_key.length() + 1)] = (*iter).second; } properties = stripped; } return properties; }
Word IUPSOPOR(Word A, Word B, Word i1, Word i2) { Word L,Bp,Lp,J,j1,j2,t,j,tp,s; Step1: /* Initialize. */ L = IPRRILBRI(A,LIST2(i1,i2)); Bp = IPPGSD(1,B); Step2: /* Loop over each interval in L. */ Lp = NIL; while(L != NIL) { ADV(L,&J,&L); FIRST2(J,&j1,&j2); t = LBRNSIGN(IUPLBREVAL(A,j2)); if (t != 0) { Step3: /* Refine (j1,j2) until Bp has no zeros. */ do { j = LSIM(j1,j2); tp = LBRNSIGN(IUPLBREVAL(A,j)); if (tp == t) j2 = j; else j1 = j; }while(IUPVSI(Bp,LIST2(LBRNRN(j1),LBRNRN(j2))) != 0); /* Is there a lbrn equivalent? */ } Step4: /* Compute the sign of B in (j1,j2) and add to Lp. */ s = LBRNSIGN(IUPLBREVAL(B,LSIM(j1,j2))); Lp = COMP(LIST2(s,LIST2(j1,j2)),Lp); } Return: /* Prepare to return; */ L = INV(Lp); return L; }
void TDTOD(Word P, Word N, Word ***P2_, Word *P1_, Word *k_) { Word **P2,Pp,i,pp,n,k,m,j,P1,I,l; Step1: /* Allocate P2. At the end of the loop k is # of pf's in P. */ P2 = (Word**)GETARRAY((N+1)*(sizeof(Word*)/sizeof(Word))); /* ASSUMES THIS / IS EXACT! */ Pp = P; k = 0; for(i = 1; i <= N; i++) { ADV(Pp,&pp,&Pp); n = LENGTH(pp); k += n; /* Finds I, the largest index in pp. */ for(I = 0; pp != NIL; pp = RED(pp)) I = IMAX(THIRD(LELTI(FIRST(pp),PO_LABEL)),I); P2[i] = (Word*)GETARRAY(I+1); P2[i][0] = n; } Step2: /* Construct P1. */ P1 = NIL; m = k - 1; Pp = NIL; for(i = N; i > 0; i--) { Pp = COMP(LELTI(P,i),Pp); } for(Pp = INV(Pp); Pp != NIL; Pp = RED(Pp)) { for(pp = CINV(FIRST(Pp)); pp != NIL; pp = RED(pp)) { l = LELTI(FIRST(pp),PO_LABEL); FIRST2(RED(l),&i,&j); P2[i][j] = m--; P1 = COMP(l,P1); } } Return: /* Prepare to return. */ *P2_ = P2; *P1_ = P1; *k_ = k; return; }
int impl::app::run(int argc, char* const* argv) { PRE(argc > 0); PRE(argv != NULL); m_argc = argc; m_argv = argv; m_argv0 = m_argv[0]; m_prog_name = std::strrchr(m_argv[0], '/'); if (m_prog_name == NULL) m_prog_name = m_argv[0]; else m_prog_name++; // Libtool workaround: if running from within the source tree (binaries // that are not installed yet), skip the "lt-" prefix added to files in // the ".libs" directory to show the real (not temporary) name. if (std::strncmp(m_prog_name, "lt-", 3) == 0) m_prog_name += 3; const std::string bug = std::string("This is probably a bug in ") + m_prog_name + " or one of the libraries it uses. Please report this problem to " PACKAGE_BUGREPORT " and provide as many details as possible " "describing how you got to this condition."; int errcode; try { int oldargc = m_argc; process_options(); if (m_hflag) { INV(m_use_ui); if (oldargc != 2) throw usage_error("-h must be given alone."); usage(std::cout); errcode = EXIT_SUCCESS; } else errcode = main(); } catch (const usage_error& e) { if (m_use_ui) { std::cerr << ui::format_error(m_prog_name, e.what()) << "\n" << ui::format_info(m_prog_name, std::string("Type `") + m_prog_name + " -h' for more details.") << "\n"; } else { std::cerr << m_prog_name << ": ERROR: " << e.what() << "\n"; std::cerr << m_prog_name << ": See " << m_manpage << " for usage " "details.\n"; } errcode = EXIT_FAILURE; } catch (const std::runtime_error& e) { if (m_use_ui) { std::cerr << ui::format_error(m_prog_name, std::string(e.what())) << "\n"; } else { std::cerr << m_prog_name << ": ERROR: " << e.what() << "\n"; } errcode = EXIT_FAILURE; } catch (const std::exception& e) { if (m_use_ui) { std::cerr << ui::format_error(m_prog_name, std::string("Caught " "unexpected error: ") + e.what() + "\n" + bug) << "\n"; } else { std::cerr << m_prog_name << ": ERROR: Caught unexpected error: " << e.what() << "\n"; } errcode = EXIT_FAILURE; } catch (...) { if (m_use_ui) { std::cerr << ui::format_error(m_prog_name, std::string("Caught " "unknown error\n") + bug) << "\n"; } else { std::cerr << m_prog_name << ": ERROR: Caught unknown error\n"; } errcode = EXIT_FAILURE; } return errcode; }
Word RMCAFS(Word F) { Word F1,F2,Fb,Fp,Fp1,Fp2,T,t,t1,t2; /* hide t,t1,t2; */ Step1: /* Classify the formula F. */ T = FIRST(F); if (T == ANDOP) goto Step3; if (T == OROP) goto Step4; if (T == NOTOP) goto Step5; if (T == RIGHTOP) goto Step6; if (T == LEFTOP) goto Step7; if (T == EQUIOP) goto Step8; Step2: /* Atomic Formula. */ t = TYPEAF(F); if (t == TRUE) { Fp = LIST4(EQOP,0,0,NIL); goto Return; } if (t == FALSE) { Fp = LIST4(NEOP,0,0,NIL); goto Return; } Fp = F; goto Return; Step3: /* Conjunction. */ Fb = RED(F); Fp = LIST1(ANDOP); while (Fb != NIL) { ADV(Fb,&F1,&Fb); Fp1 = RMCAFS(F1); t = TYPEQFF(Fp1); if (t == FALSE) { Fp = LIST4(NEOP,0,0,NIL); goto Return; } if (t == UNDET) Fp = COMP(Fp1,Fp); } if (LENGTH(Fp) == 1) { Fp = LIST4(EQOP,0,0,NIL); goto Return; } if (LENGTH(Fp) == 2) { Fp = FIRST(Fp); goto Return; } Fp = INV(Fp); goto Return; Step4: /* Disjunction. */ Fb = RED(F); Fp = LIST1(OROP); while (Fb != NIL) { ADV(Fb,&F1,&Fb); Fp1 = RMCAFS(F1); t = TYPEQFF(Fp1); if (t == TRUE) { Fp = LIST4(EQOP,0,0,NIL); goto Return; } if (t == UNDET) Fp = COMP(Fp1,Fp); } if (LENGTH(Fp) == 1) { Fp = LIST4(NEOP,0,0,NIL); goto Return; } if (LENGTH(Fp) == 2) { Fp = FIRST(Fp); goto Return; } Fp = INV(Fp); goto Return; Step5: /* Negation. */ F1 = SECOND(F); Fp1 = RMCAFS(F1); t = TYPEQFF(Fp1); if (t == TRUE) Fp = LIST4(NEOP,0,0,NIL); else if (t == FALSE) Fp = LIST4(EQOP,0,0,NIL); else Fp = LIST2(NOTOP,Fp1); goto Return; Step6: /* $\Rightarrow$. */ F1 = SECOND(F); Fp1 = RMCAFS(F1); t1 = TYPEQFF(Fp1); F2 = THIRD(F); Fp2 = RMCAFS(F2); t2 = TYPEQFF(Fp2); if (t1 == TRUE) Fp = Fp2; else if (t1 == FALSE) Fp = LIST4(EQOP,0,0,NIL); else if (t2 == TRUE) Fp = LIST4(EQOP,0,0,NIL); else if (t2 == FALSE) Fp = LIST2(NOTOP,Fp1); else Fp = LIST3(RIGHTOP,Fp1,Fp2); goto Return; Step7: /* $\Leftarrow$. */ F1 = THIRD(F); Fp1 = RMCAFS(F1); t1 = TYPEQFF(Fp1); F2 = SECOND(F); Fp2 = RMCAFS(F2); t2 = TYPEQFF(Fp2); if (t1 == TRUE) Fp = Fp2; else if (t1 == FALSE) Fp = LIST4(EQOP,0,0,NIL); else if (t2 == TRUE) Fp = LIST4(EQOP,0,0,NIL); else if (t2 == FALSE) Fp = LIST2(NOTOP,Fp1); else Fp = LIST3(LEFTOP,Fp2,Fp1); goto Return; Step8: /* $\Leftrightarrow$. */ F1 = SECOND(F); Fp1 = RMCAFS(F1); t1 = TYPEQFF(Fp1); F2 = THIRD(F); Fp2 = RMCAFS(F2); t2 = TYPEQFF(Fp2); if (t1 == TRUE) Fp = Fp2; else if (t2 == TRUE) Fp = Fp1; else if (t1 == FALSE && t2 == FALSE) Fp = LIST4(EQOP,0,0,NIL); else if (t1 == FALSE) Fp = LIST2(NOTOP,Fp2); else if (t2 == FALSE) Fp = LIST2(NOTOP,Fp1); else Fp = LIST3(EQUIOP,Fp1,Fp2); goto Return; Return: /* Prepare for return. */ return(Fp); }
Word NORMAF(Word A) { Word F,I,L,L_i,Lh,Lh_i,P,P_i,Ph_i,T,c,e_i,r,rh_i,s; /* hide rh_i,s; */ Step1: /* Get the components. */ if (FIRST(A) == IROOT) { F = NORMAETF(A); goto Return; } FIRST4(A,&T,&P,&r,&I); Step2: /* \v{P} = 0. */ if (P != 0) goto Step3; switch (T) { case EQOP: F = LIST4(EQOP,0,0,NIL); break; case GEOP: F = LIST4(EQOP,0,0,NIL); break; case LEOP: F = LIST4(EQOP,0,0,NIL); break; case GTOP: F = LIST4(NEOP,0,0,NIL); break; case LTOP: F = LIST4(NEOP,0,0,NIL); break; case NEOP: F = LIST4(NEOP,0,0,NIL); break; } goto Return; Step3: /* Factor \v{P}. */ IPFACDB(r,P,&s,&c,&L); Step4: /* Adjust \v{T}. */ if (s < 0) T = NEGRLOP(T); Step5: /* \v{P} is an integer. */ if (L != NIL) goto Step6; switch (T) { case NEOP: F = LIST4(EQOP,0,0,NIL); break; case GTOP: F = LIST4(EQOP,0,0,NIL); break; case GEOP: F = LIST4(EQOP,0,0,NIL); break; case EQOP: F = LIST4(NEOP,0,0,NIL); break; case LTOP: F = LIST4(NEOP,0,0,NIL); break; case LEOP: F = LIST4(NEOP,0,0,NIL); break; } goto Return; Step6: /* Simplify the representation of the polys in \v{L}. */ Lh = NIL; while (L != NIL) { ADV(L,&L_i,&L); FIRST2(L_i,&e_i,&P_i); PSIMREP(r,P_i,&rh_i,&Ph_i); Lh_i = LIST3(e_i,rh_i,Ph_i); Lh = COMP(Lh_i,Lh); } Lh = INV(Lh); Step7: /* Expand. */ switch (T) { case EQOP: F = EXPAFEQ(Lh); break; case GTOP: F = EXPAFGT(Lh); break; case LTOP: F = EXPAFLT(Lh); break; case NEOP: F = LIST2(NOTOP,EXPAFEQ(Lh)); break; case LEOP: F = LIST2(NOTOP,EXPAFGT(Lh)); break; case GEOP: F = LIST2(NOTOP,EXPAFLT(Lh)); break; } goto Return; Return: /* Prepare for return. */ return(F); }
/**************************************************************************** ** *F FuncINV( <self>, <obj> ) . . . . . . . . . . . . . . . . . . call 'INV' */ Obj FuncINV ( Obj self, Obj obj ) { return INV( obj ); }
/// Returns the default value for the argument to the option. /// /// \pre has_default_value() must be true. /// /// \return The default value. const std::string& cmdline::base_option::default_value(void) const { INV(has_default_value()); return _default_value;; }
/// Returns the argument name of the option for documentation purposes. /// /// \pre needs_arg() must be true. /// /// \return The argument name. const std::string& cmdline::base_option::arg_name(void) const { INV(needs_arg()); return _arg_name; }
/// Parses a command line. /// /// \param argc The number of arguments in argv, without counting the /// terminating NULL. /// \param argv The arguments to parse. The array is NULL-terminated. /// \param options The description of the supported options. /// /// \return The parsed command line. /// /// \pre args[0] must be the program or command name. /// /// \throw cmdline::missing_option_argument_error If the user specified an /// option that requires an argument, but no argument was provided. /// \throw cmdline::unknown_option_error If the user specified an unknown /// option (i.e. an option not defined in options). /// \throw cmdline::option_argument_value_error If the user passed an invalid /// argument to a supported option. cmdline::parsed_cmdline cmdline::parse(const int argc, const char* const* argv, const cmdline::options_vector& options) { PRE_MSG(argc >= 1, "No progname or command name found"); getopt_data data; options_to_getopt_data(options, data); std::map< std::string, std::vector< std::string > > option_values; for (cmdline::options_vector::const_iterator iter = options.begin(); iter != options.end(); iter++) { const cmdline::base_option* option = *iter; if (option->needs_arg() && option->has_default_value()) option_values[option->long_name()].push_back( option->default_value()); } args_vector args; int mutable_argc = argc; char** mutable_argv = make_mutable_argv(argc, argv); const int old_opterr = ::opterr; try { int ch; ::opterr = 0; while ((ch = ::getopt_long(mutable_argc, mutable_argv, ("+:" + data.short_options).c_str(), data.long_options.get(), NULL)) != -1) { if (ch == ':' ) { const std::string name = find_option_name( data, ::optopt, mutable_argv, ::optind); throw cmdline::missing_option_argument_error(name); } else if (ch == '?') { const std::string name = find_option_name( data, ::optopt, mutable_argv, ::optind); throw cmdline::unknown_option_error(name); } const std::map< int, const cmdline::base_option* >::const_iterator id = data.ids.find(ch); INV(id != data.ids.end()); const cmdline::base_option* option = (*id).second; if (option->needs_arg()) { if (::optarg != NULL) { option->validate(::optarg); option_values[option->long_name()].push_back(::optarg); } else INV(option->has_default_value()); } else { option_values[option->long_name()].push_back(""); } } args = argv_to_vector(mutable_argc - optind, mutable_argv + optind); ::opterr = old_opterr; ::optind = GETOPT_OPTIND_RESET_VALUE; #if defined(HAVE_GETOPT_WITH_OPTRESET) ::optreset = 1; #endif } catch (...) { free_mutable_argv(mutable_argv); ::opterr = old_opterr; ::optind = GETOPT_OPTIND_RESET_VALUE; #if defined(HAVE_GETOPT_WITH_OPTRESET) ::optreset = 1; #endif throw; } free_mutable_argv(mutable_argv); return parsed_cmdline(option_values, args); }
Word NECCONDS(Word L_T, Word L_F, Word L_A, Word P) { Word SF,Lp,N,a,t,Fp,SFp,A,n,S,f,S_f,T,I,i,Ap,L; Word t1,t2,t3; t1 = ACLOCK(); Step1: /* Construct N, the list of necessary conditions. */ for(Lp = CINV(L_A), N = NIL; Lp != NIL; Lp = RED(Lp)) { a = FIRST(Lp); for(t = TRUE,T = L_T; t == TRUE && T != NIL; T = RED(T)) t = FMACELLEVAL(a,FIRST(T),P); if (t == TRUE) N = COMP(a,N); } Step2: /* Construct Fp, the list of false cells satisfying N. */ for(Lp = CINV(L_F), Fp = NIL; Lp != NIL; Lp = RED(Lp)) if (FMACELLEVAL(COMP(ANDOP,N),FIRST(Lp),P) != FALSE) Fp = COMP(FIRST(Lp),Fp); t1 = ACLOCK() - t1; t2 = ACLOCK(); Step3: /* Construct formula for simplified problem. */ SFp = NAIVESF(L_T,Fp,L_A,P); t2 = ACLOCK() - t2; t3 = ACLOCK(); Step4: /* Construct Fp, the list of false cells satisfying SFp. */ for(Lp = CINV(L_F), Fp = NIL; Lp != NIL; Lp = RED(Lp)) if (FMACELLEVAL(SFp,FIRST(Lp),P) != FALSE) Fp = COMP(FIRST(Lp),Fp); if (Fp == NIL) { SF = SFp; goto Return; } Step5: /* Construct the minimum hitting set problem. */ A = CINV(N); n = LENGTH(A); for(S = NIL; Fp != NIL; Fp = RED(Fp)) { f = FIRST(Fp); S_f = NIL; for(i = n, Ap = A; Ap != NIL; i--,Ap = RED(Ap)) if (FMACELLEVAL(FIRST(Ap),f,P) == FALSE) S_f = COMP(i,S_f); S = COMP(S_f,S); } Step6: /* Get the hitting set. */ T = MINHITSETSR(S,-1); Step7: /* Convert hitting set to a formula. */ T = LBIBMS(T); for(I = NIL, L = N, i = 1; T != NIL; i++, L = RED(L)) if (i == FIRST(T)) { T = RED(T); I = COMP(FIRST(L),I); } if (LENGTH(I) == 1) I = FIRST(I); else I = COMP(ANDOP,INV(I)); Step8: /* Join I and SFp. */ SF = LIST3(ANDOP,I,SFp); Return: /* Prepare to return. */ t3 = ACLOCK() - t3; if (PCVERBOSE) { SWRITE("\nNECCONDS: t1 = ");IWRITE(t1);SWRITE(" t2 = "); IWRITE(t2);SWRITE(" t3 = ");IWRITE(t3);SWRITE("\n\n"); } return SF; }
void AFMSBM(Word M, Word A, Word B, Word *C_, Word *E_, Word *F_) { Word A1,Ap,As,B1,Bp,Bs,C,E,Ep,F,Fp,G,G11,h,i,j,m,n; /* hide h,i,j,m,n; */ Step1: /* Setup. */ As = NIL; Ap = A; while (Ap != NIL) { ADV(Ap,&A1,&Ap); As = COMP(A1,As); } As = INV(As); Bs = NIL; Bp = B; while (Bp != NIL) { ADV(Bp,&B1,&Bp); Bs = COMP(B1,Bs); } Bs = INV(Bs); Step2: /* gcd. */ G = NIL; Ap = As; while (Ap != NIL) { A1 = FIRST(Ap); Bp = Bs; while (Bp != NIL) { B1 = FIRST(Bp); if (PDEG(A1) == 0 || PDEG(B1) == 0) { G11 = PMON(AFFINT(1),0); G = COMP(G11,G); } else { AFUPGC(M,A1,B1,&G11,&A1,&B1); SFIRST(Ap,A1); SFIRST(Bp,B1); G = COMP(G11,G); } Bp = RED(Bp); } Ap = RED(Ap); } G = INV(G); Step3: /* Basis element from $A^*$. */ n = LENGTH(As); m = LENGTH(Bs); E = NIL; for (i = 1; i <= n; i++) E = COMP(NIL,E); F = NIL; for (j = 1; j <= m; j++) F = COMP(NIL,F); C = NIL; for (i = 1; i <= n; i++) { ADV(As,&A1,&As); if (PDEG(A1) > 0) { C = COMP(A1,C); Ep = E; for (h = 1; h <= i - 1; h++) { SFIRST(Ep,COMP(0,FIRST(Ep))); Ep = RED(Ep); } SFIRST(Ep,COMP(1,FIRST(Ep))); Ep = RED(Ep); for (h = i + 1; h <= n; h++) { SFIRST(Ep,COMP(0,FIRST(Ep))); Ep = RED(Ep); } Fp = F; for (h = 1; h <= m; h++) { SFIRST(Fp,COMP(0,FIRST(Fp))); Fp = RED(Fp); } } } Step4: /* Basis element from $B^*$. */ for (j = 1; j <= m; j++) { ADV(Bs,&B1,&Bs); if (PDEG(B1) > 0) { C = COMP(B1,C); Ep = E; for (h = 1; h <= n; h++) { SFIRST(Ep,COMP(0,FIRST(Ep))); Ep = RED(Ep); } Fp = F; for (h = 1; h <= j - 1; h++) { SFIRST(Fp,COMP(0,FIRST(Fp))); Fp = RED(Fp); } SFIRST(Fp,COMP(1,FIRST(Fp))); Fp = RED(Fp); for (h = j + 1; h <= m; h++) { SFIRST(Fp,COMP(0,FIRST(Fp))); Fp = RED(Fp); } } } Step5: /* Basis element from $G$. */ for (i = 1; i <= n; i++) for (j = 1; j <= m; j++) { ADV(G,&G11,&G); if (PDEG(G11) > 0) { C = COMP(G11,C); Ep = E; for (h = 1; h <= i - 1; h++) { SFIRST(Ep,COMP(0,FIRST(Ep))); Ep = RED(Ep); } SFIRST(Ep,COMP(1,FIRST(Ep))); Ep = RED(Ep); for (h = i + 1; h <= n; h++) { SFIRST(Ep,COMP(0,FIRST(Ep))); Ep = RED(Ep); } Fp = F; for (h = 1; h <= j - 1; h++) { SFIRST(Fp,COMP(0,FIRST(Fp))); Fp = RED(Fp); } SFIRST(Fp,COMP(1,FIRST(Fp))); Fp = RED(Fp); for (h = j + 1; h <= m; h++) { SFIRST(Fp,COMP(0,FIRST(Fp))); Fp = RED(Fp); } } } Return: /* Prepare for return. */ *C_ = C; *E_ = E; *F_ = F; return; }