From a98df22daa1e3e2ef80ecea149cbe286ff7fdbf1 Mon Sep 17 00:00:00 2001 From: NeilBrown Date: Sun, 9 Jun 2019 10:03:44 +1000 Subject: [PATCH] scanner: hide impossible code from coverage testing. The code in "white space" section is truly impossible, as we don't return WEOF untile ->node is NULL, and when that happens, ->col is set to 0. Other code is only "mostly dead". This brings coverage to 95% Signed-off-by: NeilBrown --- csrc/scanner-tests.mdc | 2 +- csrc/scanner.mdc | 13 ++++--------- 2 files changed, 5 insertions(+), 10 deletions(-) diff --git a/csrc/scanner-tests.mdc b/csrc/scanner-tests.mdc index 6a81989..ec34812 100644 --- a/csrc/scanner-tests.mdc +++ b/csrc/scanner-tests.mdc @@ -38,7 +38,7 @@ about each test. @mv *.gcov coverage; [ -f .gcov ] && mv .gcov coverage || true @awk '/NOTEST/ { next } /^ *[1-9]/ {ran+=1} /^ *###/ {skip+=1} \ END {printf "coverage: %6.2f%%\n", ran * 100 / (ran + skip); \ - if (ran < (ran + skip) *0.94) exit(1) }' \ + if (ran < (ran + skip) *0.95) exit(1) }' \ coverage/scanner.mdc.gcov @rm -f .tmp* diff --git a/csrc/scanner.mdc b/csrc/scanner.mdc index 7776884..fcfadca 100644 --- a/csrc/scanner.mdc +++ b/csrc/scanner.mdc @@ -882,11 +882,6 @@ tokens will continue to return the same end-of-file token. ###### white space if (ch == WEOF) { - if (state->col) { - state->col = 0; - state->check_indent = 1; - continue; - } tk.num = TK_eof; return tk; } @@ -1005,12 +1000,12 @@ a flag that tells us whether or not we need to strip. &mbstate); if (n == -2 || n == 0) { /* Not enough bytes - not really possible */ - next = '\n'; - state->offset = state->node->code.len; + next = '\n'; // NOTEST + state->offset = state->node->code.len; // NOTEST } else if (n == -1) { /* error */ - state->offset += 1; - next = 0x7f; // an illegal character + state->offset += 1; // NOTEST + next = 0x7f; // an illegal character // NOTEST } else state->offset += n; -- 2.43.0