diff --git a/phreeqcpp/basicsubs.cpp b/phreeqcpp/basicsubs.cpp index 758112f9..a21f34d5 100644 --- a/phreeqcpp/basicsubs.cpp +++ b/phreeqcpp/basicsubs.cpp @@ -195,7 +195,7 @@ diff_c(const char *species_name) g = s_ptr->dw; if (s_ptr->dw_t) g *= exp(s_ptr->dw_t / tk_x - s_ptr->dw_t / 298.15); - g *= viscos_0_25 / viscos; + g *= viscos_0_25 / viscos * tk_x / 298.15; } else { @@ -218,7 +218,7 @@ setdiff_c(const char *species_name, double d) g = s_ptr->dw; if (s_ptr->dw_t) g *= exp(s_ptr->dw_t / tk_x - s_ptr->dw_t / 298.15); - g *= viscos_0_25 / viscos; + g *= viscos_0_25 / viscos * tk_x / 298.15;; } else { @@ -2457,7 +2457,7 @@ total(const char *total_name) return (total_o_x / mass_water_aq_x); } std::string noplus = total_name; - replace(noplus, "+", ""); + replace(noplus, "(+", "("); master_ptr = master_bsearch(noplus.c_str()); t = 0.0; if (master_ptr == NULL) @@ -2528,7 +2528,7 @@ total_mole(const char *total_name) return (total_o_x); } std::string noplus = total_name; - replace(noplus, "+", ""); + replace(noplus, "(+", "("); master_ptr = master_bsearch(noplus.c_str()); t = 0.0; if (master_ptr == NULL) diff --git a/phreeqcpp/common/Parser.cxx b/phreeqcpp/common/Parser.cxx index db7d3556..4f6665ae 100644 --- a/phreeqcpp/common/Parser.cxx +++ b/phreeqcpp/common/Parser.cxx @@ -899,7 +899,7 @@ CParser::STATUS_TYPE CParser::parse_couple(std::string & token) return PARSER_OK; } - while (Utilities::replace("+", "", token)); + while (Utilities::replace("(+", "(", token)); std::string::iterator ptr = token.begin(); std::string elt1; diff --git a/phreeqcpp/tidy.cpp b/phreeqcpp/tidy.cpp index 4c95089b..1c9c0884 100644 --- a/phreeqcpp/tidy.cpp +++ b/phreeqcpp/tidy.cpp @@ -1825,7 +1825,7 @@ tidy_punch(void) { std::pair< std::string, void *> &pair_ptr = current_selected_output->Get_totals()[i]; std::string noplus = pair_ptr.first; - replace(noplus, "+", ""); + replace(noplus, "(+", "("); pair_ptr.second = master_bsearch(noplus.c_str()); } diff --git a/phreeqcpp/utilities.cpp b/phreeqcpp/utilities.cpp index d7989864..67a030ee 100644 --- a/phreeqcpp/utilities.cpp +++ b/phreeqcpp/utilities.cpp @@ -660,7 +660,7 @@ parse_couple(char *token) str_tolower(token); return (OK); } - while (replace("+", "", token) == TRUE); + while (replace("(+", "(", token) == TRUE); cptr = token; get_elt(&cptr, elt1, &e1); if (*cptr != '(') @@ -848,9 +848,10 @@ replace(const char *str1, const char *str2, char *str) void Phreeqc:: replace(std::string &stds, const char* str1, const char* str2) { - size_t pos; + size_t pos, l; + l = strlen(str1); while ((pos = stds.find(str1)) != std::string::npos) { - stds.replace(pos, 1, str2); + stds.replace(pos, l, str2); } } /* ---------------------------------------------------------------------- */