Commit a1f8d4ff authored by Barton E. Schaefer's avatar Barton E. Schaefer

35826: add getsparam_u() to return unmetafied string, use it for a number of...

35826: add getsparam_u() to return unmetafied string, use it for a number of references to non-special params
parent 045bd4e3
2015-07-22 Barton E. Schaefer <schaefer@zsh.org> 2015-07-22 Barton E. Schaefer <schaefer@zsh.org>
* 35826: Src/Modules/newuser.c, Src/Modules/zftp.c,
Src/Zle/complist.c, Src/Zle/zle_misc.c, Src/init.c, Src/params.c,
Src/utils.c, Src/watch.c: add getsparam_u() to return unmetafied
string, use it for a number of references to non-special params
* 35823: Functions/Zle/narrow-to-region: fix handling of MARK * 35823: Functions/Zle/narrow-to-region: fix handling of MARK
and CURSOR, clean up documentary comment and CURSOR, clean up documentary comment
......
...@@ -67,7 +67,7 @@ check_dotfile(const char *dotdir, const char *fname) ...@@ -67,7 +67,7 @@ check_dotfile(const char *dotdir, const char *fname)
int int
boot_(UNUSED(Module m)) boot_(UNUSED(Module m))
{ {
const char *dotdir = getsparam("ZDOTDIR"); const char *dotdir = getsparam_u("ZDOTDIR");
const char *spaths[] = { const char *spaths[] = {
#ifdef SITESCRIPT_DIR #ifdef SITESCRIPT_DIR
SITESCRIPT_DIR, SITESCRIPT_DIR,
......
...@@ -731,7 +731,7 @@ zfgetmsg(void) ...@@ -731,7 +731,7 @@ zfgetmsg(void)
stopit = (*ptr++ != '-'); stopit = (*ptr++ != '-');
queue_signals(); queue_signals();
if (!(verbose = getsparam("ZFTP_VERBOSE"))) if (!(verbose = getsparam_u("ZFTP_VERBOSE")))
verbose = ""; verbose = "";
if (strchr(verbose, lastcodestr[0])) { if (strchr(verbose, lastcodestr[0])) {
/* print the whole thing verbatim */ /* print the whole thing verbatim */
...@@ -1785,7 +1785,7 @@ zftp_open(char *name, char **args, int flags) ...@@ -1785,7 +1785,7 @@ zftp_open(char *name, char **args, int flags)
char *hname; char *hname;
alarm(0); alarm(0);
queue_signals(); queue_signals();
if ((hname = getsparam("ZFTP_HOST")) && *hname) if ((hname = getsparam_u("ZFTP_HOST")) && *hname)
zwarnnam(name, "timeout connecting to %s", hname); zwarnnam(name, "timeout connecting to %s", hname);
else else
zwarnnam(name, "timeout on host name lookup"); zwarnnam(name, "timeout on host name lookup");
...@@ -3077,7 +3077,7 @@ bin_zftp(char *name, char **args, UNUSED(Options ops), UNUSED(int func)) ...@@ -3077,7 +3077,7 @@ bin_zftp(char *name, char **args, UNUSED(Options ops), UNUSED(int func))
} }
queue_signals(); queue_signals();
if ((prefs = getsparam("ZFTP_PREFS"))) { if ((prefs = getsparam_u("ZFTP_PREFS"))) {
zfprefs = 0; zfprefs = 0;
for (ptr = prefs; *ptr; ptr++) { for (ptr = prefs; *ptr; ptr++) {
switch (toupper(STOUC(*ptr))) { switch (toupper(STOUC(*ptr))) {
......
...@@ -507,8 +507,8 @@ getcols() ...@@ -507,8 +507,8 @@ getcols()
max_caplen = lr_caplen = 0; max_caplen = lr_caplen = 0;
mcolors.flags = 0; mcolors.flags = 0;
queue_signals(); queue_signals();
if (!(s = getsparam("ZLS_COLORS")) && if (!(s = getsparam_u("ZLS_COLORS")) &&
!(s = getsparam("ZLS_COLOURS"))) { !(s = getsparam_u("ZLS_COLOURS"))) {
for (i = 0; i < NUM_COLS; i++) for (i = 0; i < NUM_COLS; i++)
mcolors.files[i] = filecol(""); mcolors.files[i] = filecol("");
mcolors.pats = NULL; mcolors.pats = NULL;
......
...@@ -1552,13 +1552,13 @@ makesuffix(int n) ...@@ -1552,13 +1552,13 @@ makesuffix(int n)
{ {
char *suffixchars; char *suffixchars;
if (!(suffixchars = getsparam("ZLE_REMOVE_SUFFIX_CHARS"))) if (!(suffixchars = getsparam_u("ZLE_REMOVE_SUFFIX_CHARS")))
suffixchars = " \t\n;&|"; suffixchars = " \t\n;&|";
addsuffixstring(SUFTYP_POSSTR, 0, suffixchars, n); addsuffixstring(SUFTYP_POSSTR, 0, suffixchars, n);
/* Do this second so it takes precedence */ /* Do this second so it takes precedence */
if ((suffixchars = getsparam("ZLE_SPACE_SUFFIX_CHARS")) && *suffixchars) if ((suffixchars = getsparam_u("ZLE_SPACE_SUFFIX_CHARS")) && *suffixchars)
addsuffixstring(SUFTYP_POSSTR, SUFFLAGS_SPACE, suffixchars, n); addsuffixstring(SUFTYP_POSSTR, SUFFLAGS_SPACE, suffixchars, n);
suffixlen = n; suffixlen = n;
......
...@@ -1426,7 +1426,7 @@ sourcehome(char *s) ...@@ -1426,7 +1426,7 @@ sourcehome(char *s)
char *h; char *h;
queue_signals(); queue_signals();
if (EMULATION(EMULATE_SH|EMULATE_KSH) || !(h = getsparam("ZDOTDIR"))) { if (EMULATION(EMULATE_SH|EMULATE_KSH) || !(h = getsparam_u("ZDOTDIR"))) {
h = home; h = home;
if (!h) if (!h)
return; return;
......
...@@ -2639,6 +2639,15 @@ getsparam(char *s) ...@@ -2639,6 +2639,15 @@ getsparam(char *s)
return getstrvalue(v); return getstrvalue(v);
} }
/**/
mod_export char *
getsparam_u(char *s)
{
if ((s = getsparam(s)))
return unmetafy(s, NULL);
return s;
}
/* Retrieve an array parameter */ /* Retrieve an array parameter */
/**/ /**/
...@@ -3971,7 +3980,7 @@ setlang(char *x) ...@@ -3971,7 +3980,7 @@ setlang(char *x)
struct localename *ln; struct localename *ln;
char *x2; char *x2;
if ((x2 = getsparam("LC_ALL")) && *x2) if ((x2 = getsparam_u("LC_ALL")) && *x2)
return; return;
/* /*
...@@ -3985,10 +3994,10 @@ setlang(char *x) ...@@ -3985,10 +3994,10 @@ setlang(char *x)
* from this is meaningless. So just all $LANG to show through in * from this is meaningless. So just all $LANG to show through in
* that case. * that case.
*/ */
setlocale(LC_ALL, x ? x : ""); setlocale(LC_ALL, x ? unmeta(x) : "");
queue_signals(); queue_signals();
for (ln = lc_names; ln->name; ln++) for (ln = lc_names; ln->name; ln++)
if ((x = getsparam(ln->name)) && *x) if ((x = getsparam_u(ln->name)) && *x)
setlocale(ln->category, x); setlocale(ln->category, x);
unqueue_signals(); unqueue_signals();
} }
...@@ -4004,7 +4013,7 @@ lc_allsetfn(Param pm, char *x) ...@@ -4004,7 +4013,7 @@ lc_allsetfn(Param pm, char *x)
* that with any LC_* that are set. * that with any LC_* that are set.
*/ */
if (!x || !*x) { if (!x || !*x) {
x = getsparam("LANG"); x = getsparam_u("LANG");
if (x && *x) { if (x && *x) {
queue_signals(); queue_signals();
setlang(x); setlang(x);
...@@ -4012,7 +4021,7 @@ lc_allsetfn(Param pm, char *x) ...@@ -4012,7 +4021,7 @@ lc_allsetfn(Param pm, char *x)
} }
} }
else else
setlocale(LC_ALL, x); setlocale(LC_ALL, unmeta(x));
} }
/**/ /**/
...@@ -4020,7 +4029,7 @@ void ...@@ -4020,7 +4029,7 @@ void
langsetfn(Param pm, char *x) langsetfn(Param pm, char *x)
{ {
strsetfn(pm, x); strsetfn(pm, x);
setlang(x); setlang(unmeta(x));
} }
/**/ /**/
...@@ -4046,7 +4055,7 @@ lcsetfn(Param pm, char *x) ...@@ -4046,7 +4055,7 @@ lcsetfn(Param pm, char *x)
if (x && *x) { if (x && *x) {
for (ln = lc_names; ln->name; ln++) for (ln = lc_names; ln->name; ln++)
if (!strcmp(ln->name, pm->node.nam)) if (!strcmp(ln->name, pm->node.nam))
setlocale(ln->category, x); setlocale(ln->category, unmeta(x));
} }
unqueue_signals(); unqueue_signals();
} }
......
...@@ -248,7 +248,7 @@ VA_DCL ...@@ -248,7 +248,7 @@ VA_DCL
VA_START(ap, message); VA_START(ap, message);
VA_GET_ARG(ap, message, const char *); VA_GET_ARG(ap, message, const char *);
if ((filename = getsparam("ZSH_DEBUG_LOG")) != NULL && if ((filename = getsparam_u("ZSH_DEBUG_LOG")) != NULL &&
(file = fopen(filename, "a")) != NULL) { (file = fopen(filename, "a")) != NULL) {
zerrmsg(file, message, ap); zerrmsg(file, message, ap);
fclose(file); fclose(file);
...@@ -1949,7 +1949,8 @@ extern char *_mktemp(char *); ...@@ -1949,7 +1949,8 @@ extern char *_mktemp(char *);
/* Get a unique filename for use as a temporary file. If "prefix" is /* Get a unique filename for use as a temporary file. If "prefix" is
* NULL, the name is relative to $TMPPREFIX; If it is non-NULL, the * NULL, the name is relative to $TMPPREFIX; If it is non-NULL, the
* unique suffix includes a prefixed '.' for improved readability. If * unique suffix includes a prefixed '.' for improved readability. If
* "use_heap" is true, we allocate the returned name on the heap. */ * "use_heap" is true, we allocate the returned name on the heap.
* The string passed as "prefix" is expected to be metafied. */
/**/ /**/
mod_export char * mod_export char *
...@@ -1976,6 +1977,9 @@ gettempname(const char *prefix, int use_heap) ...@@ -1976,6 +1977,9 @@ gettempname(const char *prefix, int use_heap)
return ret; return ret;
} }
/* The gettempfile() "prefix" is expected to be metafied, see hist.c
* and gettempname(). */
/**/ /**/
mod_export int mod_export int
gettempfile(const char *prefix, int use_heap, char **tempname) gettempfile(const char *prefix, int use_heap, char **tempname)
...@@ -3585,7 +3589,7 @@ zbeep(void) ...@@ -3585,7 +3589,7 @@ zbeep(void)
{ {
char *vb; char *vb;
queue_signals(); queue_signals();
if ((vb = getsparam("ZBEEP"))) { if ((vb = getsparam_u("ZBEEP"))) {
int len; int len;
vb = getkeystring(vb, &len, GETKEYS_BINDKEY, NULL); vb = getkeystring(vb, &len, GETKEYS_BINDKEY, NULL);
write_loop(SHTTY, vb, len); write_loop(SHTTY, vb, len);
......
...@@ -566,7 +566,7 @@ dowatch(void) ...@@ -566,7 +566,7 @@ dowatch(void)
return; return;
} }
queue_signals(); queue_signals();
if (!(fmt = getsparam("WATCHFMT"))) if (!(fmt = getsparam_u("WATCHFMT")))
fmt = DEFAULT_WATCHFMT; fmt = DEFAULT_WATCHFMT;
while ((uct || wct) && !errflag) while ((uct || wct) && !errflag)
if (!uct || (wct && ucmp(uptr, wptr) > 0)) if (!uct || (wct && ucmp(uptr, wptr) > 0))
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment