Resolved compile warnings & fixed lot of style related to sign api

This commit is contained in:
Andrej Zieger 2019-05-24 22:10:19 +02:00
parent 51563b70d7
commit 8df9213d1b
5 changed files with 307 additions and 306 deletions

View File

@ -15441,16 +15441,15 @@ static void f_shiftwidth(typval_T *argvars, typval_T *rettv, FunPtr fptr)
/*
* "sign_define()" function
*/
static void
f_sign_define(typval_T *argvars, typval_T *rettv)
static void f_sign_define(typval_T *argvars, typval_T *rettv, FunPtr fptr)
{
char_u *name;
const char *name;
dict_T *dict;
char_u *icon = NULL;
char_u *linehl = NULL;
char_u *text = NULL;
char_u *texthl = NULL;
char_u *numhl = NULL;
char *icon = NULL;
char *linehl = NULL;
char *text = NULL;
char *texthl = NULL;
char *numhl = NULL;
rettv->vval.v_number = -1;
@ -15468,20 +15467,23 @@ f_sign_define(typval_T *argvars, typval_T *rettv)
// sign attributes
dict = argvars[1].vval.v_dict;
if (tv_dict_find(dict, (char_u *)"icon", -1) != NULL)
icon = tv_dict_get_string(dict, (char_u *)"icon", TRUE);
if (tv_dict_find(dict, (char_u *)"linehl", -1) != NULL)
linehl = tv_dict_get_string(dict, (char_u *)"linehl", TRUE);
if (tv_dict_find(dict, (char_u *)"text", -1) != NULL)
text = tv_dict_get_string(dict, (char_u *)"text", TRUE);
if (tv_dict_find(dict, (char_u *)"texthl", -1) != NULL)
texthl = tv_dict_get_string(dict, (char_u *)"texthl", TRUE);
if (tv_dict_find(dict, (char_u *)"numhl", -1) != NULL)
numhl = tv_dict_get_string(dict, (char_u *)"numhl", TRUE);
if (tv_dict_find(dict, "icon", -1) != NULL)
icon = tv_dict_get_string(dict, "icon", TRUE);
if (tv_dict_find(dict, "linehl", -1) != NULL)
linehl = tv_dict_get_string(dict, "linehl", TRUE);
if (tv_dict_find(dict, "text", -1) != NULL)
text = tv_dict_get_string(dict, "text", TRUE);
if (tv_dict_find(dict, "texthl", -1) != NULL)
texthl = tv_dict_get_string(dict, "texthl", TRUE);
if (tv_dict_find(dict, "numhl", -1) != NULL)
numhl = tv_dict_get_string(dict, "numhl", TRUE);
}
if (sign_define_by_name(name, icon, linehl, text, texthl, numhl) == OK)
rettv->vval.v_number = 0;
if (sign_define_by_name((char_u *)name, (char_u *)icon, (char_u *)linehl,
(char_u *)text, (char_u *)texthl, (char_u *)numhl)
== OK) {
rettv->vval.v_number = 0;
}
xfree(icon);
xfree(linehl);
@ -15493,301 +15495,303 @@ f_sign_define(typval_T *argvars, typval_T *rettv)
* "sign_getdefined()" function
*/
static void
f_sign_getdefined(typval_T *argvars, typval_T *rettv)
f_sign_getdefined(typval_T *argvars, typval_T *rettv, FunPtr fptr)
{
char_u *name = NULL;
const char *name = NULL;
tv_list_alloc_ret(rettv, 0);
if (argvars[0].v_type != VAR_UNKNOWN)
name = tv_get_string(&argvars[0]);
name = tv_get_string(&argvars[0]);
sign_getlist(name, rettv->vval.v_list);
sign_getlist((const char_u *)name, rettv->vval.v_list);
}
/*
* "sign_getplaced()" function
*/
static void
f_sign_getplaced(typval_T *argvars, typval_T *rettv)
static void f_sign_getplaced(typval_T *argvars, typval_T *rettv, FunPtr fptr)
{
buf_T *buf = NULL;
dict_T *dict;
dictitem_T *di;
linenr_T lnum = 0;
int sign_id = 0;
char_u *group = NULL;
int notanum = FALSE;
buf_T *buf = NULL;
dict_T *dict;
dictitem_T *di;
linenr_T lnum = 0;
int sign_id = 0;
const char *group = NULL;
bool notanum = FALSE;
tv_list_alloc_ret(rettv, 0);
tv_list_alloc_ret(rettv, 0);
if (argvars[0].v_type != VAR_UNKNOWN)
{
// get signs placed in the specified buffer
buf = get_buf_arg(&argvars[0]);
if (buf == NULL)
return;
if (argvars[1].v_type != VAR_UNKNOWN)
{
if (argvars[1].v_type != VAR_DICT ||
((dict = argvars[1].vval.v_dict) == NULL))
{
EMSG(_(e_dictreq));
return;
}
if ((di = tv_dict_find(dict, (char_u *)"lnum", -1)) != NULL)
{
// get signs placed at this line
(void)tv_get_number_chk(&di->di_tv, &notanum);
if (notanum)
return;
lnum = tv_get_lnum(&di->di_tv);
}
if ((di = tv_dict_find(dict, (char_u *)"id", -1)) != NULL)
{
// get sign placed with this identifier
sign_id = (int)tv_get_number_chk(&di->di_tv, &notanum);
if (notanum)
return;
}
if ((di = tv_dict_find(dict, (char_u *)"group", -1)) != NULL)
{
group = tv_get_string_chk(&di->di_tv);
if (group == NULL)
return;
if (*group == '\0') // empty string means global group
group = NULL;
}
}
if (argvars[0].v_type != VAR_UNKNOWN)
{
// get signs placed in the specified buffer
buf = get_buf_arg(&argvars[0]);
if (buf == NULL) {
return;
}
sign_get_placed(buf, lnum, sign_id, group, rettv->vval.v_list);
if (argvars[1].v_type != VAR_UNKNOWN) {
if (argvars[1].v_type != VAR_DICT ||
((dict = argvars[1].vval.v_dict) == NULL)) {
EMSG(_(e_dictreq));
return;
}
if ((di = tv_dict_find(dict, "lnum", -1)) != NULL) {
// get signs placed at this line
lnum = (linenr_T)tv_get_number_chk(&di->di_tv, &notanum);
if (notanum) {
return;
}
lnum = tv_get_lnum(&di->di_tv);
}
if ((di = tv_dict_find(dict, "id", -1)) != NULL) {
// get sign placed with this identifier
sign_id = (int)tv_get_number_chk(&di->di_tv, &notanum);
if (notanum) {
return;
}
}
if ((di = tv_dict_find(dict, "group", -1)) != NULL)
{
group = tv_get_string_chk(&di->di_tv);
if (group == NULL)
return;
if (*group == '\0') // empty string means global group
group = NULL;
}
}
}
sign_get_placed(buf, lnum, sign_id, (const char_u*)group, rettv->vval.v_list);
}
/*
* "sign_jump()" function
*/
static void
f_sign_jump(typval_T *argvars, typval_T *rettv)
f_sign_jump(typval_T *argvars, typval_T *rettv, FunPtr fptr)
{
int sign_id;
char_u *sign_group = NULL;
buf_T *buf;
int notanum = FALSE;
int sign_id;
char *sign_group = NULL;
buf_T *buf;
bool notanum = FALSE;
rettv->vval.v_number = -1;
rettv->vval.v_number = -1;
// Sign identifer
sign_id = (int)tv_get_number_chk(&argvars[0], &notanum);
if (notanum)
return;
if (sign_id <= 0)
{
EMSG(_(e_invarg));
return;
// Sign identifer
sign_id = (int)tv_get_number_chk(&argvars[0], &notanum);
if (notanum) {
return;
}
if (sign_id <= 0)
{
EMSG(_(e_invarg));
return;
}
// Sign group
const char* sign_group_chk = tv_get_string_chk(&argvars[1]);
if (sign_group_chk == NULL)
return;
if (sign_group_chk[0] == '\0') {
sign_group = NULL; // global sign group
} else {
sign_group = xstrdup(sign_group_chk);
if (sign_group == NULL) {
return;
}
}
// Sign group
sign_group = tv_get_string_chk(&argvars[1]);
if (sign_group == NULL)
return;
if (sign_group[0] == '\0')
sign_group = NULL; // global sign group
else
{
sign_group = vim_strsave(sign_group);
if (sign_group == NULL)
return;
}
// Buffer to place the sign
buf = get_buf_arg(&argvars[2]);
if (buf == NULL)
goto cleanup;
// Buffer to place the sign
buf = get_buf_arg(&argvars[2]);
if (buf == NULL)
goto cleanup;
rettv->vval.v_number = sign_jump(sign_id, sign_group, buf);
rettv->vval.v_number = sign_jump(sign_id, (char_u*)sign_group, buf);
cleanup:
xfree(sign_group);
xfree(sign_group);
}
/*
* "sign_place()" function
*/
static void
f_sign_place(typval_T *argvars, typval_T *rettv)
static void f_sign_place(typval_T *argvars, typval_T *rettv, FunPtr fptr)
{
int sign_id;
char_u *group = NULL;
char_u *sign_name;
buf_T *buf;
dict_T *dict;
dictitem_T *di;
linenr_T lnum = 0;
int prio = SIGN_DEF_PRIO;
int notanum = FALSE;
int sign_id;
char_u *group = NULL;
const char *sign_name;
buf_T *buf;
dict_T *dict;
dictitem_T *di;
linenr_T lnum = 0;
int prio = SIGN_DEF_PRIO;
bool notanum = FALSE;
rettv->vval.v_number = -1;
rettv->vval.v_number = -1;
// Sign identifer
sign_id = (int)tv_get_number_chk(&argvars[0], &notanum);
if (notanum)
return;
if (sign_id < 0)
{
EMSG(_(e_invarg));
return;
// Sign identifer
sign_id = (int)tv_get_number_chk(&argvars[0], &notanum);
if (notanum) {
return;
}
if (sign_id < 0) {
EMSG(_(e_invarg));
return;
}
// Sign group
const char *group_chk = tv_get_string_chk(&argvars[1]);
if (group_chk == NULL) {
return;
}
if (group_chk[0] == '\0') {
group = NULL; // global sign group
} else {
group = vim_strsave((const char_u*)group_chk);
if (group == NULL) {
return;
}
}
// Sign name
sign_name = tv_get_string_chk(&argvars[2]);
if (sign_name == NULL) {
goto cleanup;
}
// Buffer to place the sign
buf = get_buf_arg(&argvars[3]);
if (buf == NULL) {
goto cleanup;
}
if (argvars[4].v_type != VAR_UNKNOWN) {
if (argvars[4].v_type != VAR_DICT ||
((dict = argvars[4].vval.v_dict) == NULL)) {
EMSG(_(e_dictreq));
goto cleanup;
}
// Sign group
group = tv_get_string_chk(&argvars[1]);
if (group == NULL)
return;
if (group[0] == '\0')
group = NULL; // global sign group
else
{
group = vim_strsave(group);
if (group == NULL)
return;
// Line number where the sign is to be placed
if ((di = tv_dict_find(dict, "lnum", -1)) != NULL) {
lnum = (linenr_T)tv_get_number_chk(&di->di_tv, &notanum);
if (notanum) {
goto cleanup;
}
lnum = tv_get_lnum(&di->di_tv);
}
// Sign name
sign_name = tv_get_string_chk(&argvars[2]);
if (sign_name == NULL)
goto cleanup;
// Buffer to place the sign
buf = get_buf_arg(&argvars[3]);
if (buf == NULL)
goto cleanup;
if (argvars[4].v_type != VAR_UNKNOWN)
{
if (argvars[4].v_type != VAR_DICT ||
((dict = argvars[4].vval.v_dict) == NULL))
{
EMSG(_(e_dictreq));
goto cleanup;
}
// Line number where the sign is to be placed
if ((di = tv_dict_find(dict, (char_u *)"lnum", -1)) != NULL)
{
(void)tv_get_number_chk(&di->di_tv, &notanum);
if (notanum)
goto cleanup;
lnum = tv_get_lnum(&di->di_tv);
}
if ((di = tv_dict_find(dict, (char_u *)"priority", -1)) != NULL)
{
// Sign priority
prio = (int)tv_get_number_chk(&di->di_tv, &notanum);
if (notanum)
goto cleanup;
}
if ((di = tv_dict_find(dict, "priority", -1)) != NULL) {
// Sign priority
prio = (int)tv_get_number_chk(&di->di_tv, &notanum);
if (notanum) {
goto cleanup;
}
}
}
if (sign_place(&sign_id, group, sign_name, buf, lnum, prio) == OK)
rettv->vval.v_number = sign_id;
if (sign_place(&sign_id, group, (const char_u*)sign_name, buf, lnum, prio) == OK) {
rettv->vval.v_number = sign_id;
}
cleanup:
xfree(group);
xfree(group);
}
/*
* "sign_undefine()" function
*/
static void
f_sign_undefine(typval_T *argvars, typval_T *rettv)
f_sign_undefine(typval_T *argvars, typval_T *rettv, FunPtr fptr)
{
char_u *name;
const char *name;
rettv->vval.v_number = -1;
rettv->vval.v_number = -1;
if (argvars[0].v_type == VAR_UNKNOWN)
{
// Free all the signs
free_signs();
rettv->vval.v_number = 0;
}
else
{
// Free only the specified sign
name = tv_get_string_chk(&argvars[0]);
if (name == NULL)
return;
if (sign_undefine_by_name(name) == OK)
rettv->vval.v_number = 0;
if (argvars[0].v_type == VAR_UNKNOWN)
{
// Free all the signs
free_signs();
rettv->vval.v_number = 0;
}
else
{
// Free only the specified sign
name = tv_get_string_chk(&argvars[0]);
if (name == NULL)
return;
if (sign_undefine_by_name((const char_u*)name) == OK) {
rettv->vval.v_number = 0;
}
}
}
/*
* "sign_unplace()" function
*/
static void
f_sign_unplace(typval_T *argvars, typval_T *rettv)
static void f_sign_unplace(typval_T *argvars, typval_T *rettv, FunPtr fptr)
{
dict_T *dict;
dictitem_T *di;
int sign_id = 0;
buf_T *buf = NULL;
char_u *group = NULL;
dict_T *dict;
dictitem_T *di;
int sign_id = 0;
buf_T *buf = NULL;
char_u *group = NULL;
rettv->vval.v_number = -1;
rettv->vval.v_number = -1;
if (argvars[0].v_type != VAR_STRING)
{
EMSG(_(e_invarg));
return;
if (argvars[0].v_type != VAR_STRING)
{
EMSG(_(e_invarg));
return;
}
const char* group_chk = tv_get_string(&argvars[0]);
if (group_chk[0] == '\0') {
group = NULL; // global sign group
} else {
group = vim_strsave((const char_u*)group_chk);
if (group == NULL) {
return;
}
}
group = tv_get_string(&argvars[0]);
if (group[0] == '\0')
group = NULL; // global sign group
else
if (argvars[1].v_type != VAR_UNKNOWN)
{
if (argvars[1].v_type != VAR_DICT)
{
group = vim_strsave(group);
if (group == NULL)
return;
EMSG(_(e_dictreq));
goto cleanup;
}
dict = argvars[1].vval.v_dict;
if (argvars[1].v_type != VAR_UNKNOWN)
if ((di = tv_dict_find(dict, "buffer", -1)) != NULL)
{
if (argvars[1].v_type != VAR_DICT)
{
EMSG(_(e_dictreq));
goto cleanup;
}
dict = argvars[1].vval.v_dict;
buf = get_buf_arg(&di->di_tv);
if (buf == NULL)
goto cleanup;
}
if (tv_dict_find(dict, "id", -1) != NULL) {
sign_id = tv_dict_get_number(dict, "id");
}
}
if ((di = tv_dict_find(dict, (char_u *)"buffer", -1)) != NULL)
{
buf = get_buf_arg(&di->di_tv);
if (buf == NULL)
goto cleanup;
}
if (tv_dict_find(dict, (char_u *)"id", -1) != NULL)
sign_id = tv_dict_get_number(dict, (char_u *)"id");
if (buf == NULL)
{
// Delete the sign in all the buffers
FOR_ALL_BUFFERS(cbuf) {
if (sign_unplace(sign_id, group, cbuf, 0) == OK) {
rettv->vval.v_number = 0;
}
}
if (buf == NULL)
{
// Delete the sign in all the buffers
FOR_ALL_BUFFERS(buf)
if (sign_unplace(sign_id, group, buf, 0) == OK)
rettv->vval.v_number = 0;
}
else
{
if (sign_unplace(sign_id, group, buf, 0) == OK)
rettv->vval.v_number = 0;
} else {
if (sign_unplace(sign_id, group, buf, 0) == OK) {
rettv->vval.v_number = 0;
}
}
cleanup:
xfree(group);
xfree(group);
}
/*

View File

@ -49,6 +49,7 @@
#include "nvim/popupmnu.h"
#include "nvim/quickfix.h"
#include "nvim/screen.h"
#include "nvim/sign.h"
#include "nvim/state.h"
#include "nvim/strings.h"
#include "nvim/syntax.h"

View File

@ -29,6 +29,7 @@
#include "nvim/path.h"
#include "nvim/quickfix.h"
#include "nvim/search.h"
#include "nvim/sign.h"
#include "nvim/strings.h"
#include "nvim/ui.h"
#include "nvim/os/os.h"

View File

@ -16,6 +16,7 @@
#include "nvim/message.h"
#include "nvim/misc1.h"
#include "nvim/ui.h"
#include "nvim/sign.h"
#include "nvim/api/vim.h"
#ifdef UNIT_TESTING

View File

@ -84,14 +84,14 @@ init_signs(void)
* A new sign in group 'groupname' is added. If the group is not present,
* create it. Otherwise reference the group.
*/
static signgroup_T * sign_group_ref(char_u *groupname)
static signgroup_T * sign_group_ref(const char_u *groupname)
{
hash_T hash;
hashitem_T *hi;
signgroup_T *group;
hash = hash_hash(groupname);
hi = hash_lookup(&sg_table, S_LEN(groupname), hash);
hi = hash_lookup(&sg_table, (char*)S_LEN(groupname), hash);
if (HASHITEM_EMPTY(hi))
{
// new group
@ -142,7 +142,7 @@ static void sign_group_unref(char_u *groupname)
* A sign can either be in the global group (sign->group == NULL)
* or in a named group. If 'group' is '*', then the sign is part of the group.
*/
int sign_in_group(signlist_T *sign, char_u *group)
int sign_in_group(signlist_T *sign, const char_u *group)
{
return ((group != NULL && STRCMP(group, "*") == 0)
|| (group == NULL && sign->group == NULL)
@ -154,7 +154,7 @@ int sign_in_group(signlist_T *sign, char_u *group)
* Get the next free sign identifier in the specified group
*/
int
sign_group_get_next_signid(buf_T *buf, char_u *groupname)
sign_group_get_next_signid(buf_T *buf, const char_u *groupname)
{
int id = 1;
signgroup_T *group = NULL;
@ -202,7 +202,7 @@ static void insert_sign(
signlist_T *prev, // previous sign entry
signlist_T *next, // next sign entry
int id, // sign ID
char_u *group, // sign group; NULL for global group
const char_u *group, // sign group; NULL for global group
int prio, // sign priority
linenr_T lnum, // line number which gets the mark
int typenr // typenr of sign we are adding
@ -254,7 +254,7 @@ static void insert_sign_by_lnum_prio(
buf_T *buf, // buffer to store sign in
signlist_T *prev, // previous sign entry
int id, // sign ID
char_u *group, // sign group; NULL for global group
const char_u *group, // sign group; NULL for global group
int prio, // sign priority
linenr_T lnum, // line number which gets the mark
int typenr // typenr of sign we are adding
@ -300,9 +300,10 @@ dict_T * sign_get_info(signlist_T *sign)
return NULL;
}
tv_dict_add_nr(d, S_LEN("id"), sign->id);
tv_dict_add_str(d, S_LEN("group"), (sign->group == NULL) ? (char_u *)"" : sign->group->sg_name);
tv_dict_add_str(d, S_LEN("group"),
(sign->group == NULL) ? (char*)"" : (char*)sign->group->sg_name);
tv_dict_add_nr(d, S_LEN("lnum"), sign->lnum);
tv_dict_add_str(d, S_LEN("name"), sign_typenr2name(sign->typenr));
tv_dict_add_str(d, S_LEN("name"), (char*)sign_typenr2name(sign->typenr));
tv_dict_add_nr(d, S_LEN("priority"), sign->priority);
return d;
@ -314,13 +315,12 @@ dict_T * sign_get_info(signlist_T *sign)
void buf_addsign(
buf_T *buf, // buffer to store sign in
int id, // sign ID
char_u *groupname, // sign group
const char_u *groupname, // sign group
int prio, // sign priority
linenr_T lnum, // line number which gets the mark
int typenr // typenr of sign we are adding
)
{
signlist_T **lastp; // pointer to pointer to current sign
signlist_T *sign; // a sign in the signlist
signlist_T *prev; // the previous sign
@ -346,7 +346,7 @@ void buf_addsign(
linenr_T buf_change_sign_type(
buf_T *buf, // buffer to store sign in
int markId, // sign ID
char_u *group, // sign group
const char_u *group, // sign group
int typenr // typenr of sign we are adding
)
{
@ -628,15 +628,11 @@ void sign_list_placed(buf_T *rbuf, char_u *sign_group)
void sign_mark_adjust(linenr_T line1, linenr_T line2, long amount, long amount_after)
{
signlist_T *sign; // a sign in a b_signlist
signlist_T *next; // the next sign in a b_signlist
signlist_T **lastp; // pointer to pointer to current sign
linenr_T new_lnum; // new line number to assign to sign
curbuf->b_signcols_max = -1;
lastp = &curbuf->b_signlist;
FOR_ALL_SIGNS_IN_BUF(curbuf, sign) {
next = sign->next;
new_lnum = sign->lnum;
if (sign->lnum >= line1 && sign->lnum <= line2) {
if (amount != MAXLNUM) {
@ -651,7 +647,6 @@ void sign_mark_adjust(linenr_T line1, linenr_T line2, long amount, long amount_a
if (sign->lnum >= line1 && new_lnum <= curbuf->b_ml.ml_line_count) {
sign->lnum = new_lnum;
}
lastp = &sign->next;
}
}
@ -665,9 +660,9 @@ static int sign_cmd_idx(
)
{
int idx;
char save = *end_cmd;
char_u save = *end_cmd;
*end_cmd = NUL;
*end_cmd = (char_u)NUL;
for (idx = 0; ; ++idx) {
if (cmds[idx] == NULL || STRCMP(begin_cmd, cmds[idx]) == 0) {
break;
@ -680,8 +675,7 @@ static int sign_cmd_idx(
/*
* Find a sign by name. Also returns pointer to the previous sign.
*/
static sign_T *
sign_find(char_u *name, sign_T **sp_prev)
static sign_T * sign_find(const char_u *name, sign_T **sp_prev)
{
sign_T *sp;
@ -769,7 +763,7 @@ sign_define_init_text(sign_T *sp, char_u *text)
char_u *s;
char_u *endp;
int cells;
int len;
size_t len;
endp = text + (int)STRLEN(text);
for (s = text; s + 1 < endp; ++s) {
@ -798,7 +792,7 @@ sign_define_init_text(sign_T *sp, char_u *text)
xfree(sp->sn_text);
// Allocate one byte more if we need to pad up
// with a space.
len = (int)(endp - text + ((cells == 1) ? 1 : 0));
len = (size_t)(endp - text + ((cells == 1) ? 1 : 0));
sp->sn_text = vim_strnsave(text, len);
if (cells == 1)
@ -864,7 +858,7 @@ int sign_define_by_name(
* Free the sign specified by 'name'.
*/
int
sign_undefine_by_name(char_u *name)
sign_undefine_by_name(const char_u *name)
{
sign_T *sp_prev;
sign_T *sp;
@ -900,15 +894,15 @@ sign_list_by_name(char_u *name)
* Place a sign at the specified file location or update a sign.
*/
int sign_place(
int *sign_id,
char_u *sign_group,
char_u *sign_name,
buf_T *buf,
linenr_T lnum,
int prio
int *sign_id,
const char_u *sign_group,
const char_u *sign_name,
buf_T *buf,
linenr_T lnum,
int prio
)
{
sign_T *sp;
sign_T *sp;
// Check for reserved character '*' in group name
if (sign_group != NULL && (*sign_group == '*' || *sign_group == '\0')) {
@ -999,7 +993,7 @@ linenr_T sign_jump(int sign_id, char_u *sign_group, buf_T *buf)
linenr_T lnum;
if ((lnum = buf_findsign(buf, sign_id, sign_group)) <= 0) {
EMSGN(_("E157: Invalid sign ID: %ld"), sign_id);
EMSGN(_("E157: Invalid sign ID: %" PRId64), sign_id);
return -1;
}
@ -1050,19 +1044,19 @@ static void sign_define_cmd(char_u *sign_name, char_u *cmdline)
p = skiptowhite_esc(arg);
if (STRNCMP(arg, "icon=", 5) == 0) {
arg += 5;
icon = vim_strnsave(arg, (int)(p - arg));
icon = vim_strnsave(arg, (size_t)(p - arg));
} else if (STRNCMP(arg, "text=", 5) == 0) {
arg += 5;
text = vim_strnsave(arg, (int)(p - arg));
text = vim_strnsave(arg, (size_t)(p - arg));
} else if (STRNCMP(arg, "linehl=", 7) == 0) {
arg += 7;
linehl = vim_strnsave(arg, (int)(p - arg));
linehl = vim_strnsave(arg, (size_t)(p - arg));
} else if (STRNCMP(arg, "texthl=", 7) == 0) {
arg += 7;
texthl = vim_strnsave(arg, (int)(p - arg));
texthl = vim_strnsave(arg, (size_t)(p - arg));
} else if (STRNCMP(arg, "numhl=", 6) == 0) {
arg += 6;
numhl = vim_strnsave(arg, (int)(p - arg));
numhl = vim_strnsave(arg, (size_t)(p - arg));
} else {
EMSG2(_(e_invarg2), arg);
failed = TRUE;
@ -1153,9 +1147,9 @@ static void sign_unplace_cmd(
// :sign unplace *
// :sign unplace * group={group}
// :sign unplace * group=*
FOR_ALL_BUFFERS(buf) {
if (buf->b_signlist != NULL) {
buf_delete_signs(buf, group);
FOR_ALL_BUFFERS(cbuf) {
if (cbuf->b_signlist != NULL) {
buf_delete_signs(cbuf, group);
}
}
}
@ -1178,8 +1172,8 @@ static void sign_unplace_cmd(
// :sign unplace {id}
// :sign unplace {id} group={group}
// :sign unplace {id} group=*
FOR_ALL_BUFFERS(buf) {
sign_unplace(id, group, buf, 0);
FOR_ALL_BUFFERS(cbuf) {
sign_unplace(id, group, cbuf, 0);
}
}
}
@ -1403,35 +1397,35 @@ void ex_sign(exarg_T *eap)
*/
static void sign_getinfo(sign_T *sp, dict_T *retdict)
{
char_u *p;
const char *p;
tv_dict_add_str(retdict, S_LEN("name"), (char_u *)sp->sn_name);
tv_dict_add_str(retdict, S_LEN("name"), (char *)sp->sn_name);
if (sp->sn_icon != NULL) {
tv_dict_add_str(retdict, S_LEN("icon"), (char_u *)sp->sn_icon);
tv_dict_add_str(retdict, S_LEN("icon"), (char *)sp->sn_icon);
}
if (sp->sn_text != NULL) {
tv_dict_add_str(retdict, S_LEN("text"), (char_u *)sp->sn_text);
tv_dict_add_str(retdict, S_LEN("text"), (char *)sp->sn_text);
}
if (sp->sn_line_hl > 0) {
p = get_highlight_name_ext(NULL, sp->sn_line_hl - 1, FALSE);
if (p == NULL) {
p = (char_u *)"NONE";
p = "NONE";
}
tv_dict_add_str(retdict, S_LEN("linehl"), (char_u *)p);
tv_dict_add_str(retdict, S_LEN("linehl"), (char *)p);
}
if (sp->sn_text_hl > 0) {
p = get_highlight_name_ext(NULL, sp->sn_text_hl - 1, FALSE);
if (p == NULL) {
p = (char_u *)"NONE";
p = "NONE";
}
tv_dict_add_str(retdict, S_LEN("texthl"), (char_u *)p);
tv_dict_add_str(retdict, S_LEN("texthl"), (char *)p);
}
if (sp->sn_num_hl > 0) {
p = get_highlight_name_ext(NULL, sp->sn_num_hl - 1, FALSE);
if (p == NULL) {
p = (char_u *)"NONE";
p = "NONE";
}
tv_dict_add_str(retdict, S_LEN("numhl"), (char_u *)p);
tv_dict_add_str(retdict, S_LEN("numhl"), (char *)p);
}
}
@ -1439,7 +1433,7 @@ static void sign_getinfo(sign_T *sp, dict_T *retdict)
* If 'name' is NULL, return a list of all the defined signs.
* Otherwise, return information about the specified sign.
*/
void sign_getlist(char_u *name, list_T *retlist)
void sign_getlist(const char_u *name, list_T *retlist)
{
sign_T *sp = first_sign;
dict_T *dict;
@ -1484,11 +1478,11 @@ list_T *get_buffer_signs(buf_T *buf)
* Return information about all the signs placed in a buffer
*/
static void sign_get_placed_in_buf(
buf_T *buf,
linenr_T lnum,
int sign_id,
char_u *sign_group,
list_T *retlist)
buf_T *buf,
linenr_T lnum,
int sign_id,
const char_u *sign_group,
list_T *retlist)
{
dict_T *d;
list_T *l;
@ -1528,18 +1522,18 @@ static void sign_get_placed_in_buf(
* placed in 'buf'. If 'buf' is NULL, return signs placed in all the buffers.
*/
void sign_get_placed(
buf_T *buf,
linenr_T lnum,
int sign_id,
char_u *sign_group,
list_T *retlist)
buf_T *buf,
linenr_T lnum,
int sign_id,
const char_u *sign_group,
list_T *retlist)
{
if (buf != NULL) {
sign_get_placed_in_buf(buf, lnum, sign_id, sign_group, retlist);
} else {
FOR_ALL_BUFFERS(buf) {
if (buf->b_signlist != NULL) {
sign_get_placed_in_buf(buf, 0, sign_id, sign_group, retlist);
FOR_ALL_BUFFERS(cbuf) {
if (cbuf->b_signlist != NULL) {
sign_get_placed_in_buf(cbuf, 0, sign_id, sign_group, retlist);
}
}
}