[prev in list] [next in list] [prev in thread] [next in thread]
List: mandoc-source
Subject: mdocml: Parse the section number from the content of preformatted pages
From: schwarze () mdocml ! bsd ! lv
Date: 2017-01-27 1:15:17
Message-ID: 2388801088330474631.enqueue () fantadrom ! bsd ! lv
[Download RAW message or body]
Log Message:
-----------
Parse the section number from the content of preformatted pages
and warn if it doesn't match the directory where the file was found.
Modified Files:
--------------
mdocml:
TODO
mandocdb.c
Revision Data
-------------
Index: TODO
===================================================================
RCS file: /home/cvs/mdocml/mdocml/TODO,v
retrieving revision 1.226
retrieving revision 1.227
diff -LTODO -LTODO -u -p -r1.226 -r1.227
--- TODO
+++ TODO
@@ -259,11 +259,6 @@ are mere guesses, and some may be wrong.
even for apropos title line output; req by bapt@
loc * exist * algo * size * imp ***
-- makewhatis(8) for preformatted pages:
- parse the section number from the header line
- and compare to the section number from the directory name
- loc * exist * algo * size * imp **
-
- Does makewhatis(8) detect missing NAME sections, missing names,
and missing descriptions in all the file formats?
loc * exist * algo * size * imp ***
Index: mandocdb.c
===================================================================
RCS file: /home/cvs/mdocml/mdocml/mandocdb.c,v
retrieving revision 1.240
retrieving revision 1.241
diff -Lmandocdb.c -Lmandocdb.c -u -p -r1.240 -r1.241
--- mandocdb.c
+++ mandocdb.c
@@ -1254,29 +1254,48 @@ static void
parse_cat(struct mpage *mpage, int fd)
{
FILE *stream;
- char *line, *p, *title;
+ struct mlink *mlink;
+ char *line, *p, *title, *sec;
size_t linesz, plen, titlesz;
ssize_t len;
int offs;
- stream = (-1 == fd) ?
- fopen(mpage->mlinks->file, "r") :
- fdopen(fd, "r");
- if (NULL == stream) {
- if (-1 != fd)
+ mlink = mpage->mlinks;
+ stream = fd == -1 ? fopen(mlink->file, "r") : fdopen(fd, "r");
+ if (stream == NULL) {
+ if (fd != -1)
close(fd);
if (warnings)
- say(mpage->mlinks->file, "&fopen");
+ say(mlink->file, "&fopen");
return;
}
line = NULL;
linesz = 0;
- /* Skip to first blank line. */
+ /* Parse the section number from the header line. */
- while (getline(&line, &linesz, stream) != -1)
+ while (getline(&line, &linesz, stream) != -1) {
if (*line == '\n')
+ continue;
+ if ((sec = strchr(line, '(')) == NULL)
+ break;
+ if ((p = strchr(++sec, ')')) == NULL)
+ break;
+ free(mpage->sec);
+ mpage->sec = mandoc_strndup(sec, p - sec);
+ if (warnings && *mlink->dsec != '\0' &&
+ strcasecmp(mpage->sec, mlink->dsec))
+ say(mlink->file,
+ "Section \"%s\" manual in %s directory",
+ mpage->sec, mlink->dsec);
+ break;
+ }
+
+ /* Skip to first blank line. */
+
+ while (line == NULL || *line != '\n')
+ if (getline(&line, &linesz, stream) == -1)
break;
/*
@@ -1322,8 +1341,7 @@ parse_cat(struct mpage *mpage, int fd)
if (NULL == title || '\0' == *title) {
if (warnings)
- say(mpage->mlinks->file,
- "Cannot find NAME section");
+ say(mlink->file, "Cannot find NAME section");
fclose(stream);
free(title);
return;
@@ -1342,8 +1360,7 @@ parse_cat(struct mpage *mpage, int fd)
/* Skip to next word. */ ;
} else {
if (warnings)
- say(mpage->mlinks->file,
- "No dash in title line");
+ say(mlink->file, "No dash in title line");
p = title;
}
--
To unsubscribe send an email to source+unsubscribe@mdocml.bsd.lv
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic