static char * cygwin_search_exe_in_path(struct ext_table * path, char * name) { char * p, * dir, * fullname; int i; for (p = name; *p != 0; p++) { if (*p == '/' || *p == '\\') goto not_found; } for (i = 0; i < path->size; i++) { dir = path->contents[i]; if (dir[0] == 0) dir = "."; /* empty path component = current dir */ fullname = caml_strconcat(3, dir, "/", name); if (cygwin_file_exists(fullname)) return fullname; caml_stat_free(fullname); fullname = caml_strconcat(4, dir, "/", name, ".exe"); if (cygwin_file_exists(fullname)) return fullname; caml_stat_free(fullname); } not_found: if (cygwin_file_exists(name)) return caml_strdup(name); fullname = caml_strconcat(2, name, ".exe"); if (cygwin_file_exists(fullname)) return fullname; caml_stat_free(fullname); return caml_strdup(name); }
static char * cygwin_search_exe_in_path(struct ext_table * path, char * name) { char * p, * fullname; int i; for (p = name; *p != 0; p++) { if (*p == '/' || *p == '\\') goto not_found; } for (i = 0; i < path->size; i++) { fullname = caml_stat_alloc(strlen((char *)(path->contents[i])) + strlen(name) + 6); strcpy(fullname, (char *)(path->contents[i])); strcat(fullname, "/"); strcat(fullname, name); if (cygwin_file_exists(fullname)) return fullname; strcat(fullname, ".exe"); if (cygwin_file_exists(fullname)) return fullname; caml_stat_free(fullname); } not_found: fullname = caml_stat_alloc(strlen(name) + 5); strcpy(fullname, name); if (cygwin_file_exists(fullname)) return fullname; strcat(fullname, ".exe"); if (cygwin_file_exists(fullname)) return fullname; strcpy(fullname, name); return fullname; }