prevent crash if files for debug-out could not be opened,
e.g. due to missing permission
This commit is contained in:
parent
bb868c74ed
commit
00d88d28ce
|
|
@ -668,21 +668,25 @@ inp_spsource(FILE *fp, bool comfile, char *filename, bool intfile)
|
|||
if (ft_ngdebug) {
|
||||
/*debug: print into file*/
|
||||
FILE *fdo = fopen("debug-out2.txt", "w");
|
||||
struct line *t = NULL;
|
||||
fprintf(fdo, "**************** uncommented deck **************\n\n");
|
||||
/* always print first line */
|
||||
fprintf(fdo, "%6d %6d %s\n", deck->li_linenum_orig, deck->li_linenum, deck->li_line);
|
||||
/* here without out-commented lines */
|
||||
for (t = deck->li_next; t; t = t->li_next) {
|
||||
if (*(t->li_line) == '*')
|
||||
continue;
|
||||
fprintf(fdo, "%6d %6d %s\n", t->li_linenum_orig, t->li_linenum, t->li_line);
|
||||
if (!fdo)
|
||||
fprintf(cp_err, "Could not open file debug-out2.txt for writing debug info. \n");
|
||||
else {
|
||||
struct line *t = NULL;
|
||||
fprintf(fdo, "**************** uncommented deck **************\n\n");
|
||||
/* always print first line */
|
||||
fprintf(fdo, "%6d %6d %s\n", deck->li_linenum_orig, deck->li_linenum, deck->li_line);
|
||||
/* here without out-commented lines */
|
||||
for (t = deck->li_next; t; t = t->li_next) {
|
||||
if (*(t->li_line) == '*')
|
||||
continue;
|
||||
fprintf(fdo, "%6d %6d %s\n", t->li_linenum_orig, t->li_linenum, t->li_line);
|
||||
}
|
||||
fprintf(fdo, "\n****************** complete deck ***************\n\n");
|
||||
/* now completely */
|
||||
for (t = deck; t; t = t->li_next)
|
||||
fprintf(fdo, "%6d %6d %s\n", t->li_linenum_orig, t->li_linenum, t->li_line);
|
||||
fclose(fdo);
|
||||
}
|
||||
fprintf(fdo, "\n****************** complete deck ***************\n\n");
|
||||
/* now completely */
|
||||
for (t = deck; t; t = t->li_next)
|
||||
fprintf(fdo, "%6d %6d %s\n", t->li_linenum_orig, t->li_linenum, t->li_line);
|
||||
fclose(fdo);
|
||||
}
|
||||
for (dd = deck; dd; dd = dd->li_next) {
|
||||
/* get csparams and create vectors, being
|
||||
|
|
@ -810,21 +814,25 @@ inp_spsource(FILE *fp, bool comfile, char *filename, bool intfile)
|
|||
if (ft_ngdebug) {
|
||||
/*debug: print into file*/
|
||||
FILE *fdo = fopen("debug-out3.txt", "w");
|
||||
struct line *t = NULL;
|
||||
fprintf(fdo, "**************** uncommented deck **************\n\n");
|
||||
/* always print first line */
|
||||
fprintf(fdo, "%6d %6d %s\n", deck->li_linenum_orig, deck->li_linenum, deck->li_line);
|
||||
/* here without out-commented lines */
|
||||
for (t = deck->li_next; t; t = t->li_next) {
|
||||
if (*(t->li_line) == '*')
|
||||
continue;
|
||||
fprintf(fdo, "%6d %6d %s\n", t->li_linenum_orig, t->li_linenum, t->li_line);
|
||||
if (!fdo)
|
||||
fprintf(cp_err, "Could not open file debug-out3.txt for writing debug info. \n");
|
||||
else {
|
||||
struct line *t = NULL;
|
||||
fprintf(fdo, "**************** uncommented deck **************\n\n");
|
||||
/* always print first line */
|
||||
fprintf(fdo, "%6d %6d %s\n", deck->li_linenum_orig, deck->li_linenum, deck->li_line);
|
||||
/* here without out-commented lines */
|
||||
for (t = deck->li_next; t; t = t->li_next) {
|
||||
if (*(t->li_line) == '*')
|
||||
continue;
|
||||
fprintf(fdo, "%6d %6d %s\n", t->li_linenum_orig, t->li_linenum, t->li_line);
|
||||
}
|
||||
fprintf(fdo, "\n****************** complete deck ***************\n\n");
|
||||
/* now completely */
|
||||
for (t = deck; t; t = t->li_next)
|
||||
fprintf(fdo, "%6d %6d %s\n", t->li_linenum_orig, t->li_linenum, t->li_line);
|
||||
fclose(fdo);
|
||||
}
|
||||
fprintf(fdo, "\n****************** complete deck ***************\n\n");
|
||||
/* now completely */
|
||||
for (t = deck; t; t = t->li_next)
|
||||
fprintf(fdo, "%6d %6d %s\n", t->li_linenum_orig, t->li_linenum, t->li_line);
|
||||
fclose(fdo);
|
||||
}
|
||||
|
||||
ft_curckt->devtlist = devtlist;
|
||||
|
|
|
|||
|
|
@ -600,24 +600,27 @@ inp_readall(FILE *fp, char *dir_name, bool comfile, bool intfile)
|
|||
if (ft_ngdebug) {
|
||||
/*debug: print into file*/
|
||||
FILE *fd = fopen("debug-out.txt", "w");
|
||||
struct line *t;
|
||||
fprintf(fd, "**************** uncommented deck **************\n\n");
|
||||
/* always print first line */
|
||||
fprintf(fd, "%6d %6d %s\n", cc->li_linenum_orig, cc->li_linenum, cc->li_line);
|
||||
/* here without out-commented lines */
|
||||
for (t = cc->li_next; t; t = t->li_next) {
|
||||
if (*(t->li_line) == '*')
|
||||
continue;
|
||||
fprintf(fd, "%6d %6d %s\n", t->li_linenum_orig, t->li_linenum, t->li_line);
|
||||
if(!fd)
|
||||
fprintf(cp_err, "Could not open file debug-out.txt for writing debug info. \n");
|
||||
else {
|
||||
struct line *t;
|
||||
fprintf(fd, "**************** uncommented deck **************\n\n");
|
||||
/* always print first line */
|
||||
fprintf(fd, "%6d %6d %s\n", cc->li_linenum_orig, cc->li_linenum, cc->li_line);
|
||||
/* here without out-commented lines */
|
||||
for (t = cc->li_next; t; t = t->li_next) {
|
||||
if (*(t->li_line) == '*')
|
||||
continue;
|
||||
fprintf(fd, "%6d %6d %s\n", t->li_linenum_orig, t->li_linenum, t->li_line);
|
||||
}
|
||||
fprintf(fd, "\n****************** complete deck ***************\n\n");
|
||||
/* now completely */
|
||||
for (t = cc; t; t = t->li_next)
|
||||
fprintf(fd, "%6d %6d %s\n", t->li_linenum_orig, t->li_linenum, t->li_line);
|
||||
fclose(fd);
|
||||
}
|
||||
fprintf(fd, "\n****************** complete deck ***************\n\n");
|
||||
/* now completely */
|
||||
for (t = cc; t; t = t->li_next)
|
||||
fprintf(fd, "%6d %6d %s\n", t->li_linenum_orig, t->li_linenum, t->li_line);
|
||||
fclose(fd);
|
||||
|
||||
fprintf(stdout, "max line length %d, max subst. per line %d, number of lines %d\n",
|
||||
(int) max_line_length, no_braces, dynmaxline);
|
||||
(int)max_line_length, no_braces, dynmaxline);
|
||||
}
|
||||
}
|
||||
/* remove white spaces in command files */
|
||||
|
|
|
|||
Loading…
Reference in New Issue