From: Richard Russon Date: Wed, 10 Jan 2018 16:25:31 +0000 (+0000) Subject: use mutt_str_getenv() X-Git-Tag: neomutt-20180223~43^2 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=6e8286c57fbf4336be3b1cf7eff45888d5010607;p=neomutt use mutt_str_getenv() --- diff --git a/conn/ssl.c b/conn/ssl.c index 0f0bdacf1..05fcb0463 100644 --- a/conn/ssl.c +++ b/conn/ssl.c @@ -609,7 +609,7 @@ static int ssl_init(void) /* load entropy from egd sockets */ #ifdef HAVE_RAND_EGD - add_entropy(getenv("EGDSOCKET")); + add_entropy(mutt_str_getenv("EGDSOCKET")); snprintf(path, sizeof(path), "%s/.entropy", NONULL(HomeDir)); add_entropy(path); add_entropy("/tmp/entropy"); diff --git a/curs_main.c b/curs_main.c index 4655a1d6b..94cee9f6c 100644 --- a/curs_main.c +++ b/curs_main.c @@ -525,7 +525,7 @@ static int main_change_folder(struct Menu *menu, int op, char *buf, */ bool mutt_ts_capability(void) { - char *term = getenv("TERM"); + const char *term = mutt_str_getenv("TERM"); char *tcaps = NULL; #ifdef HAVE_USE_EXTENDED_NAMES int tcapi; diff --git a/handler.c b/handler.c index fa0655995..4c15aa302 100644 --- a/handler.c +++ b/handler.c @@ -926,16 +926,18 @@ static int text_enriched_handler(struct Body *a, struct State *s) */ static int is_mmnoask(const char *buf) { - char tmp[LONG_STRING], *p = NULL, *q = NULL; + char *p = NULL; + const char *val = NULL; + char tmp[LONG_STRING], *q = NULL; int lng; - p = getenv("MM_NOASK"); - if (p && *p) + val = mutt_str_getenv("MM_NOASK"); + if (val) { - if (mutt_str_strcmp(p, "1") == 0) + if (mutt_str_strcmp(val, "1") == 0) return 1; - mutt_str_strfcpy(tmp, p, sizeof(tmp)); + mutt_str_strfcpy(tmp, val, sizeof(tmp)); p = tmp; while ((p = strtok(p, ",")) != NULL) diff --git a/init.c b/init.c index 59892ecc4..a32ec4419 100644 --- a/init.c +++ b/init.c @@ -703,7 +703,7 @@ int mutt_extract_token(struct Buffer *dest, struct Buffer *tok, int flags) } if (var) { - if ((env = getenv(var)) || (env = myvar_get(var))) + if ((env = mutt_str_getenv(var)) || (env = myvar_get(var))) mutt_buffer_addstr(dest, env); else if ((idx = mutt_option_index(var)) != -1) { @@ -3867,7 +3867,8 @@ void mutt_init(int skip_sys_rc, struct ListHead *commands) { struct passwd *pw = NULL; struct utsname utsname; - char *p, buffer[STRING]; + const char *p = NULL; + char buffer[STRING]; int need_pause = 0; struct Buffer err; @@ -3890,7 +3891,7 @@ void mutt_init(int skip_sys_rc, struct ListHead *commands) /* on one of the systems I use, getcwd() does not return the same prefix as is listed in the passwd file */ - p = getenv("HOME"); + p = mutt_str_getenv("HOME"); if (p) HomeDir = mutt_str_strdup(p); @@ -3916,7 +3917,7 @@ void mutt_init(int skip_sys_rc, struct ListHead *commands) fputs(_("unable to determine home directory"), stderr); exit(1); } - p = getenv("USER"); + p = mutt_str_getenv("USER"); if (p) Username = mutt_str_strdup(p); else @@ -3925,7 +3926,7 @@ void mutt_init(int skip_sys_rc, struct ListHead *commands) fputs(_("unable to determine username"), stderr); exit(1); } - Shell = mutt_str_strdup((p = getenv("SHELL")) ? p : "/bin/sh"); + Shell = mutt_str_strdup((p = mutt_str_getenv("SHELL")) ? p : "/bin/sh"); } /* Start up debugging mode if requested from cmdline */ @@ -3996,7 +3997,7 @@ void mutt_init(int skip_sys_rc, struct ListHead *commands) #endif #ifdef USE_NNTP - p = getenv("NNTPSERVER"); + p = mutt_str_getenv("NNTPSERVER"); if (p) { FREE(&NewsServer); @@ -4009,10 +4010,10 @@ void mutt_init(int skip_sys_rc, struct ListHead *commands) } #endif - p = getenv("MAIL"); + p = mutt_str_getenv("MAIL"); if (p) SpoolFile = mutt_str_strdup(p); - else if ((p = getenv("MAILDIR"))) + else if ((p = mutt_str_getenv("MAILDIR"))) SpoolFile = mutt_str_strdup(p); else { @@ -4024,7 +4025,7 @@ void mutt_init(int skip_sys_rc, struct ListHead *commands) SpoolFile = mutt_str_strdup(buffer); } - p = getenv("MAILCAPS"); + p = mutt_str_getenv("MAILCAPS"); if (p) MailcapPath = mutt_str_strdup(p); else @@ -4035,19 +4036,19 @@ void mutt_init(int skip_sys_rc, struct ListHead *commands) "/mailcap:/etc/mailcap:/usr/etc/mailcap:/usr/local/etc/mailcap"); } - Tmpdir = mutt_str_strdup((p = getenv("TMPDIR")) ? p : "/tmp"); + Tmpdir = mutt_str_strdup((p = mutt_str_getenv("TMPDIR")) ? p : "/tmp"); - p = getenv("VISUAL"); + p = mutt_str_getenv("VISUAL"); if (!p) { - p = getenv("EDITOR"); + p = mutt_str_getenv("EDITOR"); if (!p) p = "vi"; } Editor = mutt_str_strdup(p); Visual = mutt_str_strdup(p); - p = getenv("REPLYTO"); + p = mutt_str_getenv("REPLYTO"); if (p) { struct Buffer buf, token; @@ -4063,7 +4064,7 @@ void mutt_init(int skip_sys_rc, struct ListHead *commands) FREE(&token.data); } - p = getenv("EMAIL"); + p = mutt_str_getenv("EMAIL"); if (p) From = mutt_addr_parse_list(NULL, p); @@ -4083,8 +4084,8 @@ void mutt_init(int skip_sys_rc, struct ListHead *commands) #ifndef LOCALES_HACK /* Do we have a locale definition? */ - if (((p = getenv("LC_ALL")) != NULL && p[0]) || ((p = getenv("LANG")) != NULL && p[0]) || - ((p = getenv("LC_CTYPE")) != NULL && p[0])) + if (((p = mutt_str_getenv("LC_ALL")) != NULL && p[0]) || ((p = mutt_str_getenv("LANG")) != NULL && p[0]) || + ((p = mutt_str_getenv("LC_CTYPE")) != NULL && p[0])) { OPT_LOCALES = true; } @@ -4115,7 +4116,7 @@ void mutt_init(int skip_sys_rc, struct ListHead *commands) if (STAILQ_EMPTY(&Muttrc)) { - char *xdg_cfg_home = getenv("XDG_CONFIG_HOME"); + const char *xdg_cfg_home = mutt_str_getenv("XDG_CONFIG_HOME"); if (!xdg_cfg_home && HomeDir) { diff --git a/main.c b/main.c index fa247d118..75edd4f81 100644 --- a/main.c +++ b/main.c @@ -219,8 +219,8 @@ int main(int argc, char **argv, char **env) #ifdef ENABLE_NLS /* FIXME what about the LOCALES_HACK in mutt_init() [init.c] ? */ { - char *domdir = getenv("TEXTDOMAINDIR"); - if (domdir && domdir[0]) + const char *domdir = mutt_str_getenv("TEXTDOMAINDIR"); + if (domdir) bindtextdomain(PACKAGE, domdir); else bindtextdomain(PACKAGE, MUTTLOCALEDIR); diff --git a/muttlib.c b/muttlib.c index 38a00f6c0..8207aba76 100644 --- a/muttlib.c +++ b/muttlib.c @@ -1419,7 +1419,7 @@ void mutt_encode_path(char *dest, size_t dlen, const char *src) */ int mutt_set_xdg_path(enum XdgType type, char *buf, size_t bufsize) { - char *xdg_env = getenv(xdg_env_vars[type]); + const char *xdg_env = mutt_str_getenv(xdg_env_vars[type]); char *xdg = (xdg_env && *xdg_env) ? mutt_str_strdup(xdg_env) : mutt_str_strdup(xdg_defaults[type]); char *x = xdg; /* strsep() changes xdg, so free x instead later */ diff --git a/pgppubring.c b/pgppubring.c index d29a6a23c..1abb3645a 100644 --- a/pgppubring.c +++ b/pgppubring.c @@ -842,7 +842,8 @@ int main(int argc, char *const argv[]) short secring = 0; const char *tmp_kring = NULL; - char *env_pgppath = NULL, *env_home = NULL; + const char *env_pgppath = NULL; + const char *env_home = NULL; char pgppath[_POSIX_PATH_MAX]; char kring[_POSIX_PATH_MAX]; @@ -896,10 +897,10 @@ int main(int argc, char *const argv[]) mutt_str_strfcpy(kring, tmp_kring, sizeof(kring)); else { - env_pgppath = getenv("PGPPATH"); + env_pgppath = mutt_str_getenv("PGPPATH"); if (env_pgppath) mutt_str_strfcpy(pgppath, env_pgppath, sizeof(pgppath)); - else if ((env_home = getenv("HOME"))) + else if ((env_home = mutt_str_getenv("HOME"))) snprintf(pgppath, sizeof(pgppath), "%s/.pgp", env_home); else { diff --git a/resize.c b/resize.c index 633554ffc..8b6e86cc3 100644 --- a/resize.c +++ b/resize.c @@ -40,7 +40,7 @@ */ void mutt_resize_screen(void) { - char *cp = NULL; + const char *cp = NULL; int fd; struct winsize w; #ifdef HAVE_RESIZETERM @@ -61,13 +61,13 @@ void mutt_resize_screen(void) } if (SLtt_Screen_Rows <= 0) { - cp = getenv("LINES"); + cp = mutt_str_getenv("LINES"); if (cp && (mutt_str_atoi(cp, &SLtt_Screen_Rows) < 0)) SLtt_Screen_Rows = 24; } if (SLtt_Screen_Cols <= 0) { - cp = getenv("COLUMNS"); + cp = mutt_str_getenv("COLUMNS"); if (cp && (mutt_str_atoi(cp, &SLtt_Screen_Cols) < 0)) SLtt_Screen_Cols = 80; }