source@mandoc.bsd.lv
 help / color / mirror / Atom feed
From: kristaps@mdocml.bsd.lv
To: source@mdocml.bsd.lv
Subject: mdocml: Update mandoc_hyph() to the extent that numbers on either side
Date: Wed, 27 Jul 2011 03:06:29 -0400 (EDT)	[thread overview]
Message-ID: <201107270706.p6R76TTj014313@krisdoz.my.domain> (raw)

Log Message:
-----------
Update mandoc_hyph() to the extent that numbers on either side of the
hyphen make for a non-breakable hyphen.  Found by random testing.

Modified Files:
--------------
    mdocml:
        mandoc.c

Revision Data
-------------
Index: mandoc.c
===================================================================
RCS file: /usr/vhosts/mdocml.bsd.lv/cvs/mdocml/mandoc.c,v
retrieving revision 1.56
retrieving revision 1.57
diff -Lmandoc.c -Lmandoc.c -u -p -r1.56 -r1.57
--- mandoc.c
+++ mandoc.c
@@ -653,28 +653,39 @@ mandoc_eos(const char *p, size_t sz, int
 	return(found && !enclosed);
 }
 
+/*
+ * Choose whether to break at a hyphenated character (identified by the
+ * ASCII_HYPH value in the input string).
+ */
 int
 mandoc_hyph(const char *start, const char *c)
 {
+	char		l, r;
 
-	/*
-	 * Choose whether to break at a hyphenated character.  We only
-	 * do this if it's free-standing within a word.
-	 */
+	l = *(c - 1);
+	r = *(c + 1);
 
 	/* Skip first/last character of buffer. */
-	if (c == start || '\0' == *(c + 1))
+	if (c == start || '\0' == r)
 		return(0);
+
+	/* Skip a number on either side of the hyphen. */
+	if (isdigit((unsigned char)r) || isdigit((unsigned char)l))
+		return(0);
+
 	/* Skip first/last character of word. */
-	if ('\t' == *(c + 1) || '\t' == *(c - 1))
+	if ('\t' == r || '\t' == l)
 		return(0);
-	if (' ' == *(c + 1) || ' ' == *(c - 1))
+
+	if (' ' == r || ' ' == l)
 		return(0);
+
 	/* Skip double invocations. */
-	if ('-' == *(c + 1) || '-' == *(c - 1))
+	if ('-' == r || '-' == l)
 		return(0);
+
 	/* Skip escapes. */
-	if ('\\' == *(c - 1))
+	if ('\\' == l)
 		return(0);
 
 	return(1);
--
 To unsubscribe send an email to source+unsubscribe@mdocml.bsd.lv

                 reply	other threads:[~2011-07-27  7:06 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=201107270706.p6R76TTj014313@krisdoz.my.domain \
    --to=kristaps@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).