From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from krisdoz.my.domain (kristaps@localhost [127.0.0.1]) by krisdoz.my.domain (8.14.3/8.14.3) with ESMTP id p6R76TDV032433 for ; Wed, 27 Jul 2011 03:06:30 -0400 (EDT) Received: (from kristaps@localhost) by krisdoz.my.domain (8.14.3/8.14.3/Submit) id p6R76TTj014313; Wed, 27 Jul 2011 03:06:29 -0400 (EDT) Date: Wed, 27 Jul 2011 03:06:29 -0400 (EDT) Message-Id: <201107270706.p6R76TTj014313@krisdoz.my.domain> X-Mailinglist: mdocml-source Reply-To: source@mdocml.bsd.lv MIME-Version: 1.0 From: kristaps@mdocml.bsd.lv To: source@mdocml.bsd.lv Subject: mdocml: Update mandoc_hyph() to the extent that numbers on either side X-Mailer: activitymail 1.26, http://search.cpan.org/dist/activitymail/ Content-Type: text/plain; charset=utf-8 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