diff --git a/Cantera/src/equil/vcs_defs.h b/Cantera/src/equil/vcs_defs.h index 980c63bdc..437dc6d8d 100644 --- a/Cantera/src/equil/vcs_defs.h +++ b/Cantera/src/equil/vcs_defs.h @@ -17,13 +17,6 @@ namespace VCSnonideal { * COMMON DEFINITIONS -> Protect them against redefinitions */ //@{ -#ifndef TRUE -# define TRUE 1 -#endif - -#ifndef FALSE -# define FALSE 0 -#endif #ifndef MAX # define MAX(x,y) (( (x) > (y) ) ? (x) : (y)) diff --git a/Cantera/src/equil/vcs_elem.cpp b/Cantera/src/equil/vcs_elem.cpp index b0453d67d..003b45e23 100644 --- a/Cantera/src/equil/vcs_elem.cpp +++ b/Cantera/src/equil/vcs_elem.cpp @@ -57,7 +57,7 @@ namespace VCSnonideal { * 0 : Checks constraints up to the number of components. * */ - int VCS_SOLVE::vcs_elabcheck(int ibound) { + bool VCS_SOLVE::vcs_elabcheck(int ibound) { size_t top = m_numComponents; double eval, scale; int numNonZero; @@ -99,11 +99,11 @@ namespace VCSnonideal { } if (multisign) { if (fabs(m_elemAbundances[i] - m_elemAbundancesGoal[i]) > 1e-11 * scale) { - return FALSE; + return false; } } else { if (fabs(m_elemAbundances[i] - m_elemAbundancesGoal[i]) > VCS_DELETE_MINORSPECIES_CUTOFF) { - return FALSE; + return false; } } } else { @@ -112,15 +112,15 @@ namespace VCSnonideal { * even for rediculously small numbers. */ if (m_elType[i] == VCS_ELEM_TYPE_ABSPOS) { - return FALSE; + return false; } else { - return FALSE; + return false; } } } } } - return TRUE; + return true; } /* vcs_elabcheck() *********************************************************/ /*****************************************************************************/ @@ -198,7 +198,8 @@ namespace VCSnonideal { * *************************************************************************/ { - int retn = 0, goodSpec, its; + int retn = 0, its; + bool goodSpec; double xx, par, saveDir, dir; #ifdef DEBUG_MODE @@ -427,25 +428,25 @@ namespace VCSnonideal { continue; } saveDir = 0.0; - goodSpec = TRUE; + goodSpec = true; for (size_t i = 0; i < m_numComponents; ++i) { dir = m_formulaMatrix[i][kspec] * (m_elemAbundancesGoal[i] - m_elemAbundances[i]); if (fabs(dir) > 1.0E-10) { if (dir > 0.0) { if (saveDir < 0.0) { - goodSpec = FALSE; + goodSpec = false; break; } } else { if (saveDir > 0.0) { - goodSpec = FALSE; + goodSpec = false; break; } } saveDir = dir; } else { if (m_formulaMatrix[i][kspec] != 0.) { - goodSpec = FALSE; + goodSpec = false; break; } } diff --git a/Cantera/src/equil/vcs_inest.cpp b/Cantera/src/equil/vcs_inest.cpp index f389cb49f..9139d5ca3 100644 --- a/Cantera/src/equil/vcs_inest.cpp +++ b/Cantera/src/equil/vcs_inest.cpp @@ -37,11 +37,11 @@ namespace VCSnonideal { */ void VCS_SOLVE::vcs_inest(double * const aw, double * const sa, double * const sm, double * const ss, double test) { - size_t conv, lt, ikl, kspec, iph, irxn; + size_t lt, ikl, kspec, iph, irxn; double s; double s1 = 0.0; double xl, par; - int finished; + bool finished, conv; size_t nspecies = m_numSpeciesTot; size_t nrxn = m_numRxnTot; @@ -147,7 +147,7 @@ namespace VCSnonideal { * Now find the optimized basis that spans the stoichiometric * coefficient matrix */ - (void) vcs_basopt(FALSE, aw, sa, sm, ss, test, &conv); + (void) vcs_basopt(false, aw, sa, sm, ss, test, &conv); /* ***************************************************************** */ /* **** CALCULATE TOTAL MOLES, ****************** */ @@ -286,7 +286,7 @@ namespace VCSnonideal { /* ******************************************** */ /* **** CALCULATE NEW MOLE NUMBERS ************ */ /* ******************************************** */ - finished = FALSE; + finished = false; do { for (kspec = 0; kspec < m_numComponents; ++kspec) { if (m_speciesUnknownType[kspec] != VCS_SPECIES_TYPE_INTERFACIALVOLTAGE) { @@ -317,11 +317,11 @@ namespace VCSnonideal { s += m_deltaMolNumSpecies[kspec] * m_feSpecies_old[kspec]; } if (s == 0.0) { - finished = TRUE; continue; + finished = true; continue; } if (s < 0.0) { if (ikl == 0) { - finished = TRUE; continue; + finished = true; continue; } } /* ***************************************** */ @@ -454,7 +454,7 @@ namespace VCSnonideal { * Note: We won't do this unless we have to since it involves inverting * a matrix. */ - int rangeCheck = vcs_elabcheck(1); + bool rangeCheck = vcs_elabcheck(1); if (!vcs_elabcheck(0)) { if (DEBUG_MODE_ENABLED && m_debug_print_lvl >= 2) { plogf("%sInitial guess failed element abundances\n", pprefix); diff --git a/Cantera/src/equil/vcs_prep.cpp b/Cantera/src/equil/vcs_prep.cpp index 0630dd188..93896d681 100644 --- a/Cantera/src/equil/vcs_prep.cpp +++ b/Cantera/src/equil/vcs_prep.cpp @@ -59,8 +59,8 @@ namespace VCSnonideal { for (size_t kspec = 0; kspec < m_numSpeciesTot; kspec++) { iph = m_phaseID[kspec]; Vphase = m_VolPhaseList[iph]; - if (Vphase->m_singleSpecies) m_SSPhase[kspec] = TRUE; - else m_SSPhase[kspec] = FALSE; + if (Vphase->m_singleSpecies) m_SSPhase[kspec] = true; + else m_SSPhase[kspec] = false; } } /*****************************************************************************/ @@ -99,11 +99,12 @@ namespace VCSnonideal { * */ int VCS_SOLVE::vcs_prep_oneTime(int printLvl) { - size_t kspec, i, conv; + size_t kspec, i; int retn = VCS_SUCCESS; double pres, test; double *aw, *sa, *sm, *ss; bool modifiedSoln = false; + bool conv; m_debug_print_lvl = printLvl; @@ -199,7 +200,7 @@ namespace VCSnonideal { sa = aw + m_numSpeciesTot; sm = sa + m_numElemConstraints; ss = sm + (m_numElemConstraints)*(m_numElemConstraints); - retn = vcs_basopt(TRUE, aw, sa, sm, ss, test, &conv); + retn = vcs_basopt(true, aw, sa, sm, ss, test, &conv); if (retn != VCS_SUCCESS) { plogf("vcs_prep_oneTime:"); plogf(" Determination of number of components failed: %d\n", diff --git a/Cantera/src/equil/vcs_rearrange.cpp b/Cantera/src/equil/vcs_rearrange.cpp index 3f22d105d..ad8ca6801 100644 --- a/Cantera/src/equil/vcs_rearrange.cpp +++ b/Cantera/src/equil/vcs_rearrange.cpp @@ -43,7 +43,7 @@ namespace VCSnonideal { * -> because we loop over all species, reaction data * are now permanently hosed. */ - vcs_switch_pos(FALSE, i, k1); + vcs_switch_pos(false, i, k1); } return 0; } diff --git a/Cantera/src/equil/vcs_report.cpp b/Cantera/src/equil/vcs_report.cpp index 129b0220b..7fd0f1069 100644 --- a/Cantera/src/equil/vcs_report.cpp +++ b/Cantera/src/equil/vcs_report.cpp @@ -41,8 +41,8 @@ namespace VCSnonideal { * The "old" solution vector is printed out. ***************************************************************************/ int VCS_SOLVE::vcs_report(int iconv) { - bool printActualMoles = true; - size_t i, j, l, k, inertYes = FALSE, kspec; + bool printActualMoles = true, inertYes = false; + size_t i, j, l, k, kspec; size_t nspecies = m_numSpeciesTot; double g; @@ -154,7 +154,7 @@ namespace VCSnonideal { } for (i = 0; i < m_numPhases; i++) { if (TPhInertMoles[i] > 0.0) { - inertYes = TRUE; + inertYes = true; if (i == 0) { plogf(" Inert Gas Species "); } else { diff --git a/Cantera/src/equil/vcs_root1d.cpp b/Cantera/src/equil/vcs_root1d.cpp index 668492724..6b27f52a3 100644 --- a/Cantera/src/equil/vcs_root1d.cpp +++ b/Cantera/src/equil/vcs_root1d.cpp @@ -123,7 +123,8 @@ static void print_funcEval(FILE *fp, double xval, double fval, int its) static int callNum = 0; const char *stre = "vcs_root1d ERROR: "; const char *strw = "vcs_root1d WARNING: "; - int converged = FALSE, err = FALSE; + bool converged = false; + int err = 0; #ifdef DEBUG_MODE char fileName[80]; FILE *fp = 0; @@ -132,9 +133,9 @@ static void print_funcEval(FILE *fp, double xval, double fval, int its) size_t its = 0; int posStraddle = 0; int retn = VCS_SUCCESS; - int foundPosF = FALSE; - int foundNegF = FALSE; - int foundStraddle = FALSE; + bool foundPosF = false; + bool foundNegF = false; + bool foundStraddle = false; double xPosF = 0.0; double xNegF = 0.0; double fnorm; /* A valid norm for the making the function value @@ -175,10 +176,10 @@ static void print_funcEval(FILE *fp, double xval, double fval, int its) return VCS_SUCCESS; } else if (f1 > 0.0) { - foundPosF = TRUE; + foundPosF = true; xPosF = x1; } else { - foundNegF = TRUE; + foundNegF = true; xNegF = x1; } x2 = x1 * 1.1; @@ -201,19 +202,19 @@ static void print_funcEval(FILE *fp, double xval, double fval, int its) return retn; else if (f2 > 0.0) { if (!foundPosF) { - foundPosF = TRUE; + foundPosF = true; xPosF = x2; } } else { if (!foundNegF) { - foundNegF = TRUE; + foundNegF = true; xNegF = x2; } } foundStraddle = foundPosF && foundNegF; if (foundStraddle) { - if (xPosF > xNegF) posStraddle = TRUE; - else posStraddle = FALSE; + if (xPosF > xNegF) posStraddle = true; + else posStraddle = false; } do { @@ -401,19 +402,17 @@ static void print_funcEval(FILE *fp, double xval, double fval, int its) if (! foundStraddle) { if (fnew > 0.0) { if (!foundPosF) { - foundPosF = TRUE; + foundPosF = true; xPosF = xnew; - foundStraddle = TRUE; - if (xPosF > xNegF) posStraddle = TRUE; - else posStraddle = FALSE; + foundStraddle = true; + posStraddle = (xPosF > xNegF); } } else { if (!foundNegF) { - foundNegF = TRUE; + foundNegF = true; xNegF = xnew; - foundStraddle = TRUE; - if (xPosF > xNegF) posStraddle = TRUE; - else posStraddle = FALSE; + foundStraddle = true; + posStraddle = (xPosF > xNegF); } } } @@ -425,7 +424,7 @@ static void print_funcEval(FILE *fp, double xval, double fval, int its) x2 = xnew; f2 = fnew; if (fabs(fnew / fnorm) < 1.0E-5) { - converged = TRUE; + converged = true; } its++; } while (! converged && its < itmax); diff --git a/Cantera/src/equil/vcs_setMolesLinProg.cpp b/Cantera/src/equil/vcs_setMolesLinProg.cpp index 925ef7961..42de4ff8e 100644 --- a/Cantera/src/equil/vcs_setMolesLinProg.cpp +++ b/Cantera/src/equil/vcs_setMolesLinProg.cpp @@ -90,7 +90,7 @@ int VCS_SOLVE::vcs_setMolesLinProg() { int retn; int iter = 0; bool abundancesOK = true; - size_t usedZeroedSpecies; + bool usedZeroedSpecies; std::vector sm(m_numElemConstraints*m_numElemConstraints, 0.0); std::vector ss(m_numElemConstraints, 0.0); @@ -133,7 +133,7 @@ int VCS_SOLVE::vcs_setMolesLinProg() { * coefficient matrix, based on the current composition, m_molNumSpecies_old[] * We also calculate sc[][], the reaction matrix. */ - retn = vcs_basopt(FALSE, VCS_DATA_PTR(aw), VCS_DATA_PTR(sa), + retn = vcs_basopt(false, VCS_DATA_PTR(aw), VCS_DATA_PTR(sa), VCS_DATA_PTR(sm), VCS_DATA_PTR(ss), test, &usedZeroedSpecies); if (retn != VCS_SUCCESS) return retn; diff --git a/Cantera/src/equil/vcs_solve.cpp b/Cantera/src/equil/vcs_solve.cpp index f9eb0892e..759dad36a 100644 --- a/Cantera/src/equil/vcs_solve.cpp +++ b/Cantera/src/equil/vcs_solve.cpp @@ -906,7 +906,7 @@ namespace VCSnonideal { vPhase->setTotalMolesInert(pub_phase_ptr->totalMolesInert()); if (TPhInertMoles[iph] > 0.0) { vPhase->setExistence(2); - vPhase->m_singleSpecies = FALSE; + vPhase->m_singleSpecies = false; } /* diff --git a/Cantera/src/equil/vcs_solve.h b/Cantera/src/equil/vcs_solve.h index 7f2ce49f3..5424d00f2 100644 --- a/Cantera/src/equil/vcs_solve.h +++ b/Cantera/src/equil/vcs_solve.h @@ -217,8 +217,8 @@ public: * @return Returns VCS_SUCCESS if everything went ok. Returns something else if * there is a problem. */ - int vcs_basopt(const int doJustComponents, double aw[], double sa[], double sm[], - double ss[], double test, size_t* const usedZeroedSpecies); + int vcs_basopt(const bool doJustComponents, double aw[], double sa[], double sm[], + double ss[], double test, bool* const usedZeroedSpecies); //! Choose a species to test for the next component /*! @@ -635,7 +635,7 @@ public: * * @param k2 Second species index */ - void vcs_switch_pos(const int ifunc, const size_t k1, const size_t k2); + void vcs_switch_pos(const bool ifunc, const size_t k1, const size_t k2); //! Birth guess returns the number of moles of a species @@ -1011,7 +1011,7 @@ public: */ void vcs_elab(); - int vcs_elabcheck(int ibound); + bool vcs_elabcheck(int ibound); void vcs_elabPhase(size_t iphase, double * const elemAbundPhase); int vcs_elcorr(double aa[], double x[]); @@ -1269,7 +1269,7 @@ private: * * @param dx The change in mole number */ - double vcs_minor_alt_calc(size_t kspec, size_t irxn, int *do_delete + double vcs_minor_alt_calc(size_t kspec, size_t irxn, bool *do_delete #ifdef DEBUG_MODE , char *ANOTE #endif @@ -1827,7 +1827,7 @@ public: std::vector m_phaseID; //! Boolean indicating whether a species belongs to a single-species phase - std::vector m_SSPhase; + std::vector m_SSPhase; //! Species string name for the kth species diff --git a/Cantera/src/equil/vcs_solve_TP.cpp b/Cantera/src/equil/vcs_solve_TP.cpp index b134b81a6..958896ae6 100644 --- a/Cantera/src/equil/vcs_solve_TP.cpp +++ b/Cantera/src/equil/vcs_solve_TP.cpp @@ -92,20 +92,21 @@ namespace VCSnonideal { * found. */ int VCS_SOLVE::vcs_solve_TP(int print_lvl, int printDetails, int maxit) { - int conv = FALSE, retn = VCS_SUCCESS, solveFail, soldel; + int retn = VCS_SUCCESS, soldel, solveFail; double test, RT; size_t j, k, l, l1, kspec, irxn, i; - bool allMinorZeroedSpecies = false, forced; + bool conv = false, allMinorZeroedSpecies = false, forced, lec; size_t iph; double dx, xx, par; - size_t dofast, it1 = 0; - size_t lec, npb, iti, lnospec; + size_t it1 = 0; + size_t npb, iti, lnospec; + bool dofast; int rangeErrorFound = 0; bool giveUpOnElemAbund = false; int finalElemAbundAttempts = 0; bool uptodate_minors = true; bool justDeletedMultiPhase = false; - size_t usedZeroedSpecies; /* return flag from basopt indicating that + bool usedZeroedSpecies; /* return flag from basopt indicating that one of the components had a zero concentration */ size_t doPhaseDeleteIph = npos; size_t doPhaseDeleteKspec = npos; @@ -149,7 +150,7 @@ namespace VCSnonideal { std::vector aw(m_numSpeciesTot, 0.0); std::vector wx(m_numElemConstraints, 0.0); - solveFail = FALSE; + solveFail = false; /* ****************************************************** */ @@ -268,7 +269,7 @@ namespace VCSnonideal { */ L_COMPONENT_CALC: ; test = -1.0e-10; - retn = vcs_basopt(FALSE, VCS_DATA_PTR(aw), VCS_DATA_PTR(sa), + retn = vcs_basopt(false, VCS_DATA_PTR(aw), VCS_DATA_PTR(sa), VCS_DATA_PTR(sm), VCS_DATA_PTR(ss), test, &usedZeroedSpecies); if (retn != VCS_SUCCESS) return retn; @@ -286,7 +287,7 @@ namespace VCSnonideal { /************** EVALUATE INITIAL SPECIES STATUS VECTOR *******************/ /*************************************************************************/ allMinorZeroedSpecies = vcs_evaluate_speciesType(); - lec = FALSE; + lec = false; /*************************************************************************/ /************** EVALUATE THE ELELEMT ABUNDANCE CHECK ******************/ @@ -425,7 +426,7 @@ namespace VCSnonideal { } } #endif - lec = FALSE; + lec = false; doPhaseDeleteIph = npos; doPhaseDeleteKspec = npos; /* @@ -501,11 +502,13 @@ namespace VCSnonideal { /********************************************************************/ /************************ VOLTAGE SPECIES ***************************/ /********************************************************************/ + bool ret_soldel; #ifdef DEBUG_MODE - dx = vcs_minor_alt_calc(kspec, irxn, &soldel, ANOTE); + dx = vcs_minor_alt_calc(kspec, irxn, &ret_soldel, ANOTE); #else - dx = vcs_minor_alt_calc(kspec, irxn, &soldel); + dx = vcs_minor_alt_calc(kspec, irxn, &ret_soldel); #endif + soldel = ret_soldel; m_deltaMolNumSpecies[kspec] = dx; } else if (m_speciesStatus[kspec] < VCS_SPECIES_MINOR) { @@ -642,10 +645,12 @@ namespace VCSnonideal { * If soldel is true on return, then we branch to the section * that deletes a species from the current set of active species. */ + bool soldel_ret; #ifdef DEBUG_MODE - dx = vcs_minor_alt_calc(kspec, irxn, &soldel, ANOTE); + dx = vcs_minor_alt_calc(kspec, irxn, &soldel_ret, ANOTE); #else - dx = vcs_minor_alt_calc(kspec, irxn, &soldel); + dx = vcs_minor_alt_calc(kspec, irxn, &soldel_ret); + soldel = soldel_ret; #endif m_deltaMolNumSpecies[kspec] = dx; m_molNumSpecies_new[kspec] = m_molNumSpecies_old[kspec] + dx; @@ -1225,7 +1230,7 @@ namespace VCSnonideal { * number of moles less than VCS_DELETE_PHASE_CUTOFF to * absolute zero. */ - justDeletedMultiPhase = FALSE; + justDeletedMultiPhase = false; for (iph = 0; iph < m_numPhases; iph++) { Vphase = m_VolPhaseList[iph]; if (!(Vphase->m_singleSpecies)) { @@ -1245,7 +1250,7 @@ namespace VCSnonideal { plogendl(); } #endif - justDeletedMultiPhase = TRUE; + justDeletedMultiPhase = true; vcs_delete_multiphase(iph); } } @@ -1258,8 +1263,8 @@ namespace VCSnonideal { * of the thermo functions just to be safe. */ if (justDeletedMultiPhase) { - justDeletedMultiPhase = FALSE; - retn = vcs_basopt(FALSE, VCS_DATA_PTR(aw), VCS_DATA_PTR(sa), + justDeletedMultiPhase = false; + retn = vcs_basopt(false, VCS_DATA_PTR(aw), VCS_DATA_PTR(sa), VCS_DATA_PTR(sm), VCS_DATA_PTR(ss), test, &usedZeroedSpecies); if (retn != VCS_SUCCESS) { @@ -1323,7 +1328,7 @@ namespace VCSnonideal { dofast = (m_numComponents != 1); for (i = 1; i < m_numComponents; ++i) { if ((m_molNumSpecies_old[i - 1] * m_spSize[i-1]) < (m_molNumSpecies_old[i] * m_spSize[i])) { - dofast = FALSE; + dofast = false; break; } } @@ -1693,7 +1698,7 @@ namespace VCSnonideal { /* - Final checks are passed -> go check out */ goto L_RETURN_BLOCK; } - lec = TRUE; + lec = true; /* *************************************************** */ /* **** CORRECT ELEMENTAL ABUNDANCES ***************** */ /* *************************************************** */ @@ -1707,10 +1712,10 @@ namespace VCSnonideal { */ rangeErrorFound = 0; if (! vcs_elabcheck(1)) { - int ncBefore = vcs_elabcheck(0); + bool ncBefore = vcs_elabcheck(0); vcs_elcorr(VCS_DATA_PTR(sm), VCS_DATA_PTR(wx)); - int ncAfter = vcs_elabcheck(0); - int neAfter = vcs_elabcheck(1); + bool ncAfter = vcs_elabcheck(0); + bool neAfter = vcs_elabcheck(1); /* * Go back to evaluate the total moles of gas and liquid. */ @@ -1725,7 +1730,7 @@ namespace VCSnonideal { * restart the main loop calculation, resetting the * end conditions. */ - lec = FALSE; + lec = false; iti = 0; goto L_MAINLOOP_ALL_SPECIES; } else { @@ -1737,7 +1742,7 @@ namespace VCSnonideal { goto L_EQUILIB_CHECK; } else { finalElemAbundAttempts++; - lec = FALSE; + lec = false; iti = 0; goto L_MAINLOOP_ALL_SPECIES; } @@ -1956,7 +1961,7 @@ namespace VCSnonideal { * * @param dx The change in mole number */ - double VCS_SOLVE::vcs_minor_alt_calc(size_t kspec, size_t irxn, int *do_delete + double VCS_SOLVE::vcs_minor_alt_calc(size_t kspec, size_t irxn, bool *do_delete #ifdef DEBUG_MODE , char *ANOTE #endif @@ -1967,7 +1972,7 @@ namespace VCSnonideal { double wTrial; double dg_irxn = m_deltaGRxn_old[irxn]; size_t iph = m_phaseID[kspec]; - *do_delete = FALSE; + *do_delete = false; if (m_speciesUnknownType[kspec] != VCS_SPECIES_TYPE_INTERFACIALVOLTAGE) { if (w_kspec <= 0.0) { w_kspec = VCS_DELETE_MINORSPECIES_CUTOFF; @@ -2025,7 +2030,7 @@ namespace VCSnonideal { * has gotten too small. */ L_ZERO_SPECIES: ; - *do_delete = TRUE; + *do_delete = true; dx = - w_kspec; return dx; } @@ -2203,7 +2208,7 @@ namespace VCSnonideal { * species. */ if (kspec != klast) { - vcs_switch_pos(TRUE, klast, kspec); + vcs_switch_pos(true, klast, kspec); } /* * Adjust the total moles in a phase downwards. @@ -2325,7 +2330,7 @@ namespace VCSnonideal { /* * Rearrange both the species and the non-component global data */ - vcs_switch_pos(TRUE, (m_numSpeciesRdc - 1), kspec); + vcs_switch_pos(true, (m_numSpeciesRdc - 1), kspec); } } /****************************************************************************/ @@ -2490,7 +2495,7 @@ namespace VCSnonideal { /* * Rearrange both the species and the non-component global data */ - vcs_switch_pos(TRUE, (m_numSpeciesRdc - 1), kspec); + vcs_switch_pos(true, (m_numSpeciesRdc - 1), kspec); } } } @@ -3026,9 +3031,10 @@ namespace VCSnonideal { * @return Returns VCS_SUCCESS if everything went ok. Returns * VCS_FAILED_CONVERGENCE if there is a problem. */ - int VCS_SOLVE::vcs_basopt(const int doJustComponents, double aw[], double sa[], double sm[], - double ss[], double test, size_t* const usedZeroedSpecies) { - size_t j, k, l, i, jl, ml, jr, lindep, irxn, kspec; + int VCS_SOLVE::vcs_basopt(const bool doJustComponents, double aw[], double sa[], double sm[], + double ss[], double test, bool* const usedZeroedSpecies) { + size_t j, k, l, i, jl, ml, jr, irxn, kspec; + bool lindep; size_t ncTrial; size_t juse = -1; size_t jlose = -1; @@ -3075,7 +3081,7 @@ namespace VCSnonideal { */ ncTrial = MIN(m_numElemConstraints, m_numSpeciesTot); m_numComponents = ncTrial; - *usedZeroedSpecies = FALSE; + *usedZeroedSpecies = false; /* * Use a temporary work array for the mole numbers, aw[] @@ -3148,7 +3154,7 @@ namespace VCSnonideal { * */ if ((aw[k] != test) && aw[k] < VCS_DELETE_MINORSPECIES_CUTOFF) { - *usedZeroedSpecies = TRUE; + *usedZeroedSpecies = true; double maxConcPossKspec = 0.0; double maxConcPoss = 0.0; @@ -3282,8 +3288,7 @@ namespace VCSnonideal { /* **************************************************** */ /* **** IF NORM OF NEW ROW .LT. 1E-3 REJECT ********** */ /* **************************************************** */ - if (sa[jr] < 1.0e-6) lindep = TRUE; - else lindep = FALSE; + lindep = (sa[jr] < 1.0e-6); } while(lindep); /* ****************************************** */ /* **** REARRANGE THE DATA ****************** */ @@ -3297,7 +3302,7 @@ namespace VCSnonideal { plogf("(%9.2g) as component %3d\n", m_molNumSpecies_old[jr], jr); } #endif - vcs_switch_pos(FALSE, jr, k); + vcs_switch_pos(false, jr, k); vcsUtil_dsw(aw, jr, k); } #ifdef DEBUG_MODE @@ -4344,7 +4349,8 @@ namespace VCSnonideal { #ifdef DEBUG_MODE //! Print out and check the elemental abundance vector void VCS_SOLVE::prneav() const { - int kerr, j; + int j; + bool kerr; std::vector eav(m_numElemConstraints, 0.0); for (j = 0; j < m_numElemConstraints; ++j) { @@ -4354,7 +4360,7 @@ namespace VCSnonideal { } } } - kerr = FALSE; + kerr = false; plogf( "--------------------------------------------------"); plogf("ELEMENT ABUNDANCE VECTOR:\n"); plogf(" Element Now Orignal Deviation Type\n"); @@ -4364,9 +4370,9 @@ namespace VCSnonideal { eav[j], m_elemAbundancesGoal[j], eav[j] - m_elemAbundancesGoal[j], m_elType[j]); if (m_elemAbundancesGoal[j] != 0.) { if (fabs(eav[j] - m_elemAbundancesGoal[j]) > m_elemAbundancesGoal[j] * 5.0e-9) - kerr = TRUE; + kerr = true; } else { - if (fabs(eav[j]) > 1.0e-10) kerr = TRUE; + if (fabs(eav[j]) > 1.0e-10) kerr = true; } } if (kerr) { @@ -4688,7 +4694,8 @@ namespace VCSnonideal { void VCS_SOLVE::vcs_deltag(const int l, const bool doDeleted, const int vcsState, const bool alterZeroedPhases) { size_t iph; - size_t lneed, irxn, kspec; + size_t irxn, kspec; + bool lneed; double *dtmp_ptr; int icase = 0; size_t irxnl = m_numRxnRdc; @@ -4835,7 +4842,7 @@ namespace VCSnonideal { //alterZeroedPhases = false; if (alterZeroedPhases && false) { for (iph = 0; iph < m_numPhases; iph++) { - lneed = FALSE; + lneed = false; vcs_VolPhase *Vphase = m_VolPhaseList[iph]; if (! Vphase->m_singleSpecies) { double sum = 0.0; @@ -4847,7 +4854,7 @@ namespace VCSnonideal { if (sum > 0.0) break; } if (sum == 0.0) { - lneed = TRUE; + lneed = true; } } @@ -4966,14 +4973,14 @@ namespace VCSnonideal { * Multispecies Phase */ else { - bool zeroedPhase = TRUE; + bool zeroedPhase = true; for (irxn = 0; irxn < irxnl; ++irxn) { kspec = m_indexRxnToSpecies[irxn]; if (m_speciesUnknownType[kspec] != VCS_SPECIES_TYPE_INTERFACIALVOLTAGE) { iph = m_phaseID[kspec]; if (iph == iphase) { - if (m_molNumSpecies_old[kspec] > 0.0) zeroedPhase = FALSE; + if (m_molNumSpecies_old[kspec] > 0.0) zeroedPhase = false; deltaGRxn[irxn] = feSpecies[kspec]; dtmp_ptr = m_stoichCoeffRxnMatrix[irxn]; for (kcomp = 0; kcomp < m_numComponents; ++kcomp) { @@ -5065,7 +5072,7 @@ namespace VCSnonideal { * * @param k2 Second species index */ - void VCS_SOLVE::vcs_switch_pos(const int ifunc, const size_t k1, const size_t k2) { + void VCS_SOLVE::vcs_switch_pos(const bool ifunc, const size_t k1, const size_t k2) { register size_t j; register double t1 = 0.0; size_t i1, i2, iph, kp1, kp2; @@ -5102,6 +5109,7 @@ namespace VCSnonideal { //pv1->IndSpecies[kp1] = k2; //pv2->IndSpecies[kp2] = k1; int itmp; + bool btmp; vcsUtil_stsw(m_speciesName, k1, k2); SWAP(m_molNumSpecies_old[k1], m_molNumSpecies_old[k2], t1); SWAP(m_speciesUnknownType[k1], m_speciesUnknownType[k2], itmp); @@ -5111,7 +5119,7 @@ namespace VCSnonideal { SWAP(m_deltaMolNumSpecies[k1], m_deltaMolNumSpecies[k2], t1); SWAP(m_feSpecies_old[k1], m_feSpecies_old[k2], t1); SWAP(m_feSpecies_new[k1], m_feSpecies_new[k2], t1); - SWAP(m_SSPhase[k1], m_SSPhase[k2], itmp); + SWAP(m_SSPhase[k1], m_SSPhase[k2], btmp); SWAP(m_phaseID[k1], m_phaseID[k2], j); SWAP(m_speciesMapIndex[k1], m_speciesMapIndex[k2], j); SWAP(m_speciesLocalPhaseIndex[k1], m_speciesLocalPhaseIndex[k2], j); @@ -5219,12 +5227,14 @@ namespace VCSnonideal { * Logic to handle species in multiple species phases * we cap the moles here at 1.0E-15 kmol. */ + bool soldel_ret; #ifdef DEBUG_MODE char ANOTE[32]; - double dxm = vcs_minor_alt_calc(kspec, irxn, &soldel, ANOTE); + double dxm = vcs_minor_alt_calc(kspec, irxn, &soldel_ret, ANOTE); #else - double dxm = vcs_minor_alt_calc(kspec, irxn, &soldel); + double dxm = vcs_minor_alt_calc(kspec, irxn, &soldel_ret); #endif + soldel = soldel_ret; dx = w_kspec + dxm; if (dx > 1.0E-15) { dx = 1.0E-15; diff --git a/Cantera/src/numerics/CVodeInt.cpp b/Cantera/src/numerics/CVodeInt.cpp index 148f759e1..e0b7a0eea 100644 --- a/Cantera/src/numerics/CVodeInt.cpp +++ b/Cantera/src/numerics/CVodeInt.cpp @@ -203,13 +203,13 @@ namespace Cantera { if (m_itol) { m_cvode_mem = CVodeMalloc(m_neq, cvode_rhs, m_t0, nv(m_y), m_method, m_iter, m_itol, &m_reltol, - nv(m_abstol), m_data, NULL, TRUE, m_iopt, + nv(m_abstol), m_data, NULL, 1, m_iopt, DATA_PTR(m_ropt), NULL); } else { m_cvode_mem = CVodeMalloc(m_neq, cvode_rhs, m_t0, nv(m_y), m_method, m_iter, m_itol, &m_reltol, - &m_abstols, m_data, NULL, TRUE, m_iopt, + &m_abstols, m_data, NULL, 1, m_iopt, DATA_PTR(m_ropt), NULL); } @@ -252,13 +252,13 @@ namespace Cantera { if (m_itol) { result = CVReInit(m_cvode_mem, cvode_rhs, m_t0, nv(m_y), m_method, m_iter, m_itol, &m_reltol, - nv(m_abstol), m_data, NULL, TRUE, m_iopt, + nv(m_abstol), m_data, NULL, 1, m_iopt, DATA_PTR(m_ropt), NULL); } else { result = CVReInit(m_cvode_mem, cvode_rhs, m_t0, nv(m_y), m_method, m_iter, m_itol, &m_reltol, - &m_abstols, m_data, NULL, TRUE, m_iopt, + &m_abstols, m_data, NULL, 1, m_iopt, DATA_PTR(m_ropt), NULL); } diff --git a/tools/testtools/csvdiff.cpp b/tools/testtools/csvdiff.cpp index ce0811242..73a32f325 100644 --- a/tools/testtools/csvdiff.cpp +++ b/tools/testtools/csvdiff.cpp @@ -42,10 +42,6 @@ using namespace std; #include "mdp_allo.h" #include "tok_input_util.h" -#ifndef TRUE -# define TRUE 1 -# define FALSE 0 -#endif #ifndef MAX # define MAX(x,y) (( (x) > (y) ) ? (x) : (y)) #endif @@ -53,7 +49,7 @@ using namespace std; # define MIN(x,y) (( (x) < (y) ) ? (x) : (y)) #endif -int Debug_Flag = TRUE; +int Debug_Flag = true; double grtol = 1.0E-3; double gatol = 1.0E-9; @@ -322,7 +318,7 @@ static void get_sizes(FILE *fp, int &nTitleLines, int &nColTitleLines, if (fieldToken.ntokes != 1) { break; } - int rerr = FALSE; + bool rerr = false; (void) tok_to_double(&fieldToken, DBL_MAX, -DBL_MAX, 0.0, &rerr); if (!rerr) { @@ -357,20 +353,20 @@ static void get_sizes(FILE *fp, int &nTitleLines, int &nColTitleLines, } if (doingLineType == LT_COLTITLE) { - int goodDataLine = TRUE; - int rerr = FALSE; + bool goodDataLine = true; + bool rerr = false; for (j = 0; j < ncolsFound; j++) { char *fieldStr = strlets[j]; fillTokStruct(&fieldToken, fieldStr); if (fieldToken.ntokes != 1) { - goodDataLine = FALSE; + goodDataLine = false; break; } if ((ColIsFloat[j]) == 1) { (void) tok_to_double(&fieldToken, DBL_MAX, -DBL_MAX, 0.0, &rerr); if (rerr) { - goodDataLine = FALSE; + goodDataLine = false; break; } } @@ -403,20 +399,20 @@ static void get_sizes(FILE *fp, int &nTitleLines, int &nColTitleLines, if (scanLine[ccount-1] == ',') scanLine[ccount-1] = '\0'; } int ncolsFound = breakStrCommas(scanLine, strlets, nCol); - int goodDataLine = TRUE; - int rerr = FALSE; + bool goodDataLine = true; + bool rerr = false; for (j = 0; j < ncolsFound; j++) { char *fieldStr = strlets[j]; fillTokStruct(&fieldToken, fieldStr); if (fieldToken.ntokes != 1) { - goodDataLine = FALSE; + goodDataLine = false; break; } if (ColIsFloat[j] == 1) { (void) tok_to_double(&fieldToken, DBL_MAX, -DBL_MAX, 0.0, &rerr); if (rerr) { - goodDataLine = FALSE; + goodDataLine = false; break; } } @@ -551,21 +547,21 @@ read_values(FILE *fp, double **NVValues, char ***NSValues, int nCol, int nDataRo if (scanLine[ccount-1] == ',') scanLine[ccount-1] = '\0'; } int ncolsFound = breakStrCommas(scanLine, strlets, nCol); - int goodDataLine = TRUE; - int rerr = FALSE; + bool goodDataLine = true; + bool rerr = false; for (j = 0; j < ncolsFound; j++) { char *fieldStr = strlets[j]; NSValues[j][i] = mdp_copy_string(strlets[j]); fillTokStruct(&fieldToken, fieldStr); if (fieldToken.ntokes != 1) { - goodDataLine = FALSE; + goodDataLine = false; break; } if (ColIsFloat[j]) { value = tok_to_double(&fieldToken, DBL_MAX, -DBL_MAX, 0.0, &rerr); if (rerr) { - goodDataLine = FALSE; + goodDataLine = false; break; } NVValues[j][i] = value; @@ -632,7 +628,8 @@ int main(int argc, char *argv[]) int *ColIsFloat1 = NULL, *ColIsFloat2 = NULL; double *curVarValues1 = NULL, *curVarValues2 = NULL; char ** curStringValues1 = NULL, **curStringValues2 = NULL; - int i, j, ndiff, jmax, i1, i2, k, found; + int i, j, ndiff, jmax, i1, i2, k; + bool found; double max_diff, rel_diff; int testPassed = RT_PASSED; double atol_j, atol_arg = 0.0, rtol_arg = 0.0; @@ -851,13 +848,13 @@ int main(int argc, char *argv[]) compColList = mdp_alloc_int_2(nColMAX, 2, -1); nColcomparisons = 0; for (i = 0; i < nCol1; i++) { - found = FALSE; + found = false; for (j = 0; j < nCol2; j++) { if (!strcmp(ColNames1[i], ColNames2[j])) { compColList[nColcomparisons][0] = i; compColList[nColcomparisons][1] = j; nColcomparisons++; - found = TRUE; + found = true; break; } } @@ -868,9 +865,9 @@ int main(int argc, char *argv[]) } } for (j = 0; j < nCol2; j++) { - found = FALSE; + found = false; for (i = 0; i < nColcomparisons; i++) { - if (compColList[i][1] == j) found = TRUE; + if (compColList[i][1] == j) found = true; } if (! found) { printf("csvdiff WARNING Variable %s (%d) in second file " diff --git a/tools/testtools/tok_input_util.cpp b/tools/testtools/tok_input_util.cpp index c1c6d83ce..6cc9e2d67 100644 --- a/tools/testtools/tok_input_util.cpp +++ b/tools/testtools/tok_input_util.cpp @@ -15,43 +15,43 @@ static char COM_CHAR = '!'; /* This is used as a comment character */ static char COM_CHAR2 = '#'; /* This is used as a 2nd comment character */ static char KEY_CHAR = '='; /* This is used to separate the key_string from the rest of the line */ -static int PrintInputFile = TRUE; /* Used to turn on and off the +static int PrintInputFile = true; /* Used to turn on and off the printing of the input file */ /*************** R O U T I N E S I N T H E F I L E ******************* * * NAME TYPE CALLED_BY *-------------------------------------------------------------------- -* get_next_keyLine BOOLEAN extern +* get_next_keyLine bool extern * tok_to_int int extern * str_to_int int extern, tok_to_int * tok_to_double double extern * str_to_double double extern,tok_to_double -* tok_to_boolean BOOLEAN extern -* str_to_boolean BOOLEAN extern,tok_to_boolean +* tok_to_boolean bool extern +* str_to_boolean bool extern,tok_to_boolean * tok_to_string char * extern * * * scan_for_int int extern * scan_for_double double extern * scan_for_string char * extern -* scan_for_boolean BOOLEAN extern +* scan_for_boolean bool extern * scan_for_line int extern * read_line int scan_for_line, * get_next_keyLine -* interpret_int static BOOLEAN str_to_int + others -* interpret_boolean static BOOLEAN str_to_boolean -* interpret_double static BOOLEAN str_to_double +* interpret_int static bool str_to_int + others +* interpret_boolean static bool str_to_boolean +* interpret_double static bool str_to_double * strip int read_input_file, * look_for, * get_next_keyLine * read_string static void scan_for_line * stokenize int fillTokStruct -* outofbnds static BOOLEAN all -* strmatch BOOLEAN extern, toktokmatch -* strstrmatch BOOLEAN extern -* strtokmatch BOOLEAN extern -* toktokmatch BOOLEAN extern, strtokmatch +* outofbnds static bool all +* strmatch bool extern, toktokmatch +* strstrmatch bool extern +* strtokmatch bool extern +* toktokmatch bool extern, strtokmatch * strstrmatch * fillTokStruct void extern, strtokmatch * strstrmatch, @@ -63,12 +63,12 @@ static int PrintInputFile = TRUE; /* Used to turn on and off the * Definitions of static functions: */ -static BOOLEAN outofbnds(const double, const double, const double ); -static BOOLEAN interpret_boolean(const char *, int *, const int); -static BOOLEAN interpret_int (const char *, int *, const int, const int, - const int); -static BOOLEAN interpret_double (const char *, double *, const double, - const double, const double); +static bool outofbnds(const double, const double, const double ); +static bool interpret_boolean(const char *, int *, const int); +static bool interpret_int (const char *, int *, const int, const int, + const int); +static bool interpret_double(const char *, double *, const double, + const double, const double); /************ Member Functions for the TOKEN Structure ********************/ @@ -111,7 +111,7 @@ TOKEN::~TOKEN() /**************************************************************************/ -BOOLEAN get_next_keyLine(FILE *ifp, TOKEN *keyLineTok, TOKEN *keyArgTok) +bool get_next_keyLine(FILE *ifp, TOKEN *keyLineTok, TOKEN *keyArgTok) /* * This routine reads the input file to obtain the next line of * uncommented @@ -167,7 +167,7 @@ BOOLEAN get_next_keyLine(FILE *ifp, TOKEN *keyLineTok, TOKEN *keyArgTok) * keyArgTok->tok_ptr[3] = "Not" * keyArgTok->tok_ptr[4] = "Even" * - * The function returns TRUE if there is a next line to process. + * The function returns true if there is a next line to process. * It returns false if an EOF is encountered. */ { @@ -182,7 +182,7 @@ BOOLEAN get_next_keyLine(FILE *ifp, TOKEN *keyLineTok, TOKEN *keyArgTok) */ if (ifp == NULL || keyLineTok == NULL || keyArgTok == NULL) { fprintf(stderr, "get_next_keyLine ERROR, arguments are bad\n"); - return(FALSE); + return(false); } /* @@ -192,7 +192,7 @@ BOOLEAN get_next_keyLine(FILE *ifp, TOKEN *keyLineTok, TOKEN *keyArgTok) do_it_again: do { if ((retn_value = read_string(ifp, save_input, '\n')) < 0) { - return(FALSE); + return(false); } if (PrintInputFile) { if (retn_value <=0) printf ("%s\n", save_input); @@ -238,14 +238,14 @@ BOOLEAN get_next_keyLine(FILE *ifp, TOKEN *keyLineTok, TOKEN *keyArgTok) fillTokStruct(keyLineTok, save_input); fillTokStruct(keyArgTok, token_start); - return (TRUE); + return (true); } /**************************************************************************/ /**************************************************************************/ /**************************************************************************/ int tok_to_int(const TOKEN *tokPtr, const int maxVal, const int minVal, - const int defaultVal, BOOLEAN *error) + const int defaultVal, bool *error) /* * Interprets the first string of a TOKEN structure as an int. * Returns the interpreted value as the return value. @@ -268,7 +268,7 @@ int tok_to_int(const TOKEN *tokPtr, const int maxVal, const int minVal, * default may also be specified by setting devault_value to * NO_DEFAULT_INT. * - * If there is an error, *error is set to TRUE. *error isn't touched + * If there is an error, *error is set to true. *error isn't touched * if there isn't an error. */ { @@ -277,7 +277,7 @@ int tok_to_int(const TOKEN *tokPtr, const int maxVal, const int minVal, else if (tokPtr->ntokes > 1) { (void) fprintf(stderr, "ERROR: tok_to_int, ntokes > 1: %s\n", tokPtr->orig_str); - *error = TRUE; + *error = true; } return(str_to_int(tokPtr->tok_ptr[0], maxVal, minVal, defaultVal, error)); } @@ -286,7 +286,7 @@ int tok_to_int(const TOKEN *tokPtr, const int maxVal, const int minVal, /**************************************************************************/ int str_to_int(const char *int_string, const int maxVal, const int minVal, - const int defaultVal, BOOLEAN *error) + const int defaultVal, bool *error) /* * Interprets a stripped character string as an integer. * Bounds checking is done on the value before returning. Value @@ -305,19 +305,19 @@ int str_to_int(const char *int_string, const int maxVal, const int minVal, * default may also be specified by setting devault_value to * NO_DEFAULT_INT. * - * If there is an error, *error is set to TRUE. *error isn't touched + * If there is an error, *error is set to true. *error isn't touched * if there isn't an error. */ { - int retn_value, check = FALSE; + int retn_value, check = false; double LmaxVal, LminVal; - if (defaultVal == NO_DEFAULT_INT) check = TRUE; + if (defaultVal == NO_DEFAULT_INT) check = true; if (interpret_int(int_string, &retn_value, maxVal, minVal, defaultVal)) { if (check) { if (retn_value == NO_DEFAULT_INT) { (void) fprintf(stderr, "ERROR: str_to_int: Default not allowed\n"); - *error = TRUE; + *error = true; } } if (maxVal < INT_MAX) LmaxVal = (double) maxVal + 0.01; @@ -329,10 +329,10 @@ int str_to_int(const char *int_string, const int maxVal, const int minVal, "ERROR: str_to_int outofbnds:\n\t\"%s\"\n", int_string); fprintf(stderr,"\tmax = %d, min = %d\n", maxVal, minVal); - *error = TRUE; + *error = true; } } else - *error = TRUE; + *error = true; return (retn_value); } /**************************************************************************/ @@ -341,7 +341,7 @@ int str_to_int(const char *int_string, const int maxVal, const int minVal, double tok_to_double(const TOKEN * tokPtr, const double maxVal, const double minVal, const double defaultVal, - BOOLEAN *error) + bool *error) /* * Interprets the first string of a TOKEN structure as a double. * Returns the interpreted value as the return value. @@ -378,7 +378,7 @@ double tok_to_double(const TOKEN * tokPtr, const double maxVal, * The absence of a default may also be specified by setting the * value of default_value to NO_DEFAULT_DOUBLE. * - * If there is an error, *error is set to TRUE. *error isn't touched + * If there is an error, *error is set to true. *error isn't touched * if there isn't an error. */ { @@ -387,7 +387,7 @@ double tok_to_double(const TOKEN * tokPtr, const double maxVal, else if (tokPtr->ntokes > 1) { (void) fprintf(stderr, "ERROR: tok_to_double, ntokes > 1: %s\n", tokPtr->orig_str); - *error = TRUE; + *error = true; } return(str_to_double(tokPtr->tok_ptr[0], maxVal, minVal, defaultVal, error)); } @@ -397,7 +397,7 @@ double tok_to_double(const TOKEN * tokPtr, const double maxVal, double str_to_double(const char *dbl_string, const double maxVal, const double minVal, const double defaultVal, - BOOLEAN *error) + bool *error) /* * Interprets a stripped character string as a double. Returns the * interpreted value as the return value. @@ -432,47 +432,47 @@ double str_to_double(const char *dbl_string, const double maxVal, * default may also be specified by setting the value of default_value * to NO_DEFAULT_DOUBLE. * - * If there is an error, *error is set to TRUE. *error isn't touched + * If there is an error, *error is set to true. *error isn't touched * if there isn't an error. */ { double retn_value; - int check = FALSE; - if (defaultVal == NO_DEFAULT_DOUBLE) check = TRUE; + int check = false; + if (defaultVal == NO_DEFAULT_DOUBLE) check = true; if (interpret_double(dbl_string, &retn_value, maxVal, minVal, defaultVal)) { if (check) if (retn_value == NO_DEFAULT_DOUBLE) { (void) fprintf(stderr, "ERROR: keyLine_double: Default not allowed\n"); - *error = TRUE; + *error = true; } if (outofbnds(retn_value, maxVal, minVal)) { (void) fprintf(stderr, "ERROR: keyLine_double outofbnds:\n\t\"%s\"\n", dbl_string); (void) fprintf(stderr,"\tmax = %e, min = %e\n", maxVal, minVal); - *error = TRUE; + *error = true; } } else - *error = TRUE; + *error = true; return (retn_value); } /*****************************************************************************/ /*****************************************************************************/ /*****************************************************************************/ -BOOLEAN tok_to_boolean(const TOKEN *tokPtr, const int default_value, - BOOLEAN *error) +bool tok_to_boolean(const TOKEN *tokPtr, const int default_value, + bool *error) /* - * Interprets the first string of a TOKEN structure as a BOOLEAN. - * (i.e., TRUE or FALSE). Returns the interpreted value as the + * Interprets the first string of a TOKEN structure as a bool. + * (i.e., true or false). Returns the interpreted value as the * return value. * Errors conditions are created if more than one token is found. * * The following character strings are interpreted * (case doesn't matter): * - * TRUE = "YES", "TRUE", "T", "Y" - * FALSE = "NO, "FALSE", "N", "F" + * true = "YES", "true", "T", "Y" + * false = "NO, "false", "N", "F" * default_value = "DEFAULT" or "" * * A default may be specified on the command line. The absence of a @@ -480,7 +480,7 @@ BOOLEAN tok_to_boolean(const TOKEN *tokPtr, const int default_value, * If tokPtr contains no tokens, this routine will try to use the * default value. * - * If there is an error, *error is set to TRUE. *error isn't touched + * If there is an error, *error is set to true. *error isn't touched * if there isn't an error. */ { @@ -489,7 +489,7 @@ BOOLEAN tok_to_boolean(const TOKEN *tokPtr, const int default_value, else if (tokPtr->ntokes > 1) { (void) fprintf(stderr, "ERROR: tok_to_boolean, ntokes > 1: %s\n", tokPtr->orig_str); - *error = TRUE; + *error = true; } return(str_to_boolean(tokPtr->tok_ptr[0], default_value, error)); } @@ -497,23 +497,23 @@ BOOLEAN tok_to_boolean(const TOKEN *tokPtr, const int default_value, /******************************************************************************/ /******************************************************************************/ -BOOLEAN str_to_boolean(const char *string, const int default_value, - BOOLEAN *error) +bool str_to_boolean(const char *string, const int default_value, + bool *error) /* - * Interprets a stripped character string as a BOOLEAN value - * (i.e., TRUE or FALSE). It returns that value as the return value. + * Interprets a stripped character string as a bool value + * (i.e., true or false). It returns that value as the return value. * * The following character strings are interpreted * (case doesn't matter): * - * TRUE = "YES", "TRUE", "T", "Y" - * FALSE = "NO, "FALSE", "N", "F" + * true = "YES", "true", "T", "Y" + * false = "NO, "false", "N", "F" * default_value = "DEFAULT" * * A default may be specified on the command line. The absence of a * default may also be specified by using the value of NO_DEFAULT_INT. * - * If there is an error, *error is set to TRUE. *error isn't touched + * If there is an error, *error is set to true. *error isn't touched * if there isn't an error. */ { @@ -522,18 +522,18 @@ BOOLEAN str_to_boolean(const char *string, const int default_value, if (retn_value == NO_DEFAULT_BOOLEAN) { (void) fprintf(stderr, "ERROR: keyLine_boolean: Default not allowed\n"); - *error = TRUE; + *error = true; } } else - *error = TRUE; - return ((BOOLEAN) retn_value); + *error = true; + return (retn_value != 0); } /**************************************************************************/ /**************************************************************************/ /**************************************************************************/ char *tok_to_string(const TOKEN *tokPtr, const int maxTok, - const int minTok, const char *defaultVal, BOOLEAN *error) + const int minTok, const char *defaultVal, bool *error) /* * Interprets the arguments in a TOKEN structure as a string. * It mallocs new space for the string, are returns the pointer to it. @@ -551,7 +551,7 @@ char *tok_to_string(const TOKEN *tokPtr, const int maxTok, * default may also be specified by setting devault_value to * NO_DEFAULT_INT. * - * If there is an error, *error is set to TRUE. *error isn't touched + * If there is an error, *error is set to true. *error isn't touched * if there isn't an error. */ { @@ -565,7 +565,7 @@ char *tok_to_string(const TOKEN *tokPtr, const int maxTok, (void) fprintf(stderr, "ERROR: tok_to_String:\n\t\"%s\"\n", tokPtr->orig_str); (void) fprintf(stderr,"\tmaxTok = %d, minTok = %d\n", maxTok, minTok); - *error = TRUE; + *error = true; } return (str); } @@ -574,7 +574,7 @@ char *tok_to_string(const TOKEN *tokPtr, const int maxTok, /*****************************************************************************/ char *str_to_string(const char *str, const char *defaultVal, - BOOLEAN *error) + bool *error) /* * Interprets the argument string as a string. * It mallocs new space for the string, are returns the pointer to it. @@ -589,18 +589,18 @@ char *str_to_string(const char *str, const char *defaultVal, * default may also be specified by setting devault_value to * NO_DEFAULT_INT. * - * If there is an error, *error is set to TRUE. *error isn't touched + * If there is an error, *error is set to true. *error isn't touched * if there isn't an error. */ { if (str == NULL) { - *error = TRUE; + *error = true; (void) fprintf(stderr,"ERROR str_to_string: str is uninialized\n"); return(NULL); } if (strmatch(str, DEFAULT_STR)) { if (strmatch(defaultVal, NO_DEFAULT_STR)) { - *error = TRUE; + *error = true; (void) fprintf(stderr,"ERROR str_to_string: no default allowed\n"); return(copy_string(NO_DEFAULT_STR)); } else @@ -657,7 +657,7 @@ int scan_for_int(FILE *ifp, const char *str, const int maxVal, /**************************************************************************/ /**************************************************************************/ -BOOLEAN scan_for_boolean(FILE *ifp, const char *string) +bool scan_for_boolean(FILE *ifp, const char *string) /* * Scans the file for a line matching string. Then, interprets * everything after the equals sign as a single boolean value @@ -676,7 +676,7 @@ BOOLEAN scan_for_boolean(FILE *ifp, const char *string) (void) fprintf(stderr, "scan_for_boolean: default not allowed\n"); exit (-1); } - return((BOOLEAN) ret_value); + return (ret_value != 0); } } (void) fprintf(stderr, "scan_for_boolean: ERROR on line \"%s\"\n", string); @@ -723,7 +723,7 @@ double scan_for_double(FILE *ifp, const char *string, const double maxVal, double retn_value; char *tok_ptr[2]; char input[MAX_INPUT_STR_LN + 1]; - if (scan_for_line(ifp, string, input, KEY_CHAR, TRUE) < 0) exit(-1); + if (scan_for_line(ifp, string, input, KEY_CHAR, true) < 0) exit(-1); if (stokenize(input, DELIMITERS, tok_ptr, 2) > 0) { if (interpret_double(tok_ptr[0], &retn_value, maxVal, minVal, NO_DEFAULT_DOUBLE)) { @@ -809,7 +809,7 @@ int scan_for_line(FILE *ifp, const char *str, char input[], */ { int retn_value, i; - BOOLEAN found = FALSE; + bool found = false; char match_string[MAX_INPUT_STR_LN+1], save_input[MAX_INPUT_STR_LN+1]; static const char *ename = "ERROR scan_for_line: "; @@ -1023,8 +1023,8 @@ int read_string(FILE *ifp, char string[], const char ch) } /**************************************************************************/ -static BOOLEAN interpret_boolean(const char *token, int *ret_value, - const int default_value) +static bool interpret_boolean(const char *token, int *ret_value, + const int default_value) /* * This routine interprets a string token to be either true or false * and then returns the appropriate answer as an int value in the @@ -1039,37 +1039,37 @@ static BOOLEAN interpret_boolean(const char *token, int *ret_value, switch (token[0]) { case 't': case 'y': - *ret_value = TRUE; break; + *ret_value = true; break; case 'f': case 'n': - *ret_value = FALSE; break; + *ret_value = false; break; default: - return (FALSE); + return (false); } } else { if (strmatch(token,"true") || strmatch(token,"yes")) - *ret_value = TRUE; + *ret_value = true; else if (strmatch(token,"false") || strmatch(token,"no")) - *ret_value = FALSE; + *ret_value = false; else if (strmatch(token,DEFAULT_STR) == 0) { *ret_value = default_value; } else { - return (FALSE); + return (false); } } - return (TRUE); + return (true); } /**************************************************************************/ -static BOOLEAN interpret_int(const char *token, int *retn_value, - const int maxVal, const int minVal, +static bool interpret_int(const char *token, int *retn_value, + const int maxVal, const int minVal, const int defaultVal) /* * This routine interprets a string token to be an integer * and then returns the appropriate answer as an int value in the * variable ret_value. - * Errors are indicated by returning FALSE. Success is indicated - * by returning TRUE. + * Errors are indicated by returning false. Success is indicated + * by returning true. * * Certain ascii strings are checked for first (case is insignificant): * @@ -1108,23 +1108,23 @@ static BOOLEAN interpret_int(const char *token, int *retn_value, else { if ((retn = sscanf(token, "%d", retn_value)) != 1) { *retn_value = retn; - return (FALSE); + return (false); } } - return (TRUE); + return (true); } /******************************************************************************/ /******************************************************************************/ /******************************************************************************/ -static BOOLEAN interpret_double(const char *token, double *retn_value, - const double maxVal, const double minVal, - const double defaultVal) +static bool interpret_double(const char *token, double *retn_value, + const double maxVal, const double minVal, + const double defaultVal) /* * This routine interprets a string token to be a double * and then returns the appropriate answer as a double value in the * variable retn_value. - * The function itself returns TRUE if successful or FALSE if unsuccessful + * The function itself returns true if successful or false if unsuccessful * * * Certain ascii strings are checked for first (case is insignificant): @@ -1180,11 +1180,11 @@ static BOOLEAN interpret_double(const char *token, double *retn_value, else { if ((retn = sscanf(token, "%e", &retn_float)) != 1) { *retn_value = (double) retn; - return (FALSE); + return (false); } else *retn_value = (double) retn_float; } - return(TRUE); + return(true); } /******************************************************************************/ /******************************************************************************/ @@ -1338,16 +1338,16 @@ int stokenize(char *string, const char *delimiters, char *tok_ptr[], /*****************************************************************************/ /*****************************************************************************/ -static BOOLEAN outofbnds(const double value, const double maxVal, - const double minVal) +static bool outofbnds(const double value, const double maxVal, + const double minVal) /* * This routine checks the bounds of a single double value. * If it is inside or on the bounds, it returns false. * If it is outside the bounds, it returns true. */ { - if ((value <= maxVal) && (value >= minVal)) return (FALSE); - return(TRUE); + if ((value <= maxVal) && (value >= minVal)) return (false); + return(true); } /****************************************************************************** * @@ -1360,18 +1360,18 @@ static BOOLEAN outofbnds(const double value, const double maxVal, * If they are, it returns true * If they aren't, it returns false */ -BOOLEAN strmatch(const char *s1, const char *s2) +bool strmatch(const char *s1, const char *s2) { while (*s1 != '\0') { # if defined (_INCLUDE_XOPEN_SOURCE) && ! defined(__lint) - if (_tolower((*s1++)) != _tolower((*s2++))) return (FALSE); + if (_tolower((*s1++)) != _tolower((*s2++))) return (false); # else - if (tolower(*s1) != tolower(*s2)) return (FALSE); + if (tolower(*s1) != tolower(*s2)) return (false); s1++; s2++; # endif } - if (*s2 != '\0') return (FALSE); - return (TRUE); + if (*s2 != '\0') return (false); + return (true); } /***************************************************************************** @@ -1381,7 +1381,7 @@ BOOLEAN strmatch(const char *s1, const char *s2) * This routine checks whether two strings are the same modulo differences * in their white space */ -BOOLEAN strstrmatch(const char *s1, const char*s2) +bool strstrmatch(const char *s1, const char*s2) { struct TOKEN tmpKeyStruct1, tmpKeyStruct2; fillTokStruct(&tmpKeyStruct1, s1); @@ -1399,7 +1399,7 @@ BOOLEAN strstrmatch(const char *s1, const char*s2) * If they are, it returns true * If they aren't, it returns false */ -BOOLEAN strtokmatch(const TOKEN *keyptr, const char*s2) +bool strtokmatch(const TOKEN *keyptr, const char*s2) { struct TOKEN tmpKeyStruct; fillTokStruct(&tmpKeyStruct, s2); @@ -1414,15 +1414,15 @@ BOOLEAN strtokmatch(const TOKEN *keyptr, const char*s2) * same data up to differences in white space. * Case is ignored as well, as strmatch is called. */ -BOOLEAN toktokmatch(const TOKEN *keyptr1, const TOKEN *keyptr2) +bool toktokmatch(const TOKEN *keyptr1, const TOKEN *keyptr2) { int i = keyptr1->ntokes; - if (i != keyptr2->ntokes) return FALSE; + if (i != keyptr2->ntokes) return false; while (i > 0) { i--; - if (!strmatch(keyptr1->tok_ptr[i], keyptr2->tok_ptr[i])) return FALSE; + if (!strmatch(keyptr1->tok_ptr[i], keyptr2->tok_ptr[i])) return false; } - return TRUE; + return true; } /**************************************************************************/ @@ -1527,14 +1527,14 @@ void strip_item_from_token(int iword, TOKEN *tok) if (!tok) return; if (iword < 0 || iword > tok->ntokes) return; #ifdef _MSC_VER - __w64 int ioffset = tok->tok_ptr[iword] - tok->tok_str; + __w64 size_t ioffset = tok->tok_ptr[iword] - tok->tok_str; #else size_t ioffset = tok->tok_ptr[iword] - tok->tok_str; #endif size_t ilength = strlen(tok->tok_ptr[iword]); #ifdef _MSC_VER - __w64 int i = ioffset; - __w64 int j = ioffset + ilength; + __w64 size_t i = ioffset; + __w64 size_t j = ioffset + ilength; #else size_t i = ioffset; size_t j = ioffset + ilength; diff --git a/tools/testtools/tok_input_util.h b/tools/testtools/tok_input_util.h index f0b6eb1d0..c59cfc920 100644 --- a/tools/testtools/tok_input_util.h +++ b/tools/testtools/tok_input_util.h @@ -13,15 +13,6 @@ #define MAXTOKENS 20 #endif -#ifndef TRUE -# define TRUE 1 -# define FALSE 0 -#endif - -#ifndef BOOLEAN -# define BOOLEAN int -#endif - /**************************************************************************/ /* TOKEN structure: * This structure is used to parse strings. The original string is @@ -51,25 +42,25 @@ struct TOKEN { /* Prototypes for routines tok_input_util.c */ /**************************************************************************/ -extern BOOLEAN get_next_keyLine(FILE *, TOKEN *, TOKEN *); +extern bool get_next_keyLine(FILE *, TOKEN *, TOKEN *); extern int tok_to_int (const TOKEN *, const int, const int, - const int, BOOLEAN *); + const int, bool *); extern int str_to_int (const char *, const int, const int, - const int, BOOLEAN *); + const int, bool *); extern double tok_to_double (const TOKEN *, const double, const double, - const double, BOOLEAN *); + const double, bool *); extern double str_to_double (const char *, const double, const double, - const double, BOOLEAN *); -extern BOOLEAN tok_to_boolean(const TOKEN *, const int, BOOLEAN *); -extern BOOLEAN str_to_boolean(const char *, const int, BOOLEAN *); + const double, bool *); +extern bool tok_to_boolean(const TOKEN *, const int, bool *); +extern bool str_to_boolean(const char *, const int, bool *); extern char *tok_to_string (const TOKEN *, const int, const int, - const char *, BOOLEAN *); -extern char *str_to_string (const char *, const char *, BOOLEAN *); + const char *, bool *); +extern char *str_to_string (const char *, const char *, bool *); extern int scan_for_int(FILE *, const char *, const int, const int); extern double scan_for_double(FILE *, const char *, const double, const double); extern char *scan_for_string(FILE *, const char *, const int, const int); -extern BOOLEAN scan_for_boolean(FILE *, const char *); +extern bool scan_for_boolean(FILE *, const char *); extern int scan_for_line(FILE *, const char *, char [], const char, const int); extern int read_line(FILE *, char [], const int); @@ -78,10 +69,10 @@ extern int strip(char []); extern void lower_case(char []); extern char *TokToStrng(const TOKEN *); extern int stokenize(char *, const char *, char *[], const int); -extern BOOLEAN strmatch(const char *, const char*); -extern BOOLEAN strstrmatch(const char *, const char*); -extern BOOLEAN strtokmatch(const TOKEN *, const char *); -extern BOOLEAN toktokmatch(const TOKEN *, const TOKEN *); +extern bool strmatch(const char *, const char*); +extern bool strstrmatch(const char *, const char*); +extern bool strtokmatch(const TOKEN *, const char *); +extern bool toktokmatch(const TOKEN *, const TOKEN *); extern void fillTokStruct(TOKEN *, const char *); extern void copyTokStruct(TOKEN *, const TOKEN *); extern int in_char_list(const char * const, const char ** const, int);