source@mandoc.bsd.lv
 help / color / mirror / Atom feed
* mdocml: Add a warning "new sentence, new line".
@ 2017-01-28 23:30 schwarze
  0 siblings, 0 replies; only message in thread
From: schwarze @ 2017-01-28 23:30 UTC (permalink / raw)
  To: source

Log Message:
-----------
Add a warning "new sentence, new line".
This does not attempt to pinpoint each and every offender, but
instead tries very hard to avoid false positives: Currently, there
are only two false positives in the whole OpenBSD base system.
Only do this in mdoc(7), not in man(7), because manuals written
in man(7) typically have much worse problems than this.
OK jmc@ on a previous version of the patch

Modified Files:
--------------
    mdocml:
        mandoc.1
        mandoc.h
        mdoc.c
        read.c

Revision Data
-------------
Index: read.c
===================================================================
RCS file: /home/cvs/mdocml/mdocml/read.c,v
retrieving revision 1.157
retrieving revision 1.158
diff -Lread.c -Lread.c -u -p -r1.157 -r1.158
--- read.c
+++ read.c
@@ -177,6 +177,7 @@ static	const char * const	mandocerrs[MAN
 	"blank line in fill mode, using .sp",
 	"tab in filled text",
 	"whitespace at end of input line",
+	"new sentence, new line",
 	"bad comment style",
 	"invalid escape sequence",
 	"undefined string, using \"\"",
Index: mandoc.1
===================================================================
RCS file: /home/cvs/mdocml/mdocml/mandoc.1,v
retrieving revision 1.171
retrieving revision 1.172
diff -Lmandoc.1 -Lmandoc.1 -u -p -r1.171 -r1.172
--- mandoc.1
+++ mandoc.1
@@ -1357,6 +1357,10 @@ it is hard to predict which tab stop pos
 Whitespace at the end of input lines is almost never semantically
 significant \(em but in the odd case where it might be, it is
 extremely confusing when reviewing and maintaining documents.
+.It Sy "new sentence, new line"
+.Pq mdoc
+A new sentence starts in the middle of a text line.
+Start it on a new input line to help formatters produce correct spacing.
 .It Sy "bad comment style"
 .Pq roff
 Comment lines start with a dot, a backslash, and a double-quote character.
Index: mdoc.c
===================================================================
RCS file: /home/cvs/mdocml/mdocml/mdoc.c,v
retrieving revision 1.258
retrieving revision 1.259
diff -Lmdoc.c -Lmdoc.c -u -p -r1.258 -r1.259
--- mdoc.c
+++ mdoc.c
@@ -1,7 +1,7 @@
 /*	$Id$ */
 /*
  * Copyright (c) 2008, 2009, 2010, 2011 Kristaps Dzonsons <kristaps@bsd.lv>
- * Copyright (c) 2010, 2012-2016 Ingo Schwarze <schwarze@openbsd.org>
+ * Copyright (c) 2010, 2012-2017 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
@@ -312,6 +312,22 @@ mdoc_ptext(struct roff_man *mdoc, int li
 
 	if (mandoc_eos(buf+offs, (size_t)(end-buf-offs)))
 		mdoc->last->flags |= NODE_EOS;
+
+	for (c = buf + offs; c != NULL; c = strchr(c + 1, '.')) {
+		if (c - buf < offs + 2)
+			continue;
+		if (end - c < 4)
+			break;
+		if (isalpha((unsigned char)c[-2]) &&
+		    isalpha((unsigned char)c[-1]) &&
+		    c[1] == ' ' &&
+		    isupper((unsigned char)(c[2] == ' ' ? c[3] : c[2])) &&
+		    (c[-2] != 'n' || c[-1] != 'c') &&
+		    (c[-2] != 'v' || c[-1] != 's'))
+			mandoc_msg(MANDOCERR_EOS, mdoc->parse,
+			    line, (int)(c - buf), NULL);
+	}
+
 	return 1;
 }
 
Index: mandoc.h
===================================================================
RCS file: /home/cvs/mdocml/mdocml/mandoc.h,v
retrieving revision 1.213
retrieving revision 1.214
diff -Lmandoc.h -Lmandoc.h -u -p -r1.213 -r1.214
--- mandoc.h
+++ mandoc.h
@@ -134,6 +134,7 @@ enum	mandocerr {
 	MANDOCERR_FI_BLANK, /* blank line in fill mode, using .sp */
 	MANDOCERR_FI_TAB, /* tab in filled text */
 	MANDOCERR_SPACE_EOL, /* whitespace at end of input line */
+	MANDOCERR_EOS, /* new sentence, new line */
 	MANDOCERR_COMMENT_BAD, /* bad comment style */
 	MANDOCERR_ESC_BAD, /* invalid escape sequence: esc */
 	MANDOCERR_STR_UNDEF, /* undefined string, using "": name */
--
 To unsubscribe send an email to source+unsubscribe@mdocml.bsd.lv

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

only message in thread, other threads:[~2017-01-28 23:30 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-01-28 23:30 mdocml: Add a warning "new sentence, new line" schwarze

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).