- for (i = 0; i <= path_len; i++) {
- char *this_i = &path_list[i];
- if (*this_i == ':') {
- /* ^::[^:] == \.: */
- if (!i && (*(this_i + 1) == ':')) {
- *this_i = '.';
- continue;
- }
- *this_i = 0;
- count++;
- /* ^:[^:] == \.0 and [^:]::[^:] == 0\.0 and [^:]:$ == 0\.0 */
- if (!i || (*(this_i + 1) == ':') || (i == path_len-1)) {
- new_list = xrealloc(new_list, path_len += 1);
- if (i) {
- memmove(&new_list[i+2], &path_list[i+1], path_len-i);
- new_list[i+1] = '.';
- memmove(new_list, path_list, i);
- } else {
- memmove(&new_list[i+1], &path_list[i], path_len-i);
- new_list[i] = '.';
- }
- path_list = new_list;
- }
- }
- }
- } else {
- path_list = "/bin\0/sbin\0/usr/bin\0/usr/sbin\0/usr/local/bin";
- count = 5;
- }
+int which_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE;
+int which_main(int argc UNUSED_PARAM, char **argv)
+{
+ const char *env_path;
+ int status = 0;