From 64d00a6b43c3b03f8ead287ffea1aa3f07efc9d2 Mon Sep 17 00:00:00 2001 From: rlar Date: Thu, 2 Aug 2012 18:53:43 +0200 Subject: [PATCH] lexical #3/3, collapse append(NULL) into cp_ccom() the sequence orig_wlist = wlist; append(NULL); cp_ccom(wlist, ...); is transformed. expressions to care about in cp_ccom() C1 := (wlist->wl_next != NULL) C2 := (wlist->wl_word != NULL) C3 := wl_length(wlist) D1 := (orig_wlist != NULL) D2 := (orig_wlist->wl_word != NULL) D3 := wl_length(orig_wlist); cases and their significance in cp_ccom(): orig_wlist = NULL; wlist = wl_cons(NULL, NULL); C1 == false D1 == false C2,C3 dont care orig_wlist = wl_cons(E1, wl_cons(E2, ... wl_cons(En, NULL))) wlist = wl_cons(E1, wl_cons(E2, .... wl_cons(En, wl_cons(NULL, NULL)))) C1 == true D1 == true C2 === D2 C3 === D3 + 1 --- src/frontend/parser/complete.c | 4 ++-- src/frontend/parser/lexical.c | 2 -- 2 files changed, 2 insertions(+), 4 deletions(-) diff --git a/src/frontend/parser/complete.c b/src/frontend/parser/complete.c index c87026446..5bf730739 100644 --- a/src/frontend/parser/complete.c +++ b/src/frontend/parser/complete.c @@ -94,11 +94,11 @@ cp_ccom(wordlist *wlist, char *buf, bool esc) buf = cp_unquote(copy(buf)); cp_wstrip(buf); - if (wlist->wl_next) { /* Not the first word. */ + if (wlist) { /* Not the first word. */ cc = getccom(wlist->wl_word); if (cc && cc->cc_invalid) cc = NULL; - arg = wl_length(wlist) - 2; + arg = wl_length(wlist) - 1; if (arg > 3) arg = 3; /* First filenames. */ diff --git a/src/frontend/parser/lexical.c b/src/frontend/parser/lexical.c index 8d7d8aeba..3b93c6c1b 100644 --- a/src/frontend/parser/lexical.c +++ b/src/frontend/parser/lexical.c @@ -256,7 +256,6 @@ gotchar: goto done; } // cp_ccom doesn't mess wlist, read only access to wlist->wl_word - append(NULL); cp_ccom(wlist, buf, FALSE); wl_free(wlist); (void) fputc('\r', cp_out); @@ -291,7 +290,6 @@ gotchar: #else fputc(linebuf[j], cp_out); /* But you can't edit */ #endif - append(NULL); // cp_ccom doesn't mess wlist, read only access to wlist->wl_word cp_ccom(wlist, buf, TRUE); wl_free(wlist);