Working on gcc bug
Tests are passing on Appveyor
@@ -121,6 +121,45 @@ void saveauxdata(Project *pr, FILE *f)
InFile = NULL;
}
+void write_demands(Project *pr, FILE *f) {
+
+ int i, j;
+
+ Snode *node = NULL;
+ list_node_t *lnode = NULL;
+ char *temp = NULL;
+
+ char s[MAXLINE + 1],
+ s1[MAXLINE + 1];
+
+ double ucf = pr->Ucf[DEMAND];
+ Network *net = &pr->network;
+
+ fprintf(f, "\n\n");
+ fprintf(f, s_DEMANDS);
+
+ for (i = 1; i <= net->Njuncs; i++) {
+ node = &net->Node[i];
+ if (node->D) {
+ for (lnode = first_list(node->D); done_list(lnode); lnode = next_list(lnode)) {
+ sprintf(s, " %-31s %14.6f", node->ID, ucf * get_base_demand(lnode));
+
+ if
+ ((j = get_pattern_index(lnode)) > 0) sprintf(s1, " %-31s", net->Pattern[j].ID);
+ else
+ strcpy(s1, " ");
+
+ fprintf(f, "\n%s %-31s", s, s1);
+
+ if (temp = get_category_name(lnode)) {
+ fprintf(f, " ;%s", temp);
+ free(temp);
+ }
+ }
+ }
+ }
+}
+
int saveinpfile(Project *pr, const char *fname)
/*
-------------------------------------------------
@@ -137,7 +176,7 @@ int saveinpfile(Project *pr, const char *fname)
Times *time = &pr->times;
int i, j, n;
- double d, kc, ke, km, ucf;
+ double d, kc, ke, km;
char s[MAXLINE + 1], s1[MAXLINE + 1], s2[MAXLINE + 1];
//Pdemand demand;
Psource source;
@@ -327,35 +366,10 @@ int saveinpfile(Project *pr, const char *fname)
if (link->Comment) fprintf(f, " ;%s", link->Comment);
}
- // Write [DEMANDS] section
- fprintf(f, "\n\n");
- fprintf(f, s_DEMANDS);
- ucf = pr->Ucf[DEMAND];
-
- //list_t *dlist = NULL;
- list_node_t *lnode = NULL;
- char *temp = NULL;
-
- for (i = 1; i <= net->Njuncs; i++) {
- node = &net->Node[i];
- if (node->D) {
- for (lnode = first_list(node->D); done_list(lnode); lnode = next_list(lnode)) {
- sprintf(s, " %-31s %14.6f", node->ID, ucf * get_base_demand(lnode));
- if
- ((j = get_pattern_index(lnode)) > 0) sprintf(s1, " %-31s", net->Pattern[j].ID);
- else
- strcpy(s1, " ");
-
- fprintf(f, "\n%s %-31s", s, s1);
+ // Write [DEMANDS] section
+ write_demands(pr, f);
- if (temp = get_category_name(lnode)) {
- fprintf(f, " ;%s", temp);
- free(temp);
- }
- }
- }
- }
// Write [EMITTERS] section
fprintf(f, "\n\n");
