* mdocml: Update mandoc_hyph() to the extent that numbers on either side
@ 2011-07-27 7:06 kristaps
0 siblings, 0 replies; only message in thread
From: kristaps @ 2011-07-27 7:06 UTC (permalink / raw)
To: source
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
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2011-07-27 7:06 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-07-27 7:06 mdocml: Update mandoc_hyph() to the extent that numbers on either side kristaps
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).