In build_man.sh, mygrep becomes mygrep2 and all functions except fix_name_line use a new simpler mygrep. Signed-off-by: Duncan Roe <duncan_roe@xxxxxxxxxxxxxxx> --- doxygen/build_man.sh | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/doxygen/build_man.sh b/doxygen/build_man.sh index b3d1989..5c1a019 100755 --- a/doxygen/build_man.sh +++ b/doxygen/build_man.sh @@ -251,7 +251,7 @@ fix_name_line(){ head -n$linnum $target >$fileC while : - do mygrep ^\\.RI $fileC + do mygrep2 ^\\.RI $fileC [ $linnum -ne 0 ] || break # Discard this entry tail -n+$(($linnum + 1)) $fileC >$fileB @@ -264,7 +264,7 @@ fix_name_line(){ # macros (if any) come after functions while : - do mygrep '^\.SS "#' $fileC + do mygrep2 '^\.SS "#' $fileC [ $linnum -ne 0 ] || break tail -n+$(($linnum + 1)) $fileC >$fileB cp $fileB $fileC @@ -314,6 +314,13 @@ delete_lines(){ } mygrep(){ + linnum=$(grep -En "$1" $2 2>/dev/null | head -n1 | cut -f1 -d:) + [ $linnum ] || linnum=0 +} + +# mygrep2 copies found line to $fileG. Only fix_name_line() needs this. +# Using mygrep everywhere else gives a measurable CPU saving. +mygrep2(){ linnum=$(grep -En "$1" $2 2>/dev/null | head -n1 | tee $fileG | cut -f1 -d:) [ $linnum ] || linnum=0 } -- 2.35.8