line renumbering to end of inp_readall added

This commit is contained in:
h_vogt 2009-03-21 13:30:03 +00:00
parent 7f1705d60b
commit 9b2170953c
4 changed files with 442 additions and 424 deletions

View File

@ -1,3 +1,8 @@
2009-03-21 Holger Vogt
* inpcom.c, fteinp.h, inpdefs.h: line renumbering of input deck added
to the end of fcn inp_readall(). cc->li_line_original now contains
the line numbering of the input file
2009-03-15 Holger Vogt
* cktfinddev.c: some (optical) cleanup
* numparam.h, xpressn.c, spicenum.c, inpcom.c: dynamic memory

View File

@ -997,6 +997,7 @@ inp_readall(FILE *fp, struct line **data, int call_depth, char *dir_name)
char *copys=NULL, big_buff2[5000];
char *global_copy = NULL, keep_char;
int line_number = 1; /* sjb - renamed to avoid confusion with struct line */
int line_number_orig = 0;
FILE *newfp;
#if defined(TRACE) || defined(OUTDECK)
FILE *fdo;
@ -1026,7 +1027,6 @@ inp_readall(FILE *fp, struct line **data, int call_depth, char *dir_name)
/* First read in all lines & put them in the struct cc */
while (1) {
/* If IPC is not enabled, do equivalent of what SPICE did before */
if(! g_ipc.enabled) {
if ( call_depth == 0 && line_count == 0 ) {
@ -1233,13 +1233,17 @@ inp_readall(FILE *fp, struct line **data, int call_depth, char *dir_name)
end->li_error = NULL;
end->li_actual = NULL;
end->li_line = copy(buffer);
end->li_linenum = line_number++;
end->li_linenum = end->li_linenum_orig = line_number++;
if (newcard) {
end->li_next = newcard;
/* Renumber the lines */
for (end = newcard; end && end->li_next; end = end->li_next)
end->li_linenum = line_number++;
line_number_orig = 1;
for (end = newcard; end && end->li_next; end = end->li_next) {
end->li_linenum = line_number_orig++;
end->li_linenum_orig = line_number++;
}
end->li_linenum = line_number++; /* SJB - renumber the last line */
end->li_linenum_orig = line_number_orig++; /* SJB - renumber the last line */
}
/* Fix the buffer up a bit. */
@ -1303,7 +1307,7 @@ inp_readall(FILE *fp, struct line **data, int call_depth, char *dir_name)
end->li_error = NULL;
end->li_actual = NULL;
end->li_line = buffer;
end->li_linenum = line_number++;
end->li_linenum = end->li_linenum_orig = line_number++;
} /* end while ((buffer = readline(fp))) */
if (!end) { /* No stuff here */
@ -1358,7 +1362,7 @@ inp_readall(FILE *fp, struct line **data, int call_depth, char *dir_name)
* end->li_next = NULL; */
continue;
}
} /* for ... */
if ( ciprefix(".lib", buffer) ) {
if ( found_lib_name == TRUE ) {
@ -1385,9 +1389,13 @@ inp_readall(FILE *fp, struct line **data, int call_depth, char *dir_name)
library_ll_ptr[i][j]->li_next = working;
/* renumber lines */
for ( start_lib = working; !ciprefix(".endl", start_lib->li_line); start_lib = start_lib->li_next )
line_number_orig = 1;
for ( start_lib = working; !ciprefix(".endl", start_lib->li_line); start_lib = start_lib->li_next ) {
start_lib->li_linenum = line_number++;
start_lib->li_linenum_orig = line_number_orig++;
}
start_lib->li_linenum = line_number++; // renumber endl line
start_lib->li_linenum_orig = line_number_orig++;
break;
}
}
@ -1401,7 +1409,8 @@ inp_readall(FILE *fp, struct line **data, int call_depth, char *dir_name)
tfree(prev);
}
} /* end while */
}
} /* end for */
if ( found_end == TRUE ) {
end->li_next = alloc(struct line); /* create next card */
end = end->li_next; /* point to next card */
@ -1414,7 +1423,7 @@ inp_readall(FILE *fp, struct line **data, int call_depth, char *dir_name)
end->li_error = NULL;
end->li_actual = NULL;
end->li_line = buffer;
end->li_linenum = line_number++;
end->li_linenum = end->li_linenum_orig = line_number++;
}
}
@ -1465,8 +1474,7 @@ inp_readall(FILE *fp, struct line **data, int call_depth, char *dir_name)
prev->li_next = working->li_next;
working->li_next = NULL;
if (prev->li_actual) {
for (end = prev->li_actual;
end->li_next; end = end->li_next)
for (end = prev->li_actual; end->li_next; end = end->li_next)
;
end->li_next = working;
tfree(s);
@ -1522,11 +1530,14 @@ inp_readall(FILE *fp, struct line **data, int call_depth, char *dir_name)
}
*data = cc;
/* get max. line length and number of lines in input deck*/
/* get max. line length and number of lines in input deck,
* and renumber the lines */
dynmaxline = 0;
dynLlen = 0;
for(tmp_ptr1 = cc; tmp_ptr1 != NULL; tmp_ptr1 = tmp_ptr1->li_next) {
dynmaxline++;
/* renumber the lines of the processed input deck */
tmp_ptr1->li_linenum = dynmaxline;
if (dynLlen < strlen(tmp_ptr1->li_line))
dynLlen = strlen(tmp_ptr1->li_line);
}
@ -1534,8 +1545,8 @@ inp_readall(FILE *fp, struct line **data, int call_depth, char *dir_name)
/*debug: print into file*/
fdo = fopen("debug-out.txt", "w");
for(tmp_ptr1 = cc; tmp_ptr1 != NULL; tmp_ptr1 = tmp_ptr1->li_next)
fprintf(fdo, "%s\n", tmp_ptr1->li_line);
;
fprintf(fdo, "%d %d %s\n", tmp_ptr1->li_linenum_orig, tmp_ptr1->li_linenum, tmp_ptr1->li_line);
(void) fclose(fdo);
fprintf(stdout, "lLen %d, maxline %d\n", dynLlen, dynmaxline);
#endif

View File

@ -16,6 +16,7 @@ Author: 1985 Wayne A. Christopher, U. C. Berkeley CAD Group
/* This struct defines a linked list of lines from a SPICE file. */
struct line {
int li_linenum;
int li_linenum_orig;
char *li_line;
char *li_error;
struct line *li_next;

View File

@ -58,6 +58,7 @@ typedef struct sINPtables{
typedef struct card{
int linenum;
int linenum_orig;
char *line;
char *error;
struct card *nextcard;