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. - To unsubscribe from this list: send the line "unsubscribe git" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.htmlReceived on Sat Apr 23 02:17:22 2005
This archive was generated by hypermail 2.1.8 : 2005-04-23 02:17:22 EST