From: schwarze@mdocml.bsd.lv
To: source@mdocml.bsd.lv
Subject: mdocml: backport man(7) .Nd improvement
Date: Sun, 23 Mar 2014 08:37:59 -0400 (EDT) [thread overview]
Message-ID: <201403231237.s2NCbweO015476@krisdoz.my.domain> (raw)
Log Message:
-----------
backport man(7) .Nd improvement
Tags:
----
VERSION_1_12
Modified Files:
--------------
mdocml:
mandocdb.c
Revision Data
-------------
Index: mandocdb.c
===================================================================
RCS file: /usr/vhosts/mdocml.bsd.lv/cvs/mdocml/mandocdb.c,v
retrieving revision 1.49.2.14
retrieving revision 1.49.2.15
diff -Lmandocdb.c -Lmandocdb.c -u -p -r1.49.2.14 -r1.49.2.15
--- mandocdb.c
+++ mandocdb.c
@@ -1383,8 +1383,8 @@ static int
pman_node(MAN_ARGS)
{
const struct man_node *head, *body;
- char *start, *sv, *title;
- size_t sz, titlesz;
+ char *start, *title;
+ size_t sz;
if (NULL == n)
return(0);
@@ -1404,57 +1404,19 @@ pman_node(MAN_ARGS)
NULL != (head = (head->child)) &&
MAN_TEXT == head->type &&
0 == strcmp(head->string, "NAME") &&
- NULL != (body = body->child) &&
- MAN_TEXT == body->type) {
+ NULL != body->child) {
- title = NULL;
- titlesz = 0;
/*
* Suck the entire NAME section into memory.
* Yes, we might run away.
* But too many manuals have big, spread-out
* NAME sections over many lines.
*/
- for ( ; NULL != body; body = body->next) {
- if (MAN_TEXT != body->type)
- break;
- if (0 == (sz = strlen(body->string)))
- continue;
- title = mandoc_realloc
- (title, titlesz + sz + 1);
- memcpy(title + titlesz, body->string, sz);
- titlesz += sz + 1;
- title[(int)titlesz - 1] = ' ';
- }
- if (NULL == title)
- return(0);
- title = mandoc_realloc(title, titlesz + 1);
- title[(int)titlesz] = '\0';
-
- /* Skip leading space. */
-
- sv = title;
- while (isspace((unsigned char)*sv))
- sv++;
-
- if (0 == (sz = strlen(sv))) {
- free(title);
- return(0);
- }
-
- /* Erase trailing space. */
-
- start = &sv[sz - 1];
- while (start > sv && isspace((unsigned char)*start))
- *start-- = '\0';
-
- if (start == sv) {
- free(title);
+ title = NULL;
+ man_deroff(&title, body);
+ if (NULL == title)
return(0);
- }
-
- start = sv;
/*
* Go through a special heuristic dance here.
@@ -1466,6 +1428,7 @@ pman_node(MAN_ARGS)
* the name parts here.
*/
+ start = title;
for ( ;; ) {
sz = strcspn(start, " ,");
if ('\0' == start[(int)sz])
@@ -1490,7 +1453,7 @@ pman_node(MAN_ARGS)
buf->len = 0;
- if (sv == start) {
+ if (start == title) {
buf_append(buf, start);
free(title);
return(1);
--
To unsubscribe send an email to source+unsubscribe@mdocml.bsd.lv
reply other threads:[~2014-03-23 12:37 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=201403231237.s2NCbweO015476@krisdoz.my.domain \
--to=schwarze@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).