mirror of
https://github.com/neovim/neovim.git
synced 2025-02-25 18:55:25 -06:00
Use ARRAY_SIZE where Coccinelle wasn't able to do it
This commit is contained in:
parent
3c857900fe
commit
8aeb2e37ee
@ -7482,7 +7482,7 @@ int find_cmdline_var(const char_u *src, int *usedlen) FUNC_ATTR_NONNULL_ALL
|
|||||||
# define SPEC_AMATCH 9
|
# define SPEC_AMATCH 9
|
||||||
};
|
};
|
||||||
|
|
||||||
for (i = 0; i < (int)(sizeof(spec_str) / sizeof(char *)); ++i) {
|
for (i = 0; i < (int)ARRAY_SIZE(spec_str); ++i) {
|
||||||
len = (int)STRLEN(spec_str[i]);
|
len = (int)STRLEN(spec_str[i]);
|
||||||
if (STRNCMP(src, spec_str[i], len) == 0) {
|
if (STRNCMP(src, spec_str[i], len) == 0) {
|
||||||
*usedlen = len;
|
*usedlen = len;
|
||||||
|
@ -945,8 +945,6 @@ static colnr_T hardcopy_line(prt_settings_T *psettings, int page_line, prt_pos_T
|
|||||||
* http://www.adobe.com
|
* http://www.adobe.com
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#define NUM_ELEMENTS(arr) (sizeof(arr)/sizeof((arr)[0]))
|
|
||||||
|
|
||||||
#define PRT_PS_DEFAULT_DPI (72) /* Default user space resolution */
|
#define PRT_PS_DEFAULT_DPI (72) /* Default user space resolution */
|
||||||
#define PRT_PS_DEFAULT_FONTSIZE (10)
|
#define PRT_PS_DEFAULT_FONTSIZE (10)
|
||||||
#define PRT_PS_DEFAULT_BUFFER_SIZE (80)
|
#define PRT_PS_DEFAULT_BUFFER_SIZE (80)
|
||||||
@ -1139,33 +1137,33 @@ static struct prt_ps_charset_S k_charsets[] =
|
|||||||
static struct prt_ps_mbfont_S prt_ps_mbfonts[] =
|
static struct prt_ps_mbfont_S prt_ps_mbfonts[] =
|
||||||
{
|
{
|
||||||
{
|
{
|
||||||
NUM_ELEMENTS(j_encodings),
|
ARRAY_SIZE(j_encodings),
|
||||||
j_encodings,
|
j_encodings,
|
||||||
NUM_ELEMENTS(j_charsets),
|
ARRAY_SIZE(j_charsets),
|
||||||
j_charsets,
|
j_charsets,
|
||||||
"jis_roman",
|
"jis_roman",
|
||||||
"JIS_X_1983"
|
"JIS_X_1983"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
NUM_ELEMENTS(sc_encodings),
|
ARRAY_SIZE(sc_encodings),
|
||||||
sc_encodings,
|
sc_encodings,
|
||||||
NUM_ELEMENTS(sc_charsets),
|
ARRAY_SIZE(sc_charsets),
|
||||||
sc_charsets,
|
sc_charsets,
|
||||||
"gb_roman",
|
"gb_roman",
|
||||||
"GB_2312-80"
|
"GB_2312-80"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
NUM_ELEMENTS(tc_encodings),
|
ARRAY_SIZE(tc_encodings),
|
||||||
tc_encodings,
|
tc_encodings,
|
||||||
NUM_ELEMENTS(tc_charsets),
|
ARRAY_SIZE(tc_charsets),
|
||||||
tc_charsets,
|
tc_charsets,
|
||||||
"cns_roman",
|
"cns_roman",
|
||||||
"BIG5"
|
"BIG5"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
NUM_ELEMENTS(k_encodings),
|
ARRAY_SIZE(k_encodings),
|
||||||
k_encodings,
|
k_encodings,
|
||||||
NUM_ELEMENTS(k_charsets),
|
ARRAY_SIZE(k_charsets),
|
||||||
k_charsets,
|
k_charsets,
|
||||||
"ks_roman",
|
"ks_roman",
|
||||||
"KS_X_1992"
|
"KS_X_1992"
|
||||||
@ -1639,12 +1637,12 @@ static int prt_next_dsc(struct prt_dsc_line_S *p_dsc_line)
|
|||||||
return FALSE;
|
return FALSE;
|
||||||
|
|
||||||
/* Find type of DSC comment */
|
/* Find type of DSC comment */
|
||||||
for (comment = 0; comment < (int)NUM_ELEMENTS(prt_dsc_table); comment++)
|
for (comment = 0; comment < (int)ARRAY_SIZE(prt_dsc_table); comment++)
|
||||||
if (prt_resfile_strncmp(0, prt_dsc_table[comment].string,
|
if (prt_resfile_strncmp(0, prt_dsc_table[comment].string,
|
||||||
prt_dsc_table[comment].len) == 0)
|
prt_dsc_table[comment].len) == 0)
|
||||||
break;
|
break;
|
||||||
|
|
||||||
if (comment != NUM_ELEMENTS(prt_dsc_table)) {
|
if (comment != ARRAY_SIZE(prt_dsc_table)) {
|
||||||
/* Return type of comment */
|
/* Return type of comment */
|
||||||
p_dsc_line->type = prt_dsc_table[comment].type;
|
p_dsc_line->type = prt_dsc_table[comment].type;
|
||||||
offset = prt_dsc_table[comment].len;
|
offset = prt_dsc_table[comment].len;
|
||||||
@ -2135,7 +2133,7 @@ int mch_print_init(prt_settings_T *psettings, char_u *jobname, int forceit)
|
|||||||
props = enc_canon_props(p_encoding);
|
props = enc_canon_props(p_encoding);
|
||||||
if (!(props & ENC_8BIT) && ((*p_pmcs != NUL) || !(props & ENC_UNICODE))) {
|
if (!(props & ENC_8BIT) && ((*p_pmcs != NUL) || !(props & ENC_UNICODE))) {
|
||||||
p_mbenc_first = NULL;
|
p_mbenc_first = NULL;
|
||||||
for (cmap = 0; cmap < (int)NUM_ELEMENTS(prt_ps_mbfonts); cmap++)
|
for (cmap = 0; cmap < (int)ARRAY_SIZE(prt_ps_mbfonts); cmap++)
|
||||||
if (prt_match_encoding((char *)p_encoding, &prt_ps_mbfonts[cmap],
|
if (prt_match_encoding((char *)p_encoding, &prt_ps_mbfonts[cmap],
|
||||||
&p_mbenc)) {
|
&p_mbenc)) {
|
||||||
if (p_mbenc_first == NULL)
|
if (p_mbenc_first == NULL)
|
||||||
|
@ -2168,7 +2168,7 @@ static void usage(void)
|
|||||||
for (i = 0;; ++i) {
|
for (i = 0;; ++i) {
|
||||||
mch_msg(_(" vim [arguments] "));
|
mch_msg(_(" vim [arguments] "));
|
||||||
mch_msg(_(use[i]));
|
mch_msg(_(use[i]));
|
||||||
if (i == (sizeof(use) / sizeof(char_u *)) - 1)
|
if (i == ARRAY_SIZE(use) - 1)
|
||||||
break;
|
break;
|
||||||
mch_msg(_("\n or:"));
|
mch_msg(_("\n or:"));
|
||||||
}
|
}
|
||||||
|
@ -318,7 +318,7 @@ static const struct nv_cmd {
|
|||||||
};
|
};
|
||||||
|
|
||||||
/* Number of commands in nv_cmds[]. */
|
/* Number of commands in nv_cmds[]. */
|
||||||
#define NV_CMDS_SIZE (sizeof(nv_cmds) / sizeof(struct nv_cmd))
|
#define NV_CMDS_SIZE ARRAY_SIZE(nv_cmds)
|
||||||
|
|
||||||
/* Sorted index of commands in nv_cmds[]. */
|
/* Sorted index of commands in nv_cmds[]. */
|
||||||
static short nv_cmd_idx[NV_CMDS_SIZE];
|
static short nv_cmd_idx[NV_CMDS_SIZE];
|
||||||
|
@ -1808,7 +1808,7 @@ static struct vimoption
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
#define PARAM_COUNT (sizeof(options) / sizeof(struct vimoption))
|
#define PARAM_COUNT ARRAY_SIZE(options)
|
||||||
|
|
||||||
static char *(p_ambw_values[]) = {"single", "double", NULL};
|
static char *(p_ambw_values[]) = {"single", "double", NULL};
|
||||||
static char *(p_bg_values[]) = {"light", "dark", NULL};
|
static char *(p_bg_values[]) = {"light", "dark", NULL};
|
||||||
|
@ -30,7 +30,7 @@ static void vim_maketempdir(void)
|
|||||||
// Try the entries in `TEMP_DIR_NAMES` to create the temp directory.
|
// Try the entries in `TEMP_DIR_NAMES` to create the temp directory.
|
||||||
char_u template[TEMP_FILE_PATH_MAXLEN];
|
char_u template[TEMP_FILE_PATH_MAXLEN];
|
||||||
char_u path[TEMP_FILE_PATH_MAXLEN];
|
char_u path[TEMP_FILE_PATH_MAXLEN];
|
||||||
for (size_t i = 0; i < sizeof(temp_dirs) / sizeof(char *); ++i) {
|
for (size_t i = 0; i < ARRAY_SIZE(temp_dirs); ++i) {
|
||||||
// Expand environment variables, leave room for "/nvimXXXXXX/999999999"
|
// Expand environment variables, leave room for "/nvimXXXXXX/999999999"
|
||||||
expand_env((char_u *)temp_dirs[i], template, TEMP_FILE_PATH_MAXLEN - 22);
|
expand_env((char_u *)temp_dirs[i], template, TEMP_FILE_PATH_MAXLEN - 22);
|
||||||
if (!os_isdir(template)) { // directory doesn't exist
|
if (!os_isdir(template)) { // directory doesn't exist
|
||||||
|
Loading…
Reference in New Issue
Block a user