use mu_tilde_expansion()
Showing
1 changed file
with
1 additions
and
37 deletions
... | @@ -112,43 +112,7 @@ util_unquote (char **ptr) | ... | @@ -112,43 +112,7 @@ util_unquote (char **ptr) |
112 | char * | 112 | char * |
113 | util_tilde_expansion (const char *ref, const char *delim) | 113 | util_tilde_expansion (const char *ref, const char *delim) |
114 | { | 114 | { |
115 | char *p = strdup (ref); | 115 | return mu_tilde_expansion (ref, delim, homedir); |
116 | if (*p == '~') | ||
117 | { | ||
118 | p++; | ||
119 | if (*p == delim[0] || *p == '\0') | ||
120 | { | ||
121 | char *s = calloc (strlen (homedir) + strlen (p) + 1, 1); | ||
122 | strcpy (s, homedir); | ||
123 | strcat (s, p); | ||
124 | free (--p); | ||
125 | p = s; | ||
126 | } | ||
127 | else | ||
128 | { | ||
129 | struct passwd *pw; | ||
130 | char *s = p; | ||
131 | char *name; | ||
132 | while (*s && *s != delim[0]) | ||
133 | s++; | ||
134 | name = calloc (s - p + 1, 1); | ||
135 | memcpy (name, p, s - p); | ||
136 | name [s - p] = '\0'; | ||
137 | pw = getpwnam (name); | ||
138 | free (name); | ||
139 | if (pw) | ||
140 | { | ||
141 | char *buf = calloc (strlen (pw->pw_dir) + strlen (s) + 1, 1); | ||
142 | strcpy (buf, pw->pw_dir); | ||
143 | strcat (buf, s); | ||
144 | free (--p); | ||
145 | p = buf; | ||
146 | } | ||
147 | else | ||
148 | p--; | ||
149 | } | ||
150 | } | ||
151 | return p; | ||
152 | } | 116 | } |
153 | 117 | ||
154 | /* util_normalize_path: convert pathname containig relative paths specs (../) | 118 | /* util_normalize_path: convert pathname containig relative paths specs (../) | ... | ... |
-
Please register or sign in to post a comment