Commit 8d1ae76dcbbb73d8e20c6a14a7d3fe2410b95f55 added
deprecation warnings for empty continuation lines,
but also treated comment-only lines as empty.
This patch distinguishes empty continuation lines
from comment-only lines, and only outputs warnings
for the former.
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
| ... | ... |
@@ -290,6 +290,10 @@ func Parse(rwc io.Reader) (*Result, error) {
|
| 290 | 290 |
} |
| 291 | 291 |
currentLine++ |
| 292 | 292 |
|
| 293 |
+ if isComment(scanner.Bytes()) {
|
|
| 294 |
+ // original line was a comment (processLine strips comments) |
|
| 295 |
+ continue |
|
| 296 |
+ } |
|
| 293 | 297 |
if isEmptyContinuationLine(bytesRead) {
|
| 294 | 298 |
hasEmptyContinuationLine = true |
| 295 | 299 |
continue |
| ... | ... |
@@ -331,8 +335,12 @@ func trimWhitespace(src []byte) []byte {
|
| 331 | 331 |
return bytes.TrimLeftFunc(src, unicode.IsSpace) |
| 332 | 332 |
} |
| 333 | 333 |
|
| 334 |
+func isComment(line []byte) bool {
|
|
| 335 |
+ return tokenComment.Match(trimWhitespace(line)) |
|
| 336 |
+} |
|
| 337 |
+ |
|
| 334 | 338 |
func isEmptyContinuationLine(line []byte) bool {
|
| 335 |
- return len(trimComments(trimWhitespace(line))) == 0 |
|
| 339 |
+ return len(trimWhitespace(line)) == 0 |
|
| 336 | 340 |
} |
| 337 | 341 |
|
| 338 | 342 |
var utf8bom = []byte{0xEF, 0xBB, 0xBF}
|