* [patch] fixup GECOS handling
@ 2005-04-18 10:36 Martin Schlemmer
2005-04-18 12:35 ` David Woodhouse
0 siblings, 1 reply; 16+ messages in thread
From: Martin Schlemmer @ 2005-04-18 10:36 UTC (permalink / raw)
To: GIT Mailing Lists
[-- Attachment #1.1: Type: text/plain, Size: 1565 bytes --]
Hi,
The gecos is delimited by ',' or ';', so we should only use whatever
before the first ',' or ';' for the full name, and not just strip those.
Also, a '.' may be valid in the full name (Foo B. Zooman) or email
(foo.zooman@bar.com).
Signed-off-by: Martin Schlemmer <azarah@gentoo.org>
commit-tree.c: ec53a4565ec0033aaf6df2a48d233ccf4823e8b0
--- 1/commit-tree.c
+++ 2/commit-tree.c 2005-04-18 12:22:18.000000000 +0200
@@ -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[] = {
@@ -313,6 +298,11 @@
if (!pw)
die("You don't exist. Go away!");
realgecos = pw->pw_gecos;
+ /* The name is seperated from the room no., tel no, etc via [,;] */
+ if (strchr(realgecos, ','))
+ realgecos[strchr(realgecos, ',') - realgecos] = '\0';
+ else if (strchr(realgecos, ';'))
+ realgecos[strchr(realgecos, ';') - realgecos] = '\0';
len = strlen(pw->pw_name);
memcpy(realemail, pw->pw_name, len);
realemail[len] = '@';
--
Martin Schlemmer
[-- Attachment #1.2: git-gecos.patch --]
[-- Type: text/x-patch, Size: 967 bytes --]
commit-tree.c: ec53a4565ec0033aaf6df2a48d233ccf4823e8b0
--- 1/commit-tree.c
+++ 2/commit-tree.c 2005-04-18 12:22:18.000000000 +0200
@@ -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[] = {
@@ -313,6 +298,11 @@
if (!pw)
die("You don't exist. Go away!");
realgecos = pw->pw_gecos;
+ /* The name is seperated from the room no., tel no, etc via ',' or ';' */
+ if (strchr(realgecos, ','))
+ realgecos[strchr(realgecos, ',') - realgecos] = '\0';
+ else if (strchr(realgecos, ';'))
+ realgecos[strchr(realgecos, ';') - realgecos] = '\0';
len = strlen(pw->pw_name);
memcpy(realemail, pw->pw_name, len);
realemail[len] = '@';
[-- Attachment #2: This is a digitally signed message part --]
[-- Type: application/pgp-signature, Size: 189 bytes --]
^ permalink raw reply [flat|nested] 16+ messages in thread
* Re: [patch] fixup GECOS handling
2005-04-18 10:36 [patch] fixup GECOS handling Martin Schlemmer
@ 2005-04-18 12:35 ` David Woodhouse
2005-04-18 12:58 ` Martin Schlemmer
2005-04-22 14:23 ` Martin Schlemmer
0 siblings, 2 replies; 16+ messages in thread
From: David Woodhouse @ 2005-04-18 12:35 UTC (permalink / raw)
To: azarah; +Cc: GIT Mailing Lists
On Mon, 2005-04-18 at 12:36 +0200, Martin Schlemmer wrote:
> realgecos[strchr(realgecos, ',') - realgecos] = '\0';
Er, *strchr(realgecos, ',') = 0; surely? Even if the compiler is clever
enough to optimise out the gratuitous addition and subtraction, that's
no real excuse for it.
--
dwmw2
^ permalink raw reply [flat|nested] 16+ messages in thread
* Re: [patch] fixup GECOS handling
2005-04-18 12:35 ` David Woodhouse
@ 2005-04-18 12:58 ` Martin Schlemmer
2005-04-22 14:23 ` Martin Schlemmer
1 sibling, 0 replies; 16+ messages in thread
From: Martin Schlemmer @ 2005-04-18 12:58 UTC (permalink / raw)
To: David Woodhouse; +Cc: GIT Mailing Lists
[-- Attachment #1.1: Type: text/plain, Size: 1813 bytes --]
On Mon, 2005-04-18 at 22:35 +1000, David Woodhouse wrote:
> On Mon, 2005-04-18 at 12:36 +0200, Martin Schlemmer wrote:
> > realgecos[strchr(realgecos, ',') - realgecos] = '\0';
>
> Er, *strchr(realgecos, ',') = 0; surely? Even if the compiler is clever
> enough to optimise out the gratuitous addition and subtraction, that's
> no real excuse for it.
>
Err, right. Updated patch.
The gecos is delimited by ',' or ';', so we should only use whatever
before the first ',' or ';' for the full name, and not just strip those.
Signed-off-by: Martin Schlemmer <azarah@gentoo.org>
commit-tree.c: ec53a4565ec0033aaf6df2a48d233ccf4823e8b0
--- 1/commit-tree.c
+++ 2/commit-tree.c 2005-04-18 12:22:18.000000000 +0200
@@ -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[] = {
@@ -313,6 +298,11 @@
if (!pw)
die("You don't exist. Go away!");
realgecos = pw->pw_gecos;
+ /* The name is seperated from the room no., tel no, etc via [,;] */
+ if (strchr(realgecos, ','))
+ *strchr(realgecos, ',') = 0;
+ else if (strchr(realgecos, ';'))
+ *strchr(realgecos, ';') = 0;
len = strlen(pw->pw_name);
memcpy(realemail, pw->pw_name, len);
realemail[len] = '@';
--
Martin Schlemmer
[-- Attachment #1.2: git-gecos.patch --]
[-- Type: text/x-patch, Size: 917 bytes --]
commit-tree.c: ec53a4565ec0033aaf6df2a48d233ccf4823e8b0
--- 1/commit-tree.c
+++ 2/commit-tree.c 2005-04-18 12:22:18.000000000 +0200
@@ -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[] = {
@@ -313,6 +298,11 @@
if (!pw)
die("You don't exist. Go away!");
realgecos = pw->pw_gecos;
+ /* The name is seperated from the room no., tel no, etc via ',' or ';' */
+ if (strchr(realgecos, ','))
+ *strchr(realgecos, ',') = 0;
+ else if (strchr(realgecos, ';'))
+ *strchr(realgecos, ';') = 0;
len = strlen(pw->pw_name);
memcpy(realemail, pw->pw_name, len);
realemail[len] = '@';
[-- Attachment #2: This is a digitally signed message part --]
[-- Type: application/pgp-signature, Size: 189 bytes --]
^ permalink raw reply [flat|nested] 16+ messages in thread
* [patch] fixup GECOS handling
2005-04-18 12:35 ` David Woodhouse
2005-04-18 12:58 ` Martin Schlemmer
@ 2005-04-22 14:23 ` Martin Schlemmer
2005-04-22 16:16 ` Kyle Hayes
1 sibling, 1 reply; 16+ messages in thread
From: Martin Schlemmer @ 2005-04-22 14:23 UTC (permalink / raw)
To: GIT Mailing Lists; +Cc: Linus Torvalds
[-- Attachment #1.1: Type: text/plain, Size: 1514 bytes --]
Hi,
This still applies - any reason for not doing this?
Thanks,
----
The GECOS is delimited by ',' or ';', so we should only use whatever is
before the first ',' or ';' for the full name, rather than just
stripping those.
Signed-off-by: Martin Schlemmer <azarah@gentoo.org>
commit-tree.c: ec53a4565ec0033aaf6df2a48d233ccf4823e8b0
--- 1/commit-tree.c
+++ 2/commit-tree.c 2005-04-18 12:22:18.000000000 +0200
@@ -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[] = {
@@ -313,6 +298,11 @@
if (!pw)
die("You don't exist. Go away!");
realgecos = pw->pw_gecos;
+ /* The name is seperated from the room no., tel no, etc via [,;] */
+ if (strchr(realgecos, ','))
+ *strchr(realgecos, ',') = 0;
+ else if (strchr(realgecos, ';'))
+ *strchr(realgecos, ';') = 0;
len = strlen(pw->pw_name);
memcpy(realemail, pw->pw_name, len);
realemail[len] = '@';
--
Martin Schlemmer
[-- Attachment #1.2: git-gecos.patch --]
[-- Type: text/x-patch, Size: 917 bytes --]
commit-tree.c: ec53a4565ec0033aaf6df2a48d233ccf4823e8b0
--- 1/commit-tree.c
+++ 2/commit-tree.c 2005-04-18 12:22:18.000000000 +0200
@@ -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[] = {
@@ -313,6 +298,11 @@
if (!pw)
die("You don't exist. Go away!");
realgecos = pw->pw_gecos;
+ /* The name is seperated from the room no., tel no, etc via ',' or ';' */
+ if (strchr(realgecos, ','))
+ *strchr(realgecos, ',') = 0;
+ else if (strchr(realgecos, ';'))
+ *strchr(realgecos, ';') = 0;
len = strlen(pw->pw_name);
memcpy(realemail, pw->pw_name, len);
realemail[len] = '@';
[-- Attachment #2: This is a digitally signed message part --]
[-- Type: application/pgp-signature, Size: 189 bytes --]
^ permalink raw reply [flat|nested] 16+ messages in thread
* Re: [patch] fixup GECOS handling
2005-04-22 14:23 ` Martin Schlemmer
@ 2005-04-22 16:16 ` Kyle Hayes
2005-04-22 16:58 ` Martin Schlemmer
2005-04-22 23:30 ` Andy Isaacson
0 siblings, 2 replies; 16+ messages in thread
From: Kyle Hayes @ 2005-04-22 16:16 UTC (permalink / raw)
To: azarah; +Cc: GIT Mailing Lists
On Fri, 2005-04-22 at 16:23 +0200, Martin Schlemmer wrote:
> Hi,
>
> This still applies - any reason for not doing this?
Seems like this will break on certain kinds of data. See below.
> if (!pw)
> die("You don't exist. Go away!");
> realgecos = pw->pw_gecos;
> + /* The name is seperated from the room no., tel no, etc via [,;] */
> + if (strchr(realgecos, ','))
> + *strchr(realgecos, ',') = 0;
> + else if (strchr(realgecos, ';'))
> + *strchr(realgecos, ';') = 0;
> len = strlen(pw->pw_name);
> memcpy(realemail, pw->pw_name, len);
> realemail[len] = '@';
Suppose that the GECOS field is:
Hayes, Kyle; Room 42; 424-424-4242; foo bar baz...
You'll search for the first comma, find it, truncate my name to "Hayes",
and continue.
I have seen this kind of GECOS in larger environments where the
individual users are not the ones that administrate their machines.
Using the LastName, FirstName style of name is not rare.
I think you want something like this (not tested):
char *comma,*semi;
comma = strchr(realgecos,',');
semi = strchr(realgecos,';');
if(comma)
if(semi)
/* lastname, firstname; room #; phone # format */
*semi = 0;
else
*comma = 0;
else if(semi)
*semi = 0;
(hopefully Evolution won't trash the indentation...)
Best,
Kyle
--
Kyle Hayes <kyle@marchex.com>
Marchex Inc.
^ permalink raw reply [flat|nested] 16+ messages in thread
* Re: [patch] fixup GECOS handling
2005-04-22 16:16 ` Kyle Hayes
@ 2005-04-22 16:58 ` Martin Schlemmer
2005-04-22 17:18 ` Petr Baudis
2005-04-22 17:43 ` Kyle Hayes
2005-04-22 23:30 ` Andy Isaacson
1 sibling, 2 replies; 16+ messages in thread
From: Martin Schlemmer @ 2005-04-22 16:58 UTC (permalink / raw)
To: kyle; +Cc: GIT Mailing Lists
[-- Attachment #1: Type: text/plain, Size: 1855 bytes --]
On Fri, 2005-04-22 at 09:16 -0700, Kyle Hayes wrote:
> On Fri, 2005-04-22 at 16:23 +0200, Martin Schlemmer wrote:
> > Hi,
> >
> > This still applies - any reason for not doing this?
>
> Seems like this will break on certain kinds of data. See below.
>
> > if (!pw)
> > die("You don't exist. Go away!");
> > realgecos = pw->pw_gecos;
> > + /* The name is seperated from the room no., tel no, etc via [,;] */
> > + if (strchr(realgecos, ','))
> > + *strchr(realgecos, ',') = 0;
> > + else if (strchr(realgecos, ';'))
> > + *strchr(realgecos, ';') = 0;
> > len = strlen(pw->pw_name);
> > memcpy(realemail, pw->pw_name, len);
> > realemail[len] = '@';
>
> Suppose that the GECOS field is:
>
> Hayes, Kyle; Room 42; 424-424-4242; foo bar baz...
>
> You'll search for the first comma, find it, truncate my name to "Hayes",
> and continue.
>
> I have seen this kind of GECOS in larger environments where the
> individual users are not the ones that administrate their machines.
> Using the LastName, FirstName style of name is not rare.
>
What OS? With Linux at least, this is what chfn's manpage say:
----
The only restriction placed on the contents of the fields is that no control characters may be present,
nor any of comma, colon, or equal sign. The other field does not have this restriction, and is used to
store accounting information used by other applications.
----
Meaning, if they use a ',' in one of the fields (and it is a linux
system with the chfn most probably from the shadow package), then they
are looking for trouble. The only reason I added the ';' was because
somebody said whatever OS used it instead of a ','.
Thanks,
--
Martin Schlemmer
[-- Attachment #2: This is a digitally signed message part --]
[-- Type: application/pgp-signature, Size: 189 bytes --]
^ permalink raw reply [flat|nested] 16+ messages in thread
* Re: [patch] fixup GECOS handling
2005-04-22 16:58 ` Martin Schlemmer
@ 2005-04-22 17:18 ` Petr Baudis
2005-04-22 17:25 ` Martin Schlemmer
2005-04-22 17:58 ` Kyle Hayes
2005-04-22 17:43 ` Kyle Hayes
1 sibling, 2 replies; 16+ messages in thread
From: Petr Baudis @ 2005-04-22 17:18 UTC (permalink / raw)
To: Martin Schlemmer; +Cc: kyle, GIT Mailing Lists
Dear diary, on Fri, Apr 22, 2005 at 06:58:25PM CEST, I got a letter
where Martin Schlemmer <azarah@nosferatu.za.org> told me that...
> Meaning, if they use a ',' in one of the fields (and it is a linux
> system with the chfn most probably from the shadow package), then they
> are looking for trouble. The only reason I added the ';' was because
> somebody said whatever OS used it instead of a ','.
What about just swapping the two tests so that ; is cut off and , only
when no ; is around?
--
Petr "Pasky" Baudis
Stuff: http://pasky.or.cz/
C++: an octopus made by nailing extra legs onto a dog. -- Steve Taylor
^ permalink raw reply [flat|nested] 16+ messages in thread
* Re: [patch] fixup GECOS handling
2005-04-22 17:18 ` Petr Baudis
@ 2005-04-22 17:25 ` Martin Schlemmer
2005-04-22 17:58 ` Kyle Hayes
1 sibling, 0 replies; 16+ messages in thread
From: Martin Schlemmer @ 2005-04-22 17:25 UTC (permalink / raw)
To: Petr Baudis; +Cc: kyle, GIT Mailing Lists
[-- Attachment #1: Type: text/plain, Size: 725 bytes --]
On Fri, 2005-04-22 at 19:18 +0200, Petr Baudis wrote:
> Dear diary, on Fri, Apr 22, 2005 at 06:58:25PM CEST, I got a letter
> where Martin Schlemmer <azarah@nosferatu.za.org> told me that...
> > Meaning, if they use a ',' in one of the fields (and it is a linux
> > system with the chfn most probably from the shadow package), then they
> > are looking for trouble. The only reason I added the ';' was because
> > somebody said whatever OS used it instead of a ','.
>
> What about just swapping the two tests so that ; is cut off and , only
> when no ; is around?
>
Actually, maybe just leave it. Its not a train smash, and in theory on
linux ';' is a valid char in the gecos.
--
Martin Schlemmer
[-- Attachment #2: This is a digitally signed message part --]
[-- Type: application/pgp-signature, Size: 189 bytes --]
^ permalink raw reply [flat|nested] 16+ messages in thread
* Re: [patch] fixup GECOS handling
2005-04-22 16:58 ` Martin Schlemmer
2005-04-22 17:18 ` Petr Baudis
@ 2005-04-22 17:43 ` Kyle Hayes
1 sibling, 0 replies; 16+ messages in thread
From: Kyle Hayes @ 2005-04-22 17:43 UTC (permalink / raw)
To: azarah; +Cc: GIT Mailing Lists
On Fri, 2005-04-22 at 18:58 +0200, Martin Schlemmer wrote:
> On Fri, 2005-04-22 at 09:16 -0700, Kyle Hayes wrote:
> > Suppose that the GECOS field is:
> >
> > Hayes, Kyle; Room 42; 424-424-4242; foo bar baz...
> >
> > You'll search for the first comma, find it, truncate my name to "Hayes",
> > and continue.
> >
> > I have seen this kind of GECOS in larger environments where the
> > individual users are not the ones that administrate their machines.
> > Using the LastName, FirstName style of name is not rare.
> >
>
> What OS? With Linux at least, this is what chfn's manpage say:
Can't remember, it's been a while (years). We had AIX, Solaris, Linux
and BSD machines at the time. Might have been AIX, I think. The memory
of which OS is vague, but not the annoyance of finding the problem :-(
> ----
> The only restriction placed on the contents of the fields is that no control characters may be present,
> nor any of comma, colon, or equal sign. The other field does not have this restriction, and is used to
> store accounting information used by other applications.
> ----
>
> Meaning, if they use a ',' in one of the fields (and it is a linux
> system with the chfn most probably from the shadow package), then they
> are looking for trouble. The only reason I added the ';' was because
> somebody said whatever OS used it instead of a ','.
>From the AIX version of chfn:
----
You can use any printable characters in the gecos information string
except a : (colon), which is an attribute delimiter.
----
The AIX examples show use of semicolon as a separator.
So, at least on AIX, it is appears valid to use the style I showed
above. I don't have access to Solaris machines right now. The BSD
(FreeBSD 4.11) version of man 5 passwd:
----
The gecos field normally contains comma (`,') separated subfields as
follows:...
----
Best,
Kyle
--
Kyle Hayes <kyle@marchex.com>
Marchex Inc.
^ permalink raw reply [flat|nested] 16+ messages in thread
* Re: [patch] fixup GECOS handling
2005-04-22 17:18 ` Petr Baudis
2005-04-22 17:25 ` Martin Schlemmer
@ 2005-04-22 17:58 ` Kyle Hayes
2005-04-22 19:06 ` Martin Schlemmer
1 sibling, 1 reply; 16+ messages in thread
From: Kyle Hayes @ 2005-04-22 17:58 UTC (permalink / raw)
To: Petr Baudis; +Cc: Martin Schlemmer, GIT Mailing Lists
On Fri, 2005-04-22 at 19:18 +0200, Petr Baudis wrote:
> Dear diary, on Fri, Apr 22, 2005 at 06:58:25PM CEST, I got a letter
> where Martin Schlemmer <azarah@nosferatu.za.org> told me that...
> > Meaning, if they use a ',' in one of the fields (and it is a linux
> > system with the chfn most probably from the shadow package), then they
> > are looking for trouble. The only reason I added the ';' was because
> > somebody said whatever OS used it instead of a ','.
>
> What about just swapping the two tests so that ; is cut off and , only
> when no ; is around?
Even nicer. I like it. Very clean!
Best,
Kyle
--
Kyle Hayes <kyle@marchex.com>
Marchex Inc.
^ permalink raw reply [flat|nested] 16+ messages in thread
* Re: [patch] fixup GECOS handling
2005-04-22 17:58 ` Kyle Hayes
@ 2005-04-22 19:06 ` Martin Schlemmer
2005-04-22 20:46 ` Kyle Hayes
2005-04-23 23:38 ` Petr Baudis
0 siblings, 2 replies; 16+ messages in thread
From: Martin Schlemmer @ 2005-04-22 19:06 UTC (permalink / raw)
To: kyle; +Cc: Petr Baudis, GIT Mailing Lists
[-- Attachment #1: Type: text/plain, Size: 2433 bytes --]
On Fri, 2005-04-22 at 10:58 -0700, Kyle Hayes wrote:
> On Fri, 2005-04-22 at 19:18 +0200, Petr Baudis wrote:
> > Dear diary, on Fri, Apr 22, 2005 at 06:58:25PM CEST, I got a letter
> > where Martin Schlemmer <azarah@nosferatu.za.org> told me that...
> > > Meaning, if they use a ',' in one of the fields (and it is a linux
> > > system with the chfn most probably from the shadow package), then they
> > > are looking for trouble. The only reason I added the ';' was because
> > > somebody said whatever OS used it instead of a ','.
> >
> > What about just swapping the two tests so that ; is cut off and , only
> > when no ; is around?
>
> Even nicer. I like it. Very clean!
>
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):
----
(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] = '@';
--
Martin Schlemmer
[-- Attachment #2: This is a digitally signed message part --]
[-- Type: application/pgp-signature, Size: 189 bytes --]
^ permalink raw reply [flat|nested] 16+ messages in thread
* Re: [patch] fixup GECOS handling
2005-04-22 19:06 ` Martin Schlemmer
@ 2005-04-22 20:46 ` Kyle Hayes
2005-04-23 23:38 ` Petr Baudis
1 sibling, 0 replies; 16+ messages in thread
From: Kyle Hayes @ 2005-04-22 20:46 UTC (permalink / raw)
To: azarah; +Cc: Petr Baudis, GIT Mailing Lists
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
> ----
> (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.
^ permalink raw reply [flat|nested] 16+ messages in thread
* Re: [patch] fixup GECOS handling
2005-04-22 16:16 ` Kyle Hayes
2005-04-22 16:58 ` Martin Schlemmer
@ 2005-04-22 23:30 ` Andy Isaacson
2005-04-25 17:02 ` Kyle Hayes
1 sibling, 1 reply; 16+ messages in thread
From: Andy Isaacson @ 2005-04-22 23:30 UTC (permalink / raw)
To: Kyle Hayes; +Cc: azarah, git
On Fri, Apr 22, 2005 at 09:16:39AM -0700, Kyle Hayes wrote:
> if(comma)
> if(semi)
> /* lastname, firstname; room #; phone # format */
> *semi = 0;
> else
> *comma = 0;
> else if(semi)
> *semi = 0;
That's a really complicated way of writing
if(semi) *semi = 0;
else if(comma) *comma = 0;
(The two code fragments are precisely identical. Mmmm, strength
reduction.)
-andy
^ permalink raw reply [flat|nested] 16+ messages in thread
* Re: [patch] fixup GECOS handling
2005-04-22 19:06 ` Martin Schlemmer
2005-04-22 20:46 ` Kyle Hayes
@ 2005-04-23 23:38 ` Petr Baudis
2005-04-23 23:49 ` Martin Schlemmer
1 sibling, 1 reply; 16+ messages in thread
From: Petr Baudis @ 2005-04-23 23:38 UTC (permalink / raw)
To: Martin Schlemmer; +Cc: kyle, GIT Mailing Lists
Dear diary, on Fri, Apr 22, 2005 at 09:06:43PM CEST, I got a letter
where Martin Schlemmer <azarah@nosferatu.za.org> told me that...
> @@ -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] = '@';
I'm confused, what does this has to do with AIX? Do we even have / can
expect to have any major AIX users?
I'm not too happy with this, I have to say. It seems it won't do always
the right thing anyway. I would still favour the approach when you cut
off everything after ';', and everything after ',' if no ';' is found.
Seems simplest, safest, etc.
Tell me about anyone who has a semicolon in his realname.
--
Petr "Pasky" Baudis
Stuff: http://pasky.or.cz/
C++: an octopus made by nailing extra legs onto a dog. -- Steve Taylor
^ permalink raw reply [flat|nested] 16+ messages in thread
* Re: [patch] fixup GECOS handling
2005-04-23 23:38 ` Petr Baudis
@ 2005-04-23 23:49 ` Martin Schlemmer
0 siblings, 0 replies; 16+ messages in thread
From: Martin Schlemmer @ 2005-04-23 23:49 UTC (permalink / raw)
To: Petr Baudis; +Cc: kyle, GIT Mailing Lists
[-- Attachment #1: Type: text/plain, Size: 1681 bytes --]
On Sun, 2005-04-24 at 01:38 +0200, Petr Baudis wrote:
> Dear diary, on Fri, Apr 22, 2005 at 09:06:43PM CEST, I got a letter
> where Martin Schlemmer <azarah@nosferatu.za.org> told me that...
> > @@ -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] = '@';
>
> I'm confused, what does this has to do with AIX? Do we even have / can
> expect to have any major AIX users?
>
Given.
> I'm not too happy with this, I have to say. It seems it won't do always
> the right thing anyway. I would still favour the approach when you cut
> off everything after ';', and everything after ',' if no ';' is found.
> Seems simplest, safest, etc.
>
> Tell me about anyone who has a semicolon in his realname.
>
Point I guess is still that the only valid delimiter on linux is ',',
and the only reason for the ';' was because of some aix/whatever user
saying that is a delimiter as well. But like I said: cat $this
> /dev/null ... This is basically the same type of discussion as the
hash collision one, and I'm sure we all have better things to do.
Thanks,
--
Martin Schlemmer
[-- Attachment #2: This is a digitally signed message part --]
[-- Type: application/pgp-signature, Size: 189 bytes --]
^ permalink raw reply [flat|nested] 16+ messages in thread
* Re: [patch] fixup GECOS handling
2005-04-22 23:30 ` Andy Isaacson
@ 2005-04-25 17:02 ` Kyle Hayes
0 siblings, 0 replies; 16+ messages in thread
From: Kyle Hayes @ 2005-04-25 17:02 UTC (permalink / raw)
To: Andy Isaacson; +Cc: azarah, git
On Fri, 2005-04-22 at 16:30 -0700, Andy Isaacson wrote:
> On Fri, Apr 22, 2005 at 09:16:39AM -0700, Kyle Hayes wrote:
> > if(comma)
> > if(semi)
> > /* lastname, firstname; room #; phone # format */
> > *semi = 0;
> > else
> > *comma = 0;
> > else if(semi)
> > *semi = 0;
>
> That's a really complicated way of writing
>
> if(semi) *semi = 0;
> else if(comma) *comma = 0;
>
> (The two code fragments are precisely identical. Mmmm, strength
> reduction.)
Indeed :-)
As someone else noted, this was too complex. As another person noted,
this (like the SHA1 thread) has been thrashed around more than enough.
Best,
Kyle
--
Kyle Hayes <kyle@marchex.com>
Marchex Inc.
^ permalink raw reply [flat|nested] 16+ messages in thread
end of thread, other threads:[~2005-04-25 16:57 UTC | newest]
Thread overview: 16+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2005-04-18 10:36 [patch] fixup GECOS handling Martin Schlemmer
2005-04-18 12:35 ` David Woodhouse
2005-04-18 12:58 ` Martin Schlemmer
2005-04-22 14:23 ` Martin Schlemmer
2005-04-22 16:16 ` Kyle Hayes
2005-04-22 16:58 ` Martin Schlemmer
2005-04-22 17:18 ` Petr Baudis
2005-04-22 17:25 ` Martin Schlemmer
2005-04-22 17:58 ` Kyle Hayes
2005-04-22 19:06 ` Martin Schlemmer
2005-04-22 20:46 ` Kyle Hayes
2005-04-23 23:38 ` Petr Baudis
2005-04-23 23:49 ` Martin Schlemmer
2005-04-22 17:43 ` Kyle Hayes
2005-04-22 23:30 ` Andy Isaacson
2005-04-25 17:02 ` Kyle Hayes
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).