{"thread":{"id":"99","subject":"[patch] fixup GECOS handling","startedAt":"2005-04-18T10:36:29Z","lastAt":"2005-04-25T17:02:17Z","messageCount":16,"participants":["Martin Schlemmer","David Woodhouse","Kyle Hayes","Petr Baudis","Andy Isaacson"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"641","messageId":"1113820589.16288.5.camel@nosferatu.lan","threadId":"99","inReplyTo":null,"subject":"[patch] fixup GECOS handling","fromName":"Martin Schlemmer","fromEmail":"azarah@nosferatu.za.org","sentAt":"2005-04-18T10:36:29Z","receivedAt":"2005-04-18T10:36:29Z","isPatch":true,"sender":{"key":"azarah@nosferatu.za.org","avatar":null},"body":"Hi,\n\nThe gecos is delimited by ',' or ';', so we should only use whatever\nbefore the first ',' or ';' for the full name, and not just strip those.\nAlso, a '.' may be valid in the full name (Foo B. Zooman) or email\n(foo.zooman@bar.com).\n\nSigned-off-by: Martin Schlemmer <azarah@gentoo.org>\n\ncommit-tree.c: ec53a4565ec0033aaf6df2a48d233ccf4823e8b0\n--- 1/commit-tree.c\n+++ 2/commit-tree.c     2005-04-18 12:22:18.000000000 +0200\n@@ -96,21 +96,6 @@\n                if (!c)\n                        break;\n        }\n-\n-       /*\n-        * Go back, and remove crud from the end: some people\n-        * have commas etc in their gecos field\n-        */\n-       dst--;\n-       while (--dst >= p) {\n-               unsigned char c = *dst;\n-               switch (c) {\n-               case ',': case ';': case '.':\n-                       *dst = 0;\n-                       continue;\n-               }\n-               break;\n-       }\n }\n\n static const char *month_names[] = {\n@@ -313,6 +298,11 @@\n        if (!pw)\n                die(\"You don't exist. Go away!\");\n        realgecos = pw->pw_gecos;\n+       /* The name is seperated from the room no., tel no, etc via [,;] */\n+       if (strchr(realgecos, ','))\n+               realgecos[strchr(realgecos, ',') - realgecos] = '\\0';\n+       else if (strchr(realgecos, ';'))\n+               realgecos[strchr(realgecos, ';') - realgecos] = '\\0';\n        len = strlen(pw->pw_name);\n        memcpy(realemail, pw->pw_name, len);\n        realemail[len] = '@';\n\n\n-- \nMartin Schlemmer\n\n\n\ncommit-tree.c: ec53a4565ec0033aaf6df2a48d233ccf4823e8b0\n--- 1/commit-tree.c\n+++ 2/commit-tree.c\t2005-04-18 12:22:18.000000000 +0200\n@@ -96,21 +96,6 @@\n \t\tif (!c)\n \t\t\tbreak;\n \t}\n-\n-\t/*\n-\t * Go back, and remove crud from the end: some people\n-\t * have commas etc in their gecos field\n-\t */\n-\tdst--;\n-\twhile (--dst >= p) {\n-\t\tunsigned char c = *dst;\n-\t\tswitch (c) {\n-\t\tcase ',': case ';': case '.':\n-\t\t\t*dst = 0;\n-\t\t\tcontinue;\n-\t\t}\n-\t\tbreak;\n-\t}\n }\n \n static const char *month_names[] = {\n@@ -313,6 +298,11 @@\n \tif (!pw)\n \t\tdie(\"You don't exist. Go away!\");\n \trealgecos = pw->pw_gecos;\n+\t/* The name is seperated from the room no., tel no, etc via ',' or ';' */\n+\tif (strchr(realgecos, ','))\n+\t\trealgecos[strchr(realgecos, ',') - realgecos] = '\\0';\n+\telse if (strchr(realgecos, ';'))\n+\t\trealgecos[strchr(realgecos, ';') - realgecos] = '\\0';\n \tlen = strlen(pw->pw_name);\n \tmemcpy(realemail, pw->pw_name, len);\n \trealemail[len] = '@';\n"},{"id":"653","messageId":"1113827713.5286.13.camel@localhost.localdomain","threadId":"99","inReplyTo":"1113820589.16288.5.camel@nosferatu.lan","subject":"Re: [patch] fixup GECOS handling","fromName":"David Woodhouse","fromEmail":"dwmw2@infradead.org","sentAt":"2005-04-18T12:35:12Z","receivedAt":"2005-04-18T12:35:12Z","isPatch":true,"sender":{"key":"dwmw2@infradead.org","avatar":"https://gravatar.com/avatar/7afd4f07e0cf7d7e046ae2d23678296b37777c96488e6f3451e78a5514154ebd?d=mp&s=160"},"body":"On Mon, 2005-04-18 at 12:36 +0200, Martin Schlemmer wrote:\n> realgecos[strchr(realgecos, ',') - realgecos] = '\\0';\n\nEr, *strchr(realgecos, ',') = 0; surely? Even if the compiler is clever\nenough to optimise out the gratuitous addition and subtraction, that's\nno real excuse for it.\n\n-- \ndwmw2\n\n"},{"id":"654","messageId":"1113829100.16288.26.camel@nosferatu.lan","threadId":"99","inReplyTo":"1113827713.5286.13.camel@localhost.localdomain","subject":"Re: [patch] fixup GECOS handling","fromName":"Martin Schlemmer","fromEmail":"azarah@nosferatu.za.org","sentAt":"2005-04-18T12:58:20Z","receivedAt":"2005-04-18T12:58:20Z","isPatch":true,"sender":{"key":"azarah@nosferatu.za.org","avatar":null},"body":"On Mon, 2005-04-18 at 22:35 +1000, David Woodhouse wrote:\n> On Mon, 2005-04-18 at 12:36 +0200, Martin Schlemmer wrote:\n> > realgecos[strchr(realgecos, ',') - realgecos] = '\\0';\n> \n> Er, *strchr(realgecos, ',') = 0; surely? Even if the compiler is clever\n> enough to optimise out the gratuitous addition and subtraction, that's\n> no real excuse for it.\n> \n\nErr, right.  Updated patch.\n\nThe gecos is delimited by ',' or ';', so we should only use whatever\nbefore the first ',' or ';' for the full name, and not just strip those.\n\nSigned-off-by: Martin Schlemmer <azarah@gentoo.org>\n\ncommit-tree.c: ec53a4565ec0033aaf6df2a48d233ccf4823e8b0\n--- 1/commit-tree.c\n+++ 2/commit-tree.c     2005-04-18 12:22:18.000000000 +0200\n@@ -96,21 +96,6 @@\n                if (!c)\n                        break;\n        }\n-\n-       /*\n-        * Go back, and remove crud from the end: some people\n-        * have commas etc in their gecos field\n-        */\n-       dst--;\n-       while (--dst >= p) {\n-               unsigned char c = *dst;\n-               switch (c) {\n-               case ',': case ';': case '.':\n-                       *dst = 0;\n-                       continue;\n-               }\n-               break;\n-       }\n }\n\n static const char *month_names[] = {\n@@ -313,6 +298,11 @@\n        if (!pw)\n                die(\"You don't exist. Go away!\");\n        realgecos = pw->pw_gecos;\n+       /* The name is seperated from the room no., tel no, etc via [,;] */\n+       if (strchr(realgecos, ','))\n+               *strchr(realgecos, ',') = 0;\n+       else if (strchr(realgecos, ';'))\n+               *strchr(realgecos, ';') = 0;\n        len = strlen(pw->pw_name);\n        memcpy(realemail, pw->pw_name, len);\n        realemail[len] = '@';\n\n\n-- \nMartin Schlemmer\n\n\n\ncommit-tree.c: ec53a4565ec0033aaf6df2a48d233ccf4823e8b0\n--- 1/commit-tree.c\n+++ 2/commit-tree.c\t2005-04-18 12:22:18.000000000 +0200\n@@ -96,21 +96,6 @@\n \t\tif (!c)\n \t\t\tbreak;\n \t}\n-\n-\t/*\n-\t * Go back, and remove crud from the end: some people\n-\t * have commas etc in their gecos field\n-\t */\n-\tdst--;\n-\twhile (--dst >= p) {\n-\t\tunsigned char c = *dst;\n-\t\tswitch (c) {\n-\t\tcase ',': case ';': case '.':\n-\t\t\t*dst = 0;\n-\t\t\tcontinue;\n-\t\t}\n-\t\tbreak;\n-\t}\n }\n \n static const char *month_names[] = {\n@@ -313,6 +298,11 @@\n \tif (!pw)\n \t\tdie(\"You don't exist. Go away!\");\n \trealgecos = pw->pw_gecos;\n+\t/* The name is seperated from the room no., tel no, etc via ',' or ';' */\n+\tif (strchr(realgecos, ','))\n+\t\t*strchr(realgecos, ',') = 0;\n+\telse if (strchr(realgecos, ';'))\n+\t\t*strchr(realgecos, ';') = 0;\n \tlen = strlen(pw->pw_name);\n \tmemcpy(realemail, pw->pw_name, len);\n \trealemail[len] = '@';\n"},{"id":"1274","messageId":"1114179795.29271.18.camel@nosferatu.lan","threadId":"99","inReplyTo":"1113827713.5286.13.camel@localhost.localdomain","subject":"[patch] fixup GECOS handling","fromName":"Martin Schlemmer","fromEmail":"azarah@nosferatu.za.org","sentAt":"2005-04-22T14:23:15Z","receivedAt":"2005-04-22T14:23:15Z","isPatch":true,"sender":{"key":"azarah@nosferatu.za.org","avatar":null},"body":"Hi,\n\nThis still applies - any reason for not doing this?\n\n\nThanks,\n\n----\n\nThe GECOS is delimited by ',' or ';', so we should only use whatever is\nbefore the first ',' or ';' for the full name, rather than just\nstripping those.\n\nSigned-off-by: Martin Schlemmer <azarah@gentoo.org>\n\ncommit-tree.c: ec53a4565ec0033aaf6df2a48d233ccf4823e8b0\n--- 1/commit-tree.c\n+++ 2/commit-tree.c     2005-04-18 12:22:18.000000000 +0200\n@@ -96,21 +96,6 @@\n                if (!c)\n                        break;\n        }\n-\n-       /*\n-        * Go back, and remove crud from the end: some people\n-        * have commas etc in their gecos field\n-        */\n-       dst--;\n-       while (--dst >= p) {\n-               unsigned char c = *dst;\n-               switch (c) {\n-               case ',': case ';': case '.':\n-                       *dst = 0;\n-                       continue;\n-               }\n-               break;\n-       }\n }\n\n static const char *month_names[] = {\n@@ -313,6 +298,11 @@\n        if (!pw)\n                die(\"You don't exist. Go away!\");\n        realgecos = pw->pw_gecos;\n+       /* The name is seperated from the room no., tel no, etc via [,;] */\n+       if (strchr(realgecos, ','))\n+               *strchr(realgecos, ',') = 0;\n+       else if (strchr(realgecos, ';'))\n+               *strchr(realgecos, ';') = 0;\n        len = strlen(pw->pw_name);\n        memcpy(realemail, pw->pw_name, len);\n        realemail[len] = '@';\n\n\n\n-- \nMartin Schlemmer\n\n\n\ncommit-tree.c: ec53a4565ec0033aaf6df2a48d233ccf4823e8b0\n--- 1/commit-tree.c\n+++ 2/commit-tree.c\t2005-04-18 12:22:18.000000000 +0200\n@@ -96,21 +96,6 @@\n \t\tif (!c)\n \t\t\tbreak;\n \t}\n-\n-\t/*\n-\t * Go back, and remove crud from the end: some people\n-\t * have commas etc in their gecos field\n-\t */\n-\tdst--;\n-\twhile (--dst >= p) {\n-\t\tunsigned char c = *dst;\n-\t\tswitch (c) {\n-\t\tcase ',': case ';': case '.':\n-\t\t\t*dst = 0;\n-\t\t\tcontinue;\n-\t\t}\n-\t\tbreak;\n-\t}\n }\n \n static const char *month_names[] = {\n@@ -313,6 +298,11 @@\n \tif (!pw)\n \t\tdie(\"You don't exist. Go away!\");\n \trealgecos = pw->pw_gecos;\n+\t/* The name is seperated from the room no., tel no, etc via ',' or ';' */\n+\tif (strchr(realgecos, ','))\n+\t\t*strchr(realgecos, ',') = 0;\n+\telse if (strchr(realgecos, ';'))\n+\t\t*strchr(realgecos, ';') = 0;\n \tlen = strlen(pw->pw_name);\n \tmemcpy(realemail, pw->pw_name, len);\n \trealemail[len] = '@';\n"},{"id":"1289","messageId":"1114186599.31076.409.camel@axer.marchex.com","threadId":"99","inReplyTo":"1114179795.29271.18.camel@nosferatu.lan","subject":"Re: [patch] fixup GECOS handling","fromName":"Kyle Hayes","fromEmail":"kyle@marchex.com","sentAt":"2005-04-22T16:16:39Z","receivedAt":"2005-04-22T16:16:39Z","isPatch":true,"sender":{"key":"kyle@marchex.com","avatar":null},"body":"On Fri, 2005-04-22 at 16:23 +0200, Martin Schlemmer wrote:\n> Hi,\n> \n> This still applies - any reason for not doing this?\n\nSeems like this will break on certain kinds of data.  See below.\n\n>         if (!pw)\n>                 die(\"You don't exist. Go away!\");\n>         realgecos = pw->pw_gecos;\n> +       /* The name is seperated from the room no., tel no, etc via [,;] */\n> +       if (strchr(realgecos, ','))\n> +               *strchr(realgecos, ',') = 0;\n> +       else if (strchr(realgecos, ';'))\n> +               *strchr(realgecos, ';') = 0;\n>         len = strlen(pw->pw_name);\n>         memcpy(realemail, pw->pw_name, len);\n>         realemail[len] = '@';\n\nSuppose that the GECOS field is:\n\nHayes, Kyle; Room 42; 424-424-4242; foo bar baz...\n\nYou'll search for the first comma, find it, truncate my name to \"Hayes\",\nand continue.\n\nI have seen this kind of GECOS in larger environments where the\nindividual users are not the ones that administrate their machines.\nUsing the LastName, FirstName style of name is not rare. \n\nI think you want something like this (not tested):\n\nchar *comma,*semi;\n\ncomma = strchr(realgecos,',');\nsemi  = strchr(realgecos,';');\n\nif(comma)\n\tif(semi)\n\t\t/* lastname, firstname; room #; phone # format */\n\t\t*semi  = 0;\n\telse\n\t\t*comma = 0;\nelse if(semi)\n\t*semi = 0;\n\n(hopefully Evolution won't trash the indentation...)\n\nBest,\nKyle\n\n-- \nKyle Hayes <kyle@marchex.com>\nMarchex Inc.\n\n"},{"id":"1294","messageId":"1114189105.29271.36.camel@nosferatu.lan","threadId":"99","inReplyTo":"1114186599.31076.409.camel@axer.marchex.com","subject":"Re: [patch] fixup GECOS handling","fromName":"Martin Schlemmer","fromEmail":"azarah@nosferatu.za.org","sentAt":"2005-04-22T16:58:25Z","receivedAt":"2005-04-22T16:58:25Z","isPatch":true,"sender":{"key":"azarah@nosferatu.za.org","avatar":null},"body":"On Fri, 2005-04-22 at 09:16 -0700, Kyle Hayes wrote:\n> On Fri, 2005-04-22 at 16:23 +0200, Martin Schlemmer wrote:\n> > Hi,\n> > \n> > This still applies - any reason for not doing this?\n> \n> Seems like this will break on certain kinds of data.  See below.\n> \n> >         if (!pw)\n> >                 die(\"You don't exist. Go away!\");\n> >         realgecos = pw->pw_gecos;\n> > +       /* The name is seperated from the room no., tel no, etc via [,;] */\n> > +       if (strchr(realgecos, ','))\n> > +               *strchr(realgecos, ',') = 0;\n> > +       else if (strchr(realgecos, ';'))\n> > +               *strchr(realgecos, ';') = 0;\n> >         len = strlen(pw->pw_name);\n> >         memcpy(realemail, pw->pw_name, len);\n> >         realemail[len] = '@';\n> \n> Suppose that the GECOS field is:\n> \n> Hayes, Kyle; Room 42; 424-424-4242; foo bar baz...\n> \n> You'll search for the first comma, find it, truncate my name to \"Hayes\",\n> and continue.\n> \n> I have seen this kind of GECOS in larger environments where the\n> individual users are not the ones that administrate their machines.\n> Using the LastName, FirstName style of name is not rare. \n> \n\nWhat OS?  With Linux at least, this is what chfn's manpage say:\n\n----\n       The only restriction placed on the contents of the fields is that no control characters may  be  present,\n       nor  any  of  comma, colon, or equal sign. The other field does not have this restriction, and is used to\n       store accounting information used by other applications.\n----\n\nMeaning, if they use a ',' in one of the fields (and it is a linux\nsystem with the chfn most probably from the shadow package), then they\nare looking for trouble.  The only reason I added the ';' was because\nsomebody said whatever OS used it instead of a ','.\n\n\nThanks,\n\n-- \nMartin Schlemmer\n\n"},{"id":"1296","messageId":"20050422171818.GE7173@pasky.ji.cz","threadId":"99","inReplyTo":"1114189105.29271.36.camel@nosferatu.lan","subject":"Re: [patch] fixup GECOS handling","fromName":"Petr Baudis","fromEmail":"pasky@ucw.cz","sentAt":"2005-04-22T17:18:18Z","receivedAt":"2005-04-22T17:18:18Z","isPatch":true,"sender":{"key":"pasky@ucw.cz","avatar":"https://avatars.githubusercontent.com/u/18439?v=4"},"body":"Dear diary, on Fri, Apr 22, 2005 at 06:58:25PM CEST, I got a letter\nwhere Martin Schlemmer <azarah@nosferatu.za.org> told me that...\n> Meaning, if they use a ',' in one of the fields (and it is a linux\n> system with the chfn most probably from the shadow package), then they\n> are looking for trouble.  The only reason I added the ';' was because\n> somebody said whatever OS used it instead of a ','.\n\nWhat about just swapping the two tests so that ; is cut off and , only\nwhen no ; is around?\n\n-- \n\t\t\t\tPetr \"Pasky\" Baudis\nStuff: http://pasky.or.cz/\nC++: an octopus made by nailing extra legs onto a dog. -- Steve Taylor\n"},{"id":"1297","messageId":"1114190745.29271.39.camel@nosferatu.lan","threadId":"99","inReplyTo":"20050422171818.GE7173@pasky.ji.cz","subject":"Re: [patch] fixup GECOS handling","fromName":"Martin Schlemmer","fromEmail":"azarah@nosferatu.za.org","sentAt":"2005-04-22T17:25:45Z","receivedAt":"2005-04-22T17:25:45Z","isPatch":true,"sender":{"key":"azarah@nosferatu.za.org","avatar":null},"body":"On Fri, 2005-04-22 at 19:18 +0200, Petr Baudis wrote:\n> Dear diary, on Fri, Apr 22, 2005 at 06:58:25PM CEST, I got a letter\n> where Martin Schlemmer <azarah@nosferatu.za.org> told me that...\n> > Meaning, if they use a ',' in one of the fields (and it is a linux\n> > system with the chfn most probably from the shadow package), then they\n> > are looking for trouble.  The only reason I added the ';' was because\n> > somebody said whatever OS used it instead of a ','.\n> \n> What about just swapping the two tests so that ; is cut off and , only\n> when no ; is around?\n> \n\nActually, maybe just leave it.  Its not a train smash, and in theory on\nlinux ';' is a valid char in the gecos.\n\n\n-- \nMartin Schlemmer\n\n"},{"id":"1299","messageId":"1114191830.31076.426.camel@axer.marchex.com","threadId":"99","inReplyTo":"1114189105.29271.36.camel@nosferatu.lan","subject":"Re: [patch] fixup GECOS handling","fromName":"Kyle Hayes","fromEmail":"kyle@marchex.com","sentAt":"2005-04-22T17:43:50Z","receivedAt":"2005-04-22T17:43:50Z","isPatch":true,"sender":{"key":"kyle@marchex.com","avatar":null},"body":"On Fri, 2005-04-22 at 18:58 +0200, Martin Schlemmer wrote:\n> On Fri, 2005-04-22 at 09:16 -0700, Kyle Hayes wrote:\n> > Suppose that the GECOS field is:\n> > \n> > Hayes, Kyle; Room 42; 424-424-4242; foo bar baz...\n> > \n> > You'll search for the first comma, find it, truncate my name to \"Hayes\",\n> > and continue.\n> > \n> > I have seen this kind of GECOS in larger environments where the\n> > individual users are not the ones that administrate their machines.\n> > Using the LastName, FirstName style of name is not rare. \n> > \n> \n> What OS?  With Linux at least, this is what chfn's manpage say:\n\nCan't remember, it's been a while (years).  We had AIX, Solaris, Linux\nand BSD machines at the time.  Might have been AIX, I think.  The memory\nof which OS is vague, but not the annoyance of finding the problem :-(\n\n> ----\n>        The only restriction placed on the contents of the fields is that no control characters may  be  present,\n>        nor  any  of  comma, colon, or equal sign. The other field does not have this restriction, and is used to\n>        store accounting information used by other applications.\n> ----\n> \n> Meaning, if they use a ',' in one of the fields (and it is a linux\n> system with the chfn most probably from the shadow package), then they\n> are looking for trouble.  The only reason I added the ';' was because\n> somebody said whatever OS used it instead of a ','.\n\n>From the AIX version of chfn:\n\n----\nYou can use any printable characters in the gecos information string\nexcept a : (colon), which is an attribute delimiter.\n----\n\nThe AIX examples show use of semicolon as a separator.\n\nSo, at least on AIX, it is appears valid to use the style I showed\nabove.  I don't have access to Solaris machines right now.  The BSD\n(FreeBSD 4.11) version of man 5 passwd:\n\n----\nThe gecos field normally contains comma (`,') separated subfields as\nfollows:...\n----\n\nBest,\nKyle\n\n-- \nKyle Hayes <kyle@marchex.com>\nMarchex Inc.\n\n"},{"id":"1301","messageId":"1114192702.31076.428.camel@axer.marchex.com","threadId":"99","inReplyTo":"20050422171818.GE7173@pasky.ji.cz","subject":"Re: [patch] fixup GECOS handling","fromName":"Kyle Hayes","fromEmail":"kyle@marchex.com","sentAt":"2005-04-22T17:58:22Z","receivedAt":"2005-04-22T17:58:22Z","isPatch":true,"sender":{"key":"kyle@marchex.com","avatar":null},"body":"On Fri, 2005-04-22 at 19:18 +0200, Petr Baudis wrote:\n> Dear diary, on Fri, Apr 22, 2005 at 06:58:25PM CEST, I got a letter\n> where Martin Schlemmer <azarah@nosferatu.za.org> told me that...\n> > Meaning, if they use a ',' in one of the fields (and it is a linux\n> > system with the chfn most probably from the shadow package), then they\n> > are looking for trouble.  The only reason I added the ';' was because\n> > somebody said whatever OS used it instead of a ','.\n> \n> What about just swapping the two tests so that ; is cut off and , only\n> when no ; is around?\n\nEven nicer.  I like it.  Very clean!\n\nBest,\nKyle\n\n-- \nKyle Hayes <kyle@marchex.com>\nMarchex Inc.\n\n"},{"id":"1310","messageId":"1114196803.29271.52.camel@nosferatu.lan","threadId":"99","inReplyTo":"1114192702.31076.428.camel@axer.marchex.com","subject":"Re: [patch] fixup GECOS handling","fromName":"Martin Schlemmer","fromEmail":"azarah@nosferatu.za.org","sentAt":"2005-04-22T19:06:43Z","receivedAt":"2005-04-22T19:06:43Z","isPatch":true,"sender":{"key":"azarah@nosferatu.za.org","avatar":null},"body":"On Fri, 2005-04-22 at 10:58 -0700, Kyle Hayes wrote:\n> On Fri, 2005-04-22 at 19:18 +0200, Petr Baudis wrote:\n> > Dear diary, on Fri, Apr 22, 2005 at 06:58:25PM CEST, I got a letter\n> > where Martin Schlemmer <azarah@nosferatu.za.org> told me that...\n> > > Meaning, if they use a ',' in one of the fields (and it is a linux\n> > > system with the chfn most probably from the shadow package), then they\n> > > are looking for trouble.  The only reason I added the ';' was because\n> > > somebody said whatever OS used it instead of a ','.\n> > \n> > What about just swapping the two tests so that ; is cut off and , only\n> > when no ; is around?\n> \n> Even nicer.  I like it.  Very clean!\n> \n\nRight, but ';' is not cutoff on linux for one, and from what you said\nfreebsd as well.  How about this rather (note that I assumed that the\nuse of ';' as delimiter will be in the minority, but we can switch\nthings around if it turns out the other way):\n\n----\n(not signed off, etc, as just for comments)\n\nIndex: commit-tree.c\n===================================================================\n--- 5f61aecb06c2f2579bbb5951b1b53e0dedc434eb/commit-tree.c  (mode:100644 sha1:c0b07f89286c3f6cceae8122b4c3142c8efaf8e1)\n+++ uncommitted/commit-tree.c  (mode:100644)\n@@ -96,21 +96,6 @@\n                if (!c)\n                        break;\n        }\n-\n-       /*\n-        * Go back, and remove crud from the end: some people\n-        * have commas etc in their gecos field\n-        */\n-       dst--;\n-       while (--dst >= p) {\n-               unsigned char c = *dst;\n-               switch (c) {\n-               case ',': case ';': case '.':\n-                       *dst = 0;\n-                       continue;\n-               }\n-               break;\n-       }\n }\n\n static const char *month_names[] = {\n@@ -311,6 +296,17 @@\n        if (!pw)\n                die(\"You don't exist. Go away!\");\n        realgecos = pw->pw_gecos;\n+       /*\n+        * The GECOS fields are seperated via ',' on Linux, FreeBSD, etc,\n+        * and ';' on AIX.\n+        */\n+#if defined(__aix__)\n+       if (strchr(realgecos, ';'))\n+               *strchr(realgecos, ';') = 0;\n+#else\n+       if (strchr(realgecos, ','))\n+               *strchr(realgecos, ',') = 0;\n+#endif\n        len = strlen(pw->pw_name);\n        memcpy(realemail, pw->pw_name, len);\n        realemail[len] = '@';\n\n\n-- \nMartin Schlemmer\n\n"},{"id":"1321","messageId":"1114202815.31076.444.camel@axer.marchex.com","threadId":"99","inReplyTo":"1114196803.29271.52.camel@nosferatu.lan","subject":"Re: [patch] fixup GECOS handling","fromName":"Kyle Hayes","fromEmail":"kyle@marchex.com","sentAt":"2005-04-22T20:46:55Z","receivedAt":"2005-04-22T20:46:55Z","isPatch":true,"sender":{"key":"kyle@marchex.com","avatar":null},"body":"On Fri, 2005-04-22 at 21:06 +0200, Martin Schlemmer wrote:\n> Right, but ';' is not cutoff on linux for one, and from what you said\n> freebsd as well.  How about this rather (note that I assumed that the\n> use of ';' as delimiter will be in the minority, but we can switch\n> things around if it turns out the other way):\n\nI'm not sure that __aix__ is defined, but it is close enough.  Someone\nwith an AIX compiler can correct it if needed.  Anyone know about HP-UX\nand Tru64 and all those other ones?\n\nNote that the original code also cuts on '.'.  Is that used by some *nix\nin GECOS?\n\nBest,\nKyle\n\n> ----\n> (not signed off, etc, as just for comments)\n> \n> Index: commit-tree.c\n> ===================================================================\n> --- 5f61aecb06c2f2579bbb5951b1b53e0dedc434eb/commit-tree.c  (mode:100644 sha1:c0b07f89286c3f6cceae8122b4c3142c8efaf8e1)\n> +++ uncommitted/commit-tree.c  (mode:100644)\n> @@ -96,21 +96,6 @@\n>                 if (!c)\n>                         break;\n>         }\n> -\n> -       /*\n> -        * Go back, and remove crud from the end: some people\n> -        * have commas etc in their gecos field\n> -        */\n> -       dst--;\n> -       while (--dst >= p) {\n> -               unsigned char c = *dst;\n> -               switch (c) {\n> -               case ',': case ';': case '.':\n> -                       *dst = 0;\n> -                       continue;\n> -               }\n> -               break;\n> -       }\n>  }\n> \n>  static const char *month_names[] = {\n> @@ -311,6 +296,17 @@\n>         if (!pw)\n>                 die(\"You don't exist. Go away!\");\n>         realgecos = pw->pw_gecos;\n> +       /*\n> +        * The GECOS fields are seperated via ',' on Linux, FreeBSD, etc,\n> +        * and ';' on AIX.\n> +        */\n> +#if defined(__aix__)\n> +       if (strchr(realgecos, ';'))\n> +               *strchr(realgecos, ';') = 0;\n> +#else\n> +       if (strchr(realgecos, ','))\n> +               *strchr(realgecos, ',') = 0;\n> +#endif\n>         len = strlen(pw->pw_name);\n>         memcpy(realemail, pw->pw_name, len);\n>         realemail[len] = '@';\n> \n> \n-- \nKyle Hayes <kyle@marchex.com>\nMarchex Inc.\n\n"},{"id":"1356","messageId":"20050422233012.GA27638@hexapodia.org","threadId":"99","inReplyTo":"1114186599.31076.409.camel@axer.marchex.com","subject":"Re: [patch] fixup GECOS handling","fromName":"Andy Isaacson","fromEmail":"adi@hexapodia.org","sentAt":"2005-04-22T23:30:12Z","receivedAt":"2005-04-22T23:30:12Z","isPatch":true,"sender":{"key":"adi@hexapodia.org","avatar":null},"body":"On Fri, Apr 22, 2005 at 09:16:39AM -0700, Kyle Hayes wrote:\n> if(comma)\n> \tif(semi)\n> \t\t/* lastname, firstname; room #; phone # format */\n> \t\t*semi  = 0;\n> \telse\n> \t\t*comma = 0;\n> else if(semi)\n> \t*semi = 0;\n\nThat's a really complicated way of writing\n\nif(semi) *semi = 0;\nelse if(comma) *comma = 0;\n\n(The two code fragments are precisely identical.  Mmmm, strength\nreduction.)\n\n-andy\n"},{"id":"1433","messageId":"20050423233821.GN13222@pasky.ji.cz","threadId":"99","inReplyTo":"1114196803.29271.52.camel@nosferatu.lan","subject":"Re: [patch] fixup GECOS handling","fromName":"Petr Baudis","fromEmail":"pasky@ucw.cz","sentAt":"2005-04-23T23:38:21Z","receivedAt":"2005-04-23T23:38:21Z","isPatch":true,"sender":{"key":"pasky@ucw.cz","avatar":"https://avatars.githubusercontent.com/u/18439?v=4"},"body":"Dear diary, on Fri, Apr 22, 2005 at 09:06:43PM CEST, I got a letter\nwhere Martin Schlemmer <azarah@nosferatu.za.org> told me that...\n> @@ -311,6 +296,17 @@\n>         if (!pw)\n>                 die(\"You don't exist. Go away!\");\n>         realgecos = pw->pw_gecos;\n> +       /*\n> +        * The GECOS fields are seperated via ',' on Linux, FreeBSD, etc,\n> +        * and ';' on AIX.\n> +        */\n> +#if defined(__aix__)\n> +       if (strchr(realgecos, ';'))\n> +               *strchr(realgecos, ';') = 0;\n> +#else\n> +       if (strchr(realgecos, ','))\n> +               *strchr(realgecos, ',') = 0;\n> +#endif\n>         len = strlen(pw->pw_name);\n>         memcpy(realemail, pw->pw_name, len);\n>         realemail[len] = '@';\n\nI'm confused, what does this has to do with AIX? Do we even have / can\nexpect to have any major AIX users?\n\nI'm not too happy with this, I have to say. It seems it won't do always\nthe right thing anyway. I would still favour the approach when you cut\noff everything after ';', and everything after ',' if no ';' is found.\nSeems simplest, safest, etc.\n\nTell me about anyone who has a semicolon in his realname.\n\n-- \n\t\t\t\tPetr \"Pasky\" Baudis\nStuff: http://pasky.or.cz/\nC++: an octopus made by nailing extra legs onto a dog. -- Steve Taylor\n"},{"id":"1436","messageId":"1114300156.27940.22.camel@nosferatu.lan","threadId":"99","inReplyTo":"20050423233821.GN13222@pasky.ji.cz","subject":"Re: [patch] fixup GECOS handling","fromName":"Martin Schlemmer","fromEmail":"azarah@nosferatu.za.org","sentAt":"2005-04-23T23:49:16Z","receivedAt":"2005-04-23T23:49:16Z","isPatch":true,"sender":{"key":"azarah@nosferatu.za.org","avatar":null},"body":"On Sun, 2005-04-24 at 01:38 +0200, Petr Baudis wrote:\n> Dear diary, on Fri, Apr 22, 2005 at 09:06:43PM CEST, I got a letter\n> where Martin Schlemmer <azarah@nosferatu.za.org> told me that...\n> > @@ -311,6 +296,17 @@\n> >         if (!pw)\n> >                 die(\"You don't exist. Go away!\");\n> >         realgecos = pw->pw_gecos;\n> > +       /*\n> > +        * The GECOS fields are seperated via ',' on Linux, FreeBSD, etc,\n> > +        * and ';' on AIX.\n> > +        */\n> > +#if defined(__aix__)\n> > +       if (strchr(realgecos, ';'))\n> > +               *strchr(realgecos, ';') = 0;\n> > +#else\n> > +       if (strchr(realgecos, ','))\n> > +               *strchr(realgecos, ',') = 0;\n> > +#endif\n> >         len = strlen(pw->pw_name);\n> >         memcpy(realemail, pw->pw_name, len);\n> >         realemail[len] = '@';\n> \n> I'm confused, what does this has to do with AIX? Do we even have / can\n> expect to have any major AIX users?\n> \n\nGiven.\n\n> I'm not too happy with this, I have to say. It seems it won't do always\n> the right thing anyway. I would still favour the approach when you cut\n> off everything after ';', and everything after ',' if no ';' is found.\n> Seems simplest, safest, etc.\n> \n> Tell me about anyone who has a semicolon in his realname.\n> \n\nPoint I guess is still that the only valid delimiter on linux is ',',\nand the only reason for the ';' was because of some aix/whatever user\nsaying that is a delimiter as well. But like I said: cat $this\n> /dev/null ... This is basically the same type of discussion as the\nhash collision one, and I'm sure we all have better things to do.\n\n\nThanks,\n\n-- \nMartin Schlemmer\n\n"},{"id":"1620","messageId":"1114448538.13449.14.camel@axer.marchex.com","threadId":"99","inReplyTo":"20050422233012.GA27638@hexapodia.org","subject":"Re: [patch] fixup GECOS handling","fromName":"Kyle Hayes","fromEmail":"kyle@marchex.com","sentAt":"2005-04-25T17:02:17Z","receivedAt":"2005-04-25T17:02:17Z","isPatch":true,"sender":{"key":"kyle@marchex.com","avatar":null},"body":"On Fri, 2005-04-22 at 16:30 -0700, Andy Isaacson wrote:\n> On Fri, Apr 22, 2005 at 09:16:39AM -0700, Kyle Hayes wrote:\n> > if(comma)\n> > \tif(semi)\n> > \t\t/* lastname, firstname; room #; phone # format */\n> > \t\t*semi  = 0;\n> > \telse\n> > \t\t*comma = 0;\n> > else if(semi)\n> > \t*semi = 0;\n> \n> That's a really complicated way of writing\n> \n> if(semi) *semi = 0;\n> else if(comma) *comma = 0;\n> \n> (The two code fragments are precisely identical.  Mmmm, strength\n> reduction.)\n\nIndeed :-)\n\nAs someone else noted, this was too complex.  As another person noted,\nthis (like the SHA1 thread) has been thrashed around more than enough.\n\nBest,\nKyle\n\n-- \nKyle Hayes <kyle@marchex.com>\nMarchex Inc.\n\n"}]}