Use getopt_long instead of getopt, for musl.

This commit is contained in:
Christopher Brannon 2015-06-20 03:18:45 -07:00
parent 00149d0f37
commit b1e6efeebe
4 changed files with 20 additions and 4 deletions

View File

@ -62,6 +62,7 @@
#define _BSD_SOURCE
# include <sys/wait.h>
#undef _BSD_SOURCE
#include <getopt.h>
#include <xbps.h>
@ -547,8 +548,11 @@ main(int argc, char **argv)
char *bpath, *rpath, *minit, *tmp, cwd[PATH_MAX-1];
size_t blen;
int ch;
const struct option longopts[] = {
{ NULL, 0, NULL, 0 }
};
while ((ch = getopt(argc, argv, "a:hj:l:v")) != -1) {
while ((ch = getopt_long(argc, argv, "a:hj:l:v", longopts, NULL)) != -1) {
switch (ch) {
case 'a':
TargetArch = optarg;

View File

@ -51,6 +51,7 @@
#include <limits.h> /* PATH_MAX */
#include <ftw.h>
#include <signal.h>
#include <getopt.h>
#include <xbps.h>
#include "queue.h"
@ -283,11 +284,14 @@ main(int argc, char **argv)
int c, clone_flags, child_status = 0;
pid_t child;
bool overlayfs = false;
const struct option longopts[] = {
{ NULL, 0, NULL, 0 }
};
tmpfs_opts = chrootdir = cmd = NULL;
argv0 = argv[0];
while ((c = getopt(argc, argv, "Oto:b:V")) != -1) {
while ((c = getopt_long(argc, argv, "Oto:b:V", longopts, NULL)) != -1) {
switch (c) {
case 'O':
overlayfs = true;

View File

@ -32,6 +32,7 @@
#include <ctype.h>
#include <assert.h>
#include <unistd.h>
#include <getopt.h>
#include <xbps.h>
#include "../xbps-install/defs.h"
@ -106,8 +107,11 @@ main(int argc, char **argv)
const char *version, *rootdir = NULL, *confdir = NULL;
char *pkgname, *hash, *filename;
int flags = 0, c, rv = 0;
const struct option longopts[] = {
{ NULL, 0, NULL, 0 }
};
while ((c = getopt(argc, argv, "C:dr:V")) != -1) {
while ((c = getopt_long(argc, argv, "C:dr:V", longopts, NULL)) != -1) {
switch (c) {
case 'C':
confdir = optarg;

View File

@ -40,6 +40,7 @@
#include <limits.h>
#include <syscall.h>
#include <assert.h>
#include <getopt.h>
#include <xbps.h>
#include "queue.h"
@ -128,11 +129,14 @@ main(int argc, char **argv)
const char *chrootdir, *cmd, *argv0;
char **cmdargs, buf[32];
int c, fd;
const struct option longopts[] = {
{ NULL, 0, NULL, 0 }
};
chrootdir = cmd = NULL;
argv0 = argv[0];
while ((c = getopt(argc, argv, "b:V")) != -1) {
while ((c = getopt_long(argc, argv, "b:V", longopts, NULL)) != -1) {
switch (c) {
case 'b':
if (optarg == NULL || *optarg == '\0')