* 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). */
| 111 | * in each block). |
| 112 | */ |
| 113 | static void |
| 114 | permute_args(int panonopt_start, int panonopt_end, int opt_end, |
| 115 | char * const *nargv) |
| 116 | { |
| 117 | int cstart, cyclelen, i, j, ncycle, nnonopts, nopts, pos; |
| 118 | char *swap; |
| 119 | |
| 120 | /* |
| 121 | * compute lengths of blocks and number and size of cycles |
| 122 | */ |
| 123 | nnonopts = panonopt_end - panonopt_start; |
| 124 | nopts = opt_end - panonopt_end; |
| 125 | ncycle = gcd(nnonopts, nopts); |
| 126 | cyclelen = (opt_end - panonopt_start) / ncycle; |
| 127 | |
| 128 | for (i = 0; i < ncycle; i++) { |
| 129 | cstart = panonopt_end+i; |
| 130 | pos = cstart; |
| 131 | for (j = 0; j < cyclelen; j++) { |
| 132 | if (pos >= panonopt_end) |
| 133 | pos -= nnonopts; |
| 134 | else |
| 135 | pos += nopts; |
| 136 | swap = nargv[pos]; |
| 137 | /* LINTED const cast */ |
| 138 | ((char **) nargv)[pos] = nargv[cstart]; |
| 139 | /* LINTED const cast */ |
| 140 | ((char **)nargv)[cstart] = swap; |
| 141 | } |
| 142 | } |
| 143 | } |
| 144 | |
| 145 | /* |
| 146 | * parse_long_options -- |
no test coverage detected