CMake: Consider diff format for man page revert
@@ -24,16 +24,20 @@ if (NOT EXISTS "${OLD_MAN_PAGE_COPY}")
endif (NOT EXISTS "${OLD_MAN_PAGE_COPY}")
# We revert newly generated man pages, where only the date has changed.
-execute_process (COMMAND ${DIFF_COMMAND} ${MANPAGE} ${OLD_MAN_PAGE_COPY} OUTPUT_VARIABLE DIFF_OUTPUT)
-string (FIND "${DIFF_OUTPUT}" ">" DIFF_FIRST_POSITION_ADDED)
-string (FIND "${DIFF_OUTPUT}" ">" DIFF_LAST_POSITION_ADDED REVERSE)
+execute_process (COMMAND ${DIFF_COMMAND}
+ -u
+ ${MANPAGE}
+ ${OLD_MAN_PAGE_COPY}
+ OUTPUT_VARIABLE DIFF_OUTPUT)
+string (FIND "${DIFF_OUTPUT}" "\n+.TH" DIFF_POSITION_DATE_ADDED)
+string (FIND "${DIFF_OUTPUT}" "\n+" DIFF_LAST_POSITION_ADDED REVERSE)
-if ("${DIFF_FIRST_POSITION_ADDED}" STREQUAL "${DIFF_LAST_POSITION_ADDED}" AND "${DIFF_OUTPUT}" MATCHES "> .TH")
+if (NOT "${DIFF_POSITION_DATE_ADDED}" STREQUAL -1 AND "${DIFF_POSITION_DATE_ADDED}" STREQUAL "${DIFF_LAST_POSITION_ADDED}")
execute_process (COMMAND ${CMAKE_COMMAND}
-E
copy
${OLD_MAN_PAGE_COPY}
${MANPAGE})
-endif ("${DIFF_FIRST_POSITION_ADDED}" STREQUAL "${DIFF_LAST_POSITION_ADDED}" AND "${DIFF_OUTPUT}" MATCHES "> .TH")
+endif (NOT "${DIFF_POSITION_DATE_ADDED}" STREQUAL -1 AND "${DIFF_POSITION_DATE_ADDED}" STREQUAL "${DIFF_LAST_POSITION_ADDED}")
file (REMOVE "${OLD_MAN_PAGE_COPY}")
