summaryrefslogtreecommitdiff
path: root/libbb/getopt_allopts.c
blob: a67d2b70eb06528eae48b044aba12922d8ed4e54 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
/* vi: set sw=4 ts=4: */
/*
 * Copyright (C) 2017 Denys Vlasenko
 *
 * Licensed under GPLv2 or later, see file LICENSE in this source tree.
 */
#include "libbb.h"

//kbuild:lib-y += getopt_allopts.o

void FAST_FUNC make_all_argv_opts(char **argv)
{
	/* Note: we skip argv[0] */
	while (*++argv) {
		char *p;

		if (argv[0][0] == '-')
			continue;
		/* Neither top nor ps care if "" arg turns into "-" */
		/*if (argv[0][0] == '\0')
			continue;*/
		p = xmalloc(strlen(*argv) + 2);
		*p = '-';
		strcpy(p + 1, *argv);
		*argv = p;
	}
}