From deeecb0c434fc42fc71768210890fd791830e931 Mon Sep 17 00:00:00 2001 From: David Parkhurst Date: Mon, 7 Dec 2020 15:24:11 -0700 Subject: [PATCH 1/3] needed strexpr in ADD_HEADING to allow expressions --- PBasic.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/PBasic.cpp b/PBasic.cpp index 7fff465d..c7ae3711 100644 --- a/PBasic.cpp +++ b/PBasic.cpp @@ -2651,7 +2651,7 @@ factor(struct LOC_exec * LINK) case tokadd_heading: require(toklp, LINK); - name = stringfactor(STR1, LINK); + name = strexpr(LINK); require(tokrp, LINK); PhreeqcPtr->current_user_punch->Get_headings().push_back(name); n.UU.val = (parse_all) ? 1 : (double)PhreeqcPtr->current_user_punch->Get_headings().size(); From 54b992f566cfe942751eaf1b14b5d63d25b16b30 Mon Sep 17 00:00:00 2001 From: David Parkhurst Date: Tue, 8 Dec 2020 20:38:18 -0700 Subject: [PATCH 2/3] working on tabs and no newline --- PBasic.cpp | 25 ++++++++++++++++++------- Phreeqc.cpp | 2 ++ Phreeqc.h | 3 +++ SelectedOutput.cpp | 2 +- SelectedOutput.h | 6 +++--- print.cpp | 9 ++++++--- 6 files changed, 33 insertions(+), 14 deletions(-) diff --git a/PBasic.cpp b/PBasic.cpp index c7ae3711..cf86ec60 100644 --- a/PBasic.cpp +++ b/PBasic.cpp @@ -2653,8 +2653,14 @@ factor(struct LOC_exec * LINK) require(toklp, LINK); name = strexpr(LINK); require(tokrp, LINK); - PhreeqcPtr->current_user_punch->Get_headings().push_back(name); - n.UU.val = (parse_all) ? 1 : (double)PhreeqcPtr->current_user_punch->Get_headings().size(); + if (PhreeqcPtr->current_user_punch != NULL) + { + PhreeqcPtr->current_user_punch->Get_headings().push_back(name); + n.UU.val = (parse_all) ? 1 : (double)PhreeqcPtr->current_user_punch->Get_headings().size(); + } else { + n.UU.val = 0; + } + break; case toksys: @@ -4131,7 +4137,8 @@ factor(struct LOC_exec * LINK) case tokno_newline_: n.stringval = true; - PhreeqcPtr->current_selected_output->Set_punch_newline(false); + //PhreeqcPtr->current_selected_output->Set_punch_newline(false); + PhreeqcPtr->Set_output_newline(false); this->skip_punch = true; break; @@ -5035,17 +5042,21 @@ cmdprint(struct LOC_exec *LINK) n = expr(LINK); if (n.stringval) { -/* fputs(n.UU.sval, stdout); */ - output_msg(PhreeqcPtr->sformatf("%s ", n.UU.sval)); - PhreeqcPtr->PHRQ_free(n.UU.sval); + if (!skip_punch) { + /* fputs(n.UU.sval, stdout); */ + output_msg(PhreeqcPtr->sformatf("%s ", n.UU.sval)); + PhreeqcPtr->PHRQ_free(n.UU.sval); + } } else /* printf("%s ", numtostr(STR1, n.UU.val)); */ output_msg(PhreeqcPtr->sformatf("%s ", numtostr(STR1, n.UU.val))); } - if (!semiflag) + if (!semiflag && PhreeqcPtr->Get_output_newline()) /* putchar('\n');*/ output_msg("\n"); + PhreeqcPtr->Set_output_newline(true); + skip_punch = false; } void PBasic:: diff --git a/Phreeqc.cpp b/Phreeqc.cpp index 08c747ce..77a16e0b 100644 --- a/Phreeqc.cpp +++ b/Phreeqc.cpp @@ -997,6 +997,7 @@ void Phreeqc::init(void) numerical_deriv = FALSE; count_total_steps = 0; phast = FALSE; + output_newline = true; llnl_temp = 0; llnl_count_temp = 0; llnl_adh = 0; @@ -2304,6 +2305,7 @@ Phreeqc::InternalCopy(const Phreeqc *pSrc) numerical_deriv = pSrc->numerical_deriv; count_total_steps = 0; phast = FALSE; + output_newline = true; /* llnl_temp = 0; llnl_count_temp = 0; diff --git a/Phreeqc.h b/Phreeqc.h index b1089dfd..d64a2431 100644 --- a/Phreeqc.h +++ b/Phreeqc.h @@ -1697,6 +1697,9 @@ protected: int count_total_steps; int phast; + bool output_newline; + inline void Set_output_newline(bool tf) { this->output_newline = tf;} + inline bool Get_output_newline() { return this->output_newline;} LDBLE *llnl_temp, *llnl_adh, *llnl_bdh, *llnl_bdot, *llnl_co2_coefs, a_llnl, b_llnl; int llnl_count_temp, llnl_count_adh, llnl_count_bdh, llnl_count_bdot, llnl_count_co2_coefs; diff --git a/SelectedOutput.cpp b/SelectedOutput.cpp index 492f4c82..4fee070f 100644 --- a/SelectedOutput.cpp +++ b/SelectedOutput.cpp @@ -39,7 +39,7 @@ SelectedOutput::SelectedOutput(int n, PHRQ_io *io) this->charge_balance = false; this->percent_error = false; this->new_line = true; - this->punch_newline = true; + //this->punch_newline = true; // as-is set flags // diff --git a/SelectedOutput.h b/SelectedOutput.h index 1d73278e..d376dacf 100644 --- a/SelectedOutput.h +++ b/SelectedOutput.h @@ -83,7 +83,7 @@ public: inline bool Get_charge_balance(void)const {return this->charge_balance;} inline bool Get_percent_error(void)const {return this->percent_error;} inline bool Get_new_line(void)const {return this->new_line; } - inline bool Get_punch_newline(void)const {return this->punch_newline; } + //inline bool Get_punch_newline(void)const {return this->punch_newline; } // as-is setters inline void Set_user_punch(bool tf) {this->user_punch = tf; this->set_user_punch = true;} @@ -108,7 +108,7 @@ public: inline void Set_charge_balance(bool tf) {this->charge_balance = tf; this->set_charge_balance = true;} inline void Set_percent_error(bool tf) {this->percent_error = tf; this->set_percent_error = true;} inline void Set_new_line(bool tf) {this->new_line = tf; this->set_new_line = true;} - inline void Set_punch_newline(bool tf) {this->punch_newline = tf; this->set_new_line = true; } + //inline void Set_punch_newline(bool tf) {this->punch_newline = tf; this->set_new_line = true; } // set flag getters inline bool was_set_user_punch()const {return this->set_user_punch;} @@ -183,7 +183,7 @@ protected: bool charge_balance; bool percent_error; bool new_line; - bool punch_newline; + //bool punch_newline; // as-is set flags bool set_user_punch; diff --git a/print.cpp b/print.cpp index e47c17a9..ffdb8376 100644 --- a/print.cpp +++ b/print.cpp @@ -195,9 +195,9 @@ punch_all(void) /* * new line for punch_file */ - if (current_selected_output->Get_new_line() && current_selected_output->Get_punch_newline()) + if (current_selected_output->Get_new_line() && this->Get_output_newline()) punch_msg("\n"); - current_selected_output->Set_punch_newline(true); + this->Set_output_newline(true); /* * signal end of row @@ -2399,7 +2399,10 @@ print_user_print(void) { error_msg("Fatal Basic error in USER_PRINT.", STOP); } - output_msg(sformatf("\n")); + if (this->output_newline) { + output_msg(sformatf("\n")); + } + this->Set_output_newline(true); if (use.Get_kinetics_in() == TRUE) { use.Set_kinetics_ptr(kinetics_ptr); From 3e4fc7ea18da750b2746422898dc100d74271b34 Mon Sep 17 00:00:00 2001 From: David Parkhurst Date: Wed, 9 Dec 2020 10:49:13 -0700 Subject: [PATCH 3/3] cleanup commented lines --- PBasic.cpp | 3 +-- SelectedOutput.cpp | 1 - SelectedOutput.h | 2 -- 3 files changed, 1 insertion(+), 5 deletions(-) diff --git a/PBasic.cpp b/PBasic.cpp index cf86ec60..9357be6e 100644 --- a/PBasic.cpp +++ b/PBasic.cpp @@ -4137,7 +4137,6 @@ factor(struct LOC_exec * LINK) case tokno_newline_: n.stringval = true; - //PhreeqcPtr->current_selected_output->Set_punch_newline(false); PhreeqcPtr->Set_output_newline(false); this->skip_punch = true; break; @@ -5045,8 +5044,8 @@ cmdprint(struct LOC_exec *LINK) if (!skip_punch) { /* fputs(n.UU.sval, stdout); */ output_msg(PhreeqcPtr->sformatf("%s ", n.UU.sval)); - PhreeqcPtr->PHRQ_free(n.UU.sval); } + PhreeqcPtr->PHRQ_free(n.UU.sval); } else /* printf("%s ", numtostr(STR1, n.UU.val)); */ diff --git a/SelectedOutput.cpp b/SelectedOutput.cpp index 4fee070f..b6941b5a 100644 --- a/SelectedOutput.cpp +++ b/SelectedOutput.cpp @@ -39,7 +39,6 @@ SelectedOutput::SelectedOutput(int n, PHRQ_io *io) this->charge_balance = false; this->percent_error = false; this->new_line = true; - //this->punch_newline = true; // as-is set flags // diff --git a/SelectedOutput.h b/SelectedOutput.h index d376dacf..bb2cea49 100644 --- a/SelectedOutput.h +++ b/SelectedOutput.h @@ -83,7 +83,6 @@ public: inline bool Get_charge_balance(void)const {return this->charge_balance;} inline bool Get_percent_error(void)const {return this->percent_error;} inline bool Get_new_line(void)const {return this->new_line; } - //inline bool Get_punch_newline(void)const {return this->punch_newline; } // as-is setters inline void Set_user_punch(bool tf) {this->user_punch = tf; this->set_user_punch = true;} @@ -108,7 +107,6 @@ public: inline void Set_charge_balance(bool tf) {this->charge_balance = tf; this->set_charge_balance = true;} inline void Set_percent_error(bool tf) {this->percent_error = tf; this->set_percent_error = true;} inline void Set_new_line(bool tf) {this->new_line = tf; this->set_new_line = true;} - //inline void Set_punch_newline(bool tf) {this->punch_newline = tf; this->set_new_line = true; } // set flag getters inline bool was_set_user_punch()const {return this->set_user_punch;}