From 80191f3d44786e0da416d0ff242642deed3975a0 Mon Sep 17 00:00:00 2001 From: rlar Date: Tue, 31 Jul 2012 20:39:03 +0200 Subject: [PATCH] lexical #3/19, attach and instantly remove a NULL wl_word here this modification is faithful iff cw != NULL and cw->wl_next == NULL cw != NULL because we have just survived an update of cw->wl_word cw->wl_next == NULL is witnessed by: 1) cw either NULL or pointing to a wl_cons(,NULL) 2) cw not being modified, and no wl_next being modified 3) check of all function invocations with wlist/cw argument not to modify any wl_next slot which are: 1) cp_ccom(wlist, ...) 2) wl_free() always followed by goto nloop, which does a cw = wl_cons(,NULL) and cp_ccom() doesn't modify any wl_next slot the first part of the patch is intentionally similar to newword `i' and `buf' can be modified here, because we will inevitably `goto done' attach and instantly remove a NULL wl_word here --- src/frontend/parser/lexical.c | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/src/frontend/parser/lexical.c b/src/frontend/parser/lexical.c index 224949695..b9d77df29 100644 --- a/src/frontend/parser/lexical.c +++ b/src/frontend/parser/lexical.c @@ -185,6 +185,18 @@ gotchar: if (i) { buf[i] = '\0'; cw->wl_word = copy(buf); + // assumption: cw != NULL and cw->wl_next == NULL + cw->wl_next = wl_cons(NULL, NULL); + cw->wl_next->wl_prev = cw; + cw = cw->wl_next; + // note: we can overwrite buf and i here + // they won't be accessed any more (see `goto done') + bzero(buf, NEW_BSIZE_SP); + i = 0; + // cw->wl_prev is the recent cw + // thus this wl_next has been NULL per assumtion vrom above + cw->wl_prev->wl_next = NULL; + tfree(cw); } else { if (cw->wl_prev) { cw->wl_prev->wl_next = NULL;