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.5/8.14.5) with ESMTP id s32Mau3X000699 for ; Wed, 2 Apr 2014 18:36:56 -0400 (EDT) Received: (from kristaps@localhost) by krisdoz.my.domain (8.14.5/8.14.3/Submit) id s32MauRd014239; Wed, 2 Apr 2014 18:36:56 -0400 (EDT) Date: Wed, 2 Apr 2014 18:36:56 -0400 (EDT) Message-Id: <201404022236.s32MauRd014239@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: pod2mdoc: Clean up the link handler to omit the title. X-Mailer: activitymail 1.26, http://search.cpan.org/dist/activitymail/ Content-Type: text/plain; charset=utf-8 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