Merge remote-tracking branch 'upstream/dev' into dev

This commit is contained in:
Michael Tryby
2019-03-15 17:27:02 -04:00
3 changed files with 50 additions and 13 deletions

View File

@@ -7,7 +7,7 @@
Authors: see AUTHORS
Copyright: see AUTHORS
License: see LICENSE
Last Updated: 03/05/2019
Last Updated: 03/08/2019
******************************************************************************
*/
@@ -219,6 +219,13 @@ int DLLEXPORT EN_open(EN_Project p, const char *inpFile, const char *rptFile,
// Read input data
ERRCODE(getdata(p));
// Close input file
if (p->parser.InFile != NULL)
{
fclose(p->parser.InFile);
p->parser.InFile = NULL;
}
// Free temporary linked lists used for Patterns & Curves
freeTmplist(p->parser.Patlist);
freeTmplist(p->parser.Curvelist);

View File

@@ -1,6 +1,6 @@
/* MULTIPLE MINIMUM DEGREE ROW RE-ORDERING ALGORITHM
*
* Modified to work with Fortran-style arrays.
* Modified to work with Fortran-style arrays and be thread-safe.
*
*/

View File

@@ -7,7 +7,7 @@ Description: saves network data to an EPANET formatted text file
Authors: see AUTHORS
Copyright: see AUTHORS
License: see LICENSE
Last Updated: 11/27/2018
Last Updated: 03/09/2019
******************************************************************************
*/
@@ -38,7 +38,7 @@ extern char *TstatTxt[];
extern char *RptFlagTxt[];
extern char *SectTxt[];
void saveauxdata(Parser *parser, FILE *f)
void saveauxdata(Project *pr, FILE *f)
/*
------------------------------------------------------------
Writes auxilary data from original input file to new file.
@@ -47,13 +47,21 @@ void saveauxdata(Parser *parser, FILE *f)
{
int sect, newsect;
char *tok;
char write;
char line[MAXLINE + 1];
char s[MAXLINE + 1];
FILE *InFile = parser->InFile;
FILE *InFile = pr->parser.InFile;
sect = -1;
// Re-open the input file
if (InFile == NULL)
{
InFile = fopen(pr->parser.InpFname, "rt");
if (InFile == NULL) return;
}
rewind(InFile);
sect = -1;
// Read each line of the input file
while (fgets(line, MAXLINE, InFile) != NULL)
{
strcpy(s, line);
@@ -68,10 +76,8 @@ void saveauxdata(Parser *parser, FILE *f)
{
sect = newsect;
if (sect == _END) break;
}
}
// Write line of auxilary data to file
// Write section heading to file
switch (sect)
{
case _VERTICES:
@@ -79,12 +85,36 @@ void saveauxdata(Parser *parser, FILE *f)
case _BACKDROP:
case _TAGS:
fprintf(f, "%s", line);
}
}
}
// Write line of auxilary data to file
else
{
write = FALSE;
switch (sect)
{
case _VERTICES:
if (findlink(&pr->network, tok) || *tok == ';') write = TRUE; break;
case _TAGS:
if (*tok == ';' ||
(match("NODE", tok) && findnode(&pr->network, strtok(NULL, SEPSTR))) ||
(match("LINK", tok) && findlink(&pr->network, strtok(NULL, SEPSTR))))
write = TRUE;
break;
case _LABELS:
case _BACKDROP:
write = TRUE; break;
default:
break;
}
if (write) fprintf(f, "%s", line);
}
}
fclose(InFile);
InFile = NULL;
}
int saveinpfile(Project *pr, const char *fname)
/*
@@ -760,7 +790,7 @@ int saveinpfile(Project *pr, const char *fname)
fprintf(f, "\n\n");
// Save auxilary data to new input file
saveauxdata(parser, f);
saveauxdata(pr, f);
// Close the new input file
fprintf(f, "\n");