source@mandoc.bsd.lv
 help / color / mirror / Atom feed
From: schwarze@mandoc.bsd.lv
To: source@mandoc.bsd.lv
Subject: mandoc: Skip whitespace before tokens, too.
Date: Wed, 8 Jan 2020 07:16:27 -0500 (EST)	[thread overview]
Message-ID: <ba40aaa086aff0b5@mandoc.bsd.lv> (raw)

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

                 reply	other threads:[~2020-01-08 12:16 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=ba40aaa086aff0b5@mandoc.bsd.lv \
    --to=schwarze@mandoc.bsd.lv \
    --cc=source@mandoc.bsd.lv \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).