* 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). */
| 79 | * in each block). |
| 80 | */ |
| 81 | static void |
| 82 | permute_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 -- |
no test coverage detected