From: NeilBrown <neil@brown.name>
Date: Sun, 9 Jun 2019 00:03:44 +0000 (+1000)
Subject: scanner: hide impossible code from coverage testing.
X-Git-Url: https://ocean-lang.org/code/?a=commitdiff_plain;h=a98df22daa1e3e2ef80ecea149cbe286ff7fdbf1;p=ocean

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 <neil@brown.name>
---

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;