summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorJim Meyering <meyering@redhat.com>2011-05-25 22:27:53 +0200
committerJim Meyering <meyering@redhat.com>2011-05-26 22:10:46 +0200
commit3f98fe3155b8f19431411370198102f30f00b45e (patch)
tree1b5ed91108302502a89726a93ed8cd4c012d2761 /src
parenta042bba6c7cfd8147d863927bfc9cc4d21852f43 (diff)
downloadcoreutils-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.c18
1 files changed, 11 insertions, 7 deletions
diff --git a/src/env.c b/src/env.c
index 1eb39a110..9f7a8528b 100644
--- a/src/env.c
+++ b/src/env.c
@@ -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)