From: otto Date: Sun, 17 Jul 2016 17:30:47 +0000 (+0000) Subject: getopt(3) can be called twice (once for bc and once for dc), so reinit getopt X-Git-Url: http://artulab.com/gitweb/?a=commitdiff_plain;h=070edbb260799146cd493880aa7d158c96718c12;p=openbsd getopt(3) can be called twice (once for bc and once for dc), so reinit getopt ok deraadt@ --- diff --git a/usr.bin/dc/dc.c b/usr.bin/dc/dc.c index 27afad516d2..38887007669 100644 --- a/usr.bin/dc/dc.c +++ b/usr.bin/dc/dc.c @@ -1,4 +1,4 @@ -/* $OpenBSD: dc.c,v 1.17 2015/11/03 04:58:58 mmcc Exp $ */ +/* $OpenBSD: dc.c,v 1.18 2016/07/17 17:30:47 otto Exp $ */ /* * Copyright (c) 2003, Otto Moerbeek @@ -50,6 +50,8 @@ dc_main(int argc, char *argv[]) if ((buf = strdup("")) == NULL) err(1, NULL); /* accept and ignore a single dash to be 4.4BSD dc(1) compatible */ + optind = 1; + optreset = 1; while ((ch = getopt(argc, argv, "e:x-")) != -1) { switch (ch) { case 'e':