Print to file the expanded library read by .lib
This commit is contained in:
parent
a531d8428c
commit
aa2d3662f2
|
|
@ -180,6 +180,7 @@ static struct modellist *inp_find_model(
|
|||
struct nscope *scope, const char *name);
|
||||
|
||||
void tprint(struct card *deck);
|
||||
static char* libprint(struct card* t, const char *dir);
|
||||
static void print_compat_mode(void);
|
||||
static void set_compat_mode(void);
|
||||
static struct card *pspice_compat(struct card *newcard);
|
||||
|
|
@ -3401,13 +3402,23 @@ static struct card *expand_section_ref(struct card *c, const char *dir_name)
|
|||
* every library section reference (when the given section_name_ === NULL)
|
||||
* or
|
||||
* just those references occuring in the given library section definition
|
||||
*
|
||||
* Command .libsave saves the loaded and parsed lib, to be read by .include
|
||||
*/
|
||||
|
||||
static void expand_section_references(struct card *c, const char *dir_name)
|
||||
{
|
||||
for (; c; c = c->nextcard)
|
||||
if (ciprefix(".lib", c->line))
|
||||
for (; c; c = c->nextcard) {
|
||||
struct card* p = c;
|
||||
if (ciprefix(".libsave", c->line)) {
|
||||
c = expand_section_ref(c, dir_name);
|
||||
char *filename = libprint(p, dir_name);
|
||||
fprintf(stdout, "\nLibrary\n%s\nsaved to %s\n", p->line + 9, filename);
|
||||
tfree(filename);
|
||||
}
|
||||
else if (ciprefix(".lib", c->line))
|
||||
c = expand_section_ref(c, dir_name);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
|
@ -7023,6 +7034,23 @@ static void inp_poly_err(struct card *card)
|
|||
#endif
|
||||
|
||||
|
||||
static char* libprint(struct card* t, const char *dir_name)
|
||||
{
|
||||
struct card* tmp;
|
||||
static int npr = 1;
|
||||
char *outfile = tprintf("%s/lib_out%d.lib", dir_name, npr);
|
||||
npr++;
|
||||
FILE* fd = fopen(outfile, "w");
|
||||
if (fd) {
|
||||
for (tmp = t; tmp; tmp = tmp->nextcard)
|
||||
if (*(tmp->line) != '*')
|
||||
fprintf(fd, "%s\n", tmp->line);
|
||||
fclose(fd);
|
||||
}
|
||||
return outfile;
|
||||
}
|
||||
|
||||
|
||||
/* Used for debugging. You may add
|
||||
* tprint(working);
|
||||
* somewhere in function inp_readall() of this file to have
|
||||
|
|
|
|||
Loading…
Reference in New Issue