Browse Source

inpcom.c: add fcn delete_libs to free libraries[]

pre-master-46
h_vogt 13 years ago
committed by rlar
parent
commit
750b42e767
  1. 30
      src/frontend/inpcom.c

30
src/frontend/inpcom.c

@ -261,6 +261,7 @@ read_a_lib(char *y, int call_depth, char *dir_name)
dir_name_flag = TRUE; dir_name_flag = TRUE;
} }
/* lib points to a new entry in global lib array libraries[N_LIBRARIES] */
lib = new_lib(); lib = new_lib();
lib->name = strdup(y); lib->name = strdup(y);
@ -281,6 +282,24 @@ read_a_lib(char *y, int call_depth, char *dir_name)
return TRUE; return TRUE;
} }
/* remove all library entries from global libraries[] */
static void
delete_libs(void)
{
int i;
struct line *tmpdeck, *tmpdeck2;
for (i = 0; i < N_LIBRARIES; i++) {
if (libraries[i].name == NULL)
continue;
tfree(libraries[i].name);
tmpdeck = libraries[i].deck;
while (tmpdeck) { /* cannot use line_free_x(tmpdeck, TRUE); due to stack overflow */
tmpdeck2 = tmpdeck;
tmpdeck = tmpdeck->li_next;
line_free_x(tmpdeck2, FALSE);
}
}
}
static struct names * static struct names *
new_names(void) new_names(void)
@ -554,8 +573,9 @@ inp_readall(FILE *fp, int call_depth, char *dir_name, bool comfile, bool intfile
*buffer = '*'; /* change .TITLE line to comment line */ *buffer = '*'; /* change .TITLE line to comment line */
} }
/* now handle .lib statements */
if (ciprefix(".lib", buffer)) {
/* now handle old style .lib entries */
/* new style .lib entries handling is in expand_section_references() */
if (ciprefix(".lib", buffer))
if (inp_compat_mode == COMPATMODE_PS) { if (inp_compat_mode == COMPATMODE_PS) {
/* compatibility mode, /* compatibility mode,
* this is neither a libray section definition nor a reference * this is neither a libray section definition nor a reference
@ -567,8 +587,6 @@ inp_readall(FILE *fp, int call_depth, char *dir_name, bool comfile, bool intfile
memcpy(buffer, ".inc", 4); memcpy(buffer, ".inc", 4);
} }
} /* end of .lib handling */
/* now handle .include statements */ /* now handle .include statements */
if (ciprefix(".include", buffer) || ciprefix(".inc", buffer)) { if (ciprefix(".include", buffer) || ciprefix(".inc", buffer)) {
@ -680,10 +698,11 @@ inp_readall(FILE *fp, int call_depth, char *dir_name, bool comfile, bool intfile
!ciprefix("load", buffer) !ciprefix("load", buffer)
) )
{ {
/* lower case for all lines (exceptions see above!) */
for (s = buffer; *s && (*s != '\n'); s++) for (s = buffer; *s && (*s != '\n'); s++)
*s = (char) tolower(*s); *s = (char) tolower(*s);
} else { } else {
// exclude some commands to preserve filename case
/* exclude some commands to preserve filename case */
for (s = buffer; *s && (*s != '\n'); s++) for (s = buffer; *s && (*s != '\n'); s++)
; ;
} }
@ -2516,6 +2535,7 @@ expand_section_references(struct line *c, int call_depth, char *dir_name)
} }
} }
delete_libs();
} }

Loading…
Cancel
Save