mirror of
https://github.com/neovim/neovim.git
synced 2025-09-20 02:08:17 +00:00
Enable -Wconversion on cursor.c
This commit is contained in:

committed by
Justin M. Keyes

parent
e62722922b
commit
2a154ef71d
@@ -36,6 +36,7 @@ file( GLOB API_PRIV_SOURCES api/private/*.c )
|
|||||||
set(CONV_SRCS
|
set(CONV_SRCS
|
||||||
api.c
|
api.c
|
||||||
arabic.c
|
arabic.c
|
||||||
|
cursor.c
|
||||||
garray.c
|
garray.c
|
||||||
hashtab.c
|
hashtab.c
|
||||||
memory.c
|
memory.c
|
||||||
|
@@ -161,16 +161,9 @@ coladvance2 (
|
|||||||
if (line[idx] == NUL) {
|
if (line[idx] == NUL) {
|
||||||
/* Append spaces */
|
/* Append spaces */
|
||||||
int correct = wcol - col;
|
int correct = wcol - col;
|
||||||
char_u *newline = xmalloc(idx + correct + 1);
|
char_u *newline = xmallocz((size_t)(idx + correct));
|
||||||
int t;
|
memcpy(newline, line, (size_t)idx);
|
||||||
|
memset(newline + idx, ' ', (size_t)correct);
|
||||||
for (t = 0; t < idx; ++t)
|
|
||||||
newline[t] = line[t];
|
|
||||||
|
|
||||||
for (t = 0; t < correct; ++t)
|
|
||||||
newline[t + idx] = ' ';
|
|
||||||
|
|
||||||
newline[idx + correct] = NUL;
|
|
||||||
|
|
||||||
ml_replace(pos->lnum, newline, FALSE);
|
ml_replace(pos->lnum, newline, FALSE);
|
||||||
changed_bytes(pos->lnum, (colnr_T)idx);
|
changed_bytes(pos->lnum, (colnr_T)idx);
|
||||||
@@ -181,23 +174,18 @@ coladvance2 (
|
|||||||
int linelen = (int)STRLEN(line);
|
int linelen = (int)STRLEN(line);
|
||||||
int correct = wcol - col - csize + 1; /* negative!! */
|
int correct = wcol - col - csize + 1; /* negative!! */
|
||||||
char_u *newline;
|
char_u *newline;
|
||||||
int t, s = 0;
|
|
||||||
int v;
|
|
||||||
|
|
||||||
if (-correct > csize)
|
if (-correct > csize)
|
||||||
return FAIL;
|
return FAIL;
|
||||||
|
|
||||||
newline = xmalloc(linelen + csize);
|
newline = xmallocz((size_t)(linelen - 1 + csize));
|
||||||
|
// Copy first idx chars
|
||||||
for (t = 0; t < linelen; t++) {
|
memcpy(newline, line, (size_t)idx);
|
||||||
if (t != idx)
|
// Replace idx'th char with csize spaces
|
||||||
newline[s++] = line[t];
|
memset(newline + idx, ' ', (size_t)csize);
|
||||||
else
|
// Copy the rest of the line
|
||||||
for (v = 0; v < csize; v++)
|
memcpy(newline + idx + csize, line + idx + 1,
|
||||||
newline[s++] = ' ';
|
(size_t)(linelen - idx - 1));
|
||||||
}
|
|
||||||
|
|
||||||
newline[linelen + csize - 1] = NUL;
|
|
||||||
|
|
||||||
ml_replace(pos->lnum, newline, FALSE);
|
ml_replace(pos->lnum, newline, FALSE);
|
||||||
changed_bytes(pos->lnum, idx);
|
changed_bytes(pos->lnum, idx);
|
||||||
@@ -464,7 +452,7 @@ int gchar_cursor(void)
|
|||||||
* Write a character at the current cursor position.
|
* Write a character at the current cursor position.
|
||||||
* It is directly written into the block.
|
* It is directly written into the block.
|
||||||
*/
|
*/
|
||||||
void pchar_cursor(int c)
|
void pchar_cursor(char_u c)
|
||||||
{
|
{
|
||||||
*(ml_get_buf(curbuf, curwin->w_cursor.lnum, TRUE)
|
*(ml_get_buf(curbuf, curwin->w_cursor.lnum, TRUE)
|
||||||
+ curwin->w_cursor.col) = c;
|
+ curwin->w_cursor.col) = c;
|
||||||
|
@@ -19,7 +19,7 @@ void check_cursor(void);
|
|||||||
void adjust_cursor_col(void);
|
void adjust_cursor_col(void);
|
||||||
int leftcol_changed(void);
|
int leftcol_changed(void);
|
||||||
int gchar_cursor(void);
|
int gchar_cursor(void);
|
||||||
void pchar_cursor(int c);
|
void pchar_cursor(char_u c);
|
||||||
char_u *ml_get_curline(void);
|
char_u *ml_get_curline(void);
|
||||||
char_u *ml_get_cursor(void);
|
char_u *ml_get_cursor(void);
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user