Improve manpage processing robustness.

Fix regex to expressly check for starting ., and switch to regex match for SH lines to stop any potential problems with training spaces or multiple spaces before section name.
This commit is contained in:
Jim Hague 2019-10-22 14:47:49 +01:00
parent ea1111d899
commit 165078a50d
1 changed files with 4 additions and 4 deletions

View File

@ -567,15 +567,15 @@ foreach (man ${mans})
# defined in that page. Defined means listed in a line ".B <name>"
# between lines ".SH NAME" and ".SH LIBRARY". Ignore terminating ","
# or spaces in .B line.
file(STRINGS ${man} manpage REGEX "^.(SH|B) ")
file(STRINGS ${man} manpage REGEX "^\\.(SH +NAME|SH +LIBRARY|B )")
set(in_list 0)
foreach (line ${manpage})
if ("${line}" STREQUAL ".SH NAME")
if ("${line}" MATCHES "^\\.SH +NAME")
set(in_list 1)
elseif ("${line}" STREQUAL ".SH LIBRARY")
elseif ("${line}" MATCHES "^\\.SH +LIBRARY")
set(in_list 0)
elseif (${in_list})
string(REGEX REPLACE ".B *([^ ,]+).*" "\\1" alt "${line}")
string(REGEX REPLACE ".B +([^ ,]+).*" "\\1" alt "${line}")
configure_file(${man} man3/${alt}.3 @ONLY)
endif ()
endforeach()