diff options
author | Ingo Schwarze <schwarze@cvs.openbsd.org> | 2019-07-19 21:45:38 +0000 |
---|---|---|
committer | Ingo Schwarze <schwarze@cvs.openbsd.org> | 2019-07-19 21:45:38 +0000 |
commit | c0372fde0b397e99fcec7411a1b3eb06107d6636 (patch) | |
tree | 7ee0b895bd8fcf63b7199e153cdffe28ad0e8f83 /usr.bin | |
parent | ca0a3b146c65d803a350dbc118a64a32da66e812 (diff) |
#define a handful of constant strings to reduce the diff to -portable;
now, the diff is about -30 +150 lines (about 0.4%)
Diffstat (limited to 'usr.bin')
-rw-r--r-- | usr.bin/mandoc/main.c | 22 | ||||
-rw-r--r-- | usr.bin/mandoc/term_ascii.c | 6 |
2 files changed, 18 insertions, 10 deletions
diff --git a/usr.bin/mandoc/main.c b/usr.bin/mandoc/main.c index d9ee40e70a6..6be715c1c86 100644 --- a/usr.bin/mandoc/main.c +++ b/usr.bin/mandoc/main.c @@ -1,4 +1,4 @@ -/* $OpenBSD: main.c,v 1.234 2019/07/19 20:25:21 schwarze Exp $ */ +/* $OpenBSD: main.c,v 1.235 2019/07/19 21:45:37 schwarze Exp $ */ /* * Copyright (c) 2008-2012 Kristaps Dzonsons <kristaps@bsd.lv> * Copyright (c) 2010-2012, 2014-2019 Ingo Schwarze <schwarze@openbsd.org> @@ -50,6 +50,12 @@ #include "manconf.h" #include "mansearch.h" +#define BINM_APROPOS "apropos" +#define BINM_MAN "man" +#define BINM_MAKEWHATIS "makewhatis" +#define BINM_WHATIS "whatis" +#define OSENUM MANDOC_OS_OPENBSD + enum outmode { OUTMODE_DEF = 0, OUTMODE_FLN, @@ -131,7 +137,7 @@ main(int argc, char *argv[]) progname = getprogname(); mandoc_msg_setoutfile(stderr); if (strncmp(progname, "mandocdb", 8) == 0 || - strncmp(progname, "makewhatis", 10) == 0) + strcmp(progname, BINM_MAKEWHATIS) == 0) return mandocdb(argc, argv); if (pledge("stdio rpath tmppath tty proc exec", NULL) == -1) { @@ -149,11 +155,11 @@ main(int argc, char *argv[]) search.outkey = "Nd"; oarg = NULL; - if (strcmp(progname, "man") == 0) + if (strcmp(progname, BINM_MAN) == 0) search.argmode = ARG_NAME; - else if (strncmp(progname, "apropos", 7) == 0) + else if (strcmp(progname, BINM_APROPOS) == 0) search.argmode = ARG_EXPR; - else if (strncmp(progname, "whatis", 6) == 0) + else if (strcmp(progname, BINM_WHATIS) == 0) search.argmode = ARG_WORD; else if (strncmp(progname, "help", 4) == 0) search.argmode = ARG_NAME; @@ -792,8 +798,8 @@ fs_lookup(const struct manpaths *paths, size_t ipath, return globres; found: - warnx("outdated mandoc.db lacks %s(%s) entry, run makewhatis %s", - name, sec, paths->paths[ipath]); + warnx("outdated mandoc.db lacks %s(%s) entry, run %s %s", + name, sec, BINM_MAKEWHATIS, paths->paths[ipath]); if (res == NULL) { free(file); return 0; @@ -841,7 +847,7 @@ fs_search(const struct mansearch *cfg, const struct manpaths *paths, if (res != NULL && *ressz == lastsz && strchr(*argv, '/') == NULL) { if (cfg->arch != NULL && - arch_valid(cfg->arch, MANDOC_OS_OPENBSD) == 0) + arch_valid(cfg->arch, OSENUM) == 0) warnx("Unknown architecture \"%s\".", cfg->arch); else if (cfg->sec == NULL) diff --git a/usr.bin/mandoc/term_ascii.c b/usr.bin/mandoc/term_ascii.c index b2cc0e84f4c..9b280608319 100644 --- a/usr.bin/mandoc/term_ascii.c +++ b/usr.bin/mandoc/term_ascii.c @@ -1,4 +1,4 @@ -/* $OpenBSD: term_ascii.c,v 1.49 2018/11/28 14:23:02 schwarze Exp $ */ +/* $OpenBSD: term_ascii.c,v 1.50 2019/07/19 21:45:37 schwarze Exp $ */ /* * Copyright (c) 2010, 2011 Kristaps Dzonsons <kristaps@bsd.lv> * Copyright (c) 2014, 2015, 2017, 2018 Ingo Schwarze <schwarze@openbsd.org> @@ -34,6 +34,8 @@ #include "manconf.h" #include "main.h" +#define UTF8_LOCALE "en_US.UTF-8" + static struct termp *ascii_init(enum termenc, const struct manoutput *); static int ascii_hspan(const struct termp *, const struct roffsu *); @@ -90,7 +92,7 @@ ascii_init(enum termenc enc, const struct manoutput *outopts) v = enc == TERMENC_LOCALE ? setlocale(LC_CTYPE, "") : - setlocale(LC_CTYPE, "en_US.UTF-8"); + setlocale(LC_CTYPE, UTF8_LOCALE); /* * We only support UTF-8, |