From 32732dbdd54b3ff6f7576403618ec4f4710c4ab5 Mon Sep 17 00:00:00 2001 From: Alex Sinske Date: Wed, 5 Aug 2020 18:43:17 +0200 Subject: [PATCH 1/2] This solves the garbled error message and optionally adds an improved specific error message, which existed in EPANET 2.1 when a network has unconnected nodes. Another similar case in was code found and corrected with the same pattern, but could not be tested. --- src/errors.dat | 1 + src/input2.c | 3 ++- src/project.c | 3 ++- 3 files changed, 5 insertions(+), 2 deletions(-) diff --git a/src/errors.dat b/src/errors.dat index 4768cc3..7e4e5a3 100644 --- a/src/errors.dat +++ b/src/errors.dat @@ -44,6 +44,7 @@ DAT(226,"no head curve or power rating for pump") DAT(227,"invalid head curve for pump") DAT(230,"nonincreasing x-values for curve") DAT(233,"network has unconnected nodes") +DAT(2331,"network has an unconnected node with ID: ") // These errors apply only to API functions DAT(240,"nonexistent source") diff --git a/src/input2.c b/src/input2.c index a4d7fc8..27a0733 100644 --- a/src/input2.c +++ b/src/input2.c @@ -146,6 +146,7 @@ int readdata(Project *pr) char line[MAXLINE + 1], // Line from input data file wline[MAXLINE + 1]; // Working copy of input line + char errmsg[MAXMSG + 1] = ""; int sect, newsect, // Data sections errcode = 0, // Error code inperr, errsum; // Error code & total error count @@ -207,7 +208,7 @@ int readdata(Project *pr) // Check if max. line length exceeded if (strlen(line) >= MAXLINE) { - sprintf(pr->Msg, "%s section: %s", geterrmsg(214, pr->Msg), SectTxt[sect]); + sprintf(pr->Msg, "%s section: %s", geterrmsg(214, errmsg), SectTxt[sect]); writeline(pr, pr->Msg); writeline(pr, line); errsum++; diff --git a/src/project.c b/src/project.c index 8fb9a48..6893488 100644 --- a/src/project.c +++ b/src/project.c @@ -816,13 +816,14 @@ int unlinked(Project *pr) { Network *net = &pr->network; int i, count = 0; + char errmsg[MAXMSG + 1] = ""; for (i = 1; i <= net->Njuncs; i++) { if (pr->network.Adjlist[i] == NULL) { count++; - sprintf(pr->Msg, "Error 233: %s %s", geterrmsg(233, pr->Msg), net->Node[i].ID); + sprintf(pr->Msg, "Error 2331: %s %s", geterrmsg(2331, errmsg), net->Node[i].ID); writeline(pr, pr->Msg); } if (count >= 10) break; From ec11556d88a74526f754d9c0d860f2808b6347d7 Mon Sep 17 00:00:00 2001 From: Elad Salomons Date: Mon, 10 Aug 2020 11:20:51 +0300 Subject: [PATCH 2/2] Change error number 2331 to 234 --- src/errors.dat | 2 +- src/project.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/errors.dat b/src/errors.dat index 7e4e5a3..7a18303 100644 --- a/src/errors.dat +++ b/src/errors.dat @@ -44,7 +44,7 @@ DAT(226,"no head curve or power rating for pump") DAT(227,"invalid head curve for pump") DAT(230,"nonincreasing x-values for curve") DAT(233,"network has unconnected nodes") -DAT(2331,"network has an unconnected node with ID: ") +DAT(234,"network has an unconnected node with ID: ") // These errors apply only to API functions DAT(240,"nonexistent source") diff --git a/src/project.c b/src/project.c index 6893488..b470ec3 100644 --- a/src/project.c +++ b/src/project.c @@ -823,7 +823,7 @@ int unlinked(Project *pr) if (pr->network.Adjlist[i] == NULL) { count++; - sprintf(pr->Msg, "Error 2331: %s %s", geterrmsg(2331, errmsg), net->Node[i].ID); + sprintf(pr->Msg, "Error 234: %s %s", geterrmsg(234, errmsg), net->Node[i].ID); writeline(pr, pr->Msg); } if (count >= 10) break;