From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from localhost (fantadrom.bsd.lv [local]); by fantadrom.bsd.lv (OpenSMTPD) with ESMTPA id c651b5c8; for ; Mon, 20 Jul 2015 22:26:52 -0500 (EST) Date: Mon, 20 Jul 2015 22:26:52 -0500 (EST) Message-Id: <15282013172814263609.enqueue@fantadrom.bsd.lv> X-Mailinglist: mdocml-source Reply-To: source@mdocml.bsd.lv MIME-Version: 1.0 From: schwarze@mdocml.bsd.lv To: source@mdocml.bsd.lv Subject: mdocml: When creation of the temporary tags file fails, call the pager X-Mailer: activitymail 1.26, http://search.cpan.org/dist/activitymail/ Content-Type: text/plain; charset=utf-8 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