- Timestamp:
- Jul 16, 2011, 12:28:10 AM (14 years ago)
- Branches:
- master, release-1.10, release-1.8, release-1.9
- Children:
- 99ac28a
- Parents:
- e59d775
- git-author:
- David Benjamin <davidben@mit.edu> (07/10/11 19:00:08)
- git-committer:
- David Benjamin <davidben@mit.edu> (07/16/11 00:28:10)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
util.c
rdde1b4d r396505be 42 42 /* Attempt tilde-expansion of the first component. Get the 43 43 tilde-prefix, which goes up to the next slash. */ 44 struct passwd *pw;45 44 const char *end = strchr(in + 1, '/'); 46 45 if (end == NULL) 47 46 end = in + strlen(in); 48 47 48 /* Patch together a new path. Replace the ~ and tilde-prefix with 49 the homedir, if available. */ 49 50 if (end == in + 1) { 50 /* My home directory. */ 51 pw = getpwuid(getuid()); 51 /* My home directory. Use the one in owl_global for consistency with 52 * owl_zephyr_dotfile. */ 53 out = g_strconcat(owl_global_get_homedir(&g), end, NULL); 52 54 } else { 53 55 /* Someone else's home directory. */ 54 56 char *user = g_strndup(in + 1, end - (in + 1)); 55 pw = getpwnam(user);57 struct passwd *pw = getpwnam(user); 56 58 g_free(user); 57 } 58 59 /* Patch together a new path. Replace the ~ and tilde-prefix with 60 the homedir. */ 61 if (pw) { 62 out = g_strconcat(pw->pw_dir, end, NULL); 63 } else { 64 out = g_strdup(in); 59 if (pw) { 60 out = g_strconcat(pw->pw_dir, end, NULL); 61 } else { 62 out = g_strdup(in); 63 } 65 64 } 66 65 } else { 67 66 out = g_strdup(in); 68 67 } 69 68
Note: See TracChangeset
for help on using the changeset viewer.