Changeset 1411:6bd74b844e23 for alias.c

Show
Ignore:
Timestamp:
1999-12-04 01:37:20 (9 years ago)
Author:
Thomas Roessler <roessler@…>
Branch:
HEAD
Message:

William Feavish's GECOS regexp patch.

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • alias.c

    r1374 r1411  
    8484      { 
    8585        struct passwd *pw = getpwnam (a->mailbox); 
    86         char buffer[256], *p; 
    8786 
    8887        if (pw) 
    8988        { 
    90           strfcpy (buffer, pw->pw_gecos, sizeof (buffer)); 
    91           if ((p = strchr (buffer, ','))) 
    92             *p = 0; 
    93           a->personal = safe_strdup (buffer); 
     89           regmatch_t pat_match[1]; 
     90 
     91           /* Use regular expression to parse Gecos field.  This result of the 
     92            * parsing will be used as the personal ID string when the alias is 
     93            * expaned. 
     94            */ 
     95          if (regexec (GecosMask.rx, pw->pw_gecos, 1, pat_match, 0) == 0) 
     96          { 
     97            /* Malloc enough for the matching pattern + terminating NULL */ 
     98            a->personal = safe_malloc ((pat_match[0].rm_eo -  
     99                                        pat_match[0].rm_so) + 1); 
     100             
     101            strfcpy (a->personal, pw->pw_gecos + pat_match[0].rm_so,  
     102                     pat_match[0].rm_eo - pat_match[0].rm_so + 1); 
     103          } 
     104 
    94105#ifdef EXACT_ADDRESS 
    95106          FREE (&a->val);