summaryrefslogtreecommitdiff
path: root/src/misc/getopt.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/misc/getopt.c')
-rw-r--r--src/misc/getopt.c4
1 files changed, 3 insertions, 1 deletions
diff --git a/src/misc/getopt.c b/src/misc/getopt.c
index 864d52cd..b02b81c3 100644
--- a/src/misc/getopt.c
+++ b/src/misc/getopt.c
@@ -1,3 +1,4 @@
+#define _BSD_SOURCE
#include <unistd.h>
#include <wchar.h>
#include <string.h>
@@ -86,7 +87,8 @@ int getopt(int argc, char * const argv[], const char *optstring)
if (optstring[i] == ':') {
optarg = 0;
if (optstring[i+1] != ':' || optpos) {
- optarg = argv[optind++] + optpos;
+ optarg = argv[optind++];
+ if (optpos) optarg += optpos;
optpos = 0;
}
if (optind > argc) {