55# Author: Dimitar Dimitrov
66# License: Apache-2.0
77# Project: https://github.com/drdv/makefile-doc
8- # Version: v1.6
8+ # Version: v1.7
99#
1010# Usage (see project README.md for more details):
1111# awk [-v option=value] -f makefile-doc.awk [Makefile ...]
@@ -975,6 +975,9 @@ BEGIN {
975975 FILES_PROCESSED = " "
976976 SPACES_TABS_REGEX = " ^[ \t ]+|[ \t ]+$"
977977
978+ # this is equivalent to /[^\\](\\{2})*\\$/ with an extra round of escaping
979+ ODD_NUMB_TERMINAL_BACKSLASHES_REGEX = " [^\\\\ ](\\\\ {2})*\\\\ $"
980+
978981 # used to decorate double-colon targets in the documentation
979982 DOUBLE_COLON_SEPARATOR = " ~"
980983
@@ -1003,12 +1006,10 @@ FNR == 1 {
10031006}
10041007
10051008# Skip backslash multiline comments
1006- # FIXME: at some point we might allow for them to constitute anchor documentation
1007- # but for the moment they are simply ignored
1008- /^ * #[^ \\ ]*? ([\\ ]{2 } )* \\ $ / || IN_MULTILINE_BACKSLASH_COMMENT {
1009+ $0 ~ " ^ *#.*" ODD_NUMB_TERMINAL_BACKSLASHES_REGEX || IN_MULTILINE_BACKSLASH_COMMENT {
10091010 if (! IN_MULTILINE_BACKSLASH_COMMENT) {
10101011 IN_MULTILINE_BACKSLASH_COMMENT = 1
1011- } else if (! ($0 ~ / ^ [ ^ \\ ] *? ([ \\ ] { 2 } ) * \\ $ / )) {
1012+ } else if (! ($0 ~ ODD_NUMB_TERMINAL_BACKSLASHES_REGEX )) {
10121013 IN_MULTILINE_BACKSLASH_COMMENT = 0
10131014 }
10141015
@@ -1026,9 +1027,7 @@ FNR == 1 {
10261027
10271028IN_RULE && $0 ~ RECIPEPREFIX || IN_MULTILINE_BACKSLASH_COMMAND {
10281029 forget_descriptions_data()
1029-
1030- # match odd number of slashes at the end
1031- if ($0 ~ sprintf (" %s[^\\\\ ]*?([\\\\ ]{2})*\\\\ $" , RECIPEPREFIX)) {
1030+ if ($0 ~ sprintf (" %s.*%s" , RECIPEPREFIX, ODD_NUMB_TERMINAL_BACKSLASHES_REGEX)) {
10321031 IN_MULTILINE_BACKSLASH_COMMAND = 1
10331032 } else {
10341033 IN_MULTILINE_BACKSLASH_COMMAND = 0
0 commit comments