To: Victor Ott In-Reply-To: <3795F765.5E655101@frank.de> Subject: patch 5.4p.9 (was: gvim5.4p w32 install prob: entry in popup menu) Fcc: outbox From: Bram Moolenaar ------------ Victor Ott wrote: > Long filenames (win32 install.exe) and executables moving work perfectly, > thanks! > > But... when selecting "install an entry in the popup menu" the registry > entry looks like this: > C:\Programme\vim\vim54p\gvim.exe "" > > Problems: > 1. executables were moved to another directory _already in path_ ("c:\bin" > in my example) Indeed. Mostly the directory name should not be included, since gvim can be found in the path. Only when gvim isn't moved and isn't in $PATH the directory name should be used. > 2. the parameter is empty so the entry fails. > > Solution: > the registry entry should look like > gvim "%L" // long filenames > or > gvim "%1" // short filenames Ah, there was a single '%' in a printf. It must be doubled. Strange that the version compiled with Borland C++ didn't have this problem. I didn't know about using "%L" for a long filenames. "%1" gives a short filename for directories. Can we use "%L" on all Windows versions? Or does this perhaps not work on some? I'll stick to using "%1" until I'm sure "%L" works everywhere. Patch 5.4p.9 Problem: The windows install.exe created a wrong entry in the popup menu. The "%1" was "". The full directory was included, even when the executable had been moved elsewhere. (Ott) Solution: Double the '%' to get one from printf. Only include the path to gvim.exe when it wasn't moved and it's not in $PATH. Files: src/dosinst.c *** ../vim-5.4p/src/dosinst.c Mon Jul 19 11:09:00 1999 --- src/dosinst.c Wed Jul 21 21:04:09 1999 *************** *** 366,373 **** /* * Ask for directory from $PATH to move the .exe files to. */ ! void ! move_to_path(void) { char *path; char **names = NULL; --- 366,373 ---- /* * Ask for directory from $PATH to move the .exe files to. */ ! char * ! move_to_path(char *exedir) { char *path; char **names = NULL; *************** *** 379,385 **** if (path == NULL) { printf("ERROR: The variable $PATH is not set\n"); ! return; } /* --- 379,385 ---- if (path == NULL) { printf("ERROR: The variable $PATH is not set\n"); ! return exedir; } /* *************** *** 434,440 **** --- 434,443 ---- move_file("xxd.exe", names[idx]); move_file("ctags.exe", names[idx]); move_file("vimrun.exe", names[idx]); + exedir = ""; /* exe is now in path, don't need a dir */ } + + return exedir; /* return dir name where exe is */ } #define TABLE_SIZE(s) sizeof(s) / sizeof(char *) *************** *** 468,473 **** --- 471,477 ---- int exe; FILE *fd; char vimdir[BUFSIZE]; + char *exedir = ""; /* dir name where exe will be */ char vimrc[BUFSIZE]; int found_vimrc, skip_vimrc; int len; *************** *** 689,698 **** case 1: append_autoexec("set PATH=%%PATH%%;%s\n", vimdir); break; ! case 2: move_to_path(); break; case 3: printf("Skipping setting $PATH\n"); break; } } --- 693,703 ---- case 1: append_autoexec("set PATH=%%PATH%%;%s\n", vimdir); break; ! case 2: exedir = move_to_path(vimdir); break; case 3: printf("Skipping setting $PATH\n"); + exedir = vimdir; break; } } *************** *** 723,740 **** /* double the backslashes in the directory */ d = buf; ! for (s = vimdir; *s; ++s) { if (*s == '\\') *d++ = '\\'; *d++ = *s; } *d = 0; fprintf(fd, "REGEDIT4\n\n"); fprintf(fd, "[HKEY_CLASSES_ROOT\\*\\shell\\Vim]\n"); fprintf(fd, "@=\"Edit with &Vim\"\n\n"); fprintf(fd, "[HKEY_CLASSES_ROOT\\*\\shell\\Vim\\command]\n"); ! fprintf(fd, "@=\"%s\\\\gvim.exe \\\"%1\\\"\"\n", buf); fclose(fd); system("regedit vim.reg"); /* Can't delete the file, because regedit detaches itself, --- 728,751 ---- /* double the backslashes in the directory */ d = buf; ! for (s = exedir; *s; ++s) { if (*s == '\\') *d++ = '\\'; *d++ = *s; } + /* when dir is not empty, it must end in a double backslash */ + if (d > buf && d[-1] != '\\') + { + *d++ = '\\'; + *d++ = '\\'; + } *d = 0; fprintf(fd, "REGEDIT4\n\n"); fprintf(fd, "[HKEY_CLASSES_ROOT\\*\\shell\\Vim]\n"); fprintf(fd, "@=\"Edit with &Vim\"\n\n"); fprintf(fd, "[HKEY_CLASSES_ROOT\\*\\shell\\Vim\\command]\n"); ! fprintf(fd, "@=\"%sgvim.exe \\\"%%1\\\"\"\n", buf); fclose(fd); system("regedit vim.reg"); /* Can't delete the file, because regedit detaches itself, -- "You mean there really is an answer?" "Yes! But you're not going to like it!" "Oh do please tell us!" "You're really not going to like it!" "but we MUST know - tell us" "Alright, the answer is...." "yes..." "... is ..." "yes... come on!" "is 42!" (Douglas Adams - The Hitchhiker's Guide to the Galaxy) --/-/---- Bram Moolenaar ---- Bram@moolenaar.net ---- Bram@vim.org ---\-\-- \ \ www.vim.org/iccf www.moolenaar.net www.vim.org / /