Count tab as whitespace in "empty shape" check #92

This commit is contained in:
Thomas Jensen 2021-08-28 15:08:44 +02:00
parent a02e241cfa
commit ab9f123981
No known key found for this signature in database
GPG Key ID: A4ACEE270D0FB7DB
3 changed files with 52 additions and 2 deletions

View File

@ -201,7 +201,7 @@ int isempty(const sentry_t *shape)
int isdeepempty(const sentry_t *shape)
/*
* Return true if shape is empty, also checking if lines consist of spaces
* Return true if shape is empty, also checking if lines consist of whitespace
* only.
*
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
@ -215,7 +215,7 @@ int isdeepempty(const sentry_t *shape)
for (j = 0; j < shape->height; ++j) {
if (shape->chars[j]) {
if (strspn(shape->chars[j], " ") != shape->width) {
if (strspn(shape->chars[j], " \t") != shape->width) {
return 0;
}
}

View File

@ -0,0 +1,35 @@
BOX blank1
sample
(blank)
ends
shapes {
w (" ")
}
elastic (
w
)
END blank1
# -------------------------------------------------------
BOX blank2
sample
(blank)
ends
shapes {
w (" ", " ") # mix of tabs and spaces
e (" ", " ") # space only
s (" ", " ") # tab only
}
elastic (
w, e, s
)
END blank2

View File

@ -0,0 +1,15 @@
:DESC
Check that designs which consist only of whitespace are rejected.
:ARGS
-f 170_forbid_blank_box.cfg -l
:INPUT
:OUTPUT-FILTER
:EXPECTED-ERROR 1
boxes: 170_forbid_blank_box.cfg: line 9: must specify at least one non-empty shape per design
boxes: 170_forbid_blank_box.cfg: line 9: skipping to next design
boxes: 170_forbid_blank_box.cfg: line 29: must specify at least one non-empty shape per design
boxes: 170_forbid_blank_box.cfg: line 29: skipping to next design
boxes: no valid data in config file -- 170_forbid_blank_box.cfg
boxes: no valid designs found
:EOF