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
** can be overridden using my_hdr (including from send-hooks) and
** ``$reverse_name''.
*/
+ { "gecos_mask", DT_RX, R_NONE, UL &GecosMask, UL "^[^,]*" },
+ /*
+ ** .pp
+ ** A regular expression used by mutt to parse the GECOS field of a password
+ ** entry when expanding the alias. By default the regular expression is set
+ ** to "^[^,]*" which will return the string up to the first "," encountered.
+ ** If the GECOS field contains a string like "lastname, firstname" then you
+ ** should set the gecos_regexp=".*".
+ */
{ "hdr_format", DT_SYN, R_NONE, UL "index_format", 0 },
/*
*/
WHERE REGEXP QuoteRegexp;
WHERE REGEXP ReplyRegexp;
WHERE REGEXP Smileys;
+WHERE REGEXP GecosMask;
#endif /* MUTT_REGEX_H */