0
0
mirror of https://github.com/vim/vim.git synced 2025-08-31 20:53:42 -04:00

patch 8.1.0989: various small code ugliness

Problem:    Various small code ugliness.
Solution:   Remove pointless NULL checks. Fix function calls. Fix typos.
            (Dominique Pelle, closes #4060)
This commit is contained in:
Bram Moolenaar 2019-03-02 10:13:42 +01:00
parent d82a81cad9
commit bdace838c6
16 changed files with 34 additions and 39 deletions

View File

@ -2163,11 +2163,9 @@ free_buf_options(
clear_string_option(&buf->b_p_isk);
#ifdef FEAT_VARTABS
clear_string_option(&buf->b_p_vsts);
if (buf->b_p_vsts_nopaste)
vim_free(buf->b_p_vsts_nopaste);
vim_free(buf->b_p_vsts_nopaste);
buf->b_p_vsts_nopaste = NULL;
if (buf->b_p_vsts_array)
vim_free(buf->b_p_vsts_array);
vim_free(buf->b_p_vsts_array);
buf->b_p_vsts_array = NULL;
clear_string_option(&buf->b_p_vts);
VIM_CLEAR(buf->b_p_vts_array);

View File

@ -42,7 +42,7 @@ typedef struct {
/* Optional function pointer for a self-test. */
int (* self_test_fn)();
/* Function pointer for initializing encryption/decription. */
// Function pointer for initializing encryption/description.
void (* init_fn)(cryptstate_T *state, char_u *key,
char_u *salt, int salt_len, char_u *seed, int seed_len);

View File

@ -2451,7 +2451,7 @@ f_char2nr(typval_T *argvars, typval_T *rettv)
utf8 = (int)tv_get_number_chk(&argvars[1], NULL);
if (utf8)
rettv->vval.v_number = (*utf_ptr2char)(tv_get_string(&argvars[0]));
rettv->vval.v_number = utf_ptr2char(tv_get_string(&argvars[0]));
else
rettv->vval.v_number = (*mb_ptr2char)(tv_get_string(&argvars[0]));
}
@ -8701,7 +8701,7 @@ f_nr2char(typval_T *argvars, typval_T *rettv)
if (argvars[1].v_type != VAR_UNKNOWN)
utf8 = (int)tv_get_number_chk(&argvars[1], NULL);
if (utf8)
buf[(*utf_char2bytes)((int)tv_get_number(&argvars[0]), buf)] = NUL;
buf[utf_char2bytes((int)tv_get_number(&argvars[0]), buf)] = NUL;
else
buf[(*mb_char2bytes)((int)tv_get_number(&argvars[0]), buf)] = NUL;
}
@ -11647,7 +11647,7 @@ f_sign_jump(typval_T *argvars, typval_T *rettv)
rettv->vval.v_number = -1;
// Sign identifer
// Sign identifier
sign_id = (int)tv_get_number_chk(&argvars[0], &notanum);
if (notanum)
return;
@ -11699,7 +11699,7 @@ f_sign_place(typval_T *argvars, typval_T *rettv)
rettv->vval.v_number = -1;
// Sign identifer
// Sign identifier
sign_id = (int)tv_get_number_chk(&argvars[0], &notanum);
if (notanum)
return;

View File

@ -2380,7 +2380,7 @@ check_changed_any(
goto_tabpage_win(tp, wp);
/* Paranoia: did autocms wipe out the buffer with changes? */
// Paranoia: did autocmd wipe out the buffer with changes?
if (!bufref_valid(&bufref))
goto theend;
goto buf_found;

View File

@ -426,7 +426,7 @@ EXTERN int mouse_dragging INIT(= 0); /* extending Visual area with
# if defined(FEAT_MOUSE_DEC)
/*
* When the DEC mouse has been pressed but not yet released we enable
* automatic querys for the mouse position.
* automatic queries for the mouse position.
*/
EXTERN int WantQueryMouse INIT(= FALSE);
# endif

View File

@ -561,7 +561,7 @@ gtk_form_draw(GtkWidget *widget, cairo_t *cr)
* gtk_widget_size_allocate() in advance with a well-posed
* allocation for a given child widget in order to set a
* certain private GtkWidget variable, called
* widget->priv->alloc_need, to the proper value; othewise,
* widget->priv->alloc_need, to the proper value; otherwise,
* gtk_widget_draw() fails and the relevant scrollbar won't
* appear on the screen.
*

View File

@ -7015,7 +7015,7 @@ gui_mch_drawsign(int row, int col, int typenr)
(double)(MIN(height, SIGN_HEIGHT))) < 1.15)
{
/* Change the aspect ratio by at most 15% to fill the
* available space completly. */
* available space completely. */
height = (double)SIGN_HEIGHT * SIGN_ASPECT / aspect;
height = MIN(height, SIGN_HEIGHT);
}

View File

@ -1342,10 +1342,6 @@ InstallAEHandlers(void)
}
error = AEInstallEventHandler('KAHL', 'MOD ',
NewAEEventHandlerUPP(Handle_KAHL_MOD_AE), 0, false);
if (error)
{
return error;
}
#endif
return error;

View File

@ -5402,7 +5402,7 @@ op_addsub(
linenr_T amount = Prenum1;
// do_addsub() might trigger re-evaluation of 'foldexpr' halfway, when the
// buffer is not completly updated yet. Postpone updating folds until before
// buffer is not completely updated yet. Postpone updating folds until before
// the call to changed_lines().
#ifdef FEAT_FOLDING
disable_fold_update++;

View File

@ -193,8 +193,8 @@
#define SHM_WRI 'w' /* "[w]" instead of "written" */
#define SHM_A "rmfixlnw" /* represented by 'a' flag */
#define SHM_WRITE 'W' /* don't use "written" at all */
#define SHM_TRUNC 't' /* trunctate file messages */
#define SHM_TRUNCALL 'T' /* trunctate all messages */
#define SHM_TRUNC 't' /* truncate file messages */
#define SHM_TRUNCALL 'T' /* truncate all messages */
#define SHM_OVER 'o' /* overwrite file messages */
#define SHM_OVERALL 'O' /* overwrite more messages */
#define SHM_SEARCH 's' /* no search hit bottom messages */

View File

@ -6418,7 +6418,7 @@ mch_expand_wildcards(
int shell_style = STYLE_ECHO;
int check_spaces;
static int did_find_nul = FALSE;
int ampersent = FALSE;
int ampersand = FALSE;
/* vimglob() function to define for Posix shell */
static char *sh_vimglob_func = "vimglob() { while [ $# -ge 1 ]; do echo \"$1\"; shift; done }; vimglob >";
@ -6535,7 +6535,7 @@ mch_expand_wildcards(
--p;
if (*p == '&') /* remove trailing '&' */
{
ampersent = TRUE;
ampersand = TRUE;
*p = ' ';
}
STRCAT(command, ">");
@ -6604,7 +6604,7 @@ mch_expand_wildcards(
}
if (flags & EW_SILENT)
show_shell_mess = FALSE;
if (ampersent)
if (ampersand)
STRCAT(command, "&"); /* put the '&' after the redirection */
/*
@ -6630,7 +6630,7 @@ mch_expand_wildcards(
/* When running in the background, give it some time to create the temp
* file, but don't wait for it to finish. */
if (ampersent)
if (ampersand)
mch_delay(10L, TRUE);
extra_shell_arg = NULL; /* cleanup */

View File

@ -2646,7 +2646,7 @@ mch_init(void)
if (cterm_normal_bg_color == 0)
cterm_normal_bg_color = ((g_attrCurrent >> 4) & 0xf) + 1;
// Fg and Bg color index nunmber at startup
// Fg and Bg color index number at startup
g_color_index_fg = g_attrDefault & 0xf;
g_color_index_bg = (g_attrDefault >> 4) & 0xf;
@ -4210,8 +4210,7 @@ vim_create_process(
(LPSTARTUPINFOW)si, /* Startup information */
pi); /* Process information */
vim_free(wcmd);
if (wcwd != NULL)
vim_free(wcwd);
vim_free(wcwd);
return ret;
}
fallback:
@ -5312,8 +5311,8 @@ win32_build_env(dict_T *env, garray_T *gap, int is_terminal)
*((WCHAR*)gap->ga_data + gap->ga_len++) = wval[n];
*((WCHAR*)gap->ga_data + gap->ga_len++) = L'\0';
}
if (wkey != NULL) vim_free(wkey);
if (wval != NULL) vim_free(wval);
vim_free(wkey);
vim_free(wval);
}
}
}

View File

@ -405,7 +405,7 @@ pum_redraw(void)
char_u *p = NULL;
int totwidth, width, w;
int thumb_pos = 0;
int thumb_heigth = 1;
int thumb_height = 1;
int round;
int n;
@ -423,10 +423,10 @@ pum_redraw(void)
if (pum_scrollbar)
{
thumb_heigth = pum_height * pum_height / pum_size;
if (thumb_heigth == 0)
thumb_heigth = 1;
thumb_pos = (pum_first * (pum_height - thumb_heigth)
thumb_height = pum_height * pum_height / pum_size;
if (thumb_height == 0)
thumb_height = 1;
thumb_pos = (pum_first * (pum_height - thumb_height)
+ (pum_size - pum_height) / 2)
/ (pum_size - pum_height);
}
@ -600,12 +600,12 @@ pum_redraw(void)
#ifdef FEAT_RIGHTLEFT
if (curwin->w_p_rl)
screen_putchar(' ', row, pum_col - pum_width,
i >= thumb_pos && i < thumb_pos + thumb_heigth
i >= thumb_pos && i < thumb_pos + thumb_height
? attr_thumb : attr_scroll);
else
#endif
screen_putchar(' ', row, pum_col + pum_width,
i >= thumb_pos && i < thumb_pos + thumb_heigth
i >= thumb_pos && i < thumb_pos + thumb_height
? attr_thumb : attr_scroll);
}

View File

@ -6457,7 +6457,7 @@ regdump(char_u *pattern, bt_regprog_T *r)
}
else if (op == RE_LNUM || op == RE_COL || op == RE_VCOL)
{
/* one int plus comperator */
/* one int plus comparator */
fprintf(f, " count %ld", OPERAND_MIN(s));
s += 5;
}

View File

@ -1738,7 +1738,7 @@ clip_gen_set_selection(VimClipboard *cbd)
if (!clip_did_set_selection)
{
/* Updating postponed, so that accessing the system clipboard won't
* hang Vim when accessing it many times (e.g. on a :g comand). */
* hang Vim when accessing it many times (e.g. on a :g command). */
if ((cbd == &clip_plus && (clip_unnamed_saved & CLIP_UNNAMED_PLUS))
|| (cbd == &clip_star && (clip_unnamed_saved & CLIP_UNNAMED)))
{

View File

@ -41,7 +41,7 @@ init_longVersion(void)
{
/*
* Construct the long version string. Necessary because
* VAX C can't catenate strings in the preprocessor.
* VAX C can't concatenate strings in the preprocessor.
*/
strcpy(longVersion, VIM_VERSION_LONG_DATE);
strcat(longVersion, __DATE__);
@ -779,6 +779,8 @@ static char *(features[]) =
static int included_patches[] =
{ /* Add new patch number below this line */
/**/
989,
/**/
988,
/**/