Hi there This is a refactoring that gives some magic numbers some names.
-- Greetings Elias -- -- You received this message from the "vim_dev" maillist. Do not top-post! Type your reply below the text you are replying to. For more information, visit http://www.vim.org/maillist.php --- You received this message because you are subscribed to the Google Groups "vim_dev" group. To unsubscribe from this group and stop receiving emails from it, send an email to vim_dev+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out.
diff -r c7bcb04f613e src/memline.c --- a/src/memline.c Sat Dec 14 13:06:17 2013 +0100 +++ b/src/memline.c Sat Dec 14 20:10:37 2013 +0100 @@ -199,6 +199,14 @@ * When empty there is only the NUL. */ #define B0_HAS_FENC 8 +#define SWAPCHOICE_NONE 0 /* still need to ask for a choice */ +#define SWAPCHOICE_OPNRO 1 /* open read-only */ +#define SWAPCHOICE_EDIT 2 /* edit anyway */ +#define SWAPCHOICE_RECOV 3 /* recover */ +#define SWAPCHOICE_DEL 4 /* delete it */ +#define SWAPCHOICE_QUIT 5 /* quit */ +#define SWAPCHOICE_ABORT 6 /* abort */ + #define STACK_INCR 5 /* nr of entries added to ml_stack at a time */ /* @@ -4083,13 +4091,7 @@ /* * Trigger the SwapExists autocommands. * Returns a value for equivalent to do_dialog() (see below): - * 0: still need to ask for a choice - * 1: open read-only - * 2: edit anyway - * 3: recover - * 4: delete it - * 5: quit - * 6: abort + * See SWAPCHOICE_* for return values. */ static int do_swapexists(buf, fname) @@ -4109,15 +4111,15 @@ switch (*get_vim_var_str(VV_SWAPCHOICE)) { - case 'o': return 1; - case 'e': return 2; - case 'r': return 3; - case 'd': return 4; - case 'q': return 5; - case 'a': return 6; + case 'o': return SWAPCHOICE_OPNRO; + case 'e': return SWAPCHOICE_EDIT; + case 'r': return SWAPCHOICE_RECOV; + case 'd': return SWAPCHOICE_DEL; + case 'q': return SWAPCHOICE_QUIT; + case 'a': return SWAPCHOICE_ABORT; } - return 0; + return SWAPCHOICE_NONE; } #endif @@ -4447,7 +4449,7 @@ && vim_strchr(p_shm, SHM_ATTENTION) == NULL) { #if defined(HAS_SWAP_EXISTS_ACTION) - int choice = 0; + int choice = SWAPCHOICE_NONE; #endif #ifdef CREATE_DUMMY_FILE int did_use_dummy = FALSE; @@ -4478,7 +4480,7 @@ && has_autocmd(EVENT_SWAPEXISTS, buf_fname, buf)) choice = do_swapexists(buf, fname); - if (choice == 0) + if (choice == SWAPCHOICE_NONE) #endif { #ifdef FEAT_GUI @@ -4498,7 +4500,7 @@ } #if defined(FEAT_GUI_DIALOG) || defined(FEAT_CON_DIALOG) - if (swap_exists_action != SEA_NONE && choice == 0) + if (swap_exists_action != SEA_NONE && choice == SWAPCHOICE_NONE) { char_u *name; @@ -4524,7 +4526,7 @@ (char_u *)_("&Open Read-Only\n&Edit anyway\n&Recover\n&Delete it\n&Quit\n&Abort"), 1, NULL, FALSE); # if defined(UNIX) || defined(__EMX__) || defined(VMS) - if (process_still_running && choice >= 4) + if (process_still_running && choice >= SWAPCHOICE_DEL) choice++; /* Skip missing "Delete it" button */ # endif vim_free(name); @@ -4536,25 +4538,25 @@ #endif #if defined(HAS_SWAP_EXISTS_ACTION) - if (choice > 0) + if (choice > SWAPCHOICE_NONE) { switch (choice) { - case 1: + case SWAPCHOICE_OPNRO: buf->b_p_ro = TRUE; break; - case 2: + case SWAPCHOICE_EDIT: break; - case 3: + case SWAPCHOICE_RECOV: swap_exists_action = SEA_RECOVER; break; - case 4: + case SWAPCHOICE_DEL: mch_remove(fname); break; - case 5: + case SWAPCHOICE_QUIT: swap_exists_action = SEA_QUIT; break; - case 6: + case SWAPCHOICE_ABORT: swap_exists_action = SEA_QUIT; got_int = TRUE; break;