diff options
author | 2019-07-27 13:40:42 +0000 | |
---|---|---|
committer | 2019-07-27 13:40:42 +0000 | |
commit | 6181cd3477c2945e6fbd94f3eb723fc248ac79ff (patch) | |
tree | fb89f50a2bfc62d4750008ec1b92d7420ea07080 | |
parent | Make target numbers match the NVMe namespace identifiers. This fixes booting (diff) | |
download | wireguard-openbsd-6181cd3477c2945e6fbd94f3eb723fc248ac79ff.tar.xz wireguard-openbsd-6181cd3477c2945e6fbd94f3eb723fc248ac79ff.zip |
Move two more output state variables into the new struct outstate.
Also, move setting of tag_files.tagname into tag_init().
No functional change.
-rw-r--r-- | usr.bin/mandoc/main.c | 49 | ||||
-rw-r--r-- | usr.bin/mandoc/tag.c | 6 | ||||
-rw-r--r-- | usr.bin/mandoc/tag.h | 6 |
3 files changed, 29 insertions, 32 deletions
diff --git a/usr.bin/mandoc/main.c b/usr.bin/mandoc/main.c index 483005edfd0..8919de3c4aa 100644 --- a/usr.bin/mandoc/main.c +++ b/usr.bin/mandoc/main.c @@ -1,4 +1,4 @@ -/* $OpenBSD: main.c,v 1.238 2019/07/26 23:12:02 schwarze Exp $ */ +/* $OpenBSD: main.c,v 1.239 2019/07/27 13:40:42 schwarze Exp $ */ /* * Copyright (c) 2008-2012 Kristaps Dzonsons <kristaps@bsd.lv> * Copyright (c) 2010-2012, 2014-2019 Ingo Schwarze <schwarze@openbsd.org> @@ -78,7 +78,9 @@ enum outt { }; struct outstate { + struct tag_files *tag_files; /* Tagging state variables. */ void *outdata; /* data for output */ + int use_pager; int wstop; /* stop after a file with a warning */ enum outt outtype; /* which output to use */ }; @@ -117,7 +119,6 @@ main(int argc, char *argv[]) struct mansearch search; /* Search options. */ struct manpage *res, *resp; /* Search results. */ struct mparse *mp; /* Opaque parser object. */ - struct tag_files *tag_files; /* Tagging state variables. */ const char *conf_file; /* -C: alternate config file. */ const char *os_s; /* -I: Operating system for display. */ const char *progname, *sec, *thisarg; @@ -130,7 +131,6 @@ main(int argc, char *argv[]) size_t i, ssz; int options; /* Parser options. */ int show_usage; /* Invalid argument: give up. */ - int use_pager; /* According to command line. */ int prio, best_prio; int fd, startdir; int c; @@ -178,10 +178,10 @@ main(int argc, char *argv[]) /* Formatter options. */ memset(&outst, 0, sizeof(outst)); + outst.tag_files = NULL; outst.outtype = OUTT_LOCALE; + outst.use_pager = 1; - use_pager = 1; - tag_files = NULL; show_usage = 0; outmode = OUTMODE_DEF; @@ -199,14 +199,14 @@ main(int argc, char *argv[]) conf_file = optarg; break; case 'c': - use_pager = 0; + outst.use_pager = 0; break; case 'f': search.argmode = ARG_WORD; break; case 'h': conf.output.synopsisonly = 1; - use_pager = 0; + outst.use_pager = 0; outmode = OUTMODE_ALL; break; case 'I': @@ -307,7 +307,7 @@ main(int argc, char *argv[]) switch (search.argmode) { case ARG_FILE: outmode = OUTMODE_ALL; - use_pager = 0; + outst.use_pager = 0; break; case ARG_NAME: outmode = OUTMODE_ONE; @@ -336,9 +336,9 @@ main(int argc, char *argv[]) if (outmode == OUTMODE_FLN || outmode == OUTMODE_LST || !isatty(STDOUT_FILENO)) - use_pager = 0; + outst.use_pager = 0; - if (use_pager && + if (outst.use_pager && (conf.output.width == 0 || conf.output.indent == 0) && ioctl(STDOUT_FILENO, TIOCGWINSZ, &ws) != -1 && ws.ws_col > 1) { @@ -348,7 +348,7 @@ main(int argc, char *argv[]) conf.output.indent = 3; } - if (use_pager == 0) { + if (outst.use_pager == 0) { if (pledge("stdio rpath", NULL) == -1) { mandoc_msg(MANDOCERR_PLEDGE, 0, 0, "%s", strerror(errno)); @@ -511,7 +511,7 @@ main(int argc, char *argv[]) /* mandoc(1) */ - if (use_pager) { + if (outst.use_pager) { if (pledge("stdio rpath tmppath tty proc exec", NULL) == -1) { mandoc_msg(MANDOCERR_PLEDGE, 0, 0, "%s", strerror(errno)); @@ -536,11 +536,8 @@ main(int argc, char *argv[]) mp = mparse_alloc(options, os_e, os_s); if (argc < 1) { - if (use_pager) { - tag_files = tag_init(); - if (tag_files != NULL) - tag_files->tagname = conf.output.tag; - } + if (outst.use_pager) + outst.tag_files = tag_init(conf.output.tag); thisarg = "<stdin>"; mandoc_msg_setinfilename(thisarg); parse(mp, STDIN_FILENO, thisarg, &outst, &conf.output); @@ -575,11 +572,9 @@ main(int argc, char *argv[]) mandoc_msg_setinfilename(thisarg); fd = mparse_open(mp, thisarg); if (fd != -1) { - if (use_pager) { - use_pager = 0; - tag_files = tag_init(); - if (tag_files != NULL) - tag_files->tagname = conf.output.tag; + if (outst.use_pager) { + outst.use_pager = 0; + outst.tag_files = tag_init(conf.output.tag); } if (resp == NULL || resp->form == FORM_SRC) @@ -588,12 +583,12 @@ main(int argc, char *argv[]) passthrough(fd, conf.output.synopsisonly); if (ferror(stdout)) { - if (tag_files != NULL) { + if (outst.tag_files != NULL) { mandoc_msg(MANDOCERR_WRITE, 0, 0, - "%s: %s", tag_files->ofn, + "%s: %s", outst.tag_files->ofn, strerror(errno)); tag_unlink(); - tag_files = NULL; + outst.tag_files = NULL; } else mandoc_msg(MANDOCERR_WRITE, 0, 0, "%s", strerror(errno)); @@ -654,10 +649,10 @@ out: mansearch_free(res, sz); } - if (tag_files != NULL) { + if (outst.tag_files != NULL) { fclose(stdout); tag_write(); - run_pager(tag_files); + run_pager(outst.tag_files); tag_unlink(); } else if (outst.outtype != OUTT_LINT && (search.argmode == ARG_FILE || sz > 0)) diff --git a/usr.bin/mandoc/tag.c b/usr.bin/mandoc/tag.c index 2d70e52db9d..31caad35c2e 100644 --- a/usr.bin/mandoc/tag.c +++ b/usr.bin/mandoc/tag.c @@ -1,4 +1,4 @@ -/* $OpenBSD: tag.c,v 1.24 2019/07/22 03:20:55 schwarze Exp $ */ +/* $OpenBSD: tag.c,v 1.25 2019/07/27 13:40:42 schwarze Exp $ */ /* * Copyright (c) 2015, 2016, 2018, 2019 Ingo Schwarze <schwarze@openbsd.org> * @@ -51,7 +51,7 @@ static struct tag_files tag_files; * but for simplicity, create it anyway. */ struct tag_files * -tag_init(void) +tag_init(char *tagname) { struct sigaction sa; int ofd; @@ -59,6 +59,7 @@ tag_init(void) ofd = -1; tag_files.tfd = -1; tag_files.tcpgid = -1; + tag_files.tagname = tagname; /* Clean up when dying from a signal. */ @@ -127,6 +128,7 @@ fail: *tag_files.tfn = '\0'; tag_files.ofd = -1; tag_files.tfd = -1; + tag_files.tagname = NULL; return NULL; } diff --git a/usr.bin/mandoc/tag.h b/usr.bin/mandoc/tag.h index b5bfe0f370d..7b94760b41c 100644 --- a/usr.bin/mandoc/tag.h +++ b/usr.bin/mandoc/tag.h @@ -1,6 +1,6 @@ -/* $OpenBSD: tag.h,v 1.8 2018/11/22 11:30:15 schwarze Exp $ */ +/* $OpenBSD: tag.h,v 1.9 2019/07/27 13:40:42 schwarze Exp $ */ /* - * Copyright (c) 2015 Ingo Schwarze <schwarze@openbsd.org> + * Copyright (c) 2015, 2018, 2019 Ingo Schwarze <schwarze@openbsd.org> * * Permission to use, copy, modify, and distribute this software for any * purpose with or without fee is hereby granted, provided that the above @@ -26,7 +26,7 @@ struct tag_files { }; -struct tag_files *tag_init(void); +struct tag_files *tag_init(char *); void tag_put(const char *, int, size_t); void tag_write(void); void tag_unlink(void); |