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 <>,
Nicolas Joly  <> wrote:
>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.
>  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 */

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.


Home | Main Index | Thread Index | Old Index