Update of /cvsroot/tmux/tmux
In directory sfp-cvsdas-2.v30.ch3.sourceforge.com:/tmp/cvs-serv8122
Modified Files:
cmd-string.c
Log Message:
Read ${X} environment variables in strings and $HOME from the global
environment rather than getenv, this allows them to be updated during
the configuration file.
Index: cmd-string.c
===================================================================
RCS file: /cvsroot/tmux/tmux/cmd-string.c,v
retrieving revision 1.31
retrieving revision 1.32
diff -u -d -r1.31 -r1.32
--- cmd-string.c 26 Feb 2010 13:27:38 -0000 1.31
+++ cmd-string.c 13 Dec 2010 22:53:56 -0000 1.32
@@ -247,9 +247,10 @@
char *
cmd_string_variable(const char *s, size_t *p)
{
- int ch, fch;
- char *buf, *t;
- size_t len;
+ int ch, fch;
+ char *buf, *t;
+ size_t len;
+ struct environ_entry *envent;
#define cmd_string_first(ch) ((ch) == '_' || \
((ch) >= 'a' && (ch) <= 'z') || ((ch) >= 'A' && (ch) <= 'Z'))
@@ -301,12 +302,11 @@
buf = xrealloc(buf, 1, len + 1);
buf[len] = '\0';
- if ((t = getenv(buf)) == NULL) {
- xfree(buf);
- return (xstrdup(""));
- }
+ envent = environ_find(&global_environ, buf);
xfree(buf);
- return (xstrdup(t));
+ if (envent == NULL)
+ return (xstrdup(""));
+ return (xstrdup(envent->value));
error:
if (buf != NULL)
@@ -317,15 +317,17 @@
char *
cmd_string_expand_tilde(const char *s, size_t *p)
{
- struct passwd *pw;
- char *home, *path, *username;
+ struct passwd *pw;
+ struct environ_entry *envent;
+ char *home, *path, *username;
home = NULL;
if (cmd_string_getc(s, p) == '/') {
- if ((home = getenv("HOME")) == NULL || *home == '\0') {
- if ((pw = getpwuid(getuid())) != NULL)
- home = pw->pw_dir;
- }
+ envent = environ_find(&global_environ, "HOME");
+ if (envent != NULL && *envent->value != '\0')
+ home = envent->value;
+ else if ((pw = getpwuid(getuid())) != NULL)
+ home = pw->pw_dir;
} else {
cmd_string_ungetc(p);
if ((username = cmd_string_string(s, p, '/', 0)) == NULL)
------------------------------------------------------------------------------
Lotusphere 2011
Register now for Lotusphere 2011 and learn how
to connect the dots, take your collaborative environment
to the next level, and enter the era of Social Business.
http://p.sf.net/sfu/lotusphere-d2d
_______________________________________________
tmux-cvs mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/tmux-cvs