1
0
Fork 0
mirror of git://git.code.sf.net/p/zsh/code synced 2025-10-29 17:31:02 +01:00

23436: consistency with null strings in local variables

unposted: Phil Pennock: POSIX RE's are extended
This commit is contained in:
Peter Stephenson 2007-05-13 20:18:28 +00:00
parent 68c2c8f11a
commit 599a7fd7a7
3 changed files with 45 additions and 11 deletions

View file

@ -1,5 +1,11 @@
2007-05-13 Peter Stephenson <p.w.stephenson@ntlworld.com>
* Phil Pennoc: unposted: Doc/Zsh/cond.yo: should document
POSIX regular expressions as extended, not basic.
* 23436: Src/params.c: handle empty strings for locale
variables more consistently.
* 23434: Completion/Unix/Command/_configure: use also
for config.status.

View file

@ -114,7 +114,7 @@ true if var(string) matches the regular expression
var(regexp). If the option tt(RE_MATCH_PCRE) is set
var(regexp) is tested as a PCRE regular expression using
the tt(zsh/pcre) module, else it is tested as a POSIX
regular expression using the tt(zsh/regex) module.
extended regular expression using the tt(zsh/regex) module.
If the option tt(BASH_REMATCH) is set the array
tt(BASH_REMATCH) is set to the substring that matched the pattern
followed by the substrings that matched parenthesised

View file

@ -3414,10 +3414,21 @@ setlang(char *x)
{
struct localename *ln;
/*
* Set the global locale to the value passed, but override
* this with any non-empty definitions for specific
* categories.
*
* We only use non-empty definitions because empty values aren't
* valid as locales; when passed to setlocale() they mean "use the
* environment variable", but if that's what we're setting the value
* from this is meaningless. So just all $LANG to show through in
* that case.
*/
setlocale(LC_ALL, x ? x : "");
queue_signals();
for (ln = lc_names; ln->name; ln++)
if ((x = getsparam(ln->name)))
if ((x = getsparam(ln->name)) && *x)
setlocale(ln->category, x);
unqueue_signals();
}
@ -3427,11 +3438,19 @@ void
lc_allsetfn(Param pm, char *x)
{
strsetfn(pm, x);
if (!x) {
/*
* Treat an empty LC_ALL the same as an unset one,
* namely by using LANG as the default locale but overriding
* that with any LC_* that are set.
*/
if (!x || !*x) {
x = getsparam("LANG");
if (x && *x) {
queue_signals();
setlang(getsparam("LANG"));
setlang(x);
unqueue_signals();
}
}
else
setlocale(LC_ALL, x);
}
@ -3448,18 +3467,27 @@ langsetfn(Param pm, char *x)
void
lcsetfn(Param pm, char *x)
{
char *x2;
struct localename *ln;
strsetfn(pm, x);
if (getsparam("LC_ALL"))
if ((x2 = getsparam("LC_ALL")) && *x)
return;
queue_signals();
if (!x)
/* Treat empty LC_* the same as unset. */
if (!x || !*x)
x = getsparam("LANG");
/*
* If we've got no non-empty string at this
* point (after checking $LANG, too),
* we shouldn't bother setting anything.
*/
if (x && *x) {
for (ln = lc_names; ln->name; ln++)
if (!strcmp(ln->name, pm->node.nam))
setlocale(ln->category, x ? x : "");
setlocale(ln->category, x);
}
unqueue_signals();
}
#endif /* USE_LOCALE */