From 9ecd400a155752d29b5c893fa7ceb5aabcea69bd Mon Sep 17 00:00:00 2001 From: Ingo Schwarze Date: Mon, 9 Apr 2018 02:31:38 +0000 Subject: Using an undefined string or macro will cause it to be defined as empty. Observed by Werner Lemberg on Nov 14, 2011 and rotting on my TODO list ever since. --- regress/usr.bin/mandoc/roff/string/Makefile | 6 +- regress/usr.bin/mandoc/roff/string/undef.in | 69 ++++++++++++++++++++++ regress/usr.bin/mandoc/roff/string/undef.out_ascii | 37 ++++++++++++ regress/usr.bin/mandoc/roff/string/undef.out_lint | 2 + 4 files changed, 111 insertions(+), 3 deletions(-) create mode 100644 regress/usr.bin/mandoc/roff/string/undef.in create mode 100644 regress/usr.bin/mandoc/roff/string/undef.out_ascii create mode 100644 regress/usr.bin/mandoc/roff/string/undef.out_lint (limited to 'regress/usr.bin/mandoc') diff --git a/regress/usr.bin/mandoc/roff/string/Makefile b/regress/usr.bin/mandoc/roff/string/Makefile index be5c76260bc..bbc787a27b8 100644 --- a/regress/usr.bin/mandoc/roff/string/Makefile +++ b/regress/usr.bin/mandoc/roff/string/Makefile @@ -1,7 +1,7 @@ -# $OpenBSD: Makefile,v 1.7 2017/06/18 17:35:40 schwarze Exp $ +# $OpenBSD: Makefile,v 1.8 2018/04/09 02:31:37 schwarze Exp $ -REGRESS_TARGETS = escape infinite name std zerolength -LINT_TARGETS = name std +REGRESS_TARGETS = escape infinite name std undef zerolength +LINT_TARGETS = name std undef # The infinite test fails badly with groff-1.20.1: # It fails to print the following text. diff --git a/regress/usr.bin/mandoc/roff/string/undef.in b/regress/usr.bin/mandoc/roff/string/undef.in new file mode 100644 index 00000000000..63b4a2475d0 --- /dev/null +++ b/regress/usr.bin/mandoc/roff/string/undef.in @@ -0,0 +1,69 @@ +.\" $OpenBSD: undef.in,v 1.1 2018/04/09 02:31:37 schwarze Exp $ +.TH STRING-UNDEF 1 "April 9, 2018" +.SH NAME +string-undef - expanding undefined strings +.SH DESCRIPTION +.SS User defined string +The sting "mys" is +.ie dmys defined +.el undefined +and remains +.ie dmys defined. +.el undefined. +.PP +Its value is "\*[mys]", and now it is +.ie dmys defined, +.el undefined, +and its value is still "\*[mys]". +.PP +.ds mys newval +After redefining it to "\*[mys]", it is of course still +.ie dmys defined. +.el undefined. +.PP +.rm mys +After removing the definition, it is now +.ie dmys defined. +.el undefined. +.SS User defined macro +The macro "mym" is +.ie dmym defined. +.el undefined. +.PP +It has no effect: +.mym +But now it is +.ie dmym defined. +.el undefined. +.PP +.de mym +neweffect +.. +After defining it as: +.mym +it is of course still +.ie dmym defined. +.el undefined. +.PP +.rm mym +After removing the definition, it is now +.ie dmym defined. +.el undefined. +.SS Renamed macro +The standard .BR macro is +.ie dBR defined, +.el undefined, +and it +.BR works . +.PP +.rn BR newBR +After renaming it, the new name is +.ie dnewBR defined, +.el undefined, +and +.newBR works . +.SS Predefined string +A predefined string is +.ie dR defined +.el undefined +and has the value "\*R". diff --git a/regress/usr.bin/mandoc/roff/string/undef.out_ascii b/regress/usr.bin/mandoc/roff/string/undef.out_ascii new file mode 100644 index 00000000000..6e7bd01fcb0 --- /dev/null +++ b/regress/usr.bin/mandoc/roff/string/undef.out_ascii @@ -0,0 +1,37 @@ +STRING-UNDEF(1) General Commands Manual STRING-UNDEF(1) + + + +NNAAMMEE + string-undef - expanding undefined strings + +DDEESSCCRRIIPPTTIIOONN + UUsseerr ddeeffiinneedd ssttrriinngg + The sting "mys" is undefined and remains undefined. + + Its value is "", and now it is defined, and its value is still "". + + After redefining it to "newval", it is of course still defined. + + After removing the definition, it is now undefined. + + UUsseerr ddeeffiinneedd mmaaccrroo + The macro "mym" is undefined. + + It has no effect: But now it is defined. + + After defining it as: neweffect it is of course still defined. + + After removing the definition, it is now undefined. + + RReennaammeedd mmaaccrroo + The standard .BR macro is defined, and it wwoorrkkss. + + After renaming it, the new name is defined, and wwoorrkkss. + + PPrreeddeeffiinneedd ssttrriinngg + A predefined string is defined and has the value "(R)". + + + +OpenBSD April 9, 2018 STRING-UNDEF(1) diff --git a/regress/usr.bin/mandoc/roff/string/undef.out_lint b/regress/usr.bin/mandoc/roff/string/undef.out_lint new file mode 100644 index 00000000000..320ec604c83 --- /dev/null +++ b/regress/usr.bin/mandoc/roff/string/undef.out_lint @@ -0,0 +1,2 @@ +mandoc: undef.in:14:15: WARNING: undefined string, using "": mys +mandoc: undef.in:34:2: ERROR: skipping unknown macro: .mym -- cgit v1.2.3