Re: [patch] fixup GECOS handling
- From
- Kyle Hayes <kyle@marchex.com>
- Date
- Apr 22, 2005, 20:46 UTC
- Message-ID
- <1114202815.31076.444.camel@axer.marchex.com>
- In-Reply-To
- <1114196803.29271.52.camel@nosferatu.lan>
On Fri, 2005-04-22 at 21:06 +0200, Martin Schlemmer wrote:
> Right, but ';' is not cutoff on linux for one, and from what you said > freebsd as well. How about this rather (note that I assumed that the > use of ';' as delimiter will be in the minority, but we can switch > things around if it turns out the other way):
I'm not sure that __aix__ is defined, but it is close enough. Someone with an AIX compiler can correct it if needed. Anyone know about HP-UX and Tru64 and all those other ones?
Note that the original code also cuts on '.'. Is that used by some *nix in GECOS?
Best, Kyle
Show 49 quoted lines
> ----
> (not signed off, etc, as just for comments)
>
> Index: commit-tree.c
> ===================================================================
> --- 5f61aecb06c2f2579bbb5951b1b53e0dedc434eb/commit-tree.c (mode:100644 sha1:c0b07f89286c3f6cceae8122b4c3142c8efaf8e1)
> +++ uncommitted/commit-tree.c (mode:100644)
> @@ -96,21 +96,6 @@
> if (!c)
> break;
> }
> -
> - /*
> - * Go back, and remove crud from the end: some people
> - * have commas etc in their gecos field
> - */
> - dst--;
> - while (--dst >= p) {
> - unsigned char c = *dst;
> - switch (c) {
> - case ',': case ';': case '.':
> - *dst = 0;
> - continue;
> - }
> - break;
> - }
> }
>
> static const char *month_names[] = {
> @@ -311,6 +296,17 @@
> if (!pw)
> die("You don't exist. Go away!");
> realgecos = pw->pw_gecos;
> + /*
> + * The GECOS fields are seperated via ',' on Linux, FreeBSD, etc,
> + * and ';' on AIX.
> + */
> +#if defined(__aix__)
> + if (strchr(realgecos, ';'))
> + *strchr(realgecos, ';') = 0;
> +#else
> + if (strchr(realgecos, ','))
> + *strchr(realgecos, ',') = 0;
> +#endif
> len = strlen(pw->pw_name);
> memcpy(realemail, pw->pw_name, len);
> realemail[len] = '@';
>
> -- Kyle Hayes <kyle@marchex.com> Marchex Inc.