MCPcopy Create free account
hub / github.com/F-Stack/f-stack / permute_args

Function permute_args

dpdk/lib/eal/windows/getopt.c:81–111  ·  view source on GitHub ↗

* Exchange the block from nonopt_start to nonopt_end with the block * from nonopt_end to opt_end (keeping the same order of arguments * in each block). */

Source from the content-addressed store, hash-verified

79 * in each block).
80 */
81static void
82permute_args(int panonopt_start, int panonopt_end, int opt_end,
83 char **nargv)
84{
85 int cstart, cyclelen, i, j, ncycle, nnonopts, nopts, pos;
86 char *swap;
87
88 /*
89 * compute lengths of blocks and number and size of cycles
90 */
91 nnonopts = panonopt_end - panonopt_start;
92 nopts = opt_end - panonopt_end;
93 ncycle = gcd(nnonopts, nopts);
94 cyclelen = (opt_end - panonopt_start) / ncycle;
95
96 for (i = 0; i < ncycle; i++) {
97 cstart = panonopt_end+i;
98 pos = cstart;
99 for (j = 0; j < cyclelen; j++) {
100 if (pos >= panonopt_end)
101 pos -= nnonopts;
102 else
103 pos += nopts;
104 swap = nargv[pos];
105 /* LINTED const cast */
106 ((char **) nargv)[pos] = nargv[cstart];
107 /* LINTED const cast */
108 ((char **)nargv)[cstart] = swap;
109 }
110 }
111}
112
113/*
114 * parse_long_options --

Callers 1

getopt_internalFunction · 0.85

Calls 1

gcdFunction · 0.85

Tested by

no test coverage detected