summaryrefslogtreecommitdiff
path: root/src/roff
diff options
context:
space:
mode:
Diffstat (limited to 'src/roff')
-rw-r--r--src/roff/grog/grog.pl27
-rw-r--r--src/roff/grog/grog.sh23
-rw-r--r--src/roff/troff/input.cc10
3 files changed, 51 insertions, 9 deletions
diff --git a/src/roff/grog/grog.pl b/src/roff/grog/grog.pl
index 57cd1594..a61106c1 100644
--- a/src/roff/grog/grog.pl
+++ b/src/roff/grog/grog.pl
@@ -113,9 +113,36 @@ sub process {
# closed by `Oc'.
elsif (/^\.Oo$sp/) {
$Oo++;
+ s/^\.Oo/\. /;
+ redo;
+ }
+ # The test for `Oo' and `Oc' not starting a line (as allowed by the
+ # new implementation of -mdoc) is not complete; it assumes that
+ # macro arguments are well behaved, i.e., "" is used within "..." to
+ # indicate a doublequote as a string element, and weird features
+ # like `.foo a"b' are not used.
+ elsif (/^\..* Oo( |$)/) {
+ s/\\\".*//;
+ s/\"[^\"]*\"//g;
+ s/\".*//;
+ if (s/ Oo( |$)/ /) {
+ $Oo++;
+ }
+ redo;
}
elsif (/^\.Oc$sp/) {
$Oo--;
+ s/^\.Oc/\. /;
+ redo;
+ }
+ elsif (/^\..* Oc( |$)/) {
+ s/\\\".*//;
+ s/\"[^\"]*\"//g;
+ s/\".*//;
+ if (s/ Oc( |$)/ /) {
+ $Oo--;
+ }
+ redo;
}
if (/^\.so$sp/) {
chop;
diff --git a/src/roff/grog/grog.sh b/src/roff/grog/grog.sh
index 7919dbf5..ae269af5 100644
--- a/src/roff/grog/grog.sh
+++ b/src/roff/grog/grog.sh
@@ -29,12 +29,12 @@ do
esac
done
-egrep -h "^\.(P|PS|[PLI]P|[pnil]p|sh|Dd|Tp|Dp|De|Cx|Cl|Oo|Oc|TS|EQ|TH|SH|so|\[|R1|GS|G1|PH|SA)$sp" $* \
+egrep -h "^\.(P|PS|[PLI]P|[pnil]p|sh|Dd|Tp|Dp|De|Cx|Cl|Oo|.* Oo|Oc|.* Oc|TS|EQ|TH|SH|so|\[|R1|GS|G1|PH|SA)$sp" $* \
| sed -e '/^\.so/s/^.*$/.SO_START\
&\
.SO_END/' \
| $soelim \
-| egrep '^\.(P|PS|[PLI]P|[pnil]p|sh|Dd|Tp|Dp|De|Cx|Cl|Oo|Oc|TS|EQ|TH|SH|\[|R1|GS|G1|PH|SA|SO_START|SO_END)' \
+| egrep '^\.(P|PS|[PLI]P|[pnil]p|sh|Dd|Tp|Dp|De|Cx|Cl|Oo|.* Oo|Oc|.* Oc|TS|EQ|TH|SH|\[|R1|GS|G1|PH|SA|SO_START|SO_END)' \
| awk '
/^\.SO_START$/ { so = 1 }
/^\.SO_END$/ { so = 0 }
@@ -52,8 +52,23 @@ egrep -h "^\.(P|PS|[PLI]P|[pnil]p|sh|Dd|Tp|Dp|De|Cx|Cl|Oo|Oc|TS|EQ|TH|SH|so|\[|R
/^\.([pnil]p|sh)/ { me++ }
/^\.Dd/ { mdoc++ }
/^\.(Tp|Dp|De|Cx|Cl)/ { mdoc_old++ }
-/^\.Oo/ { Oo++ }
-/^\.Oc/ { Oo-- }
+/^\.(O[oc]|.* O[oc]( |$))/ {
+ sub(/\\\".*/, "")
+ gsub(/\"[^\"]*\"/, "")
+ sub(/\".*/, "")
+ sub(/^\.Oo/, " Oo ")
+ sub(/^\.Oc/, " Oc ")
+ sub(/ Oo$/, " Oo ")
+ sub(/ Oc$/, " Oc ")
+ while (/ Oo /) {
+ sub(/ Oo /, " ")
+ Oo++
+ }
+ while (/ Oc /) {
+ sub(/ Oc /, " ")
+ Oo--
+ }
+}
END {
if (files ~ /^-/)
diff --git a/src/roff/troff/input.cc b/src/roff/troff/input.cc
index 6db4ce51..54aaa3fc 100644
--- a/src/roff/troff/input.cc
+++ b/src/roff/troff/input.cc
@@ -3965,11 +3965,6 @@ static int read_size(int *x)
}
}
else if (csdigit(c)) {
- if (!inc && c == '0') {
- // special case -- \s0 means to revert to previous size.
- *x = 0;
- return 1;
- }
val = c - '0';
if (!inc && c != '0' && c < '4') {
tok.next();
@@ -4001,6 +3996,11 @@ static int read_size(int *x)
if (!bad) {
switch (inc) {
case 0:
+ if (val == 0) {
+ // special case -- \s[0] and \s0 means to revert to previous size
+ *x = 0;
+ return 1;
+ }
*x = val;
break;
case 1: