Wconversion: Fix warnings in indent_c.c.

This commit is contained in:
Florian Walch
2014-11-18 21:14:29 +01:00
parent e3fca96e18
commit 10b938bdb5
3 changed files with 26 additions and 24 deletions

View File

@@ -56,7 +56,6 @@ set(CONV_SOURCES
hardcopy.c hardcopy.c
if_cscope.c if_cscope.c
indent.c indent.c
indent_c.c
keymap.c keymap.c
main.c main.c
mark.c mark.c

View File

@@ -1,4 +1,6 @@
#include <assert.h>
#include <inttypes.h> #include <inttypes.h>
#include <stdint.h>
#include "nvim/vim.h" #include "nvim/vim.h"
#include "nvim/ascii.h" #include "nvim/ascii.h"
@@ -37,7 +39,7 @@ find_start_comment ( /* XXX */
pos_T *pos; pos_T *pos;
char_u *line; char_u *line;
char_u *p; char_u *p;
int cur_maxcomment = ind_maxcomment; int64_t cur_maxcomment = ind_maxcomment;
for (;; ) { for (;; ) {
pos = findmatchlimit(NULL, '*', FM_BACKWARD, cur_maxcomment); pos = findmatchlimit(NULL, '*', FM_BACKWARD, cur_maxcomment);
@@ -115,27 +117,25 @@ static char_u *skip_string(char_u *p)
/* /*
* Return TRUE if the string "line" starts with a word from 'cinwords'. * Return true if the string "line" starts with a word from 'cinwords'.
*/ */
int cin_is_cinword(char_u *line) bool cin_is_cinword(char_u *line)
{ {
char_u *cinw; bool retval = false;
char_u *cinw_buf;
int cinw_len;
int retval = FALSE;
int len;
cinw_len = (int)STRLEN(curbuf->b_p_cinw) + 1; size_t cinw_len = STRLEN(curbuf->b_p_cinw) + 1;
cinw_buf = xmalloc(cinw_len); char_u *cinw_buf = xmalloc(cinw_len);
line = skipwhite(line); line = skipwhite(line);
for (cinw = curbuf->b_p_cinw; *cinw; ) {
len = copy_option_part(&cinw, cinw_buf, cinw_len, ","); for (char_u *cinw = curbuf->b_p_cinw; *cinw; ) {
size_t len = copy_option_part(&cinw, cinw_buf, cinw_len, ",");
if (STRNCMP(line, cinw_buf, len) == 0 if (STRNCMP(line, cinw_buf, len) == 0
&& (!vim_iswordc(line[len]) || !vim_iswordc(line[len - 1]))) { && (!vim_iswordc(line[len]) || !vim_iswordc(line[len - 1]))) {
retval = TRUE; retval = true;
break; break;
} }
} }
free(cinw_buf); free(cinw_buf);
return retval; return retval;
@@ -662,7 +662,7 @@ static int cin_islinecomment(char_u *p)
* Return the character terminating the line (ending char's have precedence if * Return the character terminating the line (ending char's have precedence if
* both apply in order to determine initializations). * both apply in order to determine initializations).
*/ */
static int static char_u
cin_isterminated ( cin_isterminated (
char_u *s, char_u *s,
int incl_open, /* include '{' at the end as terminator */ int incl_open, /* include '{' at the end as terminator */
@@ -1281,8 +1281,6 @@ void parse_cino(buf_T *buf)
{ {
char_u *p; char_u *p;
char_u *l; char_u *l;
char_u *digits;
int n;
int divider; int divider;
int fraction = 0; int fraction = 0;
int sw = (int)get_sw_value(buf); int sw = (int)get_sw_value(buf);
@@ -1415,11 +1413,13 @@ void parse_cino(buf_T *buf)
l = p++; l = p++;
if (*p == '-') if (*p == '-')
++p; ++p;
digits = p; /* remember where the digits start */ char_u *digits_start = p; /* remember where the digits start */
n = getdigits(&p); int64_t digits = getdigits(&p);
assert(digits <= INT_MAX);
int n = (int)digits;
divider = 0; divider = 0;
if (*p == '.') { /* ".5s" means a fraction */ if (*p == '.') { /* ".5s" means a fraction */
fraction = atol((char *)++p); fraction = atoi((char *)++p);
while (VIM_ISDIGIT(*p)) { while (VIM_ISDIGIT(*p)) {
++p; ++p;
if (divider) if (divider)
@@ -1429,7 +1429,7 @@ void parse_cino(buf_T *buf)
} }
} }
if (*p == 's') { /* "2s" means two times 'shiftwidth' */ if (*p == 's') { /* "2s" means two times 'shiftwidth' */
if (p == digits) if (p == digits_start)
n = sw; /* just "s" is one 'shiftwidth' */ n = sw; /* just "s" is one 'shiftwidth' */
else { else {
n *= sw; n *= sw;
@@ -1625,8 +1625,11 @@ int get_c_indent(void)
what = *p++; what = *p++;
else if (*p == COM_LEFT || *p == COM_RIGHT) else if (*p == COM_LEFT || *p == COM_RIGHT)
align = *p++; align = *p++;
else if (VIM_ISDIGIT(*p) || *p == '-') else if (VIM_ISDIGIT(*p) || *p == '-') {
off = getdigits(&p); int64_t digits = getdigits(&p);
assert(digits <= INT_MAX);
off = (int)digits;
}
else else
++p; ++p;
} }

View File

@@ -1430,7 +1430,7 @@ static int check_prevcol(char_u *linep, int col, int ch, int *prevcol)
* NULL * NULL
*/ */
pos_T *findmatchlimit(oparg_T *oap, int initc, int flags, int maxtravel) pos_T *findmatchlimit(oparg_T *oap, int initc, int flags, int64_t maxtravel)
{ {
static pos_T pos; /* current search position */ static pos_T pos; /* current search position */
int findc = 0; /* matching brace */ int findc = 0; /* matching brace */