source@mandoc.bsd.lv
 help / color / mirror / Atom feed
From: schwarze@mdocml.bsd.lv
To: source@mdocml.bsd.lv
Subject: mdocml: For now, it can't be helped that mandoc tbl(7) ignores
Date: Wed, 28 Jan 2015 10:04:15 -0500 (EST)	[thread overview]
Message-ID: <10195831924996839069.enqueue@fantadrom.bsd.lv> (raw)

Log Message:
-----------
For now, it can't be helped that mandoc tbl(7) ignores high-level macros,
but stop throwing away their arguments.  This fixes information loss in a
handful of Xenocara manuals, at the price of a small amount of formatting
noise creeping through.

Modified Files:
--------------
    mdocml:
        libroff.h
        roff.c
        tbl.c
        tbl_data.c
        tbl_layout.c
        tbl_opts.c

Revision Data
-------------
Index: tbl_layout.c
===================================================================
RCS file: /home/cvs/mdocml/mdocml/tbl_layout.c,v
retrieving revision 1.33
retrieving revision 1.34
diff -Ltbl_layout.c -Ltbl_layout.c -u -p -r1.33 -r1.34
--- tbl_layout.c
+++ tbl_layout.c
@@ -234,14 +234,11 @@ again:
 }
 
 void
-tbl_layout(struct tbl_node *tbl, int ln, const char *p)
+tbl_layout(struct tbl_node *tbl, int ln, const char *p, int pos)
 {
 	struct tbl_row	*rp;
-	int		 pos;
 
-	pos = 0;
 	rp = NULL;
-
 	for (;;) {
 		/* Skip whitespace before and after each cell. */
 
Index: tbl_opts.c
===================================================================
RCS file: /home/cvs/mdocml/mdocml/tbl_opts.c,v
retrieving revision 1.18
retrieving revision 1.19
diff -Ltbl_opts.c -Ltbl_opts.c -u -p -r1.18 -r1.19
--- tbl_opts.c
+++ tbl_opts.c
@@ -120,17 +120,19 @@ arg(struct tbl_node *tbl, int ln, const 
  * and some options are followed by arguments.
  */
 void
-tbl_option(struct tbl_node *tbl, int ln, const char *p)
+tbl_option(struct tbl_node *tbl, int ln, const char *p, int *offs)
 {
 	int		 i, pos, len;
 
-	pos = 0;
+	pos = *offs;
 	for (;;) {
 		while (p[pos] == ' ' || p[pos] == '\t' || p[pos] == ',')
 			pos++;
 
-		if (p[pos] == ';')
+		if (p[pos] == ';') {
+			*offs = pos + 1;
 			return;
+		}
 
 		/* Parse one option name. */
 
Index: tbl_data.c
===================================================================
RCS file: /home/cvs/mdocml/mdocml/tbl_data.c,v
retrieving revision 1.34
retrieving revision 1.35
diff -Ltbl_data.c -Ltbl_data.c -u -p -r1.34 -r1.35
--- tbl_data.c
+++ tbl_data.c
@@ -138,13 +138,10 @@ getdata(struct tbl_node *tbl, struct tbl
 }
 
 int
-tbl_cdata(struct tbl_node *tbl, int ln, const char *p)
+tbl_cdata(struct tbl_node *tbl, int ln, const char *p, int pos)
 {
 	struct tbl_dat	*dat;
 	size_t		 sz;
-	int		 pos;
-
-	pos = 0;
 
 	dat = tbl->last_span->last;
 
@@ -204,11 +201,10 @@ newspan(struct tbl_node *tbl, int line, 
 }
 
 void
-tbl_data(struct tbl_node *tbl, int ln, const char *p)
+tbl_data(struct tbl_node *tbl, int ln, const char *p, int pos)
 {
 	struct tbl_span	*dp;
 	struct tbl_row	*rp;
-	int		 pos;
 
 	/*
 	 * Choose a layout row: take the one following the last parsed
@@ -259,7 +255,6 @@ tbl_data(struct tbl_node *tbl, int ln, c
 
 	dp->pos = TBL_SPAN_DATA;
 
-	pos = 0;
 	while ('\0' != p[pos])
 		getdata(tbl, dp, ln, p, &pos);
 }
Index: tbl.c
===================================================================
RCS file: /home/cvs/mdocml/mdocml/tbl.c,v
retrieving revision 1.34
retrieving revision 1.35
diff -Ltbl.c -Ltbl.c -u -p -r1.34 -r1.35
--- tbl.c
+++ tbl.c
@@ -32,7 +32,7 @@
 
 
 enum rofferr
-tbl_read(struct tbl_node *tbl, int ln, const char *p, int offs)
+tbl_read(struct tbl_node *tbl, int ln, const char *p, int pos)
 {
 	const char	*cp;
 	int		 active;
@@ -46,7 +46,7 @@ tbl_read(struct tbl_node *tbl, int ln, c
 	if (tbl->part == TBL_PART_OPTS) {
 		tbl->part = TBL_PART_LAYOUT;
 		active = 1;
-		for (cp = p; *cp != '\0'; cp++) {
+		for (cp = p + pos; *cp != '\0'; cp++) {
 			switch (*cp) {
 			case '(':
 				active = 0;
@@ -64,8 +64,8 @@ tbl_read(struct tbl_node *tbl, int ln, c
 			break;
 		}
 		if (*cp == ';') {
-			tbl_option(tbl, ln, p);
-			if (*(p = cp + 1) == '\0')
+			tbl_option(tbl, ln, p, &pos);
+			if (p[pos] == '\0')
 				return(ROFF_IGN);
 		}
 	}
@@ -74,15 +74,15 @@ tbl_read(struct tbl_node *tbl, int ln, c
 
 	switch (tbl->part) {
 	case TBL_PART_LAYOUT:
-		tbl_layout(tbl, ln, p);
+		tbl_layout(tbl, ln, p, pos);
 		return(ROFF_IGN);
 	case TBL_PART_CDATA:
-		return(tbl_cdata(tbl, ln, p) ? ROFF_TBL : ROFF_IGN);
+		return(tbl_cdata(tbl, ln, p, pos) ? ROFF_TBL : ROFF_IGN);
 	default:
 		break;
 	}
 
-	tbl_data(tbl, ln, p);
+	tbl_data(tbl, ln, p, pos);
 	return(ROFF_TBL);
 }
 
Index: roff.c
===================================================================
RCS file: /home/cvs/mdocml/mdocml/roff.c,v
retrieving revision 1.256
retrieving revision 1.257
diff -Lroff.c -Lroff.c -u -p -r1.256 -r1.257
--- roff.c
+++ roff.c
@@ -1237,7 +1237,13 @@ roff_parseln(struct roff *r, int ln, str
 	if (r->tbl != NULL && (t == ROFF_MAX || t == ROFF_TS)) {
 		mandoc_msg(MANDOCERR_TBLMACRO, r->parse,
 		    ln, pos, buf->buf + spos);
-		return(ROFF_IGN);
+		if (t == ROFF_TS)
+			return(ROFF_IGN);
+		while (buf->buf[pos] != '\0' && buf->buf[pos] != ' ')
+			pos++;
+		while (buf->buf[pos] != '\0' && buf->buf[pos] == ' ')
+			pos++;
+		return(tbl_read(r->tbl, ln, buf->buf, pos));
 	}
 
 	/*
Index: libroff.h
===================================================================
RCS file: /home/cvs/mdocml/mdocml/libroff.h,v
retrieving revision 1.35
retrieving revision 1.36
diff -Llibroff.h -Llibroff.h -u -p -r1.35 -r1.36
--- libroff.h
+++ libroff.h
@@ -1,7 +1,7 @@
 /*	$Id$ */
 /*
  * Copyright (c) 2009, 2010, 2011 Kristaps Dzonsons <kristaps@bsd.lv>
- * Copyright (c) 2014 Ingo Schwarze <schwarze@openbsd.org>
+ * Copyright (c) 2014, 2015 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
@@ -69,10 +69,10 @@ void		 tbl_restart(int, int, struct tbl_
 void		 tbl_free(struct tbl_node *);
 void		 tbl_reset(struct tbl_node *);
 enum rofferr	 tbl_read(struct tbl_node *, int, const char *, int);
-void		 tbl_option(struct tbl_node *, int, const char *);
-void		 tbl_layout(struct tbl_node *, int, const char *);
-void		 tbl_data(struct tbl_node *, int, const char *);
-int		 tbl_cdata(struct tbl_node *, int, const char *);
+void		 tbl_option(struct tbl_node *, int, const char *, int *);
+void		 tbl_layout(struct tbl_node *, int, const char *, int);
+void		 tbl_data(struct tbl_node *, int, const char *, int);
+int		 tbl_cdata(struct tbl_node *, int, const char *, int);
 const struct tbl_span	*tbl_span(struct tbl_node *);
 void		 tbl_end(struct tbl_node **);
 struct eqn_node	*eqn_alloc(int, int, struct mparse *);
--
 To unsubscribe send an email to source+unsubscribe@mdocml.bsd.lv

                 reply	other threads:[~2015-01-28 15:04 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=10195831924996839069.enqueue@fantadrom.bsd.lv \
    --to=schwarze@mdocml.bsd.lv \
    --cc=source@mdocml.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).