0
0
mirror of https://github.com/vim/vim.git synced 2025-08-27 20:13:38 -04:00

patch 9.0.1158: code is indented more than necessary

Problem:    Code is indented more than necessary.
Solution:   Use an early return where it makes sense. (Yegappan Lakshmanan,
            closes #11787)
This commit is contained in:
Yegappan Lakshmanan 2023-01-08 13:44:24 +00:00 committed by Bram Moolenaar
parent df8f947359
commit 7f8b2559a3
14 changed files with 1274 additions and 1266 deletions

View File

@ -1426,11 +1426,11 @@ ff_push(ff_search_ctx_T *search_ctx, ff_stack_T *stack_ptr)
{ {
// check for NULL pointer, not to return an error to the user, but // check for NULL pointer, not to return an error to the user, but
// to prevent a crash // to prevent a crash
if (stack_ptr != NULL) if (stack_ptr == NULL)
{ return;
stack_ptr->ffs_prev = search_ctx->ffsc_stack_ptr; stack_ptr->ffs_prev = search_ctx->ffsc_stack_ptr;
search_ctx->ffsc_stack_ptr = stack_ptr; search_ctx->ffsc_stack_ptr = stack_ptr;
}
} }
/* /*

View File

@ -513,13 +513,14 @@ newFoldLevelWin(win_T *wp)
void void
foldCheckClose(void) foldCheckClose(void)
{ {
if (*p_fcl != NUL) // can only be "all" right now if (*p_fcl == NUL)
{ return;
// can only be "all" right now
checkupdate(curwin); checkupdate(curwin);
if (checkCloseRec(&curwin->w_folds, curwin->w_cursor.lnum, if (checkCloseRec(&curwin->w_folds, curwin->w_cursor.lnum,
(int)curwin->w_p_fdl)) (int)curwin->w_p_fdl))
changed_window_setting(); changed_window_setting();
}
} }
// checkCloseRec() {{{2 // checkCloseRec() {{{2
@ -1077,8 +1078,10 @@ foldAdjustVisual(void)
} }
if (hasFolding(start->lnum, &start->lnum, NULL)) if (hasFolding(start->lnum, &start->lnum, NULL))
start->col = 0; start->col = 0;
if (hasFolding(end->lnum, NULL, &end->lnum))
{ if (!hasFolding(end->lnum, NULL, &end->lnum))
return;
ptr = ml_get(end->lnum); ptr = ml_get(end->lnum);
end->col = (colnr_T)STRLEN(ptr); end->col = (colnr_T)STRLEN(ptr);
if (end->col > 0 && *p_sel == 'o') if (end->col > 0 && *p_sel == 'o')
@ -1086,7 +1089,6 @@ foldAdjustVisual(void)
// prevent cursor from moving on the trail byte // prevent cursor from moving on the trail byte
if (has_mbyte) if (has_mbyte)
mb_adjust_cursor(); mb_adjust_cursor();
}
} }
// cursor_foldstart() {{{2 // cursor_foldstart() {{{2
@ -1215,11 +1217,11 @@ foldLevelWin(win_T *wp, linenr_T lnum)
static void static void
checkupdate(win_T *wp) checkupdate(win_T *wp)
{ {
if (wp->w_foldinvalid) if (!wp->w_foldinvalid)
{ return;
foldUpdate(wp, (linenr_T)1, (linenr_T)MAXLNUM); // will update all foldUpdate(wp, (linenr_T)1, (linenr_T)MAXLNUM); // will update all
wp->w_foldinvalid = FALSE; wp->w_foldinvalid = FALSE;
}
} }
// setFoldRepeat() {{{2 // setFoldRepeat() {{{2

View File

@ -259,11 +259,11 @@ delete_buff_tail(buffheader_T *buf, int slen)
if (buf->bh_curr == NULL) if (buf->bh_curr == NULL)
return; // nothing to delete return; // nothing to delete
len = (int)STRLEN(buf->bh_curr->b_str); len = (int)STRLEN(buf->bh_curr->b_str);
if (len >= slen) if (len < slen)
{ return;
buf->bh_curr->b_str[len - slen] = NUL; buf->bh_curr->b_str[len - slen] = NUL;
buf->bh_space += slen; buf->bh_space += slen;
}
} }
/* /*
@ -478,12 +478,12 @@ flush_buffers(flush_buffers_T flush_typeahead)
void void
ResetRedobuff(void) ResetRedobuff(void)
{ {
if (!block_redo) if (block_redo)
{ return;
free_buff(&old_redobuff); free_buff(&old_redobuff);
old_redobuff = redobuff; old_redobuff = redobuff;
redobuff.bh_first.b_next = NULL; redobuff.bh_first.b_next = NULL;
}
} }
/* /*
@ -493,15 +493,15 @@ ResetRedobuff(void)
void void
CancelRedo(void) CancelRedo(void)
{ {
if (!block_redo) if (block_redo)
{ return;
free_buff(&redobuff); free_buff(&redobuff);
redobuff = old_redobuff; redobuff = old_redobuff;
old_redobuff.bh_first.b_next = NULL; old_redobuff.bh_first.b_next = NULL;
start_stuff(); start_stuff();
while (read_readbuffers(TRUE) != NUL) while (read_readbuffers(TRUE) != NUL)
; ;
}
} }
/* /*
@ -520,11 +520,11 @@ saveRedobuff(save_redo_T *save_redo)
// Make a copy, so that ":normal ." in a function works. // Make a copy, so that ":normal ." in a function works.
s = get_buffcont(&save_redo->sr_redobuff, FALSE); s = get_buffcont(&save_redo->sr_redobuff, FALSE);
if (s != NULL) if (s == NULL)
{ return;
add_buff(&redobuff, s, -1L); add_buff(&redobuff, s, -1L);
vim_free(s); vim_free(s);
}
} }
/* /*
@ -944,15 +944,15 @@ stop_redo_ins(void)
static void static void
init_typebuf(void) init_typebuf(void)
{ {
if (typebuf.tb_buf == NULL) if (typebuf.tb_buf != NULL)
{ return;
typebuf.tb_buf = typebuf_init; typebuf.tb_buf = typebuf_init;
typebuf.tb_noremap = noremapbuf_init; typebuf.tb_noremap = noremapbuf_init;
typebuf.tb_buflen = TYPELEN_INIT; typebuf.tb_buflen = TYPELEN_INIT;
typebuf.tb_len = 0; typebuf.tb_len = 0;
typebuf.tb_off = MAXMAPLEN + 4; typebuf.tb_off = MAXMAPLEN + 4;
typebuf.tb_change_cnt = 1; typebuf.tb_change_cnt = 1;
}
} }
/* /*
@ -1324,11 +1324,11 @@ gotchars(char_u *chars, int len)
void void
ungetchars(int len) ungetchars(int len)
{ {
if (reg_recording != 0) if (reg_recording == 0)
{ return;
delete_buff_tail(&recordbuff, len); delete_buff_tail(&recordbuff, len);
last_recorded_len -= len; last_recorded_len -= len;
}
} }
/* /*
@ -2230,8 +2230,9 @@ f_getcharstr(typval_T *argvars, typval_T *rettv)
{ {
getchar_common(argvars, rettv); getchar_common(argvars, rettv);
if (rettv->v_type == VAR_NUMBER) if (rettv->v_type != VAR_NUMBER)
{ return;
char_u temp[7]; // mbyte-char: 6, NUL: 1 char_u temp[7]; // mbyte-char: 6, NUL: 1
varnumber_T n = rettv->vval.v_number; varnumber_T n = rettv->vval.v_number;
int i = 0; int i = 0;
@ -2246,7 +2247,6 @@ f_getcharstr(typval_T *argvars, typval_T *rettv)
temp[i++] = NUL; temp[i++] = NUL;
rettv->v_type = VAR_STRING; rettv->v_type = VAR_STRING;
rettv->vval.v_string = vim_strsave(temp); rettv->vval.v_string = vim_strsave(temp);
}
} }
/* /*
@ -4031,10 +4031,10 @@ do_cmdkey_command(int key UNUSED, int flags)
void void
reset_last_used_map(mapblock_T *mp) reset_last_used_map(mapblock_T *mp)
{ {
if (last_used_map == mp) if (last_used_map != mp)
{ return;
last_used_map = NULL; last_used_map = NULL;
last_used_sid = -1; last_used_sid = -1;
}
} }
#endif #endif

View File

@ -1171,9 +1171,11 @@ gui_update_cursor(
return; return;
gui_check_pos(); gui_check_pos();
if (!gui.cursor_is_valid || force
|| gui.row != gui.cursor_row || gui.col != gui.cursor_col) if (gui.cursor_is_valid && !force
{ && gui.row == gui.cursor_row && gui.col == gui.cursor_col)
return;
gui_undraw_cursor(); gui_undraw_cursor();
// If a cursor-less sleep is ongoing, leave the cursor invisible // If a cursor-less sleep is ongoing, leave the cursor invisible
@ -1392,7 +1394,6 @@ gui_update_cursor(
#endif #endif
} }
gui.highlight_mask = old_hl_mask; gui.highlight_mask = old_hl_mask;
}
} }
#if defined(FEAT_MENU) || defined(PROTO) #if defined(FEAT_MENU) || defined(PROTO)
@ -2054,13 +2055,13 @@ gui_write(
void void
gui_dont_update_cursor(int undraw) gui_dont_update_cursor(int undraw)
{ {
if (gui.in_use) if (!gui.in_use)
{ return;
// Undraw the cursor now, we probably can't do it after the change. // Undraw the cursor now, we probably can't do it after the change.
if (undraw) if (undraw)
gui_undraw_cursor(); gui_undraw_cursor();
can_update_cursor = FALSE; can_update_cursor = FALSE;
}
} }
void void
@ -2679,8 +2680,9 @@ gui_outstr_nowrap(
void void
gui_undraw_cursor(void) gui_undraw_cursor(void)
{ {
if (gui.cursor_is_valid) if (!gui.cursor_is_valid)
{ return;
// Always redraw the character just before if there is one, because // Always redraw the character just before if there is one, because
// with some fonts and characters there can be a one pixel overlap. // with some fonts and characters there can be a one pixel overlap.
int startcol = gui.cursor_col > 0 ? gui.cursor_col - 1 : gui.cursor_col; int startcol = gui.cursor_col > 0 ? gui.cursor_col - 1 : gui.cursor_col;
@ -2695,7 +2697,6 @@ gui_undraw_cursor(void)
// Cursor_is_valid is reset when the cursor is undrawn, also reset it // Cursor_is_valid is reset when the cursor is undrawn, also reset it
// here in case it wasn't needed to undraw it. // here in case it wasn't needed to undraw it.
gui.cursor_is_valid = FALSE; gui.cursor_is_valid = FALSE;
}
} }
void void
@ -3559,8 +3560,9 @@ gui_init_which_components(char_u *oldval UNUSED)
break; break;
} }
if (gui.in_use) if (!gui.in_use)
{ return;
need_set_size = 0; need_set_size = 0;
fix_size = FALSE; fix_size = FALSE;
@ -3689,7 +3691,6 @@ gui_init_which_components(char_u *oldval UNUSED)
// change. // change.
if (firstwin->w_winrow != tabline_height()) if (firstwin->w_winrow != tabline_height())
shell_new_rows(); // recompute window positions and heights shell_new_rows(); // recompute window positions and heights
}
} }
#if defined(FEAT_GUI_TABLINE) || defined(PROTO) #if defined(FEAT_GUI_TABLINE) || defined(PROTO)
@ -4768,7 +4769,7 @@ gui_mouse_focus(int x, int y)
return; return;
/* /*
* format a mouse click on status line input * Format a mouse click on status line input,
* ala gui_send_mouse_event(0, x, y, 0, 0); * ala gui_send_mouse_event(0, x, y, 0, 0);
* Trick: Use a column number -1, so that get_pseudo_mouse_code() will * Trick: Use a column number -1, so that get_pseudo_mouse_code() will
* generate a K_LEFTMOUSE_NM key code. * generate a K_LEFTMOUSE_NM key code.
@ -4852,13 +4853,14 @@ gui_mouse_correct(void)
need_mouse_correct = FALSE; need_mouse_correct = FALSE;
wp = gui_mouse_window(IGNORE_POPUP); wp = gui_mouse_window(IGNORE_POPUP);
if (wp != curwin && wp != NULL) // If in other than current window if (wp == curwin || wp == NULL)
{ return;
// If in other than current window
validate_cline_row(); validate_cline_row();
gui_mch_setmouse((int)W_ENDCOL(curwin) * gui.char_width - 3, gui_mch_setmouse((int)W_ENDCOL(curwin) * gui.char_width - 3,
(W_WINROW(curwin) + curwin->w_wrow) * gui.char_height (W_WINROW(curwin) + curwin->w_wrow) * gui.char_height
+ (gui.char_height) / 2); + (gui.char_height) / 2);
}
} }
/* /*
@ -5014,9 +5016,14 @@ display_errors(void)
char_u *p; char_u *p;
if (isatty(2)) if (isatty(2))
fflush(stderr);
else if (error_ga.ga_data != NULL)
{ {
fflush(stderr);
return;
}
if (error_ga.ga_data == NULL)
return;
// avoid putting up a message box with blanks only // avoid putting up a message box with blanks only
for (p = (char_u *)error_ga.ga_data; *p != NUL; ++p) for (p = (char_u *)error_ga.ga_data; *p != NUL; ++p)
if (!isspace(*p)) if (!isspace(*p))
@ -5029,7 +5036,6 @@ display_errors(void)
break; break;
} }
ga_clear(&error_ga); ga_clear(&error_ga);
}
} }
#endif #endif
@ -5339,12 +5345,12 @@ gui_wingoto_xy(int x, int y)
int col = X_2_COL(x); int col = X_2_COL(x);
win_T *wp; win_T *wp;
if (row >= 0 && col >= 0) if (row < 0 || col < 0)
{ return;
wp = mouse_find_win(&row, &col, FAIL_POPUP); wp = mouse_find_win(&row, &col, FAIL_POPUP);
if (wp != NULL && wp != curwin) if (wp != NULL && wp != curwin)
win_goto(wp); win_goto(wp);
}
} }
/* /*

View File

@ -373,8 +373,9 @@ pointer_event(BalloonEval *beval, int x, int y, unsigned state)
distance = ABS(x - beval->x) + ABS(y - beval->y); distance = ABS(x - beval->x) + ABS(y - beval->y);
if (distance > 4) if (distance <= 4)
{ return;
/* /*
* Moved out of the balloon location: cancel it. * Moved out of the balloon location: cancel it.
* Remember button state * Remember button state
@ -407,7 +408,6 @@ pointer_event(BalloonEval *beval, int x, int y, unsigned state)
&timeout_cb, beval); &timeout_cb, beval);
} }
} }
}
} }
static void static void
@ -698,8 +698,9 @@ timerRoutine(XtPointer dx, XtIntervalId *id UNUSED)
static void static void
requestBalloon(BalloonEval *beval) requestBalloon(BalloonEval *beval)
{ {
if (beval->showState != ShS_PENDING) if (beval->showState == ShS_PENDING)
{ return;
// Determine the beval to display // Determine the beval to display
if (beval->msgCB != NULL) if (beval->msgCB != NULL)
{ {
@ -708,7 +709,6 @@ requestBalloon(BalloonEval *beval)
} }
else if (beval->msg != NULL) else if (beval->msg != NULL)
drawBalloon(beval); drawBalloon(beval);
}
} }
#ifdef FEAT_GUI_GTK #ifdef FEAT_GUI_GTK
@ -900,8 +900,9 @@ set_printable_label_text(GtkLabel *label, char_u *text)
static void static void
drawBalloon(BalloonEval *beval) drawBalloon(BalloonEval *beval)
{ {
if (beval->msg != NULL) if (beval->msg == NULL)
{ return;
GtkRequisition requisition; GtkRequisition requisition;
int screen_w; int screen_w;
int screen_h; int screen_h;
@ -978,7 +979,6 @@ drawBalloon(BalloonEval *beval)
beval->showState = ShS_SHOWING; beval->showState = ShS_SHOWING;
gui_mch_update(); gui_mch_update();
}
} }
/* /*
@ -1060,8 +1060,9 @@ drawBalloon(BalloonEval *beval)
Position tx; Position tx;
Position ty; Position ty;
if (beval->msg != NULL) if (beval->msg == NULL)
{ return;
XmString s; XmString s;
// Show the Balloon // Show the Balloon
@ -1118,7 +1119,6 @@ drawBalloon(BalloonEval *beval)
beval->showState = ShS_SHOWING; beval->showState = ShS_SHOWING;
current_beval = beval; current_beval = beval;
}
} }
/* /*
@ -1161,7 +1161,6 @@ createBalloonEvalWindow(BalloonEval *beval)
beval->balloonShell = XtAppCreateShell("balloonEval", "BalloonEval", beval->balloonShell = XtAppCreateShell("balloonEval", "BalloonEval",
overrideShellWidgetClass, gui.dpy, args, n); overrideShellWidgetClass, gui.dpy, args, n);
{
XmFontList fl; XmFontList fl;
n = 0; n = 0;
@ -1172,7 +1171,6 @@ createBalloonEvalWindow(BalloonEval *beval)
XtSetArg(args[n], XmNalignment, XmALIGNMENT_BEGINNING); n++; XtSetArg(args[n], XmNalignment, XmALIGNMENT_BEGINNING); n++;
beval->balloonLabel = XtCreateManagedWidget("balloonLabel", beval->balloonLabel = XtCreateManagedWidget("balloonLabel",
xmLabelWidgetClass, beval->balloonShell, args, n); xmLabelWidgetClass, beval->balloonShell, args, n);
}
} }
#endif // !FEAT_GUI_GTK #endif // !FEAT_GUI_GTK

View File

@ -924,8 +924,9 @@ get_menu_position(vimmenu_T *menu)
void void
gui_mch_menu_set_tip(vimmenu_T *menu) gui_mch_menu_set_tip(vimmenu_T *menu)
{ {
if (menu->id != NULL && menu->parent != NULL && gui.toolbar != NULL) if (menu->id == NULL || menu->parent == NULL || gui.toolbar == NULL)
{ return;
char_u *tooltip; char_u *tooltip;
tooltip = CONVERT_TO_UTF8(menu->strings[MENU_INDEX_TIP]); tooltip = CONVERT_TO_UTF8(menu->strings[MENU_INDEX_TIP]);
@ -939,7 +940,6 @@ gui_mch_menu_set_tip(vimmenu_T *menu)
menu->id, (const char *)tooltip, NULL); menu->id, (const char *)tooltip, NULL);
# endif # endif
CONVERT_TO_UTF8_FREE(tooltip); CONVERT_TO_UTF8_FREE(tooltip);
}
} }
#endif // FEAT_TOOLBAR #endif // FEAT_TOOLBAR
@ -1007,8 +1007,9 @@ gui_mch_destroy_menu(vimmenu_T *menu)
void void
gui_mch_set_scrollbar_thumb(scrollbar_T *sb, long val, long size, long max) gui_mch_set_scrollbar_thumb(scrollbar_T *sb, long val, long size, long max)
{ {
if (sb->id != NULL) if (sb->id == NULL)
{ return;
GtkAdjustment *adjustment; GtkAdjustment *adjustment;
// ignore events triggered by moving the thumb (happens in GTK 3) // ignore events triggered by moving the thumb (happens in GTK 3)
@ -1034,7 +1035,6 @@ gui_mch_set_scrollbar_thumb(scrollbar_T *sb, long val, long size, long max)
g_signal_handler_unblock(G_OBJECT(adjustment), g_signal_handler_unblock(G_OBJECT(adjustment),
(gulong)sb->handler_id); (gulong)sb->handler_id);
}
} }
void void
@ -1157,8 +1157,9 @@ gui_mch_create_scrollbar(scrollbar_T *sb, int orient)
sb->id = gtk_vscrollbar_new(NULL); sb->id = gtk_vscrollbar_new(NULL);
#endif #endif
if (sb->id != NULL) if (sb->id == NULL)
{ return;
GtkAdjustment *adjustment; GtkAdjustment *adjustment;
gtk_widget_set_can_focus(sb->id, FALSE); gtk_widget_set_can_focus(sb->id, FALSE);
@ -1171,7 +1172,6 @@ gui_mch_create_scrollbar(scrollbar_T *sb, int orient)
G_CALLBACK(adjustment_value_changed), G_CALLBACK(adjustment_value_changed),
GINT_TO_POINTER(sb->ident)); GINT_TO_POINTER(sb->ident));
gui_mch_update(); gui_mch_update();
}
} }
void void
@ -1994,9 +1994,9 @@ gui_make_popup(char_u *path_name, int mouse_pos)
popup_mouse_pos = mouse_pos; popup_mouse_pos = mouse_pos;
menu = gui_find_menu(path_name); menu = gui_find_menu(path_name);
if (menu == NULL || menu->submenu_id == NULL)
return;
if (menu != NULL && menu->submenu_id != NULL)
{
# if GTK_CHECK_VERSION(3,22,2) # if GTK_CHECK_VERSION(3,22,2)
GdkWindow * const win = gtk_widget_get_window(gui.drawarea); GdkWindow * const win = gtk_widget_get_window(gui.drawarea);
GdkEventButton trigger; GdkEventButton trigger;
@ -2046,7 +2046,6 @@ gui_make_popup(char_u *path_name, int mouse_pos)
&popup_menu_position_func, NULL, &popup_menu_position_func, NULL,
0U, (guint32)GDK_CURRENT_TIME); 0U, (guint32)GDK_CURRENT_TIME);
# endif # endif
}
} }
#endif // FEAT_MENU #endif // FEAT_MENU

View File

@ -188,14 +188,14 @@ gui_gtk_form_thaw(GtkForm *form)
{ {
g_return_if_fail(GTK_IS_FORM(form)); g_return_if_fail(GTK_IS_FORM(form));
if (form->freeze_count) if (!form->freeze_count)
{ return;
if (!(--form->freeze_count)) if (!(--form->freeze_count))
{ {
form_position_children(form); form_position_children(form);
gtk_widget_queue_draw(GTK_WIDGET(form)); gtk_widget_queue_draw(GTK_WIDGET(form));
} }
}
} }
// Basic Object handling procedures // Basic Object handling procedures
@ -610,8 +610,9 @@ form_remove(GtkContainer *container, GtkWidget *widget)
tmp_list = tmp_list->next; tmp_list = tmp_list->next;
} }
if (tmp_list) if (tmp_list == NULL)
{ return;
#if GTK_CHECK_VERSION(3,0,0) #if GTK_CHECK_VERSION(3,0,0)
const gboolean was_visible = gtk_widget_get_visible(widget); const gboolean was_visible = gtk_widget_get_visible(widget);
#endif #endif
@ -635,7 +636,6 @@ form_remove(GtkContainer *container, GtkWidget *widget)
form->children = g_list_remove_link(form->children, tmp_list); form->children = g_list_remove_link(form->children, tmp_list);
g_list_free_1(tmp_list); g_list_free_1(tmp_list);
g_free(child); g_free(child);
}
} }
static void static void

View File

@ -2435,16 +2435,15 @@ setup_save_yourself(void)
GnomeClient *client; GnomeClient *client;
client = gnome_master_client(); client = gnome_master_client();
if (client == NULL)
return;
if (client != NULL)
{
// Must use the deprecated gtk_signal_connect() for compatibility // Must use the deprecated gtk_signal_connect() for compatibility
// with GNOME 1. Arrgh, zombies! // with GNOME 1. Arrgh, zombies!
gtk_signal_connect(GTK_OBJECT(client), "save_yourself", gtk_signal_connect(GTK_OBJECT(client), "save_yourself",
GTK_SIGNAL_FUNC(&sm_client_save_yourself), NULL); GTK_SIGNAL_FUNC(&sm_client_save_yourself), NULL);
gtk_signal_connect(GTK_OBJECT(client), "die", gtk_signal_connect(GTK_OBJECT(client), "die",
GTK_SIGNAL_FUNC(&sm_client_die), NULL); GTK_SIGNAL_FUNC(&sm_client_die), NULL);
}
} }
#else // !USE_GNOME_SESSION #else // !USE_GNOME_SESSION
@ -3379,13 +3378,13 @@ on_tab_reordered(
gint idx, gint idx,
gpointer data UNUSED) gpointer data UNUSED)
{ {
if (!ignore_tabline_evt) if (ignore_tabline_evt)
{ return;
if ((tabpage_index(curtab) - 1) < idx) if ((tabpage_index(curtab) - 1) < idx)
tabpage_move(idx + 1); tabpage_move(idx + 1);
else else
tabpage_move(idx); tabpage_move(idx);
}
} }
# endif # endif
@ -4069,15 +4068,15 @@ gui_mch_init(void)
void void
gui_mch_forked(void) gui_mch_forked(void)
{ {
if (using_gnome) if (!using_gnome)
{ return;
GnomeClient *client; GnomeClient *client;
client = gnome_master_client(); client = gnome_master_client();
if (client != NULL) if (client != NULL)
gnome_client_set_process_id(client, getpid()); gnome_client_set_process_id(client, getpid());
}
} }
#endif // USE_GNOME_SESSION #endif // USE_GNOME_SESSION
@ -6860,11 +6859,11 @@ clip_mch_request_selection(Clipboard_T *cbd)
void void
clip_mch_lose_selection(Clipboard_T *cbd UNUSED) clip_mch_lose_selection(Clipboard_T *cbd UNUSED)
{ {
if (!in_selection_clear_event) if (in_selection_clear_event)
{ return;
gtk_selection_owner_set(NULL, cbd->gtk_sel_atom, gui.event_time); gtk_selection_owner_set(NULL, cbd->gtk_sel_atom, gui.event_time);
gui_mch_update(); gui_mch_update();
}
} }
/* /*
@ -7029,8 +7028,9 @@ static int last_shape = 0;
void void
gui_mch_mousehide(int hide) gui_mch_mousehide(int hide)
{ {
if (gui.pointer_hidden != hide) if (gui.pointer_hidden == hide)
{ return;
gui.pointer_hidden = hide; gui.pointer_hidden = hide;
if (gtk_widget_get_window(gui.drawarea) && gui.blank_pointer != NULL) if (gtk_widget_get_window(gui.drawarea) && gui.blank_pointer != NULL)
{ {
@ -7044,7 +7044,6 @@ gui_mch_mousehide(int hide)
gdk_window_set_cursor(gtk_widget_get_window(gui.drawarea), NULL); gdk_window_set_cursor(gtk_widget_get_window(gui.drawarea), NULL);
#endif #endif
} }
}
} }
#if defined(FEAT_MOUSESHAPE) || defined(PROTO) #if defined(FEAT_MOUSESHAPE) || defined(PROTO)
@ -7132,9 +7131,10 @@ gui_mch_drawsign(int row, int col, int typenr)
sign = (GdkPixbuf *)sign_get_image(typenr); sign = (GdkPixbuf *)sign_get_image(typenr);
if (sign != NULL && gui.drawarea != NULL if (sign == NULL || gui.drawarea == NULL
&& gtk_widget_get_window(gui.drawarea) != NULL) || gtk_widget_get_window(gui.drawarea) == NULL)
{ return;
int width; int width;
int height; int height;
int xoffset; int xoffset;
@ -7266,7 +7266,6 @@ gui_mch_drawsign(int row, int col, int typenr)
# endif // !GTK_CHECK_VERSION(3,0,0) # endif // !GTK_CHECK_VERSION(3,0,0)
if (need_scale) if (need_scale)
g_object_unref(sign); g_object_unref(sign);
}
} }
void * void *

View File

@ -979,14 +979,14 @@ gui_motif_add_actext(vimmenu_T *menu)
XmString label; XmString label;
// Add accelerator text, if there is one // Add accelerator text, if there is one
if (menu->actext != NULL && menu->id != (Widget)0) if (menu->actext == NULL || menu->id == (Widget)0)
{ return;
label = XmStringCreate((char *)menu->actext, STRING_TAG); label = XmStringCreate((char *)menu->actext, STRING_TAG);
if (label == NULL) if (label == NULL)
return; return;
XtVaSetValues(menu->id, XmNacceleratorText, label, NULL); XtVaSetValues(menu->id, XmNacceleratorText, label, NULL);
XmStringFree(label); XmStringFree(label);
}
} }
void void
@ -1573,8 +1573,9 @@ gui_mch_destroy_menu(vimmenu_T *menu)
menu->submenu_id = (Widget)0; menu->submenu_id = (Widget)0;
} }
if (menu->id != (Widget)0) if (menu->id == (Widget)0)
{ return;
Widget parent; Widget parent;
parent = XtParent(menu->id); parent = XtParent(menu->id);
@ -1610,7 +1611,6 @@ gui_mch_destroy_menu(vimmenu_T *menu)
gui.toolbar_height = gui_mch_compute_toolbar_height(); gui.toolbar_height = gui_mch_compute_toolbar_height();
} }
#endif #endif
}
} }
void void
@ -1630,8 +1630,9 @@ gui_mch_show_popupmenu(vimmenu_T *menu UNUSED)
void void
gui_mch_def_colors(void) gui_mch_def_colors(void)
{ {
if (gui.in_use) if (!gui.in_use)
{ return;
gui.menu_fg_pixel = gui_get_color((char_u *)gui.rsrc_menu_fg_name); gui.menu_fg_pixel = gui_get_color((char_u *)gui.rsrc_menu_fg_name);
gui.menu_bg_pixel = gui_get_color((char_u *)gui.rsrc_menu_bg_name); gui.menu_bg_pixel = gui_get_color((char_u *)gui.rsrc_menu_bg_name);
gui.scroll_fg_pixel = gui_get_color((char_u *)gui.rsrc_scroll_fg_name); gui.scroll_fg_pixel = gui_get_color((char_u *)gui.rsrc_scroll_fg_name);
@ -1642,7 +1643,6 @@ gui_mch_def_colors(void)
gui.tooltip_bg_pixel = gui.tooltip_bg_pixel =
gui_get_color((char_u *)gui.rsrc_tooltip_bg_name); gui_get_color((char_u *)gui.rsrc_tooltip_bg_name);
#endif #endif
}
} }
@ -1674,8 +1674,9 @@ gui_mch_set_scrollbar_pos(
int w, int w,
int h) int h)
{ {
if (sb->id != (Widget)0) if (sb->id == (Widget)0)
{ return;
if (sb->type == SBAR_LEFT || sb->type == SBAR_RIGHT) if (sb->type == SBAR_LEFT || sb->type == SBAR_RIGHT)
{ {
if (y == 0) if (y == 0)
@ -1697,7 +1698,6 @@ gui_mch_set_scrollbar_pos(
XmNheight, h, XmNheight, h,
NULL); NULL);
XtManageChild(sb->id); XtManageChild(sb->id);
}
} }
int int
@ -1732,8 +1732,9 @@ gui_mch_enable_scrollbar(scrollbar_T *sb, int flag)
Arg args[16]; Arg args[16];
int n; int n;
if (sb->id != (Widget)0) if (sb->id == (Widget)0)
{ return;
n = 0; n = 0;
if (flag) if (flag)
{ {
@ -1778,7 +1779,6 @@ gui_mch_enable_scrollbar(scrollbar_T *sb, int flag)
} }
XtUnmanageChild(sb->id); XtUnmanageChild(sb->id);
} }
}
} }
void void
@ -1817,9 +1817,9 @@ gui_mch_create_scrollbar(
sb->id = XtCreateWidget("scrollBar", sb->id = XtCreateWidget("scrollBar",
xmScrollBarWidgetClass, textAreaForm, args, n); xmScrollBarWidgetClass, textAreaForm, args, n);
if (sb->id == (Widget)0)
return;
if (sb->id != (Widget)0)
{
gui_mch_set_scrollbar_colors(sb); gui_mch_set_scrollbar_colors(sb);
XtAddCallback(sb->id, XmNvalueChangedCallback, XtAddCallback(sb->id, XmNvalueChangedCallback,
scroll_cb, (XtPointer)sb->ident); scroll_cb, (XtPointer)sb->ident);
@ -1827,7 +1827,6 @@ gui_mch_create_scrollbar(
scroll_cb, (XtPointer)sb->ident); scroll_cb, (XtPointer)sb->ident);
XtAddEventHandler(sb->id, KeyPressMask, FALSE, gui_x11_key_hit_cb, XtAddEventHandler(sb->id, KeyPressMask, FALSE, gui_x11_key_hit_cb,
(XtPointer)0); (XtPointer)0);
}
} }
void void

View File

@ -992,8 +992,9 @@ gui_ph_pg_add_buffer(char *name)
char **new_titles = NULL; char **new_titles = NULL;
new_titles = ALLOC_MULT(char *, (num_panels + 1)); new_titles = ALLOC_MULT(char *, (num_panels + 1));
if (new_titles != NULL) if (new_titles == NULL)
{ return;
if (num_panels > 0) if (num_panels > 0)
memcpy(new_titles, panel_titles, num_panels * sizeof(char **)); memcpy(new_titles, panel_titles, num_panels * sizeof(char **));
@ -1004,7 +1005,6 @@ gui_ph_pg_add_buffer(char *name)
vim_free(panel_titles); vim_free(panel_titles);
panel_titles = new_titles; panel_titles = new_titles;
}
} }
static void static void
@ -1901,8 +1901,9 @@ mch_set_mouse_shape(int shape)
void void
gui_mch_mousehide(int hide) gui_mch_mousehide(int hide)
{ {
if (gui.pointer_hidden != hide) if (gui.pointer_hidden == hide)
{ return;
gui.pointer_hidden = hide; gui.pointer_hidden = hide;
#ifdef FEAT_MOUSESHAPE #ifdef FEAT_MOUSESHAPE
if (hide) if (hide)
@ -1915,7 +1916,6 @@ gui_mch_mousehide(int hide)
(hide == MOUSE_SHOW) ? GUI_PH_MOUSE_TYPE : Ph_CURSOR_NONE, (hide == MOUSE_SHOW) ? GUI_PH_MOUSE_TYPE : Ph_CURSOR_NONE,
0); 0);
#endif #endif
}
} }
void void

View File

@ -434,12 +434,12 @@ directx_enabled(void)
static void static void
directx_binddc(void) directx_binddc(void)
{ {
if (s_textArea != NULL) if (s_textArea == NULL)
{ return;
RECT rect; RECT rect;
GetClientRect(s_textArea, &rect); GetClientRect(s_textArea, &rect);
DWriteContext_BindDC(s_dwc, s_hdc, &rect); DWriteContext_BindDC(s_dwc, s_hdc, &rect);
}
} }
#endif #endif
@ -663,14 +663,14 @@ gui_mswin_rm_blink_timer(void)
{ {
MSG msg; MSG msg;
if (blink_timer != 0) if (blink_timer == 0)
{ return;
KillTimer(NULL, blink_timer); KillTimer(NULL, blink_timer);
// Eat spurious WM_TIMER messages // Eat spurious WM_TIMER messages
while (PeekMessageW(&msg, s_hwnd, WM_TIMER, WM_TIMER, PM_REMOVE)) while (PeekMessageW(&msg, s_hwnd, WM_TIMER, WM_TIMER, PM_REMOVE))
; ;
blink_timer = 0; blink_timer = 0;
}
} }
/* /*
@ -1034,8 +1034,10 @@ _OnMouseButtonDown(
else else
button = MOUSE_LEFT; button = MOUSE_LEFT;
} }
if (button >= 0)
{ if (button < 0)
return;
repeated_click = ((int)(currentTime - s_prevTime) < p_mouset); repeated_click = ((int)(currentTime - s_prevTime) < p_mouset);
/* /*
@ -1090,7 +1092,6 @@ _OnMouseButtonDown(
} }
s_prevTime = currentTime; s_prevTime = currentTime;
}
} }
static void static void
@ -1233,8 +1234,9 @@ _OnFindRepl(void)
flags = FRD_REPLACEALL; flags = FRD_REPLACEALL;
} }
if (flags != 0) if (flags == 0)
{ return;
char_u *p, *q; char_u *p, *q;
// Call the generic GUI function to do the actual work. // Call the generic GUI function to do the actual work.
@ -1249,7 +1251,6 @@ _OnFindRepl(void)
gui_do_findrepl(flags, p, q, down); gui_do_findrepl(flags, p, q, down);
vim_free(p); vim_free(p);
vim_free(q); vim_free(q);
}
} }
#endif #endif
@ -2932,11 +2933,11 @@ gui_mch_replace_dialog(exarg_T *eap)
void void
gui_mch_mousehide(int hide) gui_mch_mousehide(int hide)
{ {
if (hide != gui.pointer_hidden) if (hide == gui.pointer_hidden)
{ return;
ShowCursor(!hide); ShowCursor(!hide);
gui.pointer_hidden = hide; gui.pointer_hidden = hide;
}
} }
#ifdef FEAT_MENU #ifdef FEAT_MENU
@ -2993,8 +2994,9 @@ _OnDestroy(HWND hwnd)
_OnPaint( _OnPaint(
HWND hwnd) HWND hwnd)
{ {
if (!IsMinimized(hwnd)) if (IsMinimized(hwnd))
{ return;
PAINTSTRUCT ps; PAINTSTRUCT ps;
out_flush(); // make sure all output has been processed out_flush(); // make sure all output has been processed
@ -3019,7 +3021,6 @@ _OnPaint(
} }
EndPaint(hwnd, &ps); EndPaint(hwnd, &ps);
}
} }
static void static void
@ -3904,8 +3905,9 @@ _OnDropFiles(
DragFinish(hDrop); DragFinish(hDrop);
if (fnames != NULL) if (fnames == NULL)
{ return;
int kbd_modifiers = get_active_modifiers(); int kbd_modifiers = get_active_modifiers();
if ((kbd_modifiers & MOD_MASK_SHIFT) != 0) if ((kbd_modifiers & MOD_MASK_SHIFT) != 0)
@ -3918,7 +3920,6 @@ _OnDropFiles(
gui_handle_drop(pt.x, pt.y, modifiers, fnames, cFiles); gui_handle_drop(pt.x, pt.y, modifiers, fnames, cFiles);
s_need_activate = TRUE; s_need_activate = TRUE;
}
} }
static int static int
@ -4461,11 +4462,11 @@ show_sizing_tip(int cols, int rows)
static void static void
destroy_sizing_tip(void) destroy_sizing_tip(void)
{ {
if (hwndTip != NULL) if (hwndTip == NULL)
{ return;
DestroyWindow(hwndTip); DestroyWindow(hwndTip);
hwndTip = NULL; hwndTip = NULL;
}
} }
static int static int
@ -5844,8 +5845,9 @@ im_set_active(int active)
} }
# endif # endif
if (pImmGetContext) // if NULL imm32.dll wasn't loaded (yet) if (!pImmGetContext) // if NULL imm32.dll wasn't loaded (yet)
{ return;
if (p_imdisable) if (p_imdisable)
{ {
if (hImcOld == (HIMC)0) if (hImcOld == (HIMC)0)
@ -5863,8 +5865,9 @@ im_set_active(int active)
} }
hImc = pImmGetContext(s_hwnd); hImc = pImmGetContext(s_hwnd);
if (hImc) if (!hImc)
{ return;
/* /*
* for Korean ime * for Korean ime
*/ */
@ -5900,8 +5903,6 @@ im_set_active(int active)
pImmSetOpenStatus(hImc, active); pImmSetOpenStatus(hImc, active);
pImmReleaseContext(s_hwnd, hImc); pImmReleaseContext(s_hwnd, hImc);
}
}
} }
/* /*
@ -6459,8 +6460,9 @@ gui_make_popup(char_u *path_name, int mouse_pos)
{ {
vimmenu_T *menu = gui_find_menu(path_name); vimmenu_T *menu = gui_find_menu(path_name);
if (menu != NULL) if (menu == NULL)
{ return;
POINT p; POINT p;
// Find the position of the current cursor // Find the position of the current cursor
@ -6480,7 +6482,6 @@ gui_make_popup(char_u *path_name, int mouse_pos)
} }
msg_scroll = FALSE; msg_scroll = FALSE;
gui_mch_show_popupmenu_at(menu, (int)p.x, (int)p.y); gui_mch_show_popupmenu_at(menu, (int)p.x, (int)p.y);
}
} }
# if defined(FEAT_TEAROFF) || defined(PROTO) # if defined(FEAT_TEAROFF) || defined(PROTO)
@ -8274,7 +8275,9 @@ gui_mch_drawsign(int row, int col, int typenr)
static void static void
close_signicon_image(signicon_t *sign) close_signicon_image(signicon_t *sign)
{ {
if (sign) if (sign == NULL)
return;
switch (sign->uType) switch (sign->uType)
{ {
case IMAGE_BITMAP: case IMAGE_BITMAP:
@ -8347,11 +8350,11 @@ gui_mch_register_sign(char_u *signfile)
void void
gui_mch_destroy_sign(void *sign) gui_mch_destroy_sign(void *sign)
{ {
if (sign) if (sign == NULL)
{ return;
close_signicon_image((signicon_t *)sign); close_signicon_image((signicon_t *)sign);
vim_free(sign); vim_free(sign);
}
} }
#endif #endif
@ -8561,8 +8564,9 @@ Handle_WM_Notify(HWND hwnd UNUSED, LPNMHDR pnmh)
if (pnmh->idFrom != ID_BEVAL_TOOLTIP) // it is not our tooltip if (pnmh->idFrom != ID_BEVAL_TOOLTIP) // it is not our tooltip
return; return;
if (cur_beval != NULL) if (cur_beval == NULL)
{ return;
switch (pnmh->code) switch (pnmh->code)
{ {
case TTN_SHOW: case TTN_SHOW:
@ -8590,7 +8594,6 @@ Handle_WM_Notify(HWND hwnd UNUSED, LPNMHDR pnmh)
} }
break; break;
} }
}
} }
static void static void

View File

@ -2194,11 +2194,11 @@ gui_mch_get_rgb_color(int r, int g, int b)
void void
gui_mch_set_fg_color(guicolor_T color) gui_mch_set_fg_color(guicolor_T color)
{ {
if (color != prev_fg_color) if (color == prev_fg_color)
{ return;
XSetForeground(gui.dpy, gui.text_gc, (Pixel)color); XSetForeground(gui.dpy, gui.text_gc, (Pixel)color);
prev_fg_color = color; prev_fg_color = color;
}
} }
/* /*
@ -2207,11 +2207,11 @@ gui_mch_set_fg_color(guicolor_T color)
void void
gui_mch_set_bg_color(guicolor_T color) gui_mch_set_bg_color(guicolor_T color)
{ {
if (color != prev_bg_color) if (color == prev_bg_color)
{ return;
XSetBackground(gui.dpy, gui.text_gc, (Pixel)color); XSetBackground(gui.dpy, gui.text_gc, (Pixel)color);
prev_bg_color = color; prev_bg_color = color;
}
} }
/* /*
@ -2814,8 +2814,9 @@ clip_mch_set_selection(
void void
gui_mch_menu_grey(vimmenu_T *menu, int grey) gui_mch_menu_grey(vimmenu_T *menu, int grey)
{ {
if (menu->id != (Widget)0) if (menu->id == (Widget)0)
{ return;
gui_mch_menu_hidden(menu, False); gui_mch_menu_hidden(menu, False);
if (grey if (grey
#ifdef FEAT_GUI_MOTIF #ifdef FEAT_GUI_MOTIF
@ -2825,7 +2826,6 @@ gui_mch_menu_grey(vimmenu_T *menu, int grey)
XtSetSensitive(menu->id, False); XtSetSensitive(menu->id, False);
else else
XtSetSensitive(menu->id, True); XtSetSensitive(menu->id, True);
}
} }
/* /*
@ -2834,13 +2834,13 @@ gui_mch_menu_grey(vimmenu_T *menu, int grey)
void void
gui_mch_menu_hidden(vimmenu_T *menu, int hidden) gui_mch_menu_hidden(vimmenu_T *menu, int hidden)
{ {
if (menu->id != (Widget)0) if (menu->id == (Widget)0)
{ return;
if (hidden) if (hidden)
XtUnmanageChild(menu->id); XtUnmanageChild(menu->id);
else else
XtManageChild(menu->id); XtManageChild(menu->id);
}
} }
/* /*
@ -3130,15 +3130,15 @@ gui_mch_drawsign(int row, int col, int typenr)
{ {
XImage *sign; XImage *sign;
if (gui.in_use && (sign = (XImage *)sign_get_image(typenr)) != NULL) if (!gui.in_use || (sign = (XImage *)sign_get_image(typenr)) == NULL)
{ return;
XClearArea(gui.dpy, gui.wid, TEXT_X(col), TEXT_Y(row) - sign->height, XClearArea(gui.dpy, gui.wid, TEXT_X(col), TEXT_Y(row) - sign->height,
SIGN_WIDTH, gui.char_height, FALSE); SIGN_WIDTH, gui.char_height, FALSE);
XPutImage(gui.dpy, gui.wid, gui.text_gc, sign, 0, 0, XPutImage(gui.dpy, gui.wid, gui.text_gc, sign, 0, 0,
TEXT_X(col) + (SIGN_WIDTH - sign->width) / 2, TEXT_X(col) + (SIGN_WIDTH - sign->width) / 2,
TEXT_Y(row) - sign->height, TEXT_Y(row) - sign->height,
sign->width, sign->height); sign->width, sign->height);
}
} }
void * void *
@ -3202,8 +3202,9 @@ static int last_shape = 0;
gui_mch_mousehide( gui_mch_mousehide(
int hide) // TRUE = use blank ptr, FALSE = use parent ptr int hide) // TRUE = use blank ptr, FALSE = use parent ptr
{ {
if (gui.pointer_hidden != hide) if (gui.pointer_hidden == hide)
{ return;
gui.pointer_hidden = hide; gui.pointer_hidden = hide;
if (hide) if (hide)
XDefineCursor(gui.dpy, gui.wid, gui.blank_pointer); XDefineCursor(gui.dpy, gui.wid, gui.blank_pointer);
@ -3213,7 +3214,6 @@ gui_mch_mousehide(
#else #else
XUndefineCursor(gui.dpy, gui.wid); XUndefineCursor(gui.dpy, gui.wid);
#endif #endif
}
} }
#if defined(FEAT_MOUSESHAPE) || defined(PROTO) #if defined(FEAT_MOUSESHAPE) || defined(PROTO)
@ -3280,9 +3280,10 @@ mch_set_mouse_shape(int shape)
void void
gui_mch_menu_set_tip(vimmenu_T *menu) gui_mch_menu_set_tip(vimmenu_T *menu)
{ {
if (menu->id != NULL && menu->parent != NULL if (menu->id == NULL || menu->parent == NULL
&& menu_is_toolbar(menu->parent->name)) || !menu_is_toolbar(menu->parent->name))
{ return;
// Always destroy and create the balloon, in case the string was // Always destroy and create the balloon, in case the string was
// changed. // changed.
if (menu->tip != NULL) if (menu->tip != NULL)
@ -3296,6 +3297,5 @@ gui_mch_menu_set_tip(vimmenu_T *menu)
menu->strings[MENU_INDEX_TIP], menu->strings[MENU_INDEX_TIP],
NULL, NULL,
NULL); NULL);
}
} }
#endif #endif

View File

@ -199,20 +199,21 @@ im_set_active(int active)
void void
xim_set_focus(int focus) xim_set_focus(int focus)
{ {
if (xic != NULL) if (xic == NULL)
{ return;
if (focus) if (focus)
gtk_im_context_focus_in(xic); gtk_im_context_focus_in(xic);
else else
gtk_im_context_focus_out(xic); gtk_im_context_focus_out(xic);
}
} }
void void
im_set_position(int row, int col) im_set_position(int row, int col)
{ {
if (xic != NULL) if (xic == NULL)
{ return;
GdkRectangle area; GdkRectangle area;
area.x = FILL_X(col); area.x = FILL_X(col);
@ -224,7 +225,6 @@ im_set_position(int row, int col)
if (p_imst == IM_OVER_THE_SPOT) if (p_imst == IM_OVER_THE_SPOT)
im_preedit_window_set_position(); im_preedit_window_set_position();
}
} }
# if 0 || defined(PROTO) // apparently only used in gui_x11.c # if 0 || defined(PROTO) // apparently only used in gui_x11.c

View File

@ -695,6 +695,8 @@ static char *(features[]) =
static int included_patches[] = static int included_patches[] =
{ /* Add new patch number below this line */ { /* Add new patch number below this line */
/**/
1158,
/**/ /**/
1157, 1157,
/**/ /**/