From: schwarze@mandoc.bsd.lv
To: source@mandoc.bsd.lv
Subject: mandoc: fix the section number in the <title> element for preformatted
Date: Thu, 19 Aug 2021 10:24:07 -0500 (EST) [thread overview]
Message-ID: <c2aa956fc0f121d2@mandoc.bsd.lv> (raw)
Log Message:
-----------
fix the section number in the <title> element for preformatted pages;
minibug reported by Ian <Ropers at gmail dot com> on misc@
Modified Files:
--------------
mandoc:
cgi.c
Revision Data
-------------
Index: cgi.c
===================================================================
RCS file: /home/cvs/mandoc/mandoc/cgi.c,v
retrieving revision 1.174
retrieving revision 1.175
diff -Lcgi.c -Lcgi.c -u -p -r1.174 -r1.175
--- cgi.c
+++ cgi.c
@@ -1,6 +1,6 @@
/* $Id$ */
/*
- * Copyright (c) 2014-2019 Ingo Schwarze <schwarze@usta.de>
+ * Copyright (c) 2014-2019, 2021 Ingo Schwarze <schwarze@usta.de>
* Copyright (c) 2011, 2012 Kristaps Dzonsons <kristaps@bsd.lv>
*
* Permission to use, copy, modify, and distribute this software for any
@@ -370,7 +370,8 @@ resp_copy(const char *filename)
static void
resp_begin_html(int code, const char *msg, const char *file)
{
- char *cp;
+ const char *name, *sec, *cp;
+ int namesz, secsz;
resp_begin_http(code, msg);
@@ -385,12 +386,27 @@ resp_begin_html(int code, const char *ms
" <title>",
CSS_DIR);
if (file != NULL) {
- if ((cp = strrchr(file, '/')) != NULL)
- file = cp + 1;
- if ((cp = strrchr(file, '.')) != NULL) {
- printf("%.*s(%s) - ", (int)(cp - file), file, cp + 1);
- } else
- printf("%s - ", file);
+ cp = strrchr(file, '/');
+ name = cp == NULL ? file : cp + 1;
+ cp = strrchr(name, '.');
+ namesz = cp == NULL ? strlen(name) : cp - name;
+ sec = NULL;
+ if (cp != NULL && cp[1] != '0') {
+ sec = cp + 1;
+ secsz = strlen(sec);
+ } else if (name - file > 1) {
+ for (cp = name - 2; cp >= file; cp--) {
+ if (*cp < '1' || *cp > '9')
+ continue;
+ sec = cp;
+ secsz = name - cp - 1;
+ break;
+ }
+ }
+ printf("%.*s", namesz, name);
+ if (sec != NULL)
+ printf("(%.*s)", secsz, sec);
+ fputs(" - ", stdout);
}
printf("%s</title>\n"
"</head>\n"
--
To unsubscribe send an email to source+unsubscribe@mandoc.bsd.lv
reply other threads:[~2021-08-19 15:24 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=c2aa956fc0f121d2@mandoc.bsd.lv \
--to=schwarze@mandoc.bsd.lv \
--cc=source@mandoc.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).