patch 9.0.1234: the code style has to be checked manually

Problem:    The code style has to be checked manually.
Solution:   Add basic code style checks in a test.  Fix or avoid uncovered
            problems.
This commit is contained in:
Bram Moolenaar
2023-01-22 21:14:53 +00:00
parent 3d79f0a430
commit ebfec1c531
34 changed files with 319 additions and 149 deletions
+6 -3
View File
@@ -517,7 +517,8 @@ bf_self_test(void)
// We can't simply use sizeof(UINT32_T), it would generate a compiler
// warning.
if (ui != 0xffffffffUL || ui + 1 != 0) {
if (ui != 0xffffffffUL || ui + 1 != 0)
{
err++;
emsg(_(e_sizeof_uint32_isnot_four));
}
@@ -573,13 +574,15 @@ bf_cfb_init(
}
}
#define BF_CFB_UPDATE(bfs, c) { \
#define BF_CFB_UPDATE(bfs, c) \
{ \
bfs->cfb_buffer[bfs->update_offset] ^= (char_u)c; \
if (++bfs->update_offset == bfs->cfb_len) \
bfs->update_offset = 0; \
}
#define BF_RANBYTE(bfs, t) { \
#define BF_RANBYTE(bfs, t) \
{ \
if ((bfs->randbyte_offset & BF_BLOCK_MASK) == 0) \
bf_e_cblock(bfs, &(bfs->cfb_buffer[bfs->randbyte_offset])); \
t = bfs->cfb_buffer[bfs->randbyte_offset]; \
+4 -4
View File
@@ -2641,7 +2641,7 @@ get_c_indent(void)
// It could have been something like
// case 1: if (asdf &&
// ldfd) {
// condition) {
// }
if ((curbuf->b_ind_js || curbuf->b_ind_keep_case_label)
&& cin_iscase(skipwhite(ml_get_curline()), FALSE))
@@ -3275,7 +3275,7 @@ get_c_indent(void)
}
// Check if we are after an "if", "while", etc.
// Also allow " } else".
// Also allow "} else".
if (cin_is_cinword(l) || cin_iselse(skipwhite(l)))
{
// Found an unterminated line after an if (), line up
@@ -3335,7 +3335,7 @@ get_c_indent(void)
{
// If we're looking at "} else", let's make sure we
// find the opening brace of the enclosing scope,
// not the one from "if () {".
// not the one from "if (condition) {".
if (*l == '}')
curwin->w_cursor.col =
(colnr_T)(l - ml_get_curline()) + 1;
@@ -3680,7 +3680,7 @@ term_again:
// line needs to be indented as a function type spec.
// Don't do this if the current line looks like a comment or if the
// current line is terminated, ie. ends in ';', or if the current line
// contains { or }: "void f() {\n if (1)"
// contains { or }: "void f(condition) {\n if (1)"
if (cur_curpos.lnum < curbuf->b_ml.ml_line_count
&& !cin_nocode(theline)
&& vim_strchr(theline, '{') == NULL
+2 -1
View File
@@ -60,7 +60,8 @@ make_crc_tab(void)
/*
* Return the next byte in the pseudo-random sequence.
*/
#define DECRYPT_BYTE_ZIP(keys, t) { \
#define DECRYPT_BYTE_ZIP(keys, t) \
{ \
short_u temp = (short_u)keys[2] | 2; \
t = (int)(((unsigned)(temp * (temp ^ 1U)) >> 8) & 0xff); \
}
+1 -2
View File
@@ -1680,9 +1680,8 @@ diff_read(
{
if (dio->dio_internal)
{
if (line_idx >= dout->dout_ga.ga_len) {
if (line_idx >= dout->dout_ga.ga_len)
break; // did last line
}
hunk = ((diffhunk_T **)dout->dout_ga.ga_data)[line_idx++];
}
else
+2 -1
View File
@@ -2093,7 +2093,8 @@ f_digraph_get(typval_T *argvars, typval_T *rettv)
if (has_mbyte)
buf[(*mb_char2bytes)(code, buf)] = NUL;
else {
else
{
buf[0] = code;
buf[1] = NUL;
}
+4 -2
View File
@@ -722,7 +722,8 @@ do_move(linenr_T line1, linenr_T line2, linenr_T dest)
{
mark_adjust_nofold(line2 + 1, dest, -num_lines, 0L);
#ifdef FEAT_FOLDING
FOR_ALL_TAB_WINDOWS(tp, win) {
FOR_ALL_TAB_WINDOWS(tp, win)
{
if (win->w_buffer == curbuf)
foldMoveRange(&win->w_folds, line1, line2, dest);
}
@@ -737,7 +738,8 @@ do_move(linenr_T line1, linenr_T line2, linenr_T dest)
{
mark_adjust_nofold(dest + 1, line1 - 1, num_lines, 0L);
#ifdef FEAT_FOLDING
FOR_ALL_TAB_WINDOWS(tp, win) {
FOR_ALL_TAB_WINDOWS(tp, win)
{
if (win->w_buffer == curbuf)
foldMoveRange(&win->w_folds, dest + 1, line1 - 1, line2);
}
+2 -1
View File
@@ -98,7 +98,8 @@ typedef struct exarg exarg_T;
* Not supported commands are included to avoid ambiguities.
*/
#ifdef DO_DECLARE_EXCMD
# define EXCMD(a, b, c, d, e) {(char_u *)b, c, (long_u)(d), e}
# define EXCMD(a, b, c, d, e) \
{(char_u *)b, c, (long_u)(d), e}
typedef void (*ex_func_T) (exarg_T *eap);
+2 -1
View File
@@ -645,7 +645,8 @@ pointerEvent(BalloonEval *beval, XEvent *event)
XtTranslateKeycode(gui.dpy, event->xkey.keycode,
event->xkey.state, &modifier, &keysym);
if ((keysym == XK_Shift_L) || (keysym == XK_Shift_R)) {
if ((keysym == XK_Shift_L) || (keysym == XK_Shift_R))
{
beval->showState = ShS_UPDATE_PENDING;
(*beval->msgCB)(beval, 0);
}
+6 -5
View File
@@ -167,16 +167,17 @@ tabline_scroller_clicked(
Dimension width, height;
tab_scroll_w = XtNameToWidget(tabLine, scroller_name);
if (tab_scroll_w != (Widget)0) {
if (tab_scroll_w != (Widget)0)
{
XtVaGetValues(tab_scroll_w, XmNx, &pos_x, XmNy, &pos_y, XmNwidth,
&width, XmNheight, &height, NULL);
if (pos_x >= 0) {
if (pos_x >= 0)
{
// Tab scroller (next) is visible
if ((event->x >= pos_x) && (event->x <= pos_x + width) &&
(event->y >= pos_y) && (event->y <= pos_y + height)) {
if (event->x >= pos_x && event->x <= pos_x + width
&& event->y >= pos_y && event->y <= pos_y + height)
// Clicked on the scroller
return TRUE;
}
}
}
return FALSE;
+2 -1
View File
@@ -361,7 +361,8 @@ gui_ph_handle_window_cb(PtWidget_t *widget, void *data, PtCallbackInfo_t *info)
PhWindowEvent_t *we = info->cbdata;
ushort_t *width, *height;
switch (we->event_f) {
switch (we->event_f)
{
case Ph_WM_CLOSE:
gui_shell_closed();
break;
+5 -2
View File
@@ -3095,10 +3095,13 @@ gui_mch_getmouse(int *x, int *y)
unsigned int mask;
if (gui.wid && XQueryPointer(gui.dpy, gui.wid, &root, &child,
&rootx, &rooty, &winx, &winy, &mask)) {
&rootx, &rooty, &winx, &winy, &mask))
{
*x = winx;
*y = winy;
} else {
}
else
{
*x = -1;
*y = -1;
}
+11 -11
View File
@@ -281,21 +281,21 @@ static char * blank_xpm[] =
// width height ncolors cpp [x_hot y_hot]
"12 12 4 1 0 0",
// colors
" s iconColor1 m black c #000000",
"# s iconColor1 m black c #000000",
". s none m none c none",
"X s topShadowColor m none c #DCDEE5",
"o s bottomShadowColor m black c #5D6069",
// pixels
" ..",
" XXXXXXXX ..",
" X....... o.",
" X....... o.",
" X....... o.",
" X....... o.",
" X....... o.",
" X....... o.",
" X....... o.",
" o.",
"##########..",
"#XXXXXXXX#..",
"#X.......#o.",
"#X.......#o.",
"#X.......#o.",
"#X.......#o.",
"#X.......#o.",
"#X.......#o.",
"#X.......#o.",
"##########o.",
"..ooooooooo.",
"............"};
+4 -2
View File
@@ -1463,7 +1463,8 @@ cs_insert_filelist(
return -1;
}
(void)strcpy(csinfo[i].ppath, (const char *)ppath);
} else
}
else
csinfo[i].ppath = NULL;
if (flags != NULL)
@@ -1475,7 +1476,8 @@ cs_insert_filelist(
return -1;
}
(void)strcpy(csinfo[i].flags, (const char *)flags);
} else
}
else
csinfo[i].flags = NULL;
#if defined(UNIX)
+6 -3
View File
@@ -657,9 +657,11 @@ luaV_totypval(lua_State *L, int pos, typval_T *tv)
lua_pushvalue(L, pos);
lua_tableref = luaL_ref(L, LUA_REGISTRYINDEX);
if (lua_getmetatable(L, pos)) {
if (lua_getmetatable(L, pos))
{
lua_getfield(L, -1, LUA___CALL);
if (lua_isfunction(L, -1)) {
if (lua_isfunction(L, -1))
{
char_u *name;
int lua_funcref = luaL_ref(L, LUA_REGISTRYINDEX);
luaV_CFuncState *state = ALLOC_CLEAR_ONE(luaV_CFuncState);
@@ -827,7 +829,8 @@ luaV_msgfunc(lua_State *L, msgfunc_T mf)
luatyp *o = NULL; \
if (obj == NULL) \
lua_pushnil(L); \
else { \
else \
{ \
luaV_getudata(L, obj); \
if (lua_isnil(L, -1)) /* not interned? */ \
{ \
+6 -3
View File
@@ -1505,7 +1505,8 @@ BufferSubscript(PyObject *self, PyObject* idx)
{
long _idx = PyLong_AsLong(idx);
return BufferItem((BufferObject *)(self), _idx);
} else if (PySlice_Check(idx))
}
else if (PySlice_Check(idx))
{
Py_ssize_t start, stop, step, slicelen;
@@ -1539,7 +1540,8 @@ BufferAsSubscript(PyObject *self, PyObject* idx, PyObject* val)
return RBAsItem((BufferObject *)(self), n, val, 1,
(Py_ssize_t)((BufferObject *)(self))->buf->b_ml.ml_line_count,
NULL);
} else if (PySlice_Check(idx))
}
else if (PySlice_Check(idx))
{
Py_ssize_t start, stop, step, slicelen;
@@ -1623,7 +1625,8 @@ RangeSubscript(PyObject *self, PyObject* idx)
{
long _idx = PyLong_AsLong(idx);
return RangeItem((RangeObject *)(self), _idx);
} else if (PySlice_Check(idx))
}
else if (PySlice_Check(idx))
{
Py_ssize_t start, stop, step, slicelen;
+32 -20
View File
@@ -263,27 +263,39 @@ ins_ctrl_x(void)
/*
* Functions to check the current CTRL-X mode.
*/
int ctrl_x_mode_none(void) { return ctrl_x_mode == 0; }
int ctrl_x_mode_normal(void) { return ctrl_x_mode == CTRL_X_NORMAL; }
int ctrl_x_mode_scroll(void) { return ctrl_x_mode == CTRL_X_SCROLL; }
int ctrl_x_mode_whole_line(void) { return ctrl_x_mode == CTRL_X_WHOLE_LINE; }
int ctrl_x_mode_files(void) { return ctrl_x_mode == CTRL_X_FILES; }
int ctrl_x_mode_tags(void) { return ctrl_x_mode == CTRL_X_TAGS; }
int ctrl_x_mode_path_patterns(void) {
return ctrl_x_mode == CTRL_X_PATH_PATTERNS; }
int ctrl_x_mode_path_defines(void) {
return ctrl_x_mode == CTRL_X_PATH_DEFINES; }
int ctrl_x_mode_dictionary(void) { return ctrl_x_mode == CTRL_X_DICTIONARY; }
int ctrl_x_mode_thesaurus(void) { return ctrl_x_mode == CTRL_X_THESAURUS; }
int ctrl_x_mode_cmdline(void) {
return ctrl_x_mode == CTRL_X_CMDLINE
int ctrl_x_mode_none(void)
{ return ctrl_x_mode == 0; }
int ctrl_x_mode_normal(void)
{ return ctrl_x_mode == CTRL_X_NORMAL; }
int ctrl_x_mode_scroll(void)
{ return ctrl_x_mode == CTRL_X_SCROLL; }
int ctrl_x_mode_whole_line(void)
{ return ctrl_x_mode == CTRL_X_WHOLE_LINE; }
int ctrl_x_mode_files(void)
{ return ctrl_x_mode == CTRL_X_FILES; }
int ctrl_x_mode_tags(void)
{ return ctrl_x_mode == CTRL_X_TAGS; }
int ctrl_x_mode_path_patterns(void)
{ return ctrl_x_mode == CTRL_X_PATH_PATTERNS; }
int ctrl_x_mode_path_defines(void)
{ return ctrl_x_mode == CTRL_X_PATH_DEFINES; }
int ctrl_x_mode_dictionary(void)
{ return ctrl_x_mode == CTRL_X_DICTIONARY; }
int ctrl_x_mode_thesaurus(void)
{ return ctrl_x_mode == CTRL_X_THESAURUS; }
int ctrl_x_mode_cmdline(void)
{ return ctrl_x_mode == CTRL_X_CMDLINE
|| ctrl_x_mode == CTRL_X_CMDLINE_CTRL_X; }
int ctrl_x_mode_function(void) { return ctrl_x_mode == CTRL_X_FUNCTION; }
int ctrl_x_mode_omni(void) { return ctrl_x_mode == CTRL_X_OMNI; }
int ctrl_x_mode_spell(void) { return ctrl_x_mode == CTRL_X_SPELL; }
static int ctrl_x_mode_eval(void) { return ctrl_x_mode == CTRL_X_EVAL; }
int ctrl_x_mode_line_or_eval(void) {
return ctrl_x_mode == CTRL_X_WHOLE_LINE || ctrl_x_mode == CTRL_X_EVAL; }
int ctrl_x_mode_function(void)
{ return ctrl_x_mode == CTRL_X_FUNCTION; }
int ctrl_x_mode_omni(void)
{ return ctrl_x_mode == CTRL_X_OMNI; }
int ctrl_x_mode_spell(void)
{ return ctrl_x_mode == CTRL_X_SPELL; }
static int ctrl_x_mode_eval(void)
{ return ctrl_x_mode == CTRL_X_EVAL; }
int ctrl_x_mode_line_or_eval(void)
{ return ctrl_x_mode == CTRL_X_WHOLE_LINE || ctrl_x_mode == CTRL_X_EVAL; }
/*
* Whether other than default completion has been selected.
+8 -4
View File
@@ -274,14 +274,17 @@
# ifdef MSWIN
# ifndef isnan
# define isnan(x) _isnan(x)
static __inline int isinf(double x) { return !_finite(x) && !_isnan(x); }
static __inline int isinf(double x)
{ return !_finite(x) && !_isnan(x); }
# endif
# else
# ifndef HAVE_ISNAN
static inline int isnan(double x) { return x != x; }
static inline int isnan(double x)
{ return x != x; }
# endif
# ifndef HAVE_ISINF
static inline int isinf(double x) { return !isnan(x) && isnan(x - x); }
static inline int isinf(double x)
{ return !isnan(x) && isnan(x - x); }
# endif
# endif
# if !defined(INFINITY)
@@ -335,7 +338,8 @@
*/
#define VIM_CLEAR(p) \
do { \
if ((p) != NULL) { \
if ((p) != NULL) \
{ \
vim_free(p); \
(p) = NULL; \
} \
+19 -8
View File
@@ -59,13 +59,19 @@ nbdebug_wait(
#endif
// for debugging purposes only
if (wait_flags & WT_ENV && wait_var && getenv(wait_var) != NULL) {
if (wait_flags & WT_ENV && wait_var && getenv(wait_var) != NULL)
{
sleep(atoi(getenv(wait_var)));
} else if (wait_flags & WT_WAIT && lookup("~/.gvimwait")) {
}
else if (wait_flags & WT_WAIT && lookup("~/.gvimwait"))
{
sleep(wait_secs > 0 && wait_secs < 120 ? wait_secs : 20);
} else if (wait_flags & WT_STOP && lookup("~/.gvimstop")) {
}
else if (wait_flags & WT_STOP && lookup("~/.gvimstop"))
{
int w = 1;
while (w) {
while (w)
{
;
}
}
@@ -86,9 +92,12 @@ nbdebug_log_init(
nb_debug = fopen(file, "a");
time(&now);
fprintf(nb_debug, "%s", get_ctime(now, TRUE));
if (level_var && (cp = getenv(level_var)) != NULL) {
if (level_var && (cp = getenv(level_var)) != NULL)
{
nb_dlevel = strtoul(cp, NULL, 0);
} else {
}
else
{
nb_dlevel = NB_TRACE; // default level
}
#ifdef USE_NB_ERRORHANDLER
@@ -103,7 +112,8 @@ nbdbg(char *fmt, ...)
{
va_list ap;
if (nb_debug != NULL && nb_dlevel & NB_TRACE) {
if (nb_debug != NULL && nb_dlevel & NB_TRACE)
{
va_start(ap, fmt);
vfprintf(nb_debug, fmt, ap);
va_end(ap);
@@ -144,7 +154,8 @@ errorHandler(
"XRequest", buf, "Unknown", msg, sizeof(msg));
nbdbg("\tMajor opcode of failed request: %d (%s)\n",
err->request_code, msg);
if (err->request_code > 128) {
if (err->request_code > 128)
{
nbdbg("\tMinor opcode of failed request: %d\n",
err->minor_code);
}
+2 -1
View File
@@ -15,7 +15,8 @@
# ifndef ASSERT
# define ASSERT(c) \
if (!(c)) { \
if (!(c)) \
{ \
fprintf(stderr, "Assertion failed: line %d, file %s\n", \
__LINE__, __FILE__); \
fflush(stderr); \
+2 -1
View File
@@ -25,7 +25,8 @@
/*
* Used when building Vim.
*/
# define NVCMD(a, b, c, d) {a, b, c, d}
# define NVCMD(a, b, c, d) \
{a, b, c, d}
#ifdef FEAT_GUI
#define NV_VER_SCROLLBAR nv_ver_scrollbar
+2 -1
View File
@@ -2849,7 +2849,8 @@ static struct vimoption options[] =
{(char_u *)TRUE, (char_u *)0L} SCTX_INIT},
// terminal output codes
#define p_term(sss, vvv) {sss, NULL, P_STRING|P_VI_DEF|P_RALL|P_SECURE, \
#define p_term(sss, vvv) \
{sss, NULL, P_STRING|P_VI_DEF|P_RALL|P_SECURE, \
(char_u *)&vvv, PV_NONE, \
{(char_u *)"", (char_u *)0L} SCTX_INIT},
+2 -1
View File
@@ -1250,7 +1250,8 @@ dos_packet(
// Allocate space for a packet, make it public and clear it
packet = (struct StandardPacket *)
AllocMem((long) sizeof(struct StandardPacket), MEMF_PUBLIC | MEMF_CLEAR);
if (!packet) {
if (!packet)
{
DeletePort(replyport);
return (0);
}
+4 -2
View File
@@ -107,7 +107,8 @@ mac_string_convert(
// Determine output buffer size
CFStringGetBytes(cfstr, convertRange, to, NULL, FALSE, NULL, 0, (CFIndex *)&buflen);
retval = (buflen > 0) ? alloc(buflen) : NULL;
if (retval == NULL) {
if (retval == NULL)
{
CFRelease(cfstr);
return NULL;
}
@@ -543,7 +544,8 @@ mac_utf8_to_utf16(
utf8_str = CFStringCreateWithBytes(NULL, from, fromLen,
kCFStringEncodingUTF8, FALSE);
if (utf8_str == NULL) {
if (utf8_str == NULL)
{
if (actualLen)
*actualLen = 0;
return NULL;
+71 -34
View File
@@ -118,7 +118,8 @@ mch_settmode(tmode_T tmode)
if ( tmode == TMODE_RAW )
set_tty(0, 0);
else{
else
{
switch (orgmode.width)
{
case 132: OUT_STR_NF((char_u *)"\033[?3h\033>"); break;
@@ -379,16 +380,19 @@ vms_wproc(char *name, int val)
return 1;
// accept all DECC$K_FILE and DECC$K_DIRECTORY
if (vms_match_num == 0) {
if (vms_match_num == 0)
{
// first time through, setup some things
if (NULL == vms_fmatch) {
if (NULL == vms_fmatch)
{
vms_fmatch = ALLOC_MULT(char_u *, EXPL_ALLOC_INC);
if (!vms_fmatch)
return 0;
vms_match_alloced = EXPL_ALLOC_INC;
vms_match_free = EXPL_ALLOC_INC;
}
else {
else
{
// re-use existing space
vms_match_free = vms_match_alloced;
}
@@ -399,11 +403,13 @@ vms_wproc(char *name, int val)
name=vms_tolower(name);
// if name already exists, don't add it
for (i = 0; i<vms_match_num; i++) {
for (i = 0; i<vms_match_num; i++)
{
if (0 == STRCMP((char_u *)name,vms_fmatch[i]))
return 1;
}
if (--vms_match_free == 0) {
if (--vms_match_free == 0)
{
char_u **old_vms_fmatch = vms_fmatch;
// add more space to store matches
@@ -464,9 +470,12 @@ mch_expand_wildcards(int num_pat, char_u **pat, int *num_file, char_u ***file, i
vms_match_num = 0; // reset collection counter
result = decc$translate_vms(vms_fixfilename(buf));
if ( (int) result == 0 || (int) result == -1 ) {
if ( (int) result == 0 || (int) result == -1 )
{
cnt = 0;
} else {
}
else
{
cnt = decc$to_vms(result, vms_wproc, 1 /*allow wild*/ , (flags & EW_DIR ? 0:1 ) /*allow directory*/) ;
}
if (cnt > 0)
@@ -524,9 +533,12 @@ mch_expandpath(garray_T *gap, char_u *path, int flags)
// the result from the decc$translate_vms needs to be handled
// otherwise it might create ACCVIO error in decc$to_vms
result = decc$translate_vms(vms_fixfilename(path));
if ( (int) result == 0 || (int) result == -1 ) {
if ( (int) result == 0 || (int) result == -1 )
{
cnt = 0;
} else {
}
else
{
cnt = decc$to_vms(result, vms_wproc, 1 /*allow_wild*/, (flags & EW_DIR ? 0:1 ) /*allow directory*/);
}
if (cnt > 0)
@@ -554,7 +566,8 @@ vms_unix_mixed_filespec(char *in, char *out)
// copy vms filename portion up to last colon
// (node and/or disk)
lastcolon = strrchr(in, ':'); // find last colon
if (lastcolon != NULL) {
if (lastcolon != NULL)
{
len = lastcolon - in + 1;
strncpy(out, in, len);
out += len;
@@ -565,25 +578,34 @@ vms_unix_mixed_filespec(char *in, char *out)
// start of directory portion
ch = *in;
if ((ch == '[') || (ch == '/') || (ch == '<')) { // start of directory(s) ?
if ((ch == '[') || (ch == '/') || (ch == '<')) // start of directory(s) ?
{
ch = '[';
SKIP_FOLLOWING_SLASHES(in);
} else if (EQN(in, "../", 3)) { // Unix parent directory?
}
else if (EQN(in, "../", 3)) // Unix parent directory?
{
*out++ = '[';
*out++ = '-';
end_of_dir = out;
ch = '.';
in += 2;
SKIP_FOLLOWING_SLASHES(in);
} else { // not a special character
while (EQN(in, "./", 2)) { // Ignore Unix "current dir"
}
else
{ // not a special character
while (EQN(in, "./", 2)) // Ignore Unix "current dir"
{
in += 2;
SKIP_FOLLOWING_SLASHES(in);
}
if (strchr(in, '/') == NULL) { // any more Unix directories ?
if (strchr(in, '/') == NULL) // any more Unix directories ?
{
strcpy(out, in); // No - get rest of the spec
return;
} else {
}
else
{
*out++ = '['; // Yes, denote a Vms subdirectory
ch = '.';
--in;
@@ -596,26 +618,31 @@ vms_unix_mixed_filespec(char *in, char *out)
*out++ = ch;
++in;
while (*in != '\0') {
while (*in != '\0')
{
ch = *in;
if ((ch == ']') || (ch == '/') || (ch == '>') ) { // end of (sub)directory ?
if ((ch == ']') || (ch == '/') || (ch == '>') ) // end of (sub)directory ?
{
end_of_dir = out;
ch = '.';
SKIP_FOLLOWING_SLASHES(in);
}
else if (EQN(in, "../", 3)) { // Unix parent directory?
else if (EQN(in, "../", 3)) // Unix parent directory?
{
*out++ = '-';
end_of_dir = out;
ch = '.';
in += 2;
SKIP_FOLLOWING_SLASHES(in);
}
else {
while (EQN(in, "./", 2)) { // Ignore Unix "current dir"
end_of_dir = out;
in += 2;
SKIP_FOLLOWING_SLASHES(in);
ch = *in;
else
{
while (EQN(in, "./", 2)) // Ignore Unix "current dir"
{
end_of_dir = out;
in += 2;
SKIP_FOLLOWING_SLASHES(in);
ch = *in;
}
}
@@ -709,9 +736,12 @@ vms_remove_version(void * fname)
*cp = '\0';
else if ((cp = vim_strrchr( fname, '.')) != NULL )
{
if ((fp = vim_strrchr( fname, ']')) != NULL ) {;}
else if ((fp = vim_strrchr( fname, '>')) != NULL ) {;}
else fp = fname;
if ((fp = vim_strrchr( fname, ']')) != NULL )
{;}
else if ((fp = vim_strrchr( fname, '>')) != NULL )
{;}
else
fp = fname;
while ( *fp != '\0' && fp < cp )
if ( *fp++ == '.' )
@@ -750,7 +780,8 @@ RealWaitForChar(
if (!iochan)
get_tty();
if (sec > 0) {
if (sec > 0)
{
// time-out specified; convert it to absolute time
// sec>0 requirement of lib$cvtf_to_internal_time()
@@ -780,7 +811,8 @@ RealWaitForChar(
return 0; // error
}
while (TRUE) {
while (TRUE)
{
// select()
status = sys$qiow(0, iochan, IO$_SENSEMODE | IO$M_TYPEAHDCNT, iosb,
0, 0, &typeahead, 8, 0, 0, 0, 0);
@@ -791,13 +823,18 @@ RealWaitForChar(
return 1; // ready to read
// there's nothing to read; what now?
if (msec == 0) {
if (msec == 0)
{
// immediate time-out; return impatiently
return 0;
} else if (msec < 0) {
}
else if (msec < 0)
{
// no time-out; wait on indefinitely
return 1; // fakeout to force a wait in vms_read()
} else {
}
else
{
// time-out needs to be checked
status = sys$gettim(&time_curr);
if (status != SS$_NORMAL)
+3 -2
View File
@@ -283,7 +283,7 @@ static struct fmtpattern
{'m', ".\\+"}, // 7
#define FMT_PATTERN_R 8
{'r', ".*"}, // 8
{'p', "[- .]*"}, // 9
{'p', "[- .]*"}, // 9
{'v', "\\d\\+"}, // 10
{'s', ".\\+"}, // 11
{'o', ".\\+"} // 12
@@ -3623,7 +3623,8 @@ qf_list_entry(qfline_T *qfp, int qf_idx, int cursel)
if (qfp->qf_module != NULL && *qfp->qf_module != NUL)
vim_snprintf((char *)IObuff, IOSIZE, "%2d %s", qf_idx,
(char *)qfp->qf_module);
else {
else
{
if (qfp->qf_fnum != 0
&& (buf = buflist_findnr(qfp->qf_fnum)) != NULL)
{
+4 -2
View File
@@ -2696,11 +2696,13 @@ reg_save_equal(regsave_T *save)
REG_MULTI ? save_se_multi((savep), (posp)) : save_se_one((savep), (pp))
// After a failed match restore the sub-expressions.
#define restore_se(savep, posp, pp) { \
#define restore_se(savep, posp, pp) \
{ \
if (REG_MULTI) \
*(posp) = (savep)->se_u.pos; \
else \
*(pp) = (savep)->se_u.ptr; }
*(pp) = (savep)->se_u.ptr; \
}
/*
* Tentatively set the sub-expression start to the current position (after
+5 -4
View File
@@ -5799,10 +5799,11 @@ nfa_regmatch(
goto theend;
}
#define ADD_STATE_IF_MATCH(state) \
if (result) { \
add_state = state->out; \
add_off = clen; \
#define ADD_STATE_IF_MATCH(state) \
if (result) \
{ \
add_state = state->out; \
add_off = clen; \
}
/*
+2 -2
View File
@@ -161,7 +161,7 @@ search_regcomp(
add_to_history(HIST_SEARCH, pat, TRUE, NUL);
if (used_pat)
*used_pat = pat;
*used_pat = pat;
vim_free(mr_pattern);
#ifdef FEAT_RIGHTLEFT
@@ -2641,7 +2641,7 @@ findmatchlimit(
* (actually, we skip #\( et al)
*/
if (curbuf->b_p_lisp
&& vim_strchr((char_u *)"(){}[]", c) != NULL
&& vim_strchr((char_u *)"{}()[]", c) != NULL
&& pos.col > 1
&& check_prevcol(linep, pos.col, '\\', NULL)
&& check_prevcol(linep, pos.col - 1, '#', NULL))
+29 -14
View File
@@ -286,15 +286,19 @@ tgetstr(char *id, char **buf)
if (!*tmp)
break;
if (_match(id, tmp) == len) {
if (_match(id, tmp) == len)
{
tmp += len; // find '=' '@' or '#'
if (*tmp == '@') // :xx@: entry for tc
return 0; // deleted entry
hold= *buf;
while (*++tmp && *tmp != ':') { // not at end of field
switch(*tmp) {
while (*++tmp && *tmp != ':') // not at end of field
{
switch(*tmp)
{
case '\\': // Expand escapes here
switch(*++tmp) {
switch(*++tmp)
{
case 0: // ignore backslashes
tmp--; // at end of entry
break; // shouldn't happen
@@ -401,11 +405,16 @@ tgoto(
bufp = buffer;
ptr = cm;
while (*ptr) {
if ((c = *ptr++) != '%') { // normal char
while (*ptr)
{
if ((c = *ptr++) != '%') // normal char
{
*bufp++ = c;
} else { // % escape
switch(c = *ptr++) {
}
else
{ // % escape
switch(c = *ptr++)
{
case 'd': // decimal
bufp = _addfmt(bufp, "%d", line);
line = col;
@@ -430,7 +439,8 @@ tgoto(
if (line == '\t' || // these are
line == '\n' || // chars that
line == '\004' || // UNIX hates
line == '\0') {
line == '\0')
{
line++; // so go to next pos
if (reverse == (line == col))
addup=1; // and mark UP
@@ -472,7 +482,8 @@ tgoto(
}
if (addup) // add upline
if (UP) {
if (UP)
{
ptr=UP;
while (VIM_ISDIGIT(*ptr) || *ptr == '.')
ptr++;
@@ -483,7 +494,8 @@ tgoto(
}
if (addbak) // add backspace
if (BC) {
if (BC)
{
ptr=BC;
while (VIM_ISDIGIT(*ptr) || *ptr == '.')
ptr++;
@@ -536,17 +548,20 @@ tputs(
counter, // digits
atol(const char *);
if (VIM_ISDIGIT(*cp)) {
if (VIM_ISDIGIT(*cp))
{
counter = 0;
frac = 1000;
while (VIM_ISDIGIT(*cp))
counter = counter * 10L + (long)(*cp++ - '0');
if (*cp == '.')
while (VIM_ISDIGIT(*++cp)) {
while (VIM_ISDIGIT(*++cp))
{
counter = counter * 10L + (long)(*cp++ - '0');
frac = frac * 10;
}
if (*cp!='*') { // multiply by affected lines
if (*cp!='*') // multiply by affected lines
{
if (affcnt>1) affcnt = 1;
}
else
+2
View File
@@ -97,6 +97,7 @@ NEW_TESTS = \
test_cmdline \
test_cmdmods \
test_cmdwin \
test_codestyle \
test_command_count \
test_comments \
test_comparators \
@@ -359,6 +360,7 @@ NEW_TESTS_RES = \
test_cmdline.res \
test_cmdmods.res \
test_cmdwin.res \
test_codestyle.res \
test_command_count.res \
test_comments.res \
test_comparators.res \
+45
View File
@@ -0,0 +1,45 @@
" Test for checking the source code style.
def Test_source_files()
for fname in glob('../*.[ch]', 0, 1)
exe 'edit ' .. fname
cursor(1, 1)
var lnum = search(' \t')
assert_equal(0, lnum, fname .. ': space before tab')
cursor(1, 1)
lnum = search('\s$')
assert_equal(0, lnum, fname .. ': trailing white space')
# some files don't stick to the Vim style rules
if fname =~ 'iscygpty.c'
continue
endif
# Examples in comments use "condition) {", skip them.
# Skip if a double quote or digit comes after the "{".
# Skip specific string used in os_unix.c.
# Also skip fold markers.
var skip = 'getline(".") =~ "condition) {" || getline(".") =~ "vimglob_func" || getline(".") =~ "{\"" || getline(".") =~ "{\\d" || getline(".") =~ "{{{"'
cursor(1, 1)
lnum = search(')\s*{', '', 0, 0, skip)
assert_equal(0, lnum, fname .. ': curly after closing paren')
cursor(1, 1)
# Examples in comments use double quotes.
skip = "getline('.') =~ '\"'"
# Avoid examples that contain: "} else
lnum = search('[^"]}\s*else', '', 0, 0, skip)
assert_equal(0, lnum, fname .. ': curly before "else"')
cursor(1, 1)
lnum = search('else\s*{', '', 0, 0, skip)
assert_equal(0, lnum, fname .. ': curly after "else"')
endfor
bwipe!
enddef
" vim: shiftwidth=2 sts=2 expandtab
+2 -1
View File
@@ -49,7 +49,8 @@ reg_delete_key(HKEY hRootKey, const char *key, DWORD flag)
if (advapi_lib != NULL)
delete_key_ex = (LONG (WINAPI *)(HKEY, LPCTSTR, REGSAM, DWORD))GetProcAddress(advapi_lib, "RegDeleteKeyExA");
}
if (delete_key_ex != NULL) {
if (delete_key_ex != NULL)
{
return (*delete_key_ex)(hRootKey, key, flag, 0);
}
return RegDeleteKey(hRootKey, key);
+2
View File
@@ -695,6 +695,8 @@ static char *(features[]) =
static int included_patches[] =
{ /* Add new patch number below this line */
/**/
1234,
/**/
1233,
/**/
+20 -10
View File
@@ -2498,24 +2498,34 @@ typedef enum {
# define gtk_widget_set_window(wid, win) \
do { (wid)->window = (win); } while (0)
# define gtk_widget_set_can_default(wid, can) \
do { if (can) { GTK_WIDGET_SET_FLAGS(wid, GTK_CAN_DEFAULT); } \
else { GTK_WIDGET_UNSET_FLAGS(wid, GTK_CAN_DEFAULT); } } while (0)
do { if (can) \
{ GTK_WIDGET_SET_FLAGS(wid, GTK_CAN_DEFAULT); } \
else \
{ GTK_WIDGET_UNSET_FLAGS(wid, GTK_CAN_DEFAULT); } } while (0)
# define gtk_widget_set_can_focus(wid, can) \
do { if (can) { GTK_WIDGET_SET_FLAGS(wid, GTK_CAN_FOCUS); } \
else { GTK_WIDGET_UNSET_FLAGS(wid, GTK_CAN_FOCUS); } } while (0)
do { if (can) \
{ GTK_WIDGET_SET_FLAGS(wid, GTK_CAN_FOCUS); } \
else \
{ GTK_WIDGET_UNSET_FLAGS(wid, GTK_CAN_FOCUS); } } while (0)
# define gtk_widget_set_visible(wid, vis) \
do { if (vis) { gtk_widget_show(wid); } \
else { gtk_widget_hide(wid); } } while (0)
do { if (vis) \
{ gtk_widget_show(wid); } \
else \
{ gtk_widget_hide(wid); } } while (0)
# endif
# if !GTK_CHECK_VERSION(2,20,0)
# define gtk_widget_get_mapped(wid) GTK_WIDGET_MAPPED(wid)
# define gtk_widget_get_realized(wid) GTK_WIDGET_REALIZED(wid)
# define gtk_widget_set_mapped(wid, map) \
do { if (map) { GTK_WIDGET_SET_FLAGS(wid, GTK_MAPPED); } \
else { GTK_WIDGET_UNSET_FLAGS(wid, GTK_MAPPED); } } while (0)
do { if (map) \
{ GTK_WIDGET_SET_FLAGS(wid, GTK_MAPPED); } \
else \
{ GTK_WIDGET_UNSET_FLAGS(wid, GTK_MAPPED); } } while (0)
# define gtk_widget_set_realized(wid, rea) \
do { if (rea) { GTK_WIDGET_SET_FLAGS(wid, GTK_REALIZED); } \
else { GTK_WIDGET_UNSET_FLAGS(wid, GTK_REALIZED); } } while (0)
do { if (rea) \
{ GTK_WIDGET_SET_FLAGS(wid, GTK_REALIZED); } \
else \
{ GTK_WIDGET_UNSET_FLAGS(wid, GTK_REALIZED); } } while (0)
# endif
#endif