summaryrefslogtreecommitdiff
path: root/regress
diff options
context:
space:
mode:
authorIngo Schwarze <schwarze@cvs.openbsd.org>2011-01-03 22:27:22 +0000
committerIngo Schwarze <schwarze@cvs.openbsd.org>2011-01-03 22:27:22 +0000
commit875215927636af7bbe5a043d74515bd250db9dfd (patch)
tree5503e501ea45f2bcf220f1b99cb6bdaae2d3ebb1 /regress
parent72f9055c4558e2d50b3237459eb9614394fe64df (diff)
Unify roff macro argument parsing (in roff.c, roff_userdef()) and man macro
argument parsing (in man_argv.c, man_args()), both having different bugs, to use one common macro argument parser (in mandoc.c, mandoc_getarg()), because from the point of view of roff, man macros are just roff macros, hence their arguments are parsed in exactly the same way. While doing so, fix these bugs: * Escaped blanks (i.e. those preceded by an odd number of backslashes) were mishandled as argument separators in unquoted arguments to user-defined roff macros. * Unescaped blanks preceded by an even number of backslashes were not recognized as argument separators in unquoted arguments to man macros. * Escaped backslashes (i.e. pairs of backslashes) were not reduced to single backslashes both in unquoted and quoted arguments both to user-defined roff macros and to man macros. * Escaped quotes (i.e. pairs of quotes inside quoted arguments) were not reduced to single quotes in man macros. OK kristaps@ Note that mdoc macro argument parsing is yet another beast for no good reason and is probably afflicted by similar bugs. But i don't attempt to fix that right now because it is intricately entangled with lots of unrelated high-level mdoc(7) functionality, like delimiter handling and column list phrase handling. Disentagling that would waste too much time now.
Diffstat (limited to 'regress')
-rw-r--r--regress/usr.bin/mandoc/roff/Makefile4
-rw-r--r--regress/usr.bin/mandoc/roff/args/Makefile6
-rw-r--r--regress/usr.bin/mandoc/roff/args/man.in113
-rw-r--r--regress/usr.bin/mandoc/roff/args/man.out_ascii34
-rw-r--r--regress/usr.bin/mandoc/roff/args/roff.in65
-rw-r--r--regress/usr.bin/mandoc/roff/args/roff.out_ascii38
6 files changed, 258 insertions, 2 deletions
diff --git a/regress/usr.bin/mandoc/roff/Makefile b/regress/usr.bin/mandoc/roff/Makefile
index 33c2617c79e..cf54fb8af15 100644
--- a/regress/usr.bin/mandoc/roff/Makefile
+++ b/regress/usr.bin/mandoc/roff/Makefile
@@ -1,6 +1,6 @@
-# $OpenBSD: Makefile,v 1.2 2010/12/09 20:56:30 schwarze Exp $
+# $OpenBSD: Makefile,v 1.3 2011/01/03 22:27:21 schwarze Exp $
-SUBDIR+= cond string
+SUBDIR+= args cond string
groff groff-clean: _SUBDIRUSE
diff --git a/regress/usr.bin/mandoc/roff/args/Makefile b/regress/usr.bin/mandoc/roff/args/Makefile
new file mode 100644
index 00000000000..3df35e48910
--- /dev/null
+++ b/regress/usr.bin/mandoc/roff/args/Makefile
@@ -0,0 +1,6 @@
+# $OpenBSD: Makefile,v 1.1 2011/01/03 22:27:21 schwarze Exp $
+
+REGRESS_TARGETS=roff man
+GROFF_TARGETS=roff man
+
+.include <bsd.regress.mk>
diff --git a/regress/usr.bin/mandoc/roff/args/man.in b/regress/usr.bin/mandoc/roff/args/man.in
new file mode 100644
index 00000000000..190e66d5709
--- /dev/null
+++ b/regress/usr.bin/mandoc/roff/args/man.in
@@ -0,0 +1,113 @@
+.TH ARGS-MAN 1 "January 1, 2011"
+.SH NAME
+args-man - arguments to man macros
+.SH DESCRIPTION
+standard unquoted:
+.IB one two
+text
+.br
+escaped blanks:
+.IB one\ one two\ two
+text
+.br
+escaped 'e' character:
+.IB one\eone two
+text
+.br
+.\"escaped backslash before blank:
+.\"IB one\\ two
+.\"text
+.\"br
+escaped backslash before 'e' character:
+.IB one\\e two
+text
+.br
+double inter-argument space:
+.IB one two
+text
+.br
+triple inter-argument space:
+.IB one two
+text
+.br
+single eol blank:
+.IB one two
+text
+.br
+double eol blank:
+.IB one two
+text
+.br
+triple eol blank:
+.IB one two
+text
+.br
+standard quoted:
+.IB "one" "two"
+text
+.br
+quoted quotes:
+.IB "one""one" """two"""
+text
+.br
+quoted whitespace:
+.IB "one one" "two two"
+text
+.br
+escaped 'e' characters:
+.IB "one \e one" "\e"
+text
+.br
+escaped backslash before blank:
+.IB "one\\ one" "\\ "
+text
+.br
+escaped backslash before 'e' character:
+.IB "one\\eone" "\\e"
+text
+.br
+double inter-argument space:
+.IB "one one" "two two"
+text
+.br
+triple inter-argument space:
+.IB "one one" "two two"
+text
+.br
+missing inter-argument space:
+.IB "one one"two\ two
+text
+.br
+single eol blank:
+.IB "one one" "two two"
+text
+.br
+double eol blank:
+.IB "one one" "two two"
+text
+.br
+triple eol blank:
+.IB "one one" "two two"
+text
+.br
+.\"trailing blanks in arguments:
+.\"IB "one " "two "
+.\"text
+.\"br
+unterminated quotes:
+.IB "one
+.IB one "two
+text
+.br
+.\"single trailing blank in unterminated quotes:
+.\"IB "one
+.\"IB one "two
+.\"text
+.\"br
+.\"double trailing blank in unterminated quotes:
+.\"IB "one
+.\"IB one "two
+.\"text
+.\"br
+backslash at eol:
+.IB one two\
diff --git a/regress/usr.bin/mandoc/roff/args/man.out_ascii b/regress/usr.bin/mandoc/roff/args/man.out_ascii
new file mode 100644
index 00000000000..3b945f483ed
--- /dev/null
+++ b/regress/usr.bin/mandoc/roff/args/man.out_ascii
@@ -0,0 +1,34 @@
+ARGS-MAN(1) ARGS-MAN(1)
+
+
+
+NNAAMMEE
+ args-man - arguments to man macros
+
+DDEESSCCRRIIPPTTIIOONN
+ standard unquoted: _o_n_ettwwoo text
+ escaped blanks: _o_n_e _o_n_ettwwoo ttwwoo text
+ escaped 'e' character: _o_n_e_\_o_n_ettwwoo text
+ escaped backslash before 'e' character: _o_n_e_\ttwwoo text
+ double inter-argument space: _o_n_ettwwoo text
+ triple inter-argument space: _o_n_ettwwoo text
+ single eol blank: _o_n_ettwwoo text
+ double eol blank: _o_n_ettwwoo text
+ triple eol blank: _o_n_ettwwoo text
+ standard quoted: _o_n_ettwwoo text
+ quoted quotes: _o_n_e_"_o_n_e""ttwwoo"" text
+ quoted whitespace: _o_n_e _o_n_ettwwoo ttwwoo text
+ escaped 'e' characters: _o_n_e _\ _o_n_e\\ text
+ escaped backslash before blank: _o_n_e _o_n_e text
+ escaped backslash before 'e' character: _o_n_e_\_o_n_e\\ text
+ double inter-argument space: _o_n_e _o_n_ettwwoo ttwwoo text
+ triple inter-argument space: _o_n_e _o_n_ettwwoo ttwwoo text
+ missing inter-argument space: _o_n_e _o_n_ettwwoo ttwwoo text
+ single eol blank: _o_n_e _o_n_ettwwoo ttwwoo text
+ double eol blank: _o_n_e _o_n_ettwwoo ttwwoo text
+ triple eol blank: _o_n_e _o_n_ettwwoo ttwwoo text
+ unterminated quotes: _o_n_e _o_n_ettwwoo text
+ backslash at eol: _o_n_ettwwoo
+
+
+
diff --git a/regress/usr.bin/mandoc/roff/args/roff.in b/regress/usr.bin/mandoc/roff/args/roff.in
new file mode 100644
index 00000000000..ff9a5781cc5
--- /dev/null
+++ b/regress/usr.bin/mandoc/roff/args/roff.in
@@ -0,0 +1,65 @@
+.TH ARGS-ROFF 1 "January 1, 2011"
+.SH NAME
+args-roff - arguments to roff macros
+.SH DESCRIPTION
+.de test
+(\\$1) (\\$2)
+.br
+..
+standard unquoted:
+.test one two
+escaped blanks:
+.test one\ one two\ two
+escaped 'e' character:
+.test one\eone two
+escaped backslash before blank:
+.test one\\ two
+escaped backslash before 'e' character:
+.test one\\e two
+double inter-argument space:
+.test one two
+triple inter-argument space:
+.test one two
+single eol blank:
+.test one two
+double eol blank:
+.test one two
+triple eol blank:
+.test one two
+standard quoted:
+.test "one" "two"
+quoted quotes:
+.test "one""one" """two"""
+quoted whitespace:
+.test "one one" "two two"
+escaped 'e' characters:
+.test "one \e one" "\e"
+escaped backslash before blank:
+.test "one\\ one" "\\ "
+escaped backslash before 'e' character:
+.test "one\\eone" "\\e"
+double inter-argument space:
+.test "one one" "two two"
+triple inter-argument space:
+.test "one one" "two two"
+missing inter-argument space:
+.test "one one"two\ two
+single eol blank:
+.test "one one" "two two"
+double eol blank:
+.test "one one" "two two"
+triple eol blank:
+.test "one one" "two two"
+trailing blanks in arguments:
+.test "one " "two "
+unterminated quotes:
+.\"test "one
+.test one "two
+single trailing blank in unterminated quotes:
+.\"test "one
+.test one "two
+double trailing blank in unterminated quotes:
+.\"test "one
+.test one "two
+backslash at eol:
+.test one two\
diff --git a/regress/usr.bin/mandoc/roff/args/roff.out_ascii b/regress/usr.bin/mandoc/roff/args/roff.out_ascii
new file mode 100644
index 00000000000..e8192088e82
--- /dev/null
+++ b/regress/usr.bin/mandoc/roff/args/roff.out_ascii
@@ -0,0 +1,38 @@
+ARGS-ROFF(1) ARGS-ROFF(1)
+
+
+
+NNAAMMEE
+ args-roff - arguments to roff macros
+
+DDEESSCCRRIIPPTTIIOONN
+ standard unquoted: (one) (two)
+ escaped blanks: (one one) (two two)
+ escaped 'e' character: (one\one) (two)
+ escaped backslash before blank: (one) (two)
+ escaped backslash before 'e' character: (one\) (two)
+ double inter-argument space: (one) (two)
+ triple inter-argument space: (one) (two)
+ single eol blank: (one) (two)
+ double eol blank: (one) (two)
+ triple eol blank: (one) (two)
+ standard quoted: (one) (two)
+ quoted quotes: (one"one) ("two")
+ quoted whitespace: (one one) (two two)
+ escaped 'e' characters: (one \ one) (\)
+ escaped backslash before blank: (one one) ( )
+ escaped backslash before 'e' character: (one\one) (\)
+ double inter-argument space: (one one) (two two)
+ triple inter-argument space: (one one) (two two)
+ missing inter-argument space: (one one) (two two)
+ single eol blank: (one one) (two two)
+ double eol blank: (one one) (two two)
+ triple eol blank: (one one) (two two)
+ trailing blanks in arguments: (one ) (two )
+ unterminated quotes: (one) (two)
+ single trailing blank in unterminated quotes: (one) (two )
+ double trailing blank in unterminated quotes: (one) (two )
+ backslash at eol: (one) (two)
+
+
+