discuss@mandoc.bsd.lv
 help / color / mirror / Atom feed
From: Kristaps Dzonsons <kristaps@bsd.lv>
To: discuss@mdocml.bsd.lv
Subject: Re: -column issue
Date: Sat, 07 Aug 2010 19:32:06 +0200	[thread overview]
Message-ID: <4C5D9896.4010407@bsd.lv> (raw)
In-Reply-To: <20100807155941.GG23289@iris.usta.de>

[-- Attachment #1: Type: text/plain, Size: 656 bytes --]

> The rules are:
> 
> 1. Either a space or a tab delimit the initial macro on a line.
>    If the delimiter is a tab, that tab is lost.
> 
>    Examples:
>    .Fl<space>Fl       ->  Fl() Fl()  ->  "--"
>    .Fl<tab>Fl         ->  Fl() Fl()  ->  "--"
>    .Fl<tab><space>Fl  ->  Fl() Fl()  ->  "--"
> 
>    In this respect, there is a bug in mandoc.
>    A tab character does not delimit the initial macro on a line,
>    but .Fl<tab> gives you:
>    ERROR: bad character  <-- that's the tab
>    ERROR: unknown macro will be lost: unknown macro: Fl<tab>

Ingo,

Does the enclosed patch solve this behaviour?  I've enclosed a handy 
test as well.

Kristaps

[-- Attachment #2: patch.txt --]
[-- Type: text/plain, Size: 2258 bytes --]

? .foo.1.swp
? config.h
? config.log
? foo.1
? foo.1.html
? foo.1.pdf
? foo.1.ps
? foo.3
? foo.pdf
? mandoc
? mdoc.7.ps.gz
? patch.txt
? regress/mandoc.core
? regress/output
Index: TODO
===================================================================
RCS file: /usr/vhosts/mdocml.bsd.lv/cvs/mdocml/TODO,v
retrieving revision 1.35
diff -u -r1.35 TODO
--- TODO	27 Jul 2010 08:46:30 -0000	1.35
+++ TODO	7 Aug 2010 17:30:07 -0000
@@ -63,6 +63,9 @@
 - prohibit `Nm' from having non-text HEAD children
   (e.g., NetBSD mDNSShared/dns-sd.1)
   (mdoc_html.c and mdoc_term.c `Nm' handlers can be slightly simplified)
+
+- allow `Qq', `Dq', `Sq', `Aq', `Bq' to have 0 arguments
+  noted by Alex Kozlov 08/06/10 23:05
   
 ************************************************************************
 * formatting issues: ugly output
Index: mdoc.c
===================================================================
RCS file: /usr/vhosts/mdocml.bsd.lv/cvs/mdocml/mdoc.c,v
retrieving revision 1.159
diff -u -r1.159 mdoc.c
--- mdoc.c	18 Jul 2010 17:00:26 -0000	1.159
+++ mdoc.c	7 Aug 2010 17:30:07 -0000
@@ -764,11 +764,11 @@
 
 	i = offs;
 
-	/* Accept whitespace after the initial control char. */
+	/* Accept tabs/whitespace after the initial control char. */
 
-	if (' ' == buf[i]) {
+	if (' ' == buf[i] || '\t' == buf[i]) {
 		i++;
-		while (buf[i] && ' ' == buf[i])
+		while (buf[i] && (' ' == buf[i] || '\t' == buf[i]))
 			i++;
 		if ('\0' == buf[i])
 			return(1);
@@ -776,15 +776,19 @@
 
 	sv = i;
 
-	/* Copy the first word into a nil-terminated buffer. */
+	/* 
+	 * Copy the first word into a nil-terminated buffer.  Stop
+	 * copying when a tab, space, or eoln is encountered.
+	 */
 
 	for (j = 0; j < 4; j++, i++) {
 		if ('\0' == (mac[j] = buf[i]))
 			break;
-		else if (' ' == buf[i])
+		else if (' ' == buf[i] || '\t' == buf[i])
 			break;
 
 		/* Check for invalid characters. */
+		/* TODO: remove me, already done in main.c. */
 
 		if (isgraph((u_char)buf[i]))
 			continue;
@@ -807,7 +811,12 @@
 		return(1);
 	}
 
-	/* The macro is sane.  Jump to the next word. */
+	/* Disregard the first trailing tab, if applicable. */
+
+	if ('\t' == buf[i])
+		i++;
+
+	/* Jump to the next non-whitespace word. */
 
 	while (buf[i] && ' ' == buf[i])
 		i++;

[-- Attachment #3: foo.1 --]
[-- Type: text/plain, Size: 326 bytes --]

.Dd $Mdocdate$
.Dt FOO 1
.Os
.Sh NAME
.Nm foo
.Nd bar
.Sh SYNOPSIS
.In header.h
.Vt extern const char *global;
.Ft "char *"
.Fn foo "const char *src"
.Ft "char *"
.Fn bar "const char *src"
.Sh DESCRIPTION
.	\r	Fl Fl
.Pp
.	 	Fl Fl
.Pp
.	Fl Fl
.Pp
.Fl		Fl
.Pp
.Fl	Fl
.Pp
.Fl Fl
.Pp
.Fl	 Fl
.Pp
.Fl 	Fl
.Pp
.Fl	 	Fl
.Pp
.Op Fl	Fl

  reply	other threads:[~2010-08-07 17:32 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-08-06  7:06 Jason McIntyre
2010-08-06 17:08 ` Kristaps Dzonsons
2010-08-06 17:52   ` Jason McIntyre
2010-08-06 18:13     ` Kristaps Dzonsons
2010-08-06 18:23       ` Jason McIntyre
2010-08-06 18:35         ` Kristaps Dzonsons
2010-08-07 16:15         ` Ingo Schwarze
2010-08-07 15:59     ` Ingo Schwarze
2010-08-07 17:32       ` Kristaps Dzonsons [this message]
2010-08-07 18:03         ` Ingo Schwarze

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=4C5D9896.4010407@bsd.lv \
    --to=kristaps@bsd.lv \
    --cc=discuss@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).