Mk/Scripts/smart_makepatch.sh: Fix multi-patch file and locals bug


Mk/Scripts/smart_makepatch.sh: Fix multi-patch file and locals bug

There were two issues with the new smart_makepatch script.

  1. use of "local" declaration

All function variables were declared "local" during the review. This
caused the script to break, at least on FreeBSD 9.2. Given that it's
not being seen on 9.3R or later, it might be a bug in Bourne shell that
has since been fixed.

e.g. This resulted in stderr error on second iteration:

local contains=$(grep "^+++ " ${existing_patch} | awk '{x++; print x}')

however, this works fine:

local contains
contains=$(grep "^+++ " ${existing_patch} | awk '{x++; print x}')

To be safe, all local variables are assigned with $(<shell cmd>) on
separate lines now.

  1. The comment extraction was flawed for files that contain multiple

patches. It was not counting the hunk lines properly which caused some
portion of a patch to be considered as a comment for the next patch. The
hunk traversal algorithm has been fixed.

Since 1) involved the introduction of local declarations that broke the
script and since only Scripts/smart_makepatch.sh is touched, I will
piggy-back on the original approval. The fix was tested with devel/nspr,
the port listed in the PR, which uses multi-patch files.

Approved by: portmgr
Differential Revision: D4136
PR: 204725


marinoAuthored on
rP402219: - Update to version 2.5