To: vim-dev@vim.org Subject: Patch 6.0.212 Fcc: outbox From: Bram Moolenaar MIME-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 8bit ------------ Patch 6.0.212 Problem: GUI GTK: confirm("foo", "") causes a crash. Solution: Don't make a non-existing button the default. Add a default "OK" button if none is specified. Files: src/eval.c, src/gui_gtk.c *** ../vim60.211/src/eval.c Sun Feb 10 12:52:47 2002 --- src/eval.c Sat Feb 9 19:46:54 2002 *************** *** 2348,2354 **** {"char2nr", 1, 1, f_char2nr}, {"cindent", 1, 1, f_cindent}, {"col", 1, 1, f_col}, ! {"confirm", 2, 4, f_confirm}, {"cscope_connection",0,3, f_cscope_connection}, {"delete", 1, 1, f_delete}, {"did_filetype", 0, 0, f_did_filetype}, --- 2348,2354 ---- {"char2nr", 1, 1, f_char2nr}, {"cindent", 1, 1, f_cindent}, {"col", 1, 1, f_col}, ! {"confirm", 1, 4, f_confirm}, {"cscope_connection",0,3, f_cscope_connection}, {"delete", 1, 1, f_delete}, {"did_filetype", 0, 0, f_did_filetype}, *************** *** 3095,3101 **** { char_u *p = ml_get_cursor(); ! if (curwin->w_cursor.coladd >= chartabsize(p, curwin->w_virtcol - curwin->w_cursor.coladd)) { # ifdef FEAT_MBYTE --- 3095,3101 ---- { char_u *p = ml_get_cursor(); ! if (curwin->w_cursor.coladd >= (colnr_T)chartabsize(p, curwin->w_virtcol - curwin->w_cursor.coladd)) { # ifdef FEAT_MBYTE *************** *** 3125,3131 **** { #if defined(FEAT_GUI_DIALOG) || defined(FEAT_CON_DIALOG) char_u *message; ! char_u *buttons; char_u buf[NUMBUFLEN]; char_u buf2[NUMBUFLEN]; int def = 0; --- 3125,3131 ---- { #if defined(FEAT_GUI_DIALOG) || defined(FEAT_CON_DIALOG) char_u *message; ! char_u *buttons = NULL; char_u buf[NUMBUFLEN]; char_u buf2[NUMBUFLEN]; int def = 0; *************** *** 3133,3157 **** int c; message = get_var_string(&argvars[0]); ! buttons = get_var_string_buf(&argvars[1], buf); ! if (argvars[2].var_type != VAR_UNKNOWN) { ! def = get_var_number(&argvars[2]); ! if (argvars[3].var_type != VAR_UNKNOWN) { ! /* avoid that TO_UPPER calls get_var_string_buf() twice */ ! c = *get_var_string_buf(&argvars[3], buf2); ! switch (TO_UPPER(c)) { ! case 'E': type = VIM_ERROR; break; ! case 'Q': type = VIM_QUESTION; break; ! case 'I': type = VIM_INFO; break; ! case 'W': type = VIM_WARNING; break; ! case 'G': type = VIM_GENERIC; break; } } } retvar->var_val.var_number = do_dialog(type, NULL, message, buttons, def, NULL); #else --- 3133,3163 ---- int c; message = get_var_string(&argvars[0]); ! if (argvars[1].var_type != VAR_UNKNOWN) { ! buttons = get_var_string_buf(&argvars[1], buf); ! if (argvars[2].var_type != VAR_UNKNOWN) { ! def = get_var_number(&argvars[2]); ! if (argvars[3].var_type != VAR_UNKNOWN) { ! /* avoid that TO_UPPER calls get_var_string_buf() twice */ ! c = *get_var_string_buf(&argvars[3], buf2); ! switch (TO_UPPER(c)) ! { ! case 'E': type = VIM_ERROR; break; ! case 'Q': type = VIM_QUESTION; break; ! case 'I': type = VIM_INFO; break; ! case 'W': type = VIM_WARNING; break; ! case 'G': type = VIM_GENERIC; break; ! } } } } + if (buttons == NULL || *buttons == NUL) + buttons = (char_u *)_("&Ok"); + retvar->var_val.var_number = do_dialog(type, NULL, message, buttons, def, NULL); #else *** ../vim60.211/src/gui_gtk.c Fri Feb 8 10:29:45 2002 --- src/gui_gtk.c Sun Feb 10 19:47:26 2002 *************** *** 1386,1400 **** vim_free(names); ! --butcount; ! --def_but; /* 1 is first button */ ! if (def_but < 0) ! def_but = 0; ! if (def_but > butcount) ! def_but = butcount; - gtk_widget_grab_focus(button[def_but]); - gtk_widget_grab_default(button[def_but]); if (textfield != NULL) gtk_window_set_focus(GTK_WINDOW(dialog), dialog_textentry); --- 1385,1402 ---- vim_free(names); ! if (butcount > 0) ! { ! --def_but; /* 1 is first button */ ! if (def_but < 0) ! def_but = 0; ! if (def_but >= butcount) ! def_but = butcount - 1; ! ! gtk_widget_grab_focus(button[def_but]); ! gtk_widget_grab_default(button[def_but]); ! } if (textfield != NULL) gtk_window_set_focus(GTK_WINDOW(dialog), dialog_textentry); *** ../vim60.211/src/version.c Mon Feb 11 14:00:48 2002 --- src/version.c Mon Feb 11 14:02:09 2002 *************** *** 608,609 **** --- 608,611 ---- { /* Add new patch number below this line */ + /**/ + 212, /**/ -- A mathematician is a device for turning coffee into theorems. Paul Erdos A computer programmer is a device for turning coffee into bugs. Bram Moolenaar /// Bram Moolenaar -- Bram@moolenaar.net -- http://www.moolenaar.net \\\ ((( Creator of Vim -- http://vim.sf.net -- ftp://ftp.vim.org/pub/vim ))) \\\ Help me helping AIDS orphans in Uganda - http://iccf-holland.org ///