[news.software.b] Why does buildfname skip past hyphens?

bin@primate.wisc.edu (Brain in Neutral) (01/05/89)

The buildfname() function in fullname.c (used (indirectly) by, e.g.,
inews) looks in the gecos field to try to figure out a user's full
name.  The comments in the code say it was lifted from sendmail, but
there is a difference.  If the name part of the gecos field contains a
hyphen, the full name is stripped of everything to the left of the
hyphen.  (sendmail's buildfname() doesn't do this.)  Thus articles by a
user such as "Firstname Lastname-Hyphenated" get posted as being from
just "Hyphenated".

What is the function of this behavior?

Paul DuBois
bin@primate.wisc.edu
dubois@primate.wisc.edu

karl@triceratops.cis.ohio-state.edu (Karl Kleinpaste) (01/06/89)

bin@primate.wisc.edu (Brain in Neutral) writes:
   The comments in the code say it was lifted from sendmail, but
   there is a difference.  If the name part of the gecos field contains a
   hyphen, the full name is stripped of everything to the left of the
   hyphen.  (sendmail's buildfname() doesn't do this.)  Thus articles by a
   user such as "Firstname Lastname-Hyphenated" get posted as being from
   just "Hyphenated".

That is to accommodate the SysVish habit of having the gecos field be
some set of digits (representing, e.g., departmental affiliation),
followed by a dash and the real name.  In particular, the canned
administrative accounts on SysV machines always come with
"0000-something" in the gecos field.  E.g., root is frequently found
to be
	root:abcefghijklm:0:0:0000-Admin:/:
and hence, the left-of-dash stripping is necessary there.

It might be possible for a better heuristic to determine if it's
really SysVish as opposed to a true hyphenated name (looking for
digits would be a good start), but the generalization as it currently
stands is fairly appropriate.

--Karl

jhc@att.ATT.COM (Jonathan Hawbrook-Clark) (01/06/89)

In article <KARL.89Jan5131728@triceratops.cis.ohio-state.edu> karl@triceratops.cis.ohio-state.edu (Karl Kleinpaste) writes:
>
>It might be possible for a better heuristic to determine if it's
>really SysVish as opposed to a true hyphenated name (looking for
>digits would be a good start), but the generalization as it currently
>stands is fairly appropriate.

I modified the appropriate bit of my smail to read as attached,
this handles the System V habit of making the GCOS field look
like "12345-A. N. Other(foo)bar", and also handles this case:
"12345-Jonathan Hawbrook-Clark". The test sees whether the character
before the hyphen is alphabetic - if it is then it assumes that
the hyphen is part of a name, otherwise not. Anyone got a better test?

Jonathan Clark		jonathan@mtune.att.com, attmail!jonathan
Any affiliation is given for identification purposes only.

The Englishman never enjoys himself except for some noble purpose.
--
	if ((cend = index(fname, '-')) && !isalpha(cend[-1]))
		/*
	 	 * USG name format: name between between '-' and '('
		 * Note that this now does hyphenated names properly.
	 	 */
		return (++cend);
	else
		/*
		 * v7/BSD format: name first thing in field
		 */
	return (fname);
}

anw@nott-cs.UUCP (01/10/89)

In article <111@indri.primate.wisc.edu> bin@primate.wisc.edu (Brain in
Neutral) writes:
> [...]  Thus articles by a
>user such as "Firstname Lastname-Hyphenated" get posted as being from
>just "Hyphenated".

	He's lucky.  On this system, the "gecos" field is occupied by such
interesting info as disc quotas and priorities.  Hence my name is apparently
"4".  I dread to think what my less important [:-)] brethren and cistern are
apparently called.

	[Yes, I know how to cure the problem, but life's too short.]

-- 
Andy Walker, Maths Dept., Nott'm Univ., UK.
anw@maths.nott.ac.uk