Browse Source

use wl_delete_slice()

rlar 14 years ago
parent
commit
64b8dfc570
  1. 3
      src/frontend/cpitf.c
  2. 25
      src/frontend/plotting/plotit.c
  3. 20
      src/frontend/streams.c
  4. 6
      src/frontend/subckt.c

3
src/frontend/cpitf.c

@ -381,8 +381,7 @@ cp_oddcomm(char *s, wordlist *wl)
if (wl && eq(wl->wl_word, "=")) { if (wl && eq(wl->wl_word, "=")) {
wordlist *ww = wl_cons(copy(s), wl); wordlist *ww = wl_cons(copy(s), wl);
com_let(ww); com_let(ww);
wl_chop_rest(ww);
wl_free(ww);
wl_delete_slice(ww, ww->wl_next);
return (TRUE); return (TRUE);
} }

25
src/frontend/plotting/plotit.c

@ -42,7 +42,7 @@ getlims(wordlist *wl, char *name, int number)
if(!beg) if(!beg)
return NULL; return NULL;
wk = beg;
wk = beg->wl_next;
d = TMALLOC(double, number); d = TMALLOC(double, number);
@ -51,8 +51,6 @@ getlims(wordlist *wl, char *name, int number)
char *ss; char *ss;
double *td; double *td;
wk = wk->wl_next;
if (!wk) { if (!wk) {
fprintf(cp_err, fprintf(cp_err,
"Syntax error: not enough parameters for \"%s\".\n", name); "Syntax error: not enough parameters for \"%s\".\n", name);
@ -71,17 +69,11 @@ getlims(wordlist *wl, char *name, int number)
} }
d[n] = *td; d[n] = *td;
}
if (beg->wl_prev)
beg->wl_prev->wl_next = wk->wl_next;
if (wk->wl_next) {
wk->wl_next->wl_prev = beg->wl_prev;
wk->wl_next = NULL;
wk = wk->wl_next;
} }
wl_free(beg);
wl_delete_slice(beg, wk);
return d; return d;
} }
@ -192,10 +184,7 @@ getflag(wordlist *wl, char *name)
if (!wl) if (!wl)
return FALSE; return FALSE;
if (wl->wl_prev)
wl->wl_prev->wl_next = wl->wl_next;
if (wl->wl_next)
wl->wl_next->wl_prev = wl->wl_prev;
wl_delete_slice(wl, wl->wl_next);
return TRUE; return TRUE;
} }
@ -222,11 +211,7 @@ getword(wordlist *wl, char *name)
s = copy(beg->wl_next->wl_word); s = copy(beg->wl_next->wl_word);
beg->wl_prev->wl_next = beg->wl_next->wl_next;
if (beg->wl_next->wl_next)
beg->wl_next->wl_next->wl_prev = beg->wl_prev;
beg->wl_next->wl_next = NULL;
wl_free(beg);
wl_delete_slice(beg, beg->wl_next->wl_next);
return s; return s;
} }

20
src/frontend/streams.c

@ -55,7 +55,7 @@ cp_redirect(wordlist *wl)
while (w) { while (w) {
if (*w->wl_word == cp_lt) { if (*w->wl_word == cp_lt) {
wordlist *bt = w->wl_prev;
wordlist *beg = w;
if (gotinput++) { if (gotinput++) {
fprintf(cp_err, "Error: ambiguous input redirect.\n"); fprintf(cp_err, "Error: ambiguous input redirect.\n");
@ -74,6 +74,7 @@ cp_redirect(wordlist *wl)
} }
fname = cp_unquote(w->wl_word); fname = cp_unquote(w->wl_word);
w = w->wl_next;
#ifdef CPDEBUG #ifdef CPDEBUG
if (cp_debug) if (cp_debug)
@ -84,19 +85,17 @@ cp_redirect(wordlist *wl)
tfree(fname); tfree(fname);
if (!fp) { if (!fp) {
perror(w->wl_word);
perror(fname);
goto error; goto error;
} }
cp_in = fp; cp_in = fp;
w = wl_chop_rest(w);
wl_free(wl_chop_rest(bt));
wl_append(bt, w);
wl_delete_slice(beg, w);
} else if (*w->wl_word == cp_gt) { } else if (*w->wl_word == cp_gt) {
wordlist *bt = w->wl_prev;
wordlist *beg = w;
if (gotoutput++) { if (gotoutput++) {
fprintf(cp_err, "Error: ambiguous output redirect.\n"); fprintf(cp_err, "Error: ambiguous output redirect.\n");
@ -123,6 +122,7 @@ cp_redirect(wordlist *wl)
} }
fname = cp_unquote(w->wl_word); fname = cp_unquote(w->wl_word);
w = w->wl_next;
#ifdef CPDEBUG #ifdef CPDEBUG
if (cp_debug) if (cp_debug)
@ -139,7 +139,7 @@ cp_redirect(wordlist *wl)
tfree(fname); tfree(fname);
if (!fp) { if (!fp) {
perror(w->wl_word);
perror(fname);
goto error; goto error;
} }
@ -149,9 +149,7 @@ cp_redirect(wordlist *wl)
out_isatty = FALSE; out_isatty = FALSE;
w = wl_chop_rest(w);
wl_free(wl_chop_rest(bt));
wl_append(bt, w);
wl_delete_slice(beg, w);
} else { } else {
w = w->wl_next; w = w->wl_next;
@ -160,7 +158,7 @@ cp_redirect(wordlist *wl)
return (wl); return (wl);
error: error:
wl_free(wl);
wl_free(wl); /* FIXME, Ouch !! */
return (NULL); return (NULL);
} }

6
src/frontend/subckt.c

@ -673,11 +673,7 @@ doit(struct line *deck, wordlist *modnames) {
} }
#endif #endif
if(modnames != xmodnames) {
wl_chop(xmodnames);
wl_free(modnames);
}
wl_delete_slice(modnames, xmodnames);
wl_free(submod); wl_free(submod);
if (error) if (error)

Loading…
Cancel
Save