Commit f9361439 f93614398c956603c4bfd163b8dfdabb09788e87 by Sergey Poznyakoff

(tilde_expand): Remove

(mu_mailbox_create_default): Use  mu_tilde_expansion instead of tilde_expand
1 parent 96a55b3c
...@@ -260,48 +260,6 @@ plus_expand (const char *file, char **buf) ...@@ -260,48 +260,6 @@ plus_expand (const char *file, char **buf)
260 return 0; 260 return 0;
261 } 261 }
262 262
263 /* Do ~ , if necessary. */
264 static int
265 tilde_expand (const char *file, char **buf)
266 {
267 char *user = NULL;
268 char *path = NULL;
269 char *home;
270 int status;
271 int len;
272
273 if ((status = split_shortcut (file, "~", &user, &path)))
274 return status;
275
276 if (!path)
277 {
278 if (user)
279 free (user);
280 return ENOENT;
281 }
282
283 home = get_homedir (user);
284 if (!home)
285 {
286 free (user);
287 free (path);
288 return MU_ERR_NO_SUCH_USER;
289 }
290
291 free (user); /* not needed anymore */
292
293 len = strlen (home) + strlen (path) + 2;
294 *buf = malloc (len);
295 if (*buf)
296 {
297 sprintf (*buf, "%s/%s", home, path);
298 (*buf)[len-1] = 0;
299 }
300
301 free (path);
302 return *buf ? 0 : ENOMEM;
303 }
304
305 static int 263 static int
306 percent_expand (const char *file, char **mbox) 264 percent_expand (const char *file, char **mbox)
307 { 265 {
...@@ -338,6 +296,7 @@ mu_mailbox_create_default (mu_mailbox_t *pmbox, const char *mail) ...@@ -338,6 +296,7 @@ mu_mailbox_create_default (mu_mailbox_t *pmbox, const char *mail)
338 { 296 {
339 char *mbox = NULL; 297 char *mbox = NULL;
340 char *tmp_mbox = NULL; 298 char *tmp_mbox = NULL;
299 char *p;
341 int status = 0; 300 int status = 0;
342 301
343 /* Sanity. */ 302 /* Sanity. */
...@@ -362,16 +321,22 @@ mu_mailbox_create_default (mu_mailbox_t *pmbox, const char *mail) ...@@ -362,16 +321,22 @@ mu_mailbox_create_default (mu_mailbox_t *pmbox, const char *mail)
362 } 321 }
363 } 322 }
364 323
324 p = mu_tilde_expansion (mail, "/", NULL);
325 if (tmp_mbox)
326 {
327 free (tmp_mbox);
328 tmp_mbox = p;
329 }
330 mail = p;
331 if (!mail)
332 return ENOMEM;
333
365 switch (mail[0]) 334 switch (mail[0])
366 { 335 {
367 case '%': 336 case '%':
368 status = percent_expand (mail, &mbox); 337 status = percent_expand (mail, &mbox);
369 break; 338 break;
370 339
371 case '~':
372 status = tilde_expand (mail, &mbox);
373 break;
374
375 case '+': 340 case '+':
376 case '=': 341 case '=':
377 status = plus_expand (mail, &mbox); 342 status = plus_expand (mail, &mbox);
......