Merge remote-tracking branch 'upstream/dev' into dev
This commit is contained in:
@@ -7,7 +7,7 @@
|
|||||||
Authors: see AUTHORS
|
Authors: see AUTHORS
|
||||||
Copyright: see AUTHORS
|
Copyright: see AUTHORS
|
||||||
License: see LICENSE
|
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
|
// Read input data
|
||||||
ERRCODE(getdata(p));
|
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
|
// Free temporary linked lists used for Patterns & Curves
|
||||||
freeTmplist(p->parser.Patlist);
|
freeTmplist(p->parser.Patlist);
|
||||||
freeTmplist(p->parser.Curvelist);
|
freeTmplist(p->parser.Curvelist);
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
/* MULTIPLE MINIMUM DEGREE ROW RE-ORDERING ALGORITHM
|
/* 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.
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|||||||
@@ -7,7 +7,7 @@ Description: saves network data to an EPANET formatted text file
|
|||||||
Authors: see AUTHORS
|
Authors: see AUTHORS
|
||||||
Copyright: see AUTHORS
|
Copyright: see AUTHORS
|
||||||
License: see LICENSE
|
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 *RptFlagTxt[];
|
||||||
extern char *SectTxt[];
|
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.
|
Writes auxilary data from original input file to new file.
|
||||||
@@ -47,13 +47,21 @@ void saveauxdata(Parser *parser, FILE *f)
|
|||||||
{
|
{
|
||||||
int sect, newsect;
|
int sect, newsect;
|
||||||
char *tok;
|
char *tok;
|
||||||
|
char write;
|
||||||
char line[MAXLINE + 1];
|
char line[MAXLINE + 1];
|
||||||
char s[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;
|
if (InFile == NULL) return;
|
||||||
|
}
|
||||||
rewind(InFile);
|
rewind(InFile);
|
||||||
|
sect = -1;
|
||||||
|
|
||||||
|
// Read each line of the input file
|
||||||
while (fgets(line, MAXLINE, InFile) != NULL)
|
while (fgets(line, MAXLINE, InFile) != NULL)
|
||||||
{
|
{
|
||||||
strcpy(s, line);
|
strcpy(s, line);
|
||||||
@@ -68,10 +76,8 @@ void saveauxdata(Parser *parser, FILE *f)
|
|||||||
{
|
{
|
||||||
sect = newsect;
|
sect = newsect;
|
||||||
if (sect == _END) break;
|
if (sect == _END) break;
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Write line of auxilary data to file
|
// Write section heading to file
|
||||||
switch (sect)
|
switch (sect)
|
||||||
{
|
{
|
||||||
case _VERTICES:
|
case _VERTICES:
|
||||||
@@ -79,12 +85,36 @@ void saveauxdata(Parser *parser, FILE *f)
|
|||||||
case _BACKDROP:
|
case _BACKDROP:
|
||||||
case _TAGS:
|
case _TAGS:
|
||||||
fprintf(f, "%s", line);
|
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;
|
break;
|
||||||
|
case _LABELS:
|
||||||
|
case _BACKDROP:
|
||||||
|
write = TRUE; break;
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
if (write) fprintf(f, "%s", line);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
fclose(InFile);
|
||||||
|
InFile = NULL;
|
||||||
|
}
|
||||||
|
|
||||||
int saveinpfile(Project *pr, const char *fname)
|
int saveinpfile(Project *pr, const char *fname)
|
||||||
/*
|
/*
|
||||||
@@ -760,7 +790,7 @@ int saveinpfile(Project *pr, const char *fname)
|
|||||||
fprintf(f, "\n\n");
|
fprintf(f, "\n\n");
|
||||||
|
|
||||||
// Save auxilary data to new input file
|
// Save auxilary data to new input file
|
||||||
saveauxdata(parser, f);
|
saveauxdata(pr, f);
|
||||||
|
|
||||||
// Close the new input file
|
// Close the new input file
|
||||||
fprintf(f, "\n");
|
fprintf(f, "\n");
|
||||||
|
|||||||
Reference in New Issue
Block a user