Commit 1400dc96 1400dc96cd6c44ac2c2f3bfa41bda952107cea99 by Sergey Poznyakoff

(mh_alias_get_internal): Set `inclusive'

only if the alias matches
(mh_alias_get_address): Initialize incl
Use mu_address_set_personal to handle alias inclusion
1 parent a4449fb2
1 %{ 1 %{
2 /* GNU Mailutils -- a suite of utilities for electronic mail 2 /* GNU Mailutils -- a suite of utilities for electronic mail
3 Copyright (C) 2003, 2004, 2005 Free Software Foundation, Inc. 3 Copyright (C) 2003, 2004, 2005, 2006 Free Software Foundation, Inc.
4 4
5 GNU Mailutils is free software; you can redistribute it and/or modify 5 GNU Mailutils is free software; you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by 6 it under the terms of the GNU General Public License as published by
...@@ -333,10 +333,10 @@ mh_alias_get_internal (char *name, mu_iterator_t start, mu_list_t *return_list, ...@@ -333,10 +333,10 @@ mh_alias_get_internal (char *name, mu_iterator_t start, mu_list_t *return_list,
333 { 333 {
334 struct mh_alias *alias; 334 struct mh_alias *alias;
335 mu_iterator_current (itr, (void **)&alias); 335 mu_iterator_current (itr, (void **)&alias);
336 if (inclusive)
337 *inclusive |= alias->inclusive;
338 if (aliascmp (alias->name, name) == 0) 336 if (aliascmp (alias->name, name) == 0)
339 { 337 {
338 if (inclusive)
339 *inclusive |= alias->inclusive;
340 *return_list = ali_list_dup (alias->rcpt_list); 340 *return_list = ali_list_dup (alias->rcpt_list);
341 alias_expand_list (*return_list, itr, inclusive); 341 alias_expand_list (*return_list, itr, inclusive);
342 rc = 0; 342 rc = 0;
...@@ -360,7 +360,9 @@ mh_alias_get_address (char *name, mu_address_t *paddr, int *incl) ...@@ -360,7 +360,9 @@ mh_alias_get_address (char *name, mu_address_t *paddr, int *incl)
360 mu_iterator_t itr; 360 mu_iterator_t itr;
361 mu_list_t list; 361 mu_list_t list;
362 const char *domain = NULL; 362 const char *domain = NULL;
363 363
364 if (incl)
365 *incl = 0;
364 if (mh_alias_get_internal (name, NULL, &list, incl)) 366 if (mh_alias_get_internal (name, NULL, &list, incl))
365 return 1; 367 return 1;
366 if (mu_list_is_empty (list)) 368 if (mu_list_is_empty (list))
...@@ -378,18 +380,6 @@ mh_alias_get_address (char *name, mu_address_t *paddr, int *incl) ...@@ -378,18 +380,6 @@ mh_alias_get_address (char *name, mu_address_t *paddr, int *incl)
378 char *ptr = NULL; 380 char *ptr = NULL;
379 381
380 mu_iterator_current (itr, (void **)&item); 382 mu_iterator_current (itr, (void **)&item);
381 if (incl && *incl)
382 {
383 if (strchr (item, '@') == 0)
384 {
385 if (!domain)
386 mu_get_user_email_domain (&domain);
387 asprintf (&ptr, "\"%s\" <%s@%s>", name, item, domain);
388 }
389 else
390 asprintf (&ptr, "\"%s\" <%s>", name, item);
391 item = ptr;
392 }
393 if (mu_address_create (&a, item)) 383 if (mu_address_create (&a, item))
394 { 384 {
395 mh_error (_("Error expanding aliases -- invalid address `%s'"), 385 mh_error (_("Error expanding aliases -- invalid address `%s'"),
...@@ -397,6 +387,8 @@ mh_alias_get_address (char *name, mu_address_t *paddr, int *incl) ...@@ -397,6 +387,8 @@ mh_alias_get_address (char *name, mu_address_t *paddr, int *incl)
397 } 387 }
398 else 388 else
399 { 389 {
390 if (incl && *incl)
391 mu_address_set_personal (a, 1, name);
400 mu_address_union (paddr, a); 392 mu_address_union (paddr, a);
401 mu_address_destroy (&a); 393 mu_address_destroy (&a);
402 } 394 }
......