diff options
author | 2020-01-08 12:09:14 +0000 | |
---|---|---|
committer | 2020-01-08 12:09:14 +0000 | |
commit | 0f5f5b536900144c9b9f1df1ffd0ea5eb4218139 (patch) | |
tree | 649e3f2ab531c04dc435387ad91168ffff29e203 | |
parent | Improve the test case by changing the eqn(7) delimiters such that it (diff) | |
download | wireguard-openbsd-0f5f5b536900144c9b9f1df1ffd0ea5eb4218139.tar.xz wireguard-openbsd-0f5f5b536900144c9b9f1df1ffd0ea5eb4218139.zip |
Skip whitespace before tokens, too.
Bug found by bentley@ with input like "delim $$ delim off".
-rw-r--r-- | regress/usr.bin/mandoc/eqn/delim/Makefile | 3 | ||||
-rw-r--r-- | regress/usr.bin/mandoc/eqn/delim/basic.in | 11 | ||||
-rw-r--r-- | regress/usr.bin/mandoc/eqn/delim/basic.out_ascii | 2 | ||||
-rw-r--r-- | regress/usr.bin/mandoc/eqn/delim/basic.out_utf8 | 10 | ||||
-rw-r--r-- | usr.bin/mandoc/eqn.c | 14 |
5 files changed, 34 insertions, 6 deletions
diff --git a/regress/usr.bin/mandoc/eqn/delim/Makefile b/regress/usr.bin/mandoc/eqn/delim/Makefile index dd8d92e7a62..6de941eebe7 100644 --- a/regress/usr.bin/mandoc/eqn/delim/Makefile +++ b/regress/usr.bin/mandoc/eqn/delim/Makefile @@ -1,6 +1,7 @@ -# $OpenBSD: Makefile,v 1.2 2020/01/08 10:50:54 schwarze Exp $ +# $OpenBSD: Makefile,v 1.3 2020/01/08 12:09:14 schwarze Exp $ REGRESS_TARGETS = basic +UTF8_TARGETS = basic GOPTS = -e SKIP_GROFF = diff --git a/regress/usr.bin/mandoc/eqn/delim/basic.in b/regress/usr.bin/mandoc/eqn/delim/basic.in index d8c84b9b0ae..c7671c71fce 100644 --- a/regress/usr.bin/mandoc/eqn/delim/basic.in +++ b/regress/usr.bin/mandoc/eqn/delim/basic.in @@ -1,4 +1,4 @@ -.\" $OpenBSD: basic.in,v 1.3 2020/01/08 10:58:09 schwarze Exp $ +.\" $OpenBSD: basic.in,v 1.4 2020/01/08 12:09:14 schwarze Exp $ .Dd $Mdocdate: January 8 2020 $ .Dt DELIM-BASIC 1 .Os @@ -19,4 +19,13 @@ inline [delta] delim onepsilon .EN inline [zeta] +.EQ +delim $$ +delim off +.EN +inline $eta$ +.EQ +delim on +.EN +inline $theta$ final text diff --git a/regress/usr.bin/mandoc/eqn/delim/basic.out_ascii b/regress/usr.bin/mandoc/eqn/delim/basic.out_ascii index 03a8059bd52..7f748bcc6f6 100644 --- a/regress/usr.bin/mandoc/eqn/delim/basic.out_ascii +++ b/regress/usr.bin/mandoc/eqn/delim/basic.out_ascii @@ -5,6 +5,6 @@ NNAAMMEE DDEESSCCRRIIPPTTIIOONN initial text <alpha> inline <beta> <gamma> inline [delta] <epsilon> - inline <zeta> final text + inline <zeta> inline $eta$ inline <theta> final text OpenBSD January 8, 2020 OpenBSD diff --git a/regress/usr.bin/mandoc/eqn/delim/basic.out_utf8 b/regress/usr.bin/mandoc/eqn/delim/basic.out_utf8 new file mode 100644 index 00000000000..b7cb7e97280 --- /dev/null +++ b/regress/usr.bin/mandoc/eqn/delim/basic.out_utf8 @@ -0,0 +1,10 @@ +DELIM-BASIC(1) General Commands Manual DELIM-BASIC(1) + +NNAAMMEE + ddeelliimm--bbaassiicc – inline eqn delimiters + +DDEESSCCRRIIPPTTIIOONN + initial text α inline β γ inline [delta] ε inline ζ inline $eta$ inline θ + final text + +OpenBSD January 8, 2020 OpenBSD diff --git a/usr.bin/mandoc/eqn.c b/usr.bin/mandoc/eqn.c index 667781fd748..ad3206770bb 100644 --- a/usr.bin/mandoc/eqn.c +++ b/usr.bin/mandoc/eqn.c @@ -1,7 +1,7 @@ -/* $OpenBSD: eqn.c,v 1.46 2018/12/14 06:33:03 schwarze Exp $ */ +/* $OpenBSD: eqn.c,v 1.47 2020/01/08 12:09:14 schwarze Exp $ */ /* * Copyright (c) 2011, 2014 Kristaps Dzonsons <kristaps@bsd.lv> - * Copyright (c) 2014, 2015, 2017, 2018 Ingo Schwarze <schwarze@openbsd.org> + * Copyright (c) 2014,2015,2017,2018,2020 Ingo Schwarze <schwarze@openbsd.org> * * Permission to use, copy, modify, and distribute this software for any * purpose with or without fee is hereby granted, provided that the above @@ -397,6 +397,14 @@ eqn_next(struct eqn_node *ep, enum parse_mode mode) case '"': quoted = 1; break; + case ' ': + case '\t': + case '~': + case '^': + if (quoted) + break; + ep->start++; + continue; default: break; } @@ -667,7 +675,7 @@ eqn_parse(struct eqn_node *ep) if (ep->data == NULL) return; - ep->start = ep->end = ep->data + strspn(ep->data, " ^~"); + ep->start = ep->end = ep->data; next_tok: tok = eqn_next(ep, MODE_TOK); |