* Re: Considerably tidy mandocdb(8) catman descriptions...
[not found] <201112090121.pB91LAiY016331@krisdoz.my.domain>
@ 2011-12-09 1:55 ` Ingo Schwarze
2011-12-09 11:10 ` Kristaps Dzonsons
0 siblings, 1 reply; 2+ messages in thread
From: Ingo Schwarze @ 2011-12-09 1:55 UTC (permalink / raw)
To: tech
Hi Kristaps,
i have merged your latest improvements to pformatted() up to the
one i'm replying to with some tweaks:
* Remove trailing whitespace.
* No need to check (len > 0) after successful fgetln(3), see the manual.
* Make a few comments a bit clearer.
* If the first section is empty, use the file name as .Nd.
* Talk about the first dash in the comment, too, not only in the code.
OK?
Ingo
--- /co/mdocml/mandocdb.c Fri Dec 9 02:31:41 2011
+++ ./mandocdb.c Fri Dec 9 02:47:11 2011
@@ -1288,29 +1276,30 @@ pformatted(DB *hash, struct buf *buf, struct buf *dbuf
buf_append(buf, of->title);
hash_put(hash, buf, TYPE_Nm);
- /* Skip to first blank line. */
+ /* Skip to first blank line. */
while (NULL != (line = fgetln(stream, &len)))
- if (len && '\n' == *line)
+ if ('\n' == *line)
break;
- /*
- * Skip to first section header.
- * This happens when text is flush-left.
+ /*
+ * Assume the first line that is not indented
+ * is the first section header. Skip to it.
*/
while (NULL != (line = fgetln(stream, &len)))
- if (len && '\n' != *line && ' ' != *line)
+ if ('\n' != *line && ' ' != *line)
break;
/*
- * If no page content can be found or the input line is
- * malformed (zer-length or has no trailing newline), reuse the
- * page title as the page description.
+ * If no page content can be found, or the input line
+ * is already the next section header, or there is no
+ * trailing newline, reuse the page title as the page
+ * description.
*/
line = fgetln(stream, &len);
- if (NULL == line || len == 0 || '\n' != line[(int)len - 1]) {
+ if (NULL == line || ' ' != *line || '\n' != line[(int)len - 1]) {
buf_appendb(dbuf, buf->cp, buf->size);
hash_put(hash, buf, TYPE_Nd);
fclose(stream);
@@ -1319,8 +1308,8 @@ pformatted(DB *hash, struct buf *buf, struct buf *dbuf
line[(int)--len] = '\0';
- /*
- * Skip to the last dash.
+ /*
+ * Skip to the first dash.
* Use the remaining line as the description (no more than 70
* bytes).
*/
--
To unsubscribe send an email to tech+unsubscribe@mdocml.bsd.lv
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: Considerably tidy mandocdb(8) catman descriptions...
2011-12-09 1:55 ` Considerably tidy mandocdb(8) catman descriptions Ingo Schwarze
@ 2011-12-09 11:10 ` Kristaps Dzonsons
0 siblings, 0 replies; 2+ messages in thread
From: Kristaps Dzonsons @ 2011-12-09 11:10 UTC (permalink / raw)
To: tech
On 09/12/2011 02:55, Ingo Schwarze wrote:
> Hi Kristaps,
>
> i have merged your latest improvements to pformatted() up to the
> one i'm replying to with some tweaks:
>
> * Remove trailing whitespace.
> * No need to check (len> 0) after successful fgetln(3), see the manual.
> * Make a few comments a bit clearer.
> * If the first section is empty, use the file name as .Nd.
> * Talk about the first dash in the comment, too, not only in the code.
>
> OK?
Ingo, looks good and Ok Kristaps. Thanks!
--
To unsubscribe send an email to tech+unsubscribe@mdocml.bsd.lv
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2011-12-09 11:10 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
[not found] <201112090121.pB91LAiY016331@krisdoz.my.domain>
2011-12-09 1:55 ` Considerably tidy mandocdb(8) catman descriptions Ingo Schwarze
2011-12-09 11:10 ` Kristaps Dzonsons
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).