From 165078a50de5de829ea420a4a185d202b5c9bc99 Mon Sep 17 00:00:00 2001 From: Jim Hague Date: Tue, 22 Oct 2019 14:47:49 +0100 Subject: [PATCH] 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. --- CMakeLists.txt | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 24128218..3d6f635f 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -567,15 +567,15 @@ foreach (man ${mans}) # defined in that page. Defined means listed in a line ".B " # 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()