patch 9.1.1363: style: inconsistent indentation in various files

Problem:  style: inconsistent indentation in various files
Solution: fix style, updated codestyle test
          (Naruhiko Nishino)

closes: #17254

Signed-off-by: Naruhiko Nishino <naru123456789@gmail.com>
Signed-off-by: Christian Brabandt <cb@256bit.org>
This commit is contained in:
Naruhiko Nishino
2025-05-04 20:05:47 +02:00
committed by Christian Brabandt
parent 41cddfa177
commit c2a9000bc1
17 changed files with 1580 additions and 1556 deletions
+4 -4
View File
@@ -406,10 +406,10 @@ cin_islabel_skip(char_u **s)
while (vim_isIDc(**s))
{
if (has_mbyte)
(*s) += (*mb_ptr2len)(*s);
else
(*s)++;
if (has_mbyte)
(*s) += (*mb_ptr2len)(*s);
else
(*s)++;
}
*s = cin_skipcomment(*s);
+1 -1
View File
@@ -2221,7 +2221,7 @@ adjust_clip_reg(int *rp)
&& clip_plus.available) ? '+' : '*';
}
if ((!clip_star.available && *rp == '*') ||
(!clip_plus.available && *rp == '+'))
(!clip_plus.available && *rp == '+'))
{
msg_warn_missing_clipboard();
*rp = 0;
+15 -15
View File
@@ -5582,34 +5582,34 @@ f_get(typval_T *argvars, typval_T *rettv)
f_getcellpixels(typval_T *argvars UNUSED, typval_T *rettv)
{
if (rettv_list_alloc(rettv) == FAIL)
return;
return;
#if defined(FEAT_GUI)
if (gui.in_use)
{
// success pixel size and no gui.
list_append_number(rettv->vval.v_list, (varnumber_T)gui.char_width);
list_append_number(rettv->vval.v_list, (varnumber_T)gui.char_height);
// success pixel size and no gui.
list_append_number(rettv->vval.v_list, (varnumber_T)gui.char_width);
list_append_number(rettv->vval.v_list, (varnumber_T)gui.char_height);
}
else
#endif
{
struct cellsize cs;
struct cellsize cs;
#if defined(UNIX)
mch_calc_cell_size(&cs);
mch_calc_cell_size(&cs);
#else
// Non-Unix CUIs are not supported, so set this to -1x-1.
cs.cs_xpixel = -1;
cs.cs_ypixel = -1;
// Non-Unix CUIs are not supported, so set this to -1x-1.
cs.cs_xpixel = -1;
cs.cs_ypixel = -1;
#endif
// failed get pixel size.
if (cs.cs_xpixel == -1)
return;
// failed get pixel size.
if (cs.cs_xpixel == -1)
return;
// success pixel size and no gui.
list_append_number(rettv->vval.v_list, (varnumber_T)cs.cs_xpixel);
list_append_number(rettv->vval.v_list, (varnumber_T)cs.cs_ypixel);
// success pixel size and no gui.
list_append_number(rettv->vval.v_list, (varnumber_T)cs.cs_xpixel);
list_append_number(rettv->vval.v_list, (varnumber_T)cs.cs_ypixel);
}
}
+1 -1
View File
@@ -5975,7 +5975,7 @@ get_command_name(expand_T *xp UNUSED, int idx)
return expand_user_command_name(idx);
// the following are no real commands
if (STRNCMP(cmdnames[idx].cmd_name, "{", 1) == 0 ||
STRNCMP(cmdnames[idx].cmd_name, "}", 1) == 0)
STRNCMP(cmdnames[idx].cmd_name, "}", 1) == 0)
return (char_u *)"";
return cmdnames[idx].cmd_name;
}
+4 -4
View File
@@ -1127,17 +1127,17 @@ messagesopt_changed(void)
// Either "wait" or "hit-enter" is required
if (!(messages_flags_new & (MESSAGES_HIT_ENTER | MESSAGES_WAIT)))
return FAIL;
return FAIL;
// "history" must be set
if (!(messages_flags_new & MESSAGES_HISTORY))
return FAIL;
return FAIL;
if (messages_history_new < 0 || messages_history_new > 10000)
return FAIL;
return FAIL;
if (messages_wait_new < 0 || messages_wait_new > 10000)
return FAIL;
return FAIL;
msg_flags = messages_flags_new;
msg_wait = messages_wait_new;
+5 -5
View File
@@ -4440,14 +4440,14 @@ mch_report_winsize(int fd, int rows, int cols)
if (cs.cs_xpixel == -1)
{
// failed get pixel size.
ws.ws_xpixel = 0;
ws.ws_ypixel = 0;
// failed get pixel size.
ws.ws_xpixel = 0;
ws.ws_ypixel = 0;
}
else
{
ws.ws_xpixel = cols * cs.cs_xpixel;
ws.ws_ypixel = rows * cs.cs_ypixel;
ws.ws_xpixel = cols * cs.cs_xpixel;
ws.ws_ypixel = rows * cs.cs_ypixel;
}
retval = ioctl(tty_fd, TIOCSWINSZ, &ws);
+3 -3
View File
@@ -971,7 +971,7 @@ PlatformId(void)
ovi.dwOSVersionInfoSize = sizeof(ovi);
if (!GetVersionEx(&ovi))
return;
return;
#ifdef FEAT_EVAL
vim_snprintf(windowsVersion, sizeof(windowsVersion), "%d.%d",
@@ -988,7 +988,7 @@ PlatformId(void)
#ifdef HAVE_ACL
// Enable privilege for getting or setting SACLs.
if (!win32_enable_privilege(SE_SECURITY_NAME))
return;
return;
#endif
}
#ifdef _MSC_VER
@@ -6349,7 +6349,7 @@ termcap_mode_end(void)
// Switch back to main screen buffer.
if (exiting && use_alternate_screen_buffer)
vtp_printf("\033[?1049l");
vtp_printf("\033[?1049l");
if (!USE_WT && (p_rs || exiting))
{
+47 -47
View File
@@ -228,7 +228,7 @@ pum_display(
pum_size = size;
pum_compute_size();
max_width = pum_base_width;
if (p_pmw > 0 && max_width > p_pmw)
if (p_pmw > 0 && max_width > p_pmw)
max_width = p_pmw;
// Calculate column
@@ -785,61 +785,61 @@ pum_process_item(
for ( ; ; MB_PTR_ADV(p))
{
if (s == NULL)
s = p;
w = ptr2cells(p);
if (*p != NUL && *p != TAB && *totwidth_ptr + w <= pum_width)
{
width += w;
continue;
}
if (s == NULL)
s = p;
w = ptr2cells(p);
if (*p != NUL && *p != TAB && *totwidth_ptr + w <= pum_width)
{
width += w;
continue;
}
// Display the text that fits or comes before a Tab.
// First convert it to printable characters.
char_u *st;
int *attrs = NULL;
int saved = *p;
// Display the text that fits or comes before a Tab.
// First convert it to printable characters.
char_u *st;
int *attrs = NULL;
int saved = *p;
if (saved != NUL)
*p = NUL;
st = transstr(s);
if (saved != NUL)
*p = saved;
if (saved != NUL)
*p = NUL;
st = transstr(s);
if (saved != NUL)
*p = saved;
if (item_type == CPT_ABBR)
attrs = pum_compute_text_attrs(st, hlf,
pum_array[idx].pum_user_abbr_hlattr);
if (item_type == CPT_ABBR)
attrs = pum_compute_text_attrs(st, hlf,
pum_array[idx].pum_user_abbr_hlattr);
#ifdef FEAT_RIGHTLEFT
if (pum_rl)
col = pum_display_rtl_text(row, col, st, attr, attrs,
width, pum_width, *totwidth_ptr, next_isempty);
else
if (pum_rl)
col = pum_display_rtl_text(row, col, st, attr, attrs,
width, pum_width, *totwidth_ptr, next_isempty);
else
#endif
col = pum_display_ltr_text(row, col, st, attr, attrs,
width, pum_width, *totwidth_ptr, next_isempty);
col = pum_display_ltr_text(row, col, st, attr, attrs,
width, pum_width, *totwidth_ptr, next_isempty);
if (attrs != NULL)
VIM_CLEAR(attrs);
if (attrs != NULL)
VIM_CLEAR(attrs);
if (*p != TAB)
break;
if (*p != TAB)
break;
// Display two spaces for a Tab.
// Display two spaces for a Tab.
#ifdef FEAT_RIGHTLEFT
if (pum_rl)
{
screen_puts_len((char_u *)" ", 2, row, col - 1, attr);
col -= 2;
}
else
if (pum_rl)
{
screen_puts_len((char_u *)" ", 2, row, col - 1, attr);
col -= 2;
}
else
#endif
{
screen_puts_len((char_u *)" ", 2, row, col, attr);
col += 2;
}
*totwidth_ptr += 2;
s = NULL; // start text at next char
width = 0;
{
screen_puts_len((char_u *)" ", 2, row, col, attr);
col += 2;
}
*totwidth_ptr += 2;
s = NULL; // start text at next char
width = 0;
}
return col;
@@ -856,7 +856,7 @@ pum_draw_scrollbar(
int thumb_height)
{
if (pum_scrollbar <= 0)
return;
return;
int attr = (i >= thumb_pos && i < thumb_pos + thumb_height) ?
highlight_attr[HLF_PST] : highlight_attr[HLF_PSB];
+2 -2
View File
@@ -3592,8 +3592,8 @@ popup_do_filter(int c)
{
popup_reset_handled(POPUP_HANDLED_2);
wp = find_next_popup(FALSE, POPUP_HANDLED_2);
if (wp != NULL)
{
if (wp != NULL)
{
popup_close_with_retval(wp, -1);
res = TRUE;
}
+6 -6
View File
@@ -2268,12 +2268,12 @@ qf_add_entry(
if (buf != NULL &&
buf->b_ffname != NULL && fullname != NULL)
{
if (fnamecmp(fullname, buf->b_ffname) != 0)
{
p = shorten_fname1(fullname);
if (p != NULL)
if (fnamecmp(fullname, buf->b_ffname) != 0)
{
p = shorten_fname1(fullname);
if (p != NULL)
qfp->qf_fname = vim_strsave(p);
}
}
}
vim_free(fullname);
if ((qfp->qf_text = vim_strsave(mesg)) == NULL)
@@ -7893,7 +7893,7 @@ qf_add_entries(
{
entry_to_select = entry;
entry_to_select_index = qfl->qf_count;
}
}
}
// Check if any valid error entries are added to the list.
+7 -7
View File
@@ -4518,13 +4518,13 @@ fuzzy_match_compute_score(
}
// Check exact match condition
if (currIdx != (int_u)i)
if (currIdx != (int_u)i)
is_exact_match = FALSE;
}
// Boost score for exact matches
if (is_exact_match && numMatches == strSz)
score += EXACT_MATCH_BONUS;
score += EXACT_MATCH_BONUS;
return score;
}
@@ -5265,7 +5265,7 @@ fuzzy_match_str_in_line(
char_u *line_end = NULL;
if (str == NULL || pat == NULL)
return found;
return found;
line_end = find_line_end(str);
while (str < line_end)
@@ -5333,12 +5333,12 @@ search_for_fuzzy_match(
int whole_line = ctrl_x_mode_whole_line();
if (buf == curbuf)
circly_end = *start_pos;
circly_end = *start_pos;
else
{
circly_end.lnum = buf->b_ml.ml_line_count;
circly_end.col = 0;
circly_end.coladd = 0;
circly_end.lnum = buf->b_ml.ml_line_count;
circly_end.col = 0;
circly_end.coladd = 0;
}
if (whole_line && start_pos->lnum != pos->lnum)
+1174 -1174
View File
File diff suppressed because it is too large Load Diff
+103 -103
View File
@@ -48,23 +48,23 @@ get_sound_callback(typval_T *arg)
soundcb_T *soundcb;
if (arg->v_type == VAR_UNKNOWN)
return NULL;
return NULL;
callback = get_callback(arg);
if (callback.cb_name == NULL)
return NULL;
return NULL;
soundcb = ALLOC_ONE(soundcb_T);
if (soundcb == NULL)
{
free_callback(&callback);
return NULL;
free_callback(&callback);
return NULL;
}
soundcb->snd_next = first_callback;
first_callback = soundcb;
set_callback(&soundcb->snd_callback, &callback);
if (callback.cb_free_name)
vim_free(callback.cb_name);
vim_free(callback.cb_name);
return soundcb;
}
@@ -97,16 +97,16 @@ delete_sound_callback(soundcb_T *soundcb)
soundcb_T *prev = NULL;
for (p = first_callback; p != NULL; prev = p, p = p->snd_next)
if (p == soundcb)
{
if (prev == NULL)
first_callback = p->snd_next;
else
prev->snd_next = p->snd_next;
free_callback(&p->snd_callback);
vim_free(p);
break;
}
if (p == soundcb)
{
if (prev == NULL)
first_callback = p->snd_next;
else
prev->snd_next = p->snd_next;
free_callback(&p->snd_callback);
vim_free(p);
break;
}
}
# if defined(HAVE_CANBERRA) || defined(PROTO)
@@ -139,24 +139,24 @@ static soundcb_queue_T *callback_queue = NULL;
*/
static void
sound_callback(ca_context *c UNUSED,
uint32_t id,
int error_code,
void *userdata)
uint32_t id,
int error_code,
void *userdata)
{
soundcb_T *soundcb = (soundcb_T *)userdata;
soundcb_queue_T *scb;
scb = ALLOC_ONE(soundcb_queue_T);
if (scb == NULL)
return;
return;
scb->scb_next = callback_queue;
callback_queue = scb;
scb->scb_id = id;
scb->scb_result = error_code == CA_SUCCESS ? 0
: error_code == CA_ERROR_CANCELED ||
error_code == CA_ERROR_DESTROYED
? 1
: 2;
: error_code == CA_ERROR_CANCELED ||
error_code == CA_ERROR_DESTROYED
? 1
: 2;
scb->scb_callback = soundcb;
}
@@ -179,13 +179,13 @@ invoke_sound_callback(void)
while (callback_queue != NULL)
{
scb = callback_queue;
callback_queue = scb->scb_next;
scb = callback_queue;
callback_queue = scb->scb_next;
call_sound_callback(scb->scb_callback, scb->scb_id, scb->scb_result);
call_sound_callback(scb->scb_callback, scb->scb_id, scb->scb_result);
delete_sound_callback(scb->scb_callback);
vim_free(scb);
delete_sound_callback(scb->scb_callback);
vim_free(scb);
}
redraw_after_callback(TRUE, FALSE);
}
@@ -194,12 +194,12 @@ static void
sound_play_common(typval_T *argvars, typval_T *rettv, int playfile)
{
if (in_vim9script() && check_for_string_arg(argvars, 0) == FAIL)
return;
return;
if (context == NULL)
ca_context_create(&context);
ca_context_create(&context);
if (context == NULL)
return;
return;
soundcb_T *soundcb = get_sound_callback(&argvars[1]);
int res = CA_ERROR_INVALID;
@@ -207,34 +207,34 @@ sound_play_common(typval_T *argvars, typval_T *rettv, int playfile)
++sound_id;
if (soundcb == NULL)
{
res = ca_context_play(context, sound_id,
playfile ? CA_PROP_MEDIA_FILENAME
: CA_PROP_EVENT_ID,
tv_get_string(&argvars[0]),
CA_PROP_CANBERRA_CACHE_CONTROL, "volatile", NULL);
res = ca_context_play(context, sound_id,
playfile ? CA_PROP_MEDIA_FILENAME
: CA_PROP_EVENT_ID,
tv_get_string(&argvars[0]),
CA_PROP_CANBERRA_CACHE_CONTROL, "volatile", NULL);
}
else
{
static ca_proplist *proplist = NULL;
static ca_proplist *proplist = NULL;
ca_proplist_create(&proplist);
if (proplist != NULL)
{
if (playfile)
ca_proplist_sets(proplist, CA_PROP_MEDIA_FILENAME,
(char *)tv_get_string(&argvars[0]));
else
ca_proplist_sets(proplist, CA_PROP_EVENT_ID,
(char *)tv_get_string(&argvars[0]));
ca_proplist_sets(proplist, CA_PROP_CANBERRA_CACHE_CONTROL,
"volatile");
res = ca_context_play_full(context, sound_id, proplist,
sound_callback, soundcb);
if (res != CA_SUCCESS)
delete_sound_callback(soundcb);
ca_proplist_create(&proplist);
if (proplist != NULL)
{
if (playfile)
ca_proplist_sets(proplist, CA_PROP_MEDIA_FILENAME,
(char *)tv_get_string(&argvars[0]));
else
ca_proplist_sets(proplist, CA_PROP_EVENT_ID,
(char *)tv_get_string(&argvars[0]));
ca_proplist_sets(proplist, CA_PROP_CANBERRA_CACHE_CONTROL,
"volatile");
res = ca_context_play_full(context, sound_id, proplist,
sound_callback, soundcb);
if (res != CA_SUCCESS)
delete_sound_callback(soundcb);
ca_proplist_destroy(proplist);
}
ca_proplist_destroy(proplist);
}
}
rettv->vval.v_number = res == CA_SUCCESS ? sound_id : 0;
}
@@ -261,10 +261,10 @@ void
f_sound_stop(typval_T *argvars, typval_T *rettv UNUSED)
{
if (in_vim9script() && check_for_number_arg(argvars, 0) == FAIL)
return;
return;
if (context != NULL)
ca_context_cancel(context, tv_get_number(&argvars[0]));
ca_context_cancel(context, tv_get_number(&argvars[0]));
}
/*
@@ -274,7 +274,7 @@ void
f_sound_clear(typval_T *argvars UNUSED, typval_T *rettv UNUSED)
{
if (context == NULL)
return;
return;
ca_context_destroy(context);
context = NULL;
}
@@ -286,17 +286,17 @@ sound_free(void)
soundcb_queue_T *scb;
if (context != NULL)
ca_context_destroy(context);
ca_context_destroy(context);
while (first_callback != NULL)
delete_sound_callback(first_callback);
delete_sound_callback(first_callback);
while (callback_queue != NULL)
{
scb = callback_queue;
callback_queue = scb->scb_next;
delete_sound_callback(scb->scb_callback);
vim_free(scb);
scb = callback_queue;
callback_queue = scb->scb_next;
delete_sound_callback(scb->scb_callback);
vim_free(scb);
}
}
# endif
@@ -316,25 +316,25 @@ sound_wndproc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
switch (message)
{
case MM_MCINOTIFY:
for (p = first_callback; p != NULL; p = p->snd_next)
if (p->snd_device_id == (MCIDEVICEID)lParam)
{
char buf[32];
case MM_MCINOTIFY:
for (p = first_callback; p != NULL; p = p->snd_next)
if (p->snd_device_id == (MCIDEVICEID)lParam)
{
char buf[32];
vim_snprintf(buf, sizeof(buf), "close sound%06ld",
p->snd_id);
mciSendStringA(buf, NULL, 0, 0);
vim_snprintf(buf, sizeof(buf), "close sound%06ld",
p->snd_id);
mciSendStringA(buf, NULL, 0, 0);
long result = wParam == MCI_NOTIFY_SUCCESSFUL ? 0
: wParam == MCI_NOTIFY_ABORTED ? 1
: 2;
call_sound_callback(p, p->snd_id, result);
long result = wParam == MCI_NOTIFY_SUCCESSFUL ? 0
: wParam == MCI_NOTIFY_ABORTED ? 1
: 2;
call_sound_callback(p, p->snd_id, result);
delete_sound_callback(p);
redraw_after_callback(TRUE, FALSE);
}
break;
delete_sound_callback(p);
redraw_after_callback(TRUE, FALSE);
}
break;
}
return DefWindowProc(hwnd, message, wParam, lParam);
@@ -345,12 +345,12 @@ sound_window(void)
{
if (g_hWndSound == NULL)
{
LPCSTR clazz = "VimSound";
WNDCLASS wndclass = { 0, sound_wndproc, 0, 0, g_hinst, NULL, 0,
0, NULL, clazz };
RegisterClass(&wndclass);
g_hWndSound = CreateWindow(clazz, NULL, 0, 0, 0, 0, 0, HWND_MESSAGE,
NULL, g_hinst, NULL);
LPCSTR clazz = "VimSound";
WNDCLASS wndclass = { 0, sound_wndproc, 0, 0, g_hinst, NULL, 0,
0, NULL, clazz };
RegisterClass(&wndclass);
g_hWndSound = CreateWindow(clazz, NULL, 0, 0, 0, 0, 0, HWND_MESSAGE,
NULL, g_hinst, NULL);
}
return g_hWndSound;
@@ -362,14 +362,14 @@ f_sound_playevent(typval_T *argvars, typval_T *rettv)
WCHAR *wp;
if (in_vim9script() && check_for_string_arg(argvars, 0) == FAIL)
return;
return;
wp = enc_to_utf16(tv_get_string(&argvars[0]), NULL);
if (wp == NULL)
return;
return;
if (PlaySoundW(wp, NULL, SND_ASYNC | SND_ALIAS))
rettv->vval.v_number = ++sound_id;
rettv->vval.v_number = ++sound_id;
free(wp);
}
@@ -385,7 +385,7 @@ f_sound_playfile(typval_T *argvars, typval_T *rettv)
MCIERROR err;
if (in_vim9script() && check_for_string_arg(argvars, 0) == FAIL)
return;
return;
filename = tv_get_string(&argvars[0]);
@@ -393,25 +393,25 @@ f_sound_playfile(typval_T *argvars, typval_T *rettv)
p = alloc(len);
if (p == NULL)
{
return;
return;
}
vim_snprintf((char *)p, len, "open \"%s\" alias sound%06ld", filename,
newid);
newid);
wp = enc_to_utf16((char_u *)p, NULL);
free(p);
if (wp == NULL)
return;
return;
err = mciSendStringW(wp, NULL, 0, sound_window());
free(wp);
if (err != 0)
return;
return;
vim_snprintf(buf, sizeof(buf), "play sound%06ld notify", newid);
err = mciSendStringA(buf, NULL, 0, sound_window());
if (err != 0)
goto failure;
goto failure;
sound_id = newid;
rettv->vval.v_number = sound_id;
@@ -419,9 +419,9 @@ f_sound_playfile(typval_T *argvars, typval_T *rettv)
soundcb = get_sound_callback(&argvars[1]);
if (soundcb != NULL)
{
vim_snprintf(buf, sizeof(buf), "sound%06ld", newid);
soundcb->snd_id = newid;
soundcb->snd_device_id = mciGetDeviceID(buf);
vim_snprintf(buf, sizeof(buf), "sound%06ld", newid);
soundcb->snd_id = newid;
soundcb->snd_device_id = mciGetDeviceID(buf);
}
return;
@@ -437,7 +437,7 @@ f_sound_stop(typval_T *argvars, typval_T *rettv UNUSED)
char buf[32];
if (in_vim9script() && check_for_number_arg(argvars, 0) == FAIL)
return;
return;
id = tv_get_number(&argvars[0]);
vim_snprintf(buf, sizeof(buf), "stop sound%06ld", id);
@@ -458,7 +458,7 @@ sound_free(void)
CloseWindow(g_hWndSound);
while (first_callback != NULL)
delete_sound_callback(first_callback);
delete_sound_callback(first_callback);
}
# endif
@@ -469,7 +469,7 @@ static void
sound_play_common(typval_T *argvars, typval_T *rettv, bool playfile)
{
if (in_vim9script() && check_for_string_arg(argvars, 0) == FAIL)
return;
return;
char_u *sound_name = tv_get_string(&argvars[0]);
soundcb_T *soundcb = get_sound_callback(&argvars[1]);
@@ -479,7 +479,7 @@ sound_play_common(typval_T *argvars, typval_T *rettv, bool playfile)
bool play_success = sound_mch_play(sound_name, sound_id, soundcb, playfile);
if (!play_success && soundcb)
{
delete_sound_callback(soundcb);
delete_sound_callback(soundcb);
}
rettv->vval.v_number = play_success ? sound_id : 0;
}
@@ -500,7 +500,7 @@ void
f_sound_stop(typval_T *argvars, typval_T *rettv UNUSED)
{
if (in_vim9script() && check_for_number_arg(argvars, 0) == FAIL)
return;
return;
sound_mch_stop(tv_get_number(&argvars[0]));
}
@@ -516,7 +516,7 @@ sound_free(void)
{
sound_mch_free();
while (first_callback != NULL)
delete_sound_callback(first_callback);
delete_sound_callback(first_callback);
}
# endif
+2 -2
View File
@@ -603,9 +603,9 @@ vim_strnicmp_asc(char *s1, char *s2, size_t len)
{
i = TOLOWER_ASC(*s1) - TOLOWER_ASC(*s2);
if (i != 0)
break; // this character is different
break; // this character is different
if (*s1 == NUL)
break; // strings match until NUL
break; // strings match until NUL
++s1;
++s2;
--len;
+22
View File
@@ -163,5 +163,27 @@ def Test_help_files()
bwipe!
enddef
def Test_indent_of_source_files()
for fname in glob('../*.[ch]', 0, 1) + ['../xxd/xxd.c']
execute 'tabnew ' .. fname
for lnum in range(1, line('$'))
var name: string = synIDattr(synID(lnum, 1, 0), 'name')
if -1 == index(['cComment', 'cCommentStart'], name)
var line: string = getline(lnum)
var indent: string = matchstr(line, '^\s*')
var tailing: string = matchstr(line, '\s*$')
if !empty(indent)
if indent !~# '^\t* \{0,7\}$'
ReportError('testdir/' .. fname, lnum, 'invalid indent')
endif
endif
if !empty(tailing)
ReportError('testdir/' .. fname, lnum, 'tailing spaces')
endif
endif
endfor
close
endfor
enddef
" vim: shiftwidth=2 sts=2 expandtab nofoldenable
+2
View File
@@ -704,6 +704,8 @@ static char *(features[]) =
static int included_patches[] =
{ /* Add new patch number below this line */
/**/
1363,
/**/
1362,
/**/
+182 -182
View File
@@ -357,7 +357,7 @@ parse_hex_digit(int c)
parse_bin_digit(int c)
{
return (c >= '0' && c <= '1') ? c - '0'
: -1;
: -1;
}
/*
@@ -405,53 +405,53 @@ huntype(
continue;
if (hextype == HEX_NORMAL || hextype == HEX_POSTSCRIPT)
{
{
n3 = n2;
n2 = n1;
n1 = parse_hex_digit(c);
if (n1 == -1 && ign_garb)
continue;
}
}
else /* HEX_BITS */
{
{
n1 = parse_hex_digit(c);
if (n1 == -1 && ign_garb)
continue;
bt = parse_bin_digit(c);
if (bt != -1)
{
b = ((b << 1) | bt);
++bcnt;
}
}
bt = parse_bin_digit(c);
if (bt != -1)
{
b = ((b << 1) | bt);
++bcnt;
}
}
ign_garb = 0;
if ((hextype != HEX_POSTSCRIPT) && (p >= cols))
{
if (hextype == HEX_NORMAL)
{
if (hextype == HEX_NORMAL)
{
if (n1 < 0)
{
p = 0;
continue;
}
{
p = 0;
continue;
}
want_off = (want_off << 4) | n1;
}
else /* HEX_BITS */
{
}
else /* HEX_BITS */
{
if (n1 < 0)
{
p = 0;
bcnt = 0;
continue;
}
{
p = 0;
bcnt = 0;
continue;
}
want_off = (want_off << 4) | n1;
}
continue;
}
}
continue;
}
if (base_off + want_off != have_off)
{
@@ -468,35 +468,35 @@ huntype(
}
if (hextype == HEX_NORMAL || hextype == HEX_POSTSCRIPT)
{
if (n2 >= 0 && n1 >= 0)
{
putc_or_die((n2 << 4) | n1, fpo);
have_off++;
want_off++;
n1 = -1;
if (!hextype && (++p >= cols))
/* skip the rest of the line as garbage */
c = skip_to_eol(fpi, c);
}
else if (n1 < 0 && n2 < 0 && n3 < 0)
/* already stumbled into garbage, skip line, wait and see */
c = skip_to_eol(fpi, c);
}
{
if (n2 >= 0 && n1 >= 0)
{
putc_or_die((n2 << 4) | n1, fpo);
have_off++;
want_off++;
n1 = -1;
if (!hextype && (++p >= cols))
/* skip the rest of the line as garbage */
c = skip_to_eol(fpi, c);
}
else if (n1 < 0 && n2 < 0 && n3 < 0)
/* already stumbled into garbage, skip line, wait and see */
c = skip_to_eol(fpi, c);
}
else /* HEX_BITS */
{
if (bcnt == 8)
{
putc_or_die(b, fpo);
have_off++;
want_off++;
b = 0;
bcnt = 0;
if (++p >= cols)
/* skip the rest of the line as garbage */
c = skip_to_eol(fpi, c);
}
}
{
if (bcnt == 8)
{
putc_or_die(b, fpo);
have_off++;
want_off++;
b = 0;
bcnt = 0;
if (++p >= cols)
/* skip the rest of the line as garbage */
c = skip_to_eol(fpi, c);
}
}
if (c == '\n')
{
@@ -595,41 +595,41 @@ begin_coloring_char (char *l, int *c, int e, int ebcdic)
if (ebcdic)
{
if ((e >= 75 && e <= 80) || (e >= 90 && e <= 97) ||
(e >= 107 && e <= 111) || (e >= 121 && e <= 127) ||
(e >= 129 && e <= 137) || (e >= 145 && e <= 154) ||
(e >= 162 && e <= 169) || (e >= 192 && e <= 201) ||
(e >= 208 && e <= 217) || (e >= 226 && e <= 233) ||
(e >= 240 && e <= 249) || (e == 189) || (e == 64) ||
(e == 173) || (e == 224) )
l[(*c)++] = COLOR_GREEN;
(e >= 107 && e <= 111) || (e >= 121 && e <= 127) ||
(e >= 129 && e <= 137) || (e >= 145 && e <= 154) ||
(e >= 162 && e <= 169) || (e >= 192 && e <= 201) ||
(e >= 208 && e <= 217) || (e >= 226 && e <= 233) ||
(e >= 240 && e <= 249) || (e == 189) || (e == 64) ||
(e == 173) || (e == 224) )
l[(*c)++] = COLOR_GREEN;
else if (e == 37 || e == 13 || e == 5)
l[(*c)++] = COLOR_YELLOW;
l[(*c)++] = COLOR_YELLOW;
else if (e == 0)
l[(*c)++] = COLOR_WHITE;
l[(*c)++] = COLOR_WHITE;
else if (e == 255)
l[(*c)++] = COLOR_BLUE;
l[(*c)++] = COLOR_BLUE;
else
l[(*c)++] = COLOR_RED;
l[(*c)++] = COLOR_RED;
}
else /* ASCII */
{
#if defined(__MVS__) && __CHARSET_LIB == 0
if (e >= 64)
l[(*c)++] = COLOR_GREEN;
l[(*c)++] = COLOR_GREEN;
#else
if (e > 31 && e < 127)
l[(*c)++] = COLOR_GREEN;
l[(*c)++] = COLOR_GREEN;
#endif
else if (e == 9 || e == 10 || e == 13)
l[(*c)++] = COLOR_YELLOW;
l[(*c)++] = COLOR_YELLOW;
else if (e == 0)
l[(*c)++] = COLOR_WHITE;
l[(*c)++] = COLOR_WHITE;
else if (e == 255)
l[(*c)++] = COLOR_BLUE;
l[(*c)++] = COLOR_BLUE;
else
l[(*c)++] = COLOR_RED;
l[(*c)++] = COLOR_RED;
}
l[(*c)++] = 'm';
}
@@ -815,20 +815,20 @@ main(int argc, char *argv[])
}
}
else if (!STRNCMP(pp, "-n", 2))
{
if (pp[2] && STRNCMP("ame", pp + 2, 3))
varname = pp + 2;
else
{
if (!argv[2])
exit_with_usage();
varname = argv[2];
argv++;
argc--;
}
}
{
if (pp[2] && STRNCMP("ame", pp + 2, 3))
varname = pp + 2;
else
{
if (!argv[2])
exit_with_usage();
varname = argv[2];
argv++;
argc--;
}
}
else if (!STRNCMP(pp, "-R", 2))
{
{
char *pw = pp + 2;
if (!pw[0])
{
@@ -849,7 +849,7 @@ main(int argc, char *argv[])
color = enable_color();
else
exit_with_usage();
}
}
else if (!strcmp(argv[1], "--")) /* end of options */
{
argv++;
@@ -867,9 +867,9 @@ main(int argc, char *argv[])
if (hextype != (HEX_CINCLUDE | HEX_BITS))
{
/* Allow at most one bit to be set in hextype */
if (hextype & (hextype - 1))
error_exit(1, "only one of -b, -e, -u, -p, -i can be used");
/* Allow at most one bit to be set in hextype */
if (hextype & (hextype - 1))
error_exit(1, "only one of -b, -e, -u, -p, -i can be used");
}
if (!colsgiven || (!cols && hextype != HEX_POSTSCRIPT))
@@ -952,11 +952,11 @@ main(int argc, char *argv[])
case HEX_NORMAL:
case HEX_POSTSCRIPT:
case HEX_BITS:
return huntype(fp, fpo, cols, hextype,
negseek ? -seekoff : seekoff);
break;
return huntype(fp, fpo, cols, hextype,
negseek ? -seekoff : seekoff);
break;
default:
error_exit(-1, "Sorry, cannot revert this type of hexdump");
error_exit(-1, "Sorry, cannot revert this type of hexdump");
}
if (seekoff || negseek || !relseek)
@@ -988,7 +988,7 @@ main(int argc, char *argv[])
{
/* A user-set variable name overrides fp == stdin */
if (varname == NULL && fp != stdin)
varname = argv[1];
varname = argv[1];
if (varname != NULL)
{
@@ -1000,28 +1000,28 @@ main(int argc, char *argv[])
p = 0;
while ((length < 0 || p < length) && (c = getc_or_die(fp)) != EOF)
{
if (hextype & HEX_BITS)
{
if (hextype & HEX_BITS)
{
if (p == 0)
fputs_or_die(" ", fpo);
else if (p % cols == 0)
fputs_or_die(",\n ", fpo);
else
fputs_or_die(", ", fpo);
if (p == 0)
fputs_or_die(" ", fpo);
else if (p % cols == 0)
fputs_or_die(",\n ", fpo);
else
fputs_or_die(", ", fpo);
FPRINTF_OR_DIE((fpo, "0b"));
for (int j = 7; j >= 0; j--)
putc_or_die((c & (1 << j)) ? '1' : '0', fpo);
p++;
FPRINTF_OR_DIE((fpo, "0b"));
for (int j = 7; j >= 0; j--)
putc_or_die((c & (1 << j)) ? '1' : '0', fpo);
p++;
}
else
else
{
FPRINTF_OR_DIE((fpo, (hexx == hexxa) ? "%s0x%02x" : "%s0X%02X",
(p % cols) ? ", " : (!p ? " " : ",\n "), c));
p++;
}
}
}
if (p)
fputs_or_die("\n", fpo);
@@ -1065,7 +1065,7 @@ main(int argc, char *argv[])
{
grplen = octspergrp + octspergrp + 1; /* chars per octet group */
if (color)
grplen += 11 * octspergrp; /* color-code needs 11 extra characters */
grplen += 11 * octspergrp; /* color-code needs 11 extra characters */
}
else /* hextype == HEX_BITS */
grplen = 8 * octspergrp + 1;
@@ -1083,15 +1083,15 @@ main(int argc, char *argv[])
c = addrlen + 1 + (grplen * x) / octspergrp;
if (hextype == HEX_NORMAL || hextype == HEX_LITTLEENDIAN)
{
if (color)
{
if (color)
{
COLOR_PROLOGUE
begin_coloring_char(l,&c,e,ebcdic);
l[c++] = hexx[(e >> 4) & 0xf];
l[c++] = hexx[e & 0xf];
COLOR_EPILOGUE
}
else /*No colors*/
else /*No colors*/
{
l[c] = hexx[(e >> 4) & 0xf];
l[++c] = hexx[e & 0xf];
@@ -1112,95 +1112,95 @@ main(int argc, char *argv[])
c = (grplen * cols - 1) / octspergrp;
if (color)
{
if (hextype == HEX_BITS)
c += addrlen + 3 + p*12;
else
c = addrlen + 3 + (grplen * cols - 1)/octspergrp + p*12;
{
if (hextype == HEX_BITS)
c += addrlen + 3 + p*12;
else
c = addrlen + 3 + (grplen * cols - 1)/octspergrp + p*12;
COLOR_PROLOGUE
begin_coloring_char(l,&c,e,ebcdic);
COLOR_PROLOGUE
begin_coloring_char(l,&c,e,ebcdic);
#if defined(__MVS__) && __CHARSET_LIB == 0
if (e >= 64)
l[c++] = e;
else
l[c++] = '.';
if (e >= 64)
l[c++] = e;
else
l[c++] = '.';
#else
if (ebcdic)
e = (e < 64) ? '.' : etoa64[e-64];
l[c++] = (e > 31 && e < 127) ? e : '.';
if (ebcdic)
e = (e < 64) ? '.' : etoa64[e-64];
l[c++] = (e > 31 && e < 127) ? e : '.';
#endif
COLOR_EPILOGUE
}
COLOR_EPILOGUE
}
else /*no colors*/
{
if (ebcdic)
e = (e < 64) ? '.' : etoa64[e-64];
{
if (ebcdic)
e = (e < 64) ? '.' : etoa64[e-64];
if (hextype == HEX_LITTLEENDIAN)
c -= 1;
if (hextype == HEX_LITTLEENDIAN)
c -= 1;
c += addrlen + 3 + p;
l[c++] =
c += addrlen + 3 + p;
l[c++] =
#if defined(__MVS__) && __CHARSET_LIB == 0
(e >= 64)
(e >= 64)
#else
(e > 31 && e < 127)
(e > 31 && e < 127)
#endif
? e : '.';
}
n++;
if (++p == cols)
{
l[c++] = '\n';
l[c] = '\0';
xxdline(fpo, l, autoskip ? nonzero : 1);
nonzero = 0;
p = 0;
}
? e : '.';
}
n++;
if (++p == cols)
{
l[c++] = '\n';
l[c] = '\0';
xxdline(fpo, l, autoskip ? nonzero : 1);
nonzero = 0;
p = 0;
}
}
if (p)
{
l[c++] = '\n';
l[c] = '\0';
if (color)
{
x = p;
if (hextype == HEX_LITTLEENDIAN)
{
int fill = octspergrp - (p % octspergrp);
if (fill == octspergrp) fill = 0;
{
x = p;
if (hextype == HEX_LITTLEENDIAN)
{
int fill = octspergrp - (p % octspergrp);
if (fill == octspergrp) fill = 0;
c = addrlen + 1 + (grplen * (x - (octspergrp-fill))) / octspergrp;
c = addrlen + 1 + (grplen * (x - (octspergrp-fill))) / octspergrp;
for (i = 0; i < fill;i++)
{
COLOR_PROLOGUE
l[c++] = COLOR_RED;
l[c++] = 'm';
l[c++] = ' '; /* empty space */
COLOR_EPILOGUE
x++;
p++;
}
}
for (i = 0; i < fill;i++)
{
COLOR_PROLOGUE
l[c++] = COLOR_RED;
l[c++] = 'm';
l[c++] = ' '; /* empty space */
COLOR_EPILOGUE
x++;
p++;
}
}
if (hextype != HEX_BITS)
{
c = addrlen + 1 + (grplen * x) / octspergrp;
c += cols - p;
c += (cols - p) / octspergrp;
if (hextype != HEX_BITS)
{
c = addrlen + 1 + (grplen * x) / octspergrp;
c += cols - p;
c += (cols - p) / octspergrp;
for (i = cols - p; i > 0;i--)
{
COLOR_PROLOGUE
l[c++] = COLOR_RED;
l[c++] = 'm';
l[c++] = ' '; /* empty space */
COLOR_EPILOGUE
}
}
}
for (i = cols - p; i > 0;i--)
{
COLOR_PROLOGUE
l[c++] = COLOR_RED;
l[c++] = 'm';
l[c++] = ' '; /* empty space */
COLOR_EPILOGUE
}
}
}
xxdline(fpo, l, 1);
}
else if (autoskip)