* mdocml: When creation of the temporary tags file fails, call the pager
@ 2015-07-21 3:26 schwarze
0 siblings, 0 replies; only message in thread
From: schwarze @ 2015-07-21 3:26 UTC (permalink / raw)
To: source
Log Message:
-----------
When creation of the temporary tags file fails, call the pager
without the -T option, because otherwise the pager won't even start.
Fixing a bug reported by jca@.
While here, shorten the code by two lines
and delete one internal interface function.
Modified Files:
--------------
mdocml:
main.c
tag.c
tag.h
Revision Data
-------------
Index: tag.h
===================================================================
RCS file: /home/cvs/mdocml/mdocml/tag.h,v
retrieving revision 1.1
retrieving revision 1.2
diff -Ltag.h -Ltag.h -u -p -r1.1 -r1.2
--- tag.h
+++ tag.h
@@ -17,8 +17,7 @@
__BEGIN_DECLS
-void tag_init(void);
-char *tag_filename(void);
+char *tag_init(void);
size_t tag_get(const char *, size_t);
void tag_put(const char *, size_t, size_t);
void tag_write(void);
Index: tag.c
===================================================================
RCS file: /home/cvs/mdocml/mdocml/tag.c,v
retrieving revision 1.2
retrieving revision 1.3
diff -Ltag.c -Ltag.c -u -p -r1.2 -r1.3
--- tag.c
+++ tag.c
@@ -52,7 +52,7 @@ static int tag_fd = -1;
* where various marked-up terms are documented and create
* the temporary tags file, saving the name for the pager.
*/
-void
+char *
tag_init(void)
{
struct ohash_info tag_info;
@@ -64,7 +64,7 @@ tag_init(void)
if ((tag_fd = mkstemp(tag_fn)) == -1) {
free(tag_fn);
tag_fn = NULL;
- return;
+ return(NULL);
}
tag_info.alloc = tag_alloc;
@@ -73,12 +73,6 @@ tag_init(void)
tag_info.key_offset = offsetof(struct tag_entry, s);
tag_info.data = NULL;
ohash_init(&tag_data, 4, &tag_info);
-}
-
-char *
-tag_filename(void)
-{
-
return(tag_fn);
}
Index: main.c
===================================================================
RCS file: /home/cvs/mdocml/mdocml/main.c,v
retrieving revision 1.242
retrieving revision 1.243
diff -Lmain.c -Lmain.c -u -p -r1.242 -r1.243
--- main.c
+++ main.c
@@ -993,15 +993,18 @@ spawn_pager(void)
/* Read all text right away and use the tag file. */
- if ((cmdlen = strlen(argv[0])) >= 4) {
+ for (;;) {
+ if ((cmdlen = strlen(argv[0])) < 4)
+ break;
cp = argv[0] + cmdlen - 4;
- if (strcmp(cp, "less") == 0 ||
- strcmp(cp, "more") == 0) {
- tag_init();
- argv[argc++] = mandoc_strdup("+G1G");
- argv[argc++] = mandoc_strdup("-T");
- argv[argc++] = tag_filename();
- }
+ if (strcmp(cp, "less") && strcmp(cp, "more"))
+ break;
+ if ((cp = tag_init()) == NULL)
+ break;
+ argv[argc++] = mandoc_strdup("+G1G");
+ argv[argc++] = mandoc_strdup("-T");
+ argv[argc++] = cp;
+ break;
}
argv[argc] = NULL;
--
To unsubscribe send an email to source+unsubscribe@mdocml.bsd.lv
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2015-07-21 3:26 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-07-21 3:26 mdocml: When creation of the temporary tags file fails, call the pager schwarze
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).