diff options
author | Jim Meyering <meyering@redhat.com> | 2011-05-25 22:27:53 +0200 |
---|---|---|
committer | Jim Meyering <meyering@redhat.com> | 2011-05-26 22:10:46 +0200 |
commit | 3f98fe3155b8f19431411370198102f30f00b45e (patch) | |
tree | 1b5ed91108302502a89726a93ed8cd4c012d2761 /src | |
parent | a042bba6c7cfd8147d863927bfc9cc4d21852f43 (diff) | |
download | coreutils-3f98fe3155b8f19431411370198102f30f00b45e.tar.xz |
maint: env.c: remove unnecessary use of strchr
* src/env.c (main): Remove excess (and confusing to static analyzers)
use of strchr.
Diffstat (limited to 'src')
-rw-r--r-- | src/env.c | 18 |
1 files changed, 11 insertions, 7 deletions
@@ -123,13 +123,17 @@ main (int argc, char **argv) if (optind < argc && STREQ (argv[optind], "-")) ++optind; - while (optind < argc && strchr (argv[optind], '=')) - if (putenv (argv[optind++])) - { - char *name = argv[optind - 1]; - *(strchr (name, '=')) = '\0'; - error (EXIT_CANCELED, errno, _("cannot set %s"), quote (name)); - } + char *eq; + while (optind < argc && (eq = strchr (argv[optind], '='))) + { + if (putenv (argv[optind])) + { + *eq = '\0'; + error (EXIT_CANCELED, errno, _("cannot set %s"), + quote (argv[optind])); + } + optind++; + } /* If no program is specified, print the environment and exit. */ if (argc <= optind) |