Current-Users archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

Re: Some more setenv(3) update



In article <20101011221824.GA423910%medusa.sis.pasteur.fr@localhost>,
Nicolas Joly  <njoly%pasteur.fr@localhost> wrote:
>-=-=-=-=-=-
>
>
>Hi,
>
>Following the recent setenv(3) update, i made the attached patch which
>aims the following :
>
>- make it fails with EINVAL for bad name values, just like our
>  unsetenv(3); following the opengroup online function description.
>  http://www.opengroup.org/onlinepubs/009695399/functions/setenv.html
>  Likewise do reject NULL value.
>
>- Do not strip (anymore) a leading `=' in provided value, mostly to
>  give consistent results with putenv("var==val"). In both case getenv
>  now return `=val'.
>
>The patch do include the corresponding testcases, and an updated
>version of the man page.
>
>Comments ?

You could move the loop:

       for (cc = name; *cc && *cc != '='; ++cc)        /* no `=' in name */
               continue;

before the initial test, and then check for *cc instead of scanning the
name twice, once in strchr and a second time in strlen.

You can compute size as before:

       size = cc - name;

Unless people feel this makes the code so much less readable.

christos



Home | Main Index | Thread Index | Old Index