source@mandoc.bsd.lv
 help / color / mirror / Atom feed
From: kristaps@mdocml.bsd.lv
To: source@mdocml.bsd.lv
Subject: pod2mdoc: Clean up the link handler to omit the title.
Date: Wed, 2 Apr 2014 18:36:56 -0400 (EDT)	[thread overview]
Message-ID: <201404022236.s32MauRd014239@krisdoz.my.domain> (raw)

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

                 reply	other threads:[~2014-04-02 22:36 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=201404022236.s32MauRd014239@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).