comparison src/memline.c @ 16455:1ae13586edf8 v8.1.1232

patch 8.1.1232: can't build on MS-Windows commit https://github.com/vim/vim/commit/1b243eafb0bf21daaba01004c450cfd8fea70c66 Author: Bram Moolenaar <Bram@vim.org> Date: Sun Apr 28 22:50:40 2019 +0200 patch 8.1.1232: can't build on MS-Windows Problem: Can't build on MS-Windows. Solution: Define process_still_running.
author Bram Moolenaar <Bram@vim.org>
date Sun, 28 Apr 2019 23:00:05 +0200
parents 4e9bea9b8025
children 7ad3fc329e08
comparison
equal deleted inserted replaced
16454:a525b0447547 16455:1ae13586edf8
2025 } 2025 }
2026 return d; 2026 return d;
2027 } 2027 }
2028 #endif 2028 #endif
2029 2029
2030 #if (defined(UNIX) || defined(VMS)) && (defined(FEAT_GUI_DIALOG) || defined(FEAT_CON_DIALOG)) 2030 #if (defined(UNIX) || defined(VMS) || defined(MSWIN)) \
2031 && (defined(FEAT_GUI_DIALOG) || defined(FEAT_CON_DIALOG))
2032 # define HAVE_PROCESS_STILL_RUNNING
2031 static int process_still_running; 2033 static int process_still_running;
2032 #endif 2034 #endif
2033 2035
2034 #if defined(FEAT_EVAL) || defined(PROTO) 2036 #if defined(FEAT_EVAL) || defined(PROTO)
2035 /* 2037 /*
2158 if (char_to_long(b0.b0_pid) != 0L) 2160 if (char_to_long(b0.b0_pid) != 0L)
2159 { 2161 {
2160 msg_puts(_("\n process ID: ")); 2162 msg_puts(_("\n process ID: "));
2161 msg_outnum(char_to_long(b0.b0_pid)); 2163 msg_outnum(char_to_long(b0.b0_pid));
2162 #if defined(UNIX) || defined(MSWIN) 2164 #if defined(UNIX) || defined(MSWIN)
2163 if (mch_process_running((pid_t)char_to_long(b0.b0_pid))) 2165 if (mch_process_running(char_to_long(b0.b0_pid)))
2164 { 2166 {
2165 msg_puts(_(" (STILL RUNNING)")); 2167 msg_puts(_(" (STILL RUNNING)"));
2166 # if defined(FEAT_GUI_DIALOG) || defined(FEAT_CON_DIALOG) 2168 # ifdef HAVE_PROCESS_STILL_RUNNING
2167 process_still_running = TRUE; 2169 process_still_running = TRUE;
2168 # endif 2170 # endif
2169 } 2171 }
2170 #endif 2172 #endif
2171 } 2173 }
2201 { 2203 {
2202 stat_T st; 2204 stat_T st;
2203 int fd; 2205 int fd;
2204 struct block0 b0; 2206 struct block0 b0;
2205 int ret = TRUE; 2207 int ret = TRUE;
2206 #ifdef UNIX 2208 #if defined(UNIX) || defined(MSWIN)
2207 long pid; 2209 long pid;
2208 #endif 2210 #endif
2209 2211
2210 // must be able to stat the swap file 2212 // must be able to stat the swap file
2211 if (mch_stat((char *)fname, &st) == -1) 2213 if (mch_stat((char *)fname, &st) == -1)
2230 ret = FALSE; 2232 ret = FALSE;
2231 2233
2232 #if defined(UNIX) || defined(MSWIN) 2234 #if defined(UNIX) || defined(MSWIN)
2233 // process must known and not be running 2235 // process must known and not be running
2234 pid = char_to_long(b0.b0_pid); 2236 pid = char_to_long(b0.b0_pid);
2235 if (pid == 0L || mch_process_running((pid_t)pid)) 2237 if (pid == 0L || mch_process_running(pid))
2236 ret = FALSE; 2238 ret = FALSE;
2237 #endif 2239 #endif
2238 2240
2239 // TODO: Should we check if the swap file was created on the current 2241 // TODO: Should we check if the swap file was created on the current
2240 // system? And the current user? 2242 // system? And the current user?
4823 mch_remove(buf_fname); 4825 mch_remove(buf_fname);
4824 did_use_dummy = TRUE; 4826 did_use_dummy = TRUE;
4825 } 4827 }
4826 #endif 4828 #endif
4827 4829
4828 #if (defined(UNIX) || defined(VMS)) && (defined(FEAT_GUI_DIALOG) || defined(FEAT_CON_DIALOG)) 4830 #ifdef HAVE_PROCESS_STILL_RUNNING
4829 process_still_running = FALSE; 4831 process_still_running = FALSE;
4830 #endif 4832 #endif
4831 // It's safe to delete the swap file if all these are true: 4833 // It's safe to delete the swap file if all these are true:
4832 // - the edited file exists 4834 // - the edited file exists
4833 // - the swap file has no changes and looks OK 4835 // - the swap file has no changes and looks OK
4891 choice = do_dialog(VIM_WARNING, 4893 choice = do_dialog(VIM_WARNING,
4892 (char_u *)_("VIM - ATTENTION"), 4894 (char_u *)_("VIM - ATTENTION"),
4893 name == NULL 4895 name == NULL
4894 ? (char_u *)_("Swap file already exists!") 4896 ? (char_u *)_("Swap file already exists!")
4895 : name, 4897 : name,
4896 # if defined(UNIX) || defined(VMS) 4898 # ifdef HAVE_PROCESS_STILL_RUNNING
4897 process_still_running 4899 process_still_running
4898 ? (char_u *)_("&Open Read-Only\n&Edit anyway\n&Recover\n&Quit\n&Abort") : 4900 ? (char_u *)_("&Open Read-Only\n&Edit anyway\n&Recover\n&Quit\n&Abort") :
4899 # endif 4901 # endif
4900 (char_u *)_("&Open Read-Only\n&Edit anyway\n&Recover\n&Delete it\n&Quit\n&Abort"), 1, NULL, FALSE); 4902 (char_u *)_("&Open Read-Only\n&Edit anyway\n&Recover\n&Delete it\n&Quit\n&Abort"), 1, NULL, FALSE);
4901 4903
4902 # if defined(UNIX) || defined(VMS) 4904 # ifdef HAVE_PROCESS_STILL_RUNNING
4903 if (process_still_running && choice >= 4) 4905 if (process_still_running && choice >= 4)
4904 choice++; /* Skip missing "Delete it" button */ 4906 choice++; /* Skip missing "Delete it" button */
4905 # endif 4907 # endif
4906 vim_free(name); 4908 vim_free(name);
4907 4909