* pod2mdoc: Clean up the link handler to omit the title.
@ 2014-04-02 22:36 kristaps
0 siblings, 0 replies; only message in thread
From: kristaps @ 2014-04-02 22:36 UTC (permalink / raw)
To: source
Log Message:
-----------
Clean up the link handler to omit the title.
This really cleans up SSL's links (Xr) and also sets the stage for the
generalised Xr/Lk/Sx handling.
Modified Files:
--------------
pod2mdoc:
pod2mdoc.c
Revision Data
-------------
Index: pod2mdoc.c
===================================================================
RCS file: /usr/vhosts/mdocml.bsd.lv/cvs/pod2mdoc/pod2mdoc.c,v
retrieving revision 1.17
retrieving revision 1.18
diff -Lpod2mdoc.c -Lpod2mdoc.c -u -p -r1.17 -r1.18
--- pod2mdoc.c
+++ pod2mdoc.c
@@ -179,21 +179,16 @@ formatescape(const char *buf, size_t *st
static int
trylink(const char *buf, size_t *start, size_t end, size_t dsz)
{
- size_t sv, nstart, nend, i, j;
- int hasdouble;
+ size_t sv, nstart, nend, i, j, textsz;
+ const char *text;
+ int hasdouble;
/*
* Scan to the start of the terminus.
* This function is more or less replicated in the formatcode()
* for null or index formatting codes.
*/
- hasdouble = 0;
for (sv = nstart = *start; nstart < end; nstart++) {
- /* Do we have a double-colon? */
- if (':' == buf[nstart] &&
- nstart > sv &&
- ':' == buf[nstart - 1])
- hasdouble = 1;
if ('>' != buf[nstart])
continue;
else if (dsz == 1)
@@ -201,8 +196,7 @@ trylink(const char *buf, size_t *start,
assert(nstart > 0);
if (' ' != buf[nstart - 1])
continue;
- i = nstart;
- for (j = 0; i < end && j < dsz; j++)
+ for (i = nstart, j = 0; i < end && j < dsz; j++)
if ('>' != buf[i++])
break;
if (dsz == j)
@@ -217,6 +211,25 @@ trylink(const char *buf, size_t *start,
nend = nstart;
if (dsz > 1)
nend--;
+
+ /* Re-scan to see if we have a title. */
+ text = &buf[*start];
+ for (textsz = *start; textsz < nend; textsz++)
+ if ('|' == buf[textsz])
+ break;
+
+ if (textsz < nend) {
+ sv = textsz + 1;
+ textsz = textsz - *start;
+ } else
+ textsz = 0;
+
+ /* Now see if we're a Perl manual. */
+ for (hasdouble = 0, i = sv + 1; i < end; i++)
+ if (':' == buf[i] && ':' == buf[i - 1]) {
+ hasdouble = 1;
+ break;
+ }
/*
* Provide for some common invocations of the link primitive.
--
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:[~2014-04-02 22:36 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-04-02 22:36 pod2mdoc: Clean up the link handler to omit the title 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).