source@mandoc.bsd.lv
 help / color / Atom feed
* mandoc: Skip whitespace before tokens, too.
@ 2020-01-08 12:16 schwarze
  0 siblings, 0 replies; only message in thread
From: schwarze @ 2020-01-08 12:16 UTC (permalink / raw)
  To: source

Log Message:
-----------
Skip whitespace before tokens, too.
Bug found by bentley@ with input like "delim $$ delim off".

Modified Files:
--------------
    mandoc:
        eqn.c
    mandoc/regress/eqn/delim:
        Makefile
        basic.in
        basic.out_ascii

Added Files:
-----------
    mandoc/regress/eqn/delim:
        basic.out_utf8

Revision Data
-------------
Index: eqn.c
===================================================================
RCS file: /home/cvs/mandoc/mandoc/eqn.c,v
retrieving revision 1.83
retrieving revision 1.84
diff -Leqn.c -Leqn.c -u -p -r1.83 -r1.84
--- eqn.c
+++ eqn.c
@@ -1,7 +1,7 @@
 /*	$Id$ */
 /*
  * 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
@@ -399,6 +399,14 @@ eqn_next(struct eqn_node *ep, enum parse
 		case '"':
 			quoted = 1;
 			break;
+		case ' ':
+		case '\t':
+		case '~':
+		case '^':
+			if (quoted)
+				break;
+			ep->start++;
+			continue;
 		default:
 			break;
 		}
@@ -669,7 +677,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);
Index: Makefile
===================================================================
RCS file: /home/cvs/mandoc/mandoc/regress/eqn/delim/Makefile,v
retrieving revision 1.2
retrieving revision 1.3
diff -Lregress/eqn/delim/Makefile -Lregress/eqn/delim/Makefile -u -p -r1.2 -r1.3
--- regress/eqn/delim/Makefile
+++ regress/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	 =
 
--- /dev/null
+++ regress/eqn/delim/basic.out_utf8
@@ -0,0 +1,10 @@
+DELIM-BASIC(1)              General Commands Manual             DELIM-BASIC(1)
+
+N\bNA\bAM\bME\bE
+     d\bde\bel\bli\bim\bm-\b-b\bba\bas\bsi\bic\bc – inline eqn delimiters
+
+D\bDE\bES\bSC\bCR\bRI\bIP\bPT\bTI\bIO\bON\bN
+     initial text α inline β γ inline [delta] ε inline ζ inline $eta$ inline θ
+     final text
+
+OpenBSD                         January 8, 2020                        OpenBSD
Index: basic.out_ascii
===================================================================
RCS file: /home/cvs/mandoc/mandoc/regress/eqn/delim/basic.out_ascii,v
retrieving revision 1.4
retrieving revision 1.5
diff -Lregress/eqn/delim/basic.out_ascii -Lregress/eqn/delim/basic.out_ascii -u -p -r1.4 -r1.5
--- regress/eqn/delim/basic.out_ascii
+++ regress/eqn/delim/basic.out_ascii
@@ -5,6 +5,6 @@ N\bNA\bAM\bME\bE
 
 D\bDE\bES\bSC\bCR\bRI\bIP\bPT\bTI\bIO\bON\bN
      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
Index: basic.in
===================================================================
RCS file: /home/cvs/mandoc/mandoc/regress/eqn/delim/basic.in,v
retrieving revision 1.3
retrieving revision 1.4
diff -Lregress/eqn/delim/basic.in -Lregress/eqn/delim/basic.in -u -p -r1.3 -r1.4
--- regress/eqn/delim/basic.in
+++ regress/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$
 .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
--
 To unsubscribe send an email to source+unsubscribe@mandoc.bsd.lv

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, back to index

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-01-08 12:16 mandoc: Skip whitespace before tokens, too schwarze

source@mandoc.bsd.lv

Archives are clonable: git clone --mirror http://inbox.vuxu.org/mandoc-source

Example config snippet for mirrors

Newsgroup available over NNTP:
	nntp://inbox.vuxu.org/vuxu.archive.mandoc.source


AGPL code for this site: git clone https://public-inbox.org/public-inbox.git