static void compute_merlinpath(char merlin_path[PATHSZ], const char *argv0, struct stat *st) { char argv0_dirname[PATHSZ]; size_t strsz; strcpy(argv0_dirname, argv0); prune_binary_name(argv0_dirname); // Check if we were called with a path or not if (strlen(argv0_dirname) == 0) { if (search_in_path(getenv("PATH"), argv0, merlin_path) == NULL) failwith("cannot resolve path to ocamlmerlin"); } else { #ifdef _WIN32 // GetFullPathName does not resolve symbolic links, which realpath does. // @@DRA GetLongPathName ensures that the file exists (better way?!). // Not sure if this matters. DWORD dwResult = GetFullPathName(argv0, PATHSZ, merlin_path, NULL); if (!dwResult || dwResult >= PATHSZ || !GetLongPathName(merlin_path, NULL, 0)) #else if (realpath(argv0, merlin_path) == NULL) #endif failwith("argv0 does not point to a valid file"); } prune_binary_name(merlin_path); strsz = strlen(merlin_path); // Append ocamlmerlin-server if (strsz + sizeof(ocamlmerlin_server) + 8 > PATHSZ) failwith("path is too long"); strcpy(merlin_path + strsz, ocamlmerlin_server); if (stat(merlin_path, st) != 0) { strcpy(merlin_path + strsz, "ocamlmerlin_server.exe"); if (stat(merlin_path, st) != 0) { strcpy(merlin_path + strsz, ocamlmerlin_server); failwith_perror("stat(ocamlmerlin-server, also tried ocamlmerlin_server.exe)"); } } }
static void on_search_click (void) { char buf[256]; //msgbox ("Seaching..."); Edit_GetText (GetDlgItem(hMainWindow, IDC_TXT), buf, sizeof(buf)); ListView_DeleteAllItems (hResult); text_set (""); Edit_SetText (GetDlgItem(hMainWindow, IDC_LFIND), ""); Button_Enable (GetDlgItem (hMainWindow, IDC_SAVELF), 0); Button_Enable (GetDlgItem (hMainWindow, IDC_SAVECRLF), 0); recent_current_reset (); get_options (); if (strlen(buf) > 0) { recent_add (buf); recent_fill_combo (IDC_RECENT); search_in_path (buf, CurrentPath, FileMask); } else { status_bar (1, "Empty search string!"); } }