diff options
author | Thomas Roessler <roessler@does-not-exist.org> | 1999-12-04 09:37:20 +0000 |
---|---|---|
committer | Thomas Roessler <roessler@does-not-exist.org> | 1999-12-04 09:37:20 +0000 |
commit | bf5a271200174642196d0870435bf1b3b02bee03 (patch) | |
tree | 321386b97d3d6c8725d11e99bbf515d244d137c0 /alias.c | |
parent | 33da12a597aca9f62f88bc13977280c430c87e4a (diff) |
William Feavish's GECOS regexp patch.
Diffstat (limited to 'alias.c')
-rw-r--r-- | alias.c | 21 |
1 files changed, 16 insertions, 5 deletions
@@ -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 |