summaryrefslogtreecommitdiffstats
path: root/alias.c
diff options
context:
space:
mode:
authorThomas Roessler <roessler@does-not-exist.org>1999-12-04 09:37:20 +0000
committerThomas Roessler <roessler@does-not-exist.org>1999-12-04 09:37:20 +0000
commitbf5a271200174642196d0870435bf1b3b02bee03 (patch)
tree321386b97d3d6c8725d11e99bbf515d244d137c0 /alias.c
parent33da12a597aca9f62f88bc13977280c430c87e4a (diff)
William Feavish's GECOS regexp patch.
Diffstat (limited to 'alias.c')
-rw-r--r--alias.c21
1 files changed, 16 insertions, 5 deletions
diff --git a/alias.c b/alias.c
index 093455b7..7a27b71d 100644
--- a/alias.c
+++ b/alias.c
@@ -83,14 +83,25 @@ static ADDRESS *mutt_expand_aliases_r (ADDRESS *a, LIST **expn)
else
{
struct passwd *pw = getpwnam (a->mailbox);
- char buffer[256], *p;
if (pw)
{
- strfcpy (buffer, pw->pw_gecos, sizeof (buffer));
- if ((p = strchr (buffer, ',')))
- *p = 0;
- a->personal = safe_strdup (buffer);
+ regmatch_t pat_match[1];
+
+ /* Use regular expression to parse Gecos field. This result of the
+ * parsing will be used as the personal ID string when the alias is
+ * expaned.
+ */
+ if (regexec (GecosMask.rx, pw->pw_gecos, 1, pat_match, 0) == 0)
+ {
+ /* Malloc enough for the matching pattern + terminating NULL */
+ a->personal = safe_malloc ((pat_match[0].rm_eo -
+ pat_match[0].rm_so) + 1);
+
+ strfcpy (a->personal, pw->pw_gecos + pat_match[0].rm_so,
+ pat_match[0].rm_eo - pat_match[0].rm_so + 1);
+ }
+
#ifdef EXACT_ADDRESS
FREE (&a->val);
#endif