From a866e60c31239d492ad694a2910a437b194c78bc Mon Sep 17 00:00:00 2001 From: Bjarni Ingi Gislason Date: Thu, 20 Apr 2023 21:34:11 +0000 Subject: [PATCH] P-indentation-works.sh: make it more robust Directory: contrib/mm/tests/ Use the register 'O' and 'Pi' in the mm macro to calculate the expected indents and use these instead of constant numbers. Signed-off-by: Bjarni Ingi Gislason --- contrib/mm/tests/P-indentation-works.sh | 36 +++++++++++++++++-------- 1 file changed, 25 insertions(+), 11 deletions(-) diff --git a/contrib/mm/tests/P-indentation-works.sh b/contrib/mm/tests/P-indentation-works.sh index 5be7efdc5..531c3580e 100755 --- a/contrib/mm/tests/P-indentation-works.sh +++ b/contrib/mm/tests/P-indentation-works.sh @@ -63,6 +63,20 @@ P10 not indented. .P P11 indented.' +# page offset is in register O for the macro mm +p_offset=$(printf '%s\n%s\n' '.nr p_off \nOu/1n' '.tm \n[p_off]' \ + | $groff -mm -Tascii 2>&1 | grep -e '^[1-9]' ) +#echo p_offset is $p_offset; # exit 1 + +# Paragraph indent is the register Pi for the macro mm +p_indent=$(printf '%s\n' '.tm \n[Pi]' \ + | "$groff" -mm -Tascii 2>&1 | grep -e '^[1-9]' ) +#echo p_indent is $p_indent; #exit 1 + +t_off=$(expr $p_offset + $p_indent) + +#echo t_off is $t_off; exit + output=$(printf "%s\n" "$input" | "$groff" -mm -Tascii -P-cbou) echo "$output" @@ -98,37 +112,37 @@ echo "$output" # P11 indented. echo "checking that initial untyped paragraph not indented" >&2 -echo "$output" | grep -Eqx ' {7}P1 not indented\.' || wail +echo "$output" | grep -Eqx ' {'$p_offset'}P1 not indented\.' || wail echo "checking that initial type 0 paragraph not indented" >&2 -echo "$output" | grep -Eqx ' {7}P2 not indented\.' || wail +echo "$output" | grep -Eqx ' {'$p_offset'}P2 not indented\.' || wail echo "checking that first paragraph after Pt=2 indented" >&2 -echo "$output" | grep -Eqx ' {12}P3 indented\.' || wail +echo "$output" | grep -Eqx ' {'$t_off'}P3 indented\.' || wail echo "checking that second paragraph after Pt=2 indented" >&2 -echo "$output" | grep -Eqx ' {12}P4 indented\.' || wail +echo "$output" | grep -Eqx ' {'$t_off'}P4 indented\.' || wail echo "checking that first paragraph after heading not indented" >&2 -echo "$output" | grep -Eqx ' {7}P5 not indented\.' || wail +echo "$output" | grep -Eqx ' {'$p_offset'}P5 not indented\.' || wail echo "checking that second paragraph after heading indented" >&2 -echo "$output" | grep -Eqx ' {12}P6 indented\.' || wail +echo "$output" | grep -Eqx ' {'$t_off'}P6 indented\.' || wail echo "checking that paragraph after run-in heading indented" >&2 -echo "$output" | grep -Eqx ' {12}P7 indented\.' || wail +echo "$output" | grep -Eqx ' {'$t_off'}P7 indented\.' || wail echo "checking that first paragraph after display not indented" >&2 -echo "$output" | grep -Eqx ' {7}P8 not indented\.' || wail +echo "$output" | grep -Eqx ' {'$p_offset'}P8 not indented\.' || wail echo "checking that second paragraph after display indented" >&2 -echo "$output" | grep -Eqx ' {12}P9 indented\.' || wail +echo "$output" | grep -Eqx ' {'$t_off'}P9 indented\.' || wail echo "checking that first paragraph after list not indented" >&2 -echo "$output" | grep -Eqx ' {7}P10 not indented\.' || wail +echo "$output" | grep -Eqx ' {'$p_offset'}P10 not indented\.' || wail echo "checking that second paragraph after list indented" >&2 -echo "$output" | grep -Eqx ' {12}P11 indented\.' || wail +echo "$output" | grep -Eqx ' {'$t_off'}P11 indented\.' || wail test -z "$fail" -- 2.39.2