refactor: replace char_u with char

Work on https://github.com/neovim/neovim/issues/459
This commit is contained in:
Dundar Göc
2022-08-26 23:11:25 +02:00
committed by dundargoc
parent f078a3453a
commit bd51ac2a34
26 changed files with 492 additions and 509 deletions

View File

@@ -26,11 +26,11 @@
typedef struct sign sign_T;
struct sign {
sign_T *sn_next; // next sign in list
sign_T *sn_next; // next sign in list
int sn_typenr; // type number of sign
char_u *sn_name; // name of sign
char_u *sn_icon; // name of pixmap
char_u *sn_text; // text used instead of pixmap
char *sn_name; // name of sign
char *sn_icon; // name of pixmap
char *sn_text; // text used instead of pixmap
int sn_line_hl; // highlight ID for line
int sn_text_hl; // highlight ID for text
int sn_cul_hl; // highlight ID for text on current line when 'cursorline' is set
@@ -71,14 +71,13 @@ void 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(const char_u *groupname)
static signgroup_T *sign_group_ref(const char *groupname)
{
hash_T hash;
hashitem_T *hi;
signgroup_T *group;
hash = hash_hash(groupname);
hash = hash_hash((char_u *)groupname);
hi = hash_lookup(&sg_table, (char *)groupname, STRLEN(groupname), hash);
if (HASHITEM_EMPTY(hi)) {
// new group
@@ -99,11 +98,11 @@ static signgroup_T *sign_group_ref(const char_u *groupname)
/// A sign in group 'groupname' is removed. If all the signs in this group are
/// removed, then remove the group.
static void sign_group_unref(char_u *groupname)
static void sign_group_unref(char *groupname)
{
signgroup_T *group;
hashitem_T *hi = hash_find(&sg_table, (char *)groupname);
hashitem_T *hi = hash_find(&sg_table, groupname);
if (!HASHITEM_EMPTY(hi)) {
group = HI2SG(hi);
group->sg_refcount--;
@@ -118,7 +117,7 @@ static void sign_group_unref(char_u *groupname)
/// @return true if 'sign' is in 'group'.
/// 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.
static bool sign_in_group(sign_entry_T *sign, const char_u *group)
static bool sign_in_group(sign_entry_T *sign, const char *group)
{
return ((group != NULL && STRCMP(group, "*") == 0)
|| (group == NULL && sign->se_group == NULL)
@@ -127,7 +126,7 @@ static bool sign_in_group(sign_entry_T *sign, const char_u *group)
}
/// Get the next free sign identifier in the specified group
static int sign_group_get_next_signid(buf_T *buf, const char_u *groupname)
static int sign_group_get_next_signid(buf_T *buf, const char *groupname)
{
int id = 1;
signgroup_T *group = NULL;
@@ -154,7 +153,7 @@ static int sign_group_get_next_signid(buf_T *buf, const char_u *groupname)
// Check whether this sign is already placed in the buffer
found = true;
FOR_ALL_SIGNS_IN_BUF(buf, sign) {
if (id == sign->se_id && sign_in_group(sign, groupname)) {
if (id == sign->se_id && sign_in_group(sign, (char *)groupname)) {
found = false; // sign identifier is in use
break;
}
@@ -177,7 +176,7 @@ static int sign_group_get_next_signid(buf_T *buf, const char_u *groupname)
/// @param typenr typenr of sign we are adding
/// @param has_text_or_icon sign has text or icon
static void insert_sign(buf_T *buf, sign_entry_T *prev, sign_entry_T *next, int id,
const char_u *group, int prio, linenr_T lnum, int typenr,
const char *group, int prio, linenr_T lnum, int typenr,
bool has_text_or_icon)
{
sign_entry_T *newsign = xmalloc(sizeof(sign_entry_T));
@@ -224,7 +223,7 @@ static void insert_sign(buf_T *buf, sign_entry_T *prev, sign_entry_T *next, int
/// @param lnum line number which gets the mark
/// @param typenr typenr of sign we are adding
/// @param has_text_or_icon sign has text or icon
static void insert_sign_by_lnum_prio(buf_T *buf, sign_entry_T *prev, int id, const char_u *group,
static void insert_sign_by_lnum_prio(buf_T *buf, sign_entry_T *prev, int id, const char *group,
int prio, linenr_T lnum, int typenr, bool has_text_or_icon)
{
sign_entry_T *sign;
@@ -259,7 +258,7 @@ static sign_T *find_sign_by_typenr(int typenr)
}
/// Get the name of a sign by its typenr.
static char_u *sign_typenr2name(int typenr)
static char *sign_typenr2name(int typenr)
{
sign_T *sp;
@@ -268,7 +267,7 @@ static char_u *sign_typenr2name(int typenr)
return sp->sn_name;
}
}
return (char_u *)_("[Deleted]");
return _("[Deleted]");
}
/// Return information about a sign in a Dict
@@ -280,7 +279,7 @@ static dict_T *sign_get_info(sign_entry_T *sign)
? (char *)""
: (char *)sign->se_group->sg_name));
tv_dict_add_nr(d, S_LEN("lnum"), sign->se_lnum);
tv_dict_add_str(d, S_LEN("name"), (char *)sign_typenr2name(sign->se_typenr));
tv_dict_add_str(d, S_LEN("name"), sign_typenr2name(sign->se_typenr));
tv_dict_add_nr(d, S_LEN("priority"), sign->se_priority);
return d;
@@ -369,7 +368,7 @@ static void sign_sort_by_prio_on_line(buf_T *buf, sign_entry_T *sign)
/// @param lnum line number which gets the mark
/// @param typenr typenr of sign we are adding
/// @param has_text_or_icon sign has text or icon
static void buf_addsign(buf_T *buf, int id, const char_u *groupname, int prio, linenr_T lnum,
static void buf_addsign(buf_T *buf, int id, const char *groupname, int prio, linenr_T lnum,
int typenr, bool has_text_or_icon)
{
sign_entry_T *sign; // a sign in the signlist
@@ -416,13 +415,13 @@ static void buf_addsign(buf_T *buf, int id, const char_u *groupname, int prio, l
/// @param group sign group
/// @param typenr typenr of sign we are adding
/// @param prio sign priority
static linenr_T buf_change_sign_type(buf_T *buf, int markId, const char_u *group, int typenr,
static linenr_T buf_change_sign_type(buf_T *buf, int markId, const char *group, int typenr,
int prio)
{
sign_entry_T *sign; // a sign in the signlist
FOR_ALL_SIGNS_IN_BUF(buf, sign) {
if (sign->se_id == markId && sign_in_group(sign, group)) {
if (sign->se_id == markId && sign_in_group(sign, (char *)group)) {
sign->se_typenr = typenr;
sign->se_priority = prio;
sign_sort_by_prio_on_line(buf, sign);
@@ -534,7 +533,7 @@ int buf_get_signattrs(buf_T *buf, linenr_T lnum, SignTextAttrs sattrs[], HlPriAt
///
/// @return the line number of the deleted sign. If multiple signs are deleted,
/// then returns the line number of the last sign deleted.
static linenr_T buf_delsign(buf_T *buf, linenr_T atlnum, int id, char_u *group)
static linenr_T buf_delsign(buf_T *buf, linenr_T atlnum, int id, char *group)
{
sign_entry_T **lastp; // pointer to pointer to current sign
sign_entry_T *sign; // a sign in a b_signlist
@@ -555,7 +554,7 @@ static linenr_T buf_delsign(buf_T *buf, linenr_T atlnum, int id, char_u *group)
lnum = sign->se_lnum;
buf_signcols_del_check(buf, lnum, lnum);
if (sign->se_group != NULL) {
sign_group_unref(sign->se_group->sg_name);
sign_group_unref((char *)sign->se_group->sg_name);
}
xfree(sign);
redraw_buf_line_later(buf, lnum);
@@ -590,7 +589,7 @@ static linenr_T buf_delsign(buf_T *buf, linenr_T atlnum, int id, char_u *group)
/// @param buf buffer to store sign in
/// @param id sign ID
/// @param group sign group
static int buf_findsign(buf_T *buf, int id, char_u *group)
static int buf_findsign(buf_T *buf, int id, char *group)
{
sign_entry_T *sign; // a sign in the signlist
@@ -609,7 +608,7 @@ static int buf_findsign(buf_T *buf, int id, char_u *group)
/// @param buf buffer whose sign we are searching for
/// @param lnum line number of sign
/// @param groupname sign group name
static sign_entry_T *buf_getsign_at_line(buf_T *buf, linenr_T lnum, char_u *groupname)
static sign_entry_T *buf_getsign_at_line(buf_T *buf, linenr_T lnum, char *groupname)
{
sign_entry_T *sign; // a sign in the signlist
@@ -633,7 +632,7 @@ static sign_entry_T *buf_getsign_at_line(buf_T *buf, linenr_T lnum, char_u *grou
/// @param buf buffer whose sign we are searching for
/// @param lnum line number of sign
/// @param groupname sign group name
static int buf_findsign_id(buf_T *buf, linenr_T lnum, char_u *groupname)
static int buf_findsign_id(buf_T *buf, linenr_T lnum, char *groupname)
{
sign_entry_T *sign; // a sign in the signlist
@@ -661,13 +660,13 @@ void buf_delete_signs(buf_T *buf, char *group)
lastp = &buf->b_signlist;
for (sign = buf->b_signlist; sign != NULL; sign = next) {
next = sign->se_next;
if (sign_in_group(sign, (char_u *)group)) {
if (sign_in_group(sign, group)) {
*lastp = next;
if (next != NULL) {
next->se_prev = sign->se_prev;
}
if (sign->se_group != NULL) {
sign_group_unref(sign->se_group->sg_name);
sign_group_unref((char *)sign->se_group->sg_name);
}
xfree(sign);
} else {
@@ -678,7 +677,7 @@ void buf_delete_signs(buf_T *buf, char *group)
}
/// List placed signs for "rbuf". If "rbuf" is NULL do it for all buffers.
static void sign_list_placed(buf_T *rbuf, char_u *sign_group)
static void sign_list_placed(buf_T *rbuf, char *sign_group)
{
buf_T *buf;
sign_entry_T *sign;
@@ -778,12 +777,12 @@ void sign_mark_adjust(linenr_T line1, linenr_T line2, linenr_T amount, linenr_T
///
/// @param begin_cmd begin of sign subcmd
/// @param end_cmd just after sign subcmd
static int sign_cmd_idx(char_u *begin_cmd, char_u *end_cmd)
static int sign_cmd_idx(char *begin_cmd, char *end_cmd)
{
int idx;
char_u save = *end_cmd;
char save = *end_cmd;
*end_cmd = (char_u)NUL;
*end_cmd = NUL;
for (idx = 0;; idx++) {
if (cmds[idx] == NULL || STRCMP(begin_cmd, cmds[idx]) == 0) {
break;
@@ -794,7 +793,7 @@ static int sign_cmd_idx(char_u *begin_cmd, char_u *end_cmd)
}
/// Find a sign by name. Also returns pointer to the previous sign.
static sign_T *sign_find(const char_u *name, sign_T **sp_prev)
static sign_T *sign_find(const char *name, sign_T **sp_prev)
{
sign_T *sp;
@@ -814,7 +813,7 @@ static sign_T *sign_find(const char_u *name, sign_T **sp_prev)
}
/// Allocate a new sign
static sign_T *alloc_new_sign(char_u *name)
static sign_T *alloc_new_sign(char *name)
{
sign_T *sp;
sign_T *lp;
@@ -848,24 +847,24 @@ static sign_T *alloc_new_sign(char_u *name)
next_sign_typenr = 1; // wrap around
}
sp->sn_name = vim_strsave(name);
sp->sn_name = xstrdup(name);
return sp;
}
/// Initialize the icon information for a new sign
static void sign_define_init_icon(sign_T *sp, char_u *icon)
static void sign_define_init_icon(sign_T *sp, char *icon)
{
xfree(sp->sn_icon);
sp->sn_icon = vim_strsave(icon);
backslash_halve((char *)sp->sn_icon);
sp->sn_icon = xstrdup(icon);
backslash_halve(sp->sn_icon);
}
/// Initialize the text for a new sign
static int sign_define_init_text(sign_T *sp, char_u *text)
static int sign_define_init_text(sign_T *sp, char *text)
{
char_u *s;
char_u *endp;
char *s;
char *endp;
int cells;
size_t len;
@@ -880,11 +879,11 @@ static int sign_define_init_text(sign_T *sp, char_u *text)
}
// Count cells and check for non-printable chars
cells = 0;
for (s = text; s < endp; s += utfc_ptr2len((char *)s)) {
if (!vim_isprintc(utf_ptr2char((char *)s))) {
for (s = text; s < endp; s += utfc_ptr2len(s)) {
if (!vim_isprintc(utf_ptr2char(s))) {
break;
}
cells += utf_ptr2cells((char *)s);
cells += utf_ptr2cells(s);
}
// Currently must be empty, one or two display cells
if (s != endp || cells > 2) {
@@ -900,7 +899,7 @@ static int sign_define_init_text(sign_T *sp, char_u *text)
// Allocate one byte more if we need to pad up
// with a space.
len = (size_t)(endp - text + ((cells == 1) ? 1 : 0));
sp->sn_text = vim_strnsave(text, len);
sp->sn_text = xstrnsave(text, len);
if (cells == 1) {
STRCPY(sp->sn_text + len - 1, " ");
@@ -910,8 +909,8 @@ static int sign_define_init_text(sign_T *sp, char_u *text)
}
/// Define a new sign or update an existing sign
static int sign_define_by_name(char_u *name, char_u *icon, char_u *linehl, char_u *text,
char_u *texthl, char_u *culhl, char *numhl)
static int sign_define_by_name(char *name, char *icon, char *linehl, char *text, char *texthl,
char *culhl, char *numhl)
{
sign_T *sp_prev;
sign_T *sp;
@@ -952,7 +951,7 @@ static int sign_define_by_name(char_u *name, char_u *icon, char_u *linehl, char_
if (*linehl == NUL) {
sp->sn_line_hl = 0;
} else {
sp->sn_line_hl = syn_check_group((char *)linehl, STRLEN(linehl));
sp->sn_line_hl = syn_check_group(linehl, STRLEN(linehl));
}
}
@@ -960,7 +959,7 @@ static int sign_define_by_name(char_u *name, char_u *icon, char_u *linehl, char_
if (*texthl == NUL) {
sp->sn_text_hl = 0;
} else {
sp->sn_text_hl = syn_check_group((char *)texthl, STRLEN(texthl));
sp->sn_text_hl = syn_check_group(texthl, STRLEN(texthl));
}
}
@@ -968,7 +967,7 @@ static int sign_define_by_name(char_u *name, char_u *icon, char_u *linehl, char_
if (*culhl == NUL) {
sp->sn_cul_hl = 0;
} else {
sp->sn_cul_hl = syn_check_group((char *)culhl, STRLEN(culhl));
sp->sn_cul_hl = syn_check_group(culhl, STRLEN(culhl));
}
}
@@ -984,7 +983,7 @@ static int sign_define_by_name(char_u *name, char_u *icon, char_u *linehl, char_
}
/// Free the sign specified by 'name'.
static int sign_undefine_by_name(const char_u *name)
static int sign_undefine_by_name(const char *name)
{
sign_T *sp_prev;
sign_T *sp;
@@ -1000,7 +999,7 @@ static int sign_undefine_by_name(const char_u *name)
}
/// List the signs matching 'name'
static void sign_list_by_name(char_u *name)
static void sign_list_by_name(char *name)
{
sign_T *sp;
@@ -1024,7 +1023,7 @@ static void may_force_numberwidth_recompute(buf_T *buf, int unplace)
}
/// Place a sign at the specified file location or update a sign.
static int sign_place(int *sign_id, const char_u *sign_group, const char_u *sign_name, buf_T *buf,
static int sign_place(int *sign_id, const char *sign_group, const char *sign_name, buf_T *buf,
linenr_T lnum, int prio)
{
sign_T *sp;
@@ -1044,7 +1043,7 @@ static int sign_place(int *sign_id, const char_u *sign_group, const char_u *sign
return FAIL;
}
if (*sign_id == 0) {
*sign_id = sign_group_get_next_signid(buf, sign_group);
*sign_id = sign_group_get_next_signid(buf, (char *)sign_group);
}
if (lnum > 0) {
@@ -1053,14 +1052,14 @@ static int sign_place(int *sign_id, const char_u *sign_group, const char_u *sign
bool has_text_or_icon = sp->sn_text != NULL || sp->sn_icon != NULL;
buf_addsign(buf,
*sign_id,
sign_group,
(char *)sign_group,
prio,
lnum,
sp->sn_typenr,
has_text_or_icon);
} else {
// ":sign place {id} file={fname}": change sign type and/or priority
lnum = buf_change_sign_type(buf, *sign_id, sign_group, sp->sn_typenr, prio);
lnum = buf_change_sign_type(buf, *sign_id, (char *)sign_group, sp->sn_typenr, prio);
}
if (lnum > 0) {
redraw_buf_line_later(buf, lnum);
@@ -1077,7 +1076,7 @@ static int sign_place(int *sign_id, const char_u *sign_group, const char_u *sign
}
/// Unplace the specified sign
static int sign_unplace(int sign_id, char_u *sign_group, buf_T *buf, linenr_T atlnum)
static int sign_unplace(int sign_id, char *sign_group, buf_T *buf, linenr_T atlnum)
{
if (buf->b_signlist == NULL) { // No signs in the buffer
return OK;
@@ -1085,7 +1084,7 @@ static int sign_unplace(int sign_id, char_u *sign_group, buf_T *buf, linenr_T at
if (sign_id == 0) {
// Delete all the signs in the specified buffer
redraw_buf_later(buf, UPD_NOT_VALID);
buf_delete_signs(buf, (char *)sign_group);
buf_delete_signs(buf, sign_group);
} else {
linenr_T lnum;
@@ -1108,7 +1107,7 @@ static int sign_unplace(int sign_id, char_u *sign_group, buf_T *buf, linenr_T at
}
/// Unplace the sign at the current cursor line.
static void sign_unplace_at_cursor(char_u *groupname)
static void sign_unplace_at_cursor(char *groupname)
{
int id = -1;
@@ -1121,7 +1120,7 @@ static void sign_unplace_at_cursor(char_u *groupname)
}
/// Jump to a sign.
static linenr_T sign_jump(int sign_id, char_u *sign_group, buf_T *buf)
static linenr_T sign_jump(int sign_id, char *sign_group, buf_T *buf)
{
linenr_T lnum;
@@ -1154,49 +1153,49 @@ static linenr_T sign_jump(int sign_id, char_u *sign_group, buf_T *buf)
}
/// ":sign define {name} ..." command
static void sign_define_cmd(char_u *sign_name, char_u *cmdline)
static void sign_define_cmd(char *sign_name, char *cmdline)
{
char_u *arg;
char_u *p = cmdline;
char_u *icon = NULL;
char_u *text = NULL;
char_u *linehl = NULL;
char_u *texthl = NULL;
char_u *culhl = NULL;
char_u *numhl = NULL;
char *arg;
char *p = cmdline;
char *icon = NULL;
char *text = NULL;
char *linehl = NULL;
char *texthl = NULL;
char *culhl = NULL;
char *numhl = NULL;
int failed = false;
// set values for a defined sign.
for (;;) {
arg = (char_u *)skipwhite((char *)p);
arg = skipwhite(p);
if (*arg == NUL) {
break;
}
p = (char_u *)skiptowhite_esc((char *)arg);
p = skiptowhite_esc(arg);
if (STRNCMP(arg, "icon=", 5) == 0) {
arg += 5;
XFREE_CLEAR(icon);
icon = vim_strnsave(arg, (size_t)(p - arg));
icon = xstrnsave(arg, (size_t)(p - arg));
} else if (STRNCMP(arg, "text=", 5) == 0) {
arg += 5;
XFREE_CLEAR(text);
text = vim_strnsave(arg, (size_t)(p - arg));
text = xstrnsave(arg, (size_t)(p - arg));
} else if (STRNCMP(arg, "linehl=", 7) == 0) {
arg += 7;
XFREE_CLEAR(linehl);
linehl = vim_strnsave(arg, (size_t)(p - arg));
linehl = xstrnsave(arg, (size_t)(p - arg));
} else if (STRNCMP(arg, "texthl=", 7) == 0) {
arg += 7;
XFREE_CLEAR(texthl);
texthl = vim_strnsave(arg, (size_t)(p - arg));
texthl = xstrnsave(arg, (size_t)(p - arg));
} else if (STRNCMP(arg, "culhl=", 6) == 0) {
arg += 6;
XFREE_CLEAR(culhl);
culhl = vim_strnsave(arg, (size_t)(p - arg));
culhl = xstrnsave(arg, (size_t)(p - arg));
} else if (STRNCMP(arg, "numhl=", 6) == 0) {
arg += 6;
XFREE_CLEAR(numhl);
numhl = vim_strnsave(arg, (size_t)(p - arg));
numhl = xstrnsave(arg, (size_t)(p - arg));
} else {
semsg(_(e_invarg2), arg);
failed = true;
@@ -1205,7 +1204,8 @@ static void sign_define_cmd(char_u *sign_name, char_u *cmdline)
}
if (!failed) {
sign_define_by_name(sign_name, icon, linehl, text, texthl, culhl, (char *)numhl);
sign_define_by_name(sign_name, icon, linehl, text,
texthl, culhl, numhl);
}
xfree(icon);
@@ -1217,7 +1217,7 @@ static void sign_define_cmd(char_u *sign_name, char_u *cmdline)
}
/// ":sign place" command
static void sign_place_cmd(buf_T *buf, linenr_T lnum, char_u *sign_name, int id, char_u *group,
static void sign_place_cmd(buf_T *buf, linenr_T lnum, char *sign_name, int id, char *group,
int prio)
{
if (id <= 0) {
@@ -1250,7 +1250,7 @@ static void sign_place_cmd(buf_T *buf, linenr_T lnum, char_u *sign_name, int id,
}
/// ":sign unplace" command
static void sign_unplace_cmd(buf_T *buf, linenr_T lnum, char_u *sign_name, int id, char_u *group)
static void sign_unplace_cmd(buf_T *buf, linenr_T lnum, char *sign_name, int id, char *group)
{
if (lnum >= 0 || sign_name != NULL || (group != NULL && *group == '\0')) {
emsg(_(e_invarg));
@@ -1272,7 +1272,7 @@ static void sign_unplace_cmd(buf_T *buf, linenr_T lnum, char_u *sign_name, int i
// :sign unplace * group=*
FOR_ALL_BUFFERS(cbuf) {
if (cbuf->b_signlist != NULL) {
buf_delete_signs(cbuf, (char *)group);
buf_delete_signs(cbuf, group);
}
}
}
@@ -1307,7 +1307,7 @@ static void sign_unplace_cmd(buf_T *buf, linenr_T lnum, char_u *sign_name, int i
/// :sign jump {id} buffer={nr}
/// :sign jump {id} group={group} file={fname}
/// :sign jump {id} group={group} buffer={nr}
static void sign_jump_cmd(buf_T *buf, linenr_T lnum, char_u *sign_name, int id, char_u *group)
static void sign_jump_cmd(buf_T *buf, linenr_T lnum, char *sign_name, int id, char *group)
{
if (sign_name == NULL && group == NULL && id == -1) {
emsg(_(e_argreq));
@@ -1329,31 +1329,31 @@ static void sign_jump_cmd(buf_T *buf, linenr_T lnum, char_u *sign_name, int id,
/// ":sign jump" commands.
/// The supported arguments are: line={lnum} name={name} group={group}
/// priority={prio} and file={fname} or buffer={nr}.
static int parse_sign_cmd_args(int cmd, char_u *arg, char_u **sign_name, int *signid,
char_u **group, int *prio, buf_T **buf, linenr_T *lnum)
static int parse_sign_cmd_args(int cmd, char *arg, char **sign_name, int *signid, char **group,
int *prio, buf_T **buf, linenr_T *lnum)
{
char_u *arg1;
char_u *name;
char_u *filename = NULL;
char *arg1;
char *name;
char *filename = NULL;
int lnum_arg = false;
// first arg could be placed sign id
arg1 = arg;
if (ascii_isdigit(*arg)) {
*signid = getdigits_int((char **)&arg, true, 0);
*signid = getdigits_int(&arg, true, 0);
if (!ascii_iswhite(*arg) && *arg != NUL) {
*signid = -1;
arg = arg1;
} else {
arg = (char_u *)skipwhite((char *)arg);
arg = skipwhite(arg);
}
}
while (*arg != NUL) {
if (STRNCMP(arg, "line=", 5) == 0) {
arg += 5;
*lnum = atoi((char *)arg);
arg = (char_u *)skiptowhite((char *)arg);
*lnum = atoi(arg);
arg = skiptowhite(arg);
lnum_arg = true;
} else if (STRNCMP(arg, "*", 1) == 0 && cmd == SIGNCMD_UNPLACE) {
if (*signid != -1) {
@@ -1361,11 +1361,11 @@ static int parse_sign_cmd_args(int cmd, char_u *arg, char_u **sign_name, int *si
return FAIL;
}
*signid = -2;
arg = (char_u *)skiptowhite((char *)arg + 1);
arg = skiptowhite(arg + 1);
} else if (STRNCMP(arg, "name=", 5) == 0) {
arg += 5;
name = arg;
arg = (char_u *)skiptowhite((char *)arg);
arg = skiptowhite(arg);
if (*arg != NUL) {
*arg++ = NUL;
}
@@ -1376,24 +1376,24 @@ static int parse_sign_cmd_args(int cmd, char_u *arg, char_u **sign_name, int *si
} else if (STRNCMP(arg, "group=", 6) == 0) {
arg += 6;
*group = arg;
arg = (char_u *)skiptowhite((char *)arg);
arg = skiptowhite(arg);
if (*arg != NUL) {
*arg++ = NUL;
}
} else if (STRNCMP(arg, "priority=", 9) == 0) {
arg += 9;
*prio = atoi((char *)arg);
arg = (char_u *)skiptowhite((char *)arg);
*prio = atoi(arg);
arg = skiptowhite(arg);
} else if (STRNCMP(arg, "file=", 5) == 0) {
arg += 5;
filename = arg;
*buf = buflist_findname_exp((char *)arg);
*buf = buflist_findname_exp(arg);
break;
} else if (STRNCMP(arg, "buffer=", 7) == 0) {
arg += 7;
filename = arg;
*buf = buflist_findnr(getdigits_int((char **)&arg, true, 0));
if (*skipwhite((char *)arg) != NUL) {
*buf = buflist_findnr(getdigits_int(&arg, true, 0));
if (*skipwhite(arg) != NUL) {
semsg(_(e_trailing_arg), arg);
}
break;
@@ -1401,7 +1401,7 @@ static int parse_sign_cmd_args(int cmd, char_u *arg, char_u **sign_name, int *si
emsg(_(e_invarg));
return FAIL;
}
arg = (char_u *)skipwhite((char *)arg);
arg = skipwhite(arg);
}
if (filename != NULL && *buf == NULL) {
@@ -1421,19 +1421,19 @@ static int parse_sign_cmd_args(int cmd, char_u *arg, char_u **sign_name, int *si
/// ":sign" command
void ex_sign(exarg_T *eap)
{
char_u *arg = (char_u *)eap->arg;
char_u *p;
char *arg = eap->arg;
char *p;
int idx;
sign_T *sp;
// Parse the subcommand.
p = (char_u *)skiptowhite((char *)arg);
p = skiptowhite(arg);
idx = sign_cmd_idx(arg, p);
if (idx == SIGNCMD_LAST) {
semsg(_("E160: Unknown sign command: %s"), arg);
return;
}
arg = (char_u *)skipwhite((char *)p);
arg = skipwhite(p);
if (idx <= SIGNCMD_LIST) {
// Define, undefine or list signs.
@@ -1445,18 +1445,18 @@ void ex_sign(exarg_T *eap)
} else if (*arg == NUL) {
emsg(_("E156: Missing sign name"));
} else {
char_u *name;
char *name;
// Isolate the sign name. If it's a number skip leading zeroes,
// so that "099" and "99" are the same sign. But keep "0".
p = (char_u *)skiptowhite((char *)arg);
p = skiptowhite(arg);
if (*p != NUL) {
*p++ = NUL;
}
while (arg[0] == '0' && arg[1] != NUL) {
arg++;
}
name = vim_strsave(arg);
name = xstrdup(arg);
if (idx == SIGNCMD_DEFINE) {
sign_define_cmd(name, p);
@@ -1474,8 +1474,8 @@ void ex_sign(exarg_T *eap)
} else {
int id = -1;
linenr_T lnum = -1;
char_u *sign_name = NULL;
char_u *group = NULL;
char *sign_name = NULL;
char *group = NULL;
int prio = SIGN_DEF_PRIO;
buf_T *buf = NULL;
@@ -1500,12 +1500,12 @@ static void sign_getinfo(sign_T *sp, dict_T *retdict)
{
const char *p;
tv_dict_add_str(retdict, S_LEN("name"), (char *)sp->sn_name);
tv_dict_add_str(retdict, S_LEN("name"), sp->sn_name);
if (sp->sn_icon != NULL) {
tv_dict_add_str(retdict, S_LEN("icon"), (char *)sp->sn_icon);
tv_dict_add_str(retdict, S_LEN("icon"), sp->sn_icon);
}
if (sp->sn_text != NULL) {
tv_dict_add_str(retdict, S_LEN("text"), (char *)sp->sn_text);
tv_dict_add_str(retdict, S_LEN("text"), sp->sn_text);
}
if (sp->sn_line_hl > 0) {
p = get_highlight_name_ext(NULL, sp->sn_line_hl - 1, false);
@@ -1539,13 +1539,13 @@ 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.
static void sign_getlist(const char_u *name, list_T *retlist)
static void sign_getlist(const char *name, list_T *retlist)
{
sign_T *sp = first_sign;
dict_T *dict;
if (name != NULL) {
sp = sign_find(name, NULL);
sp = sign_find((char *)name, NULL);
if (sp == NULL) {
return;
}
@@ -1577,8 +1577,8 @@ list_T *get_buffer_signs(buf_T *buf)
return l;
}
/// 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, const char_u *sign_group,
/// @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, const char *sign_group,
list_T *retlist)
{
dict_T *d;
@@ -1594,7 +1594,7 @@ static void sign_get_placed_in_buf(buf_T *buf, linenr_T lnum, int sign_id, const
tv_dict_add_list(d, S_LEN("signs"), l);
FOR_ALL_SIGNS_IN_BUF(buf, sign) {
if (!sign_in_group(sign, sign_group)) {
if (!sign_in_group(sign, (char *)sign_group)) {
continue;
}
if ((lnum == 0 && sign_id == 0)
@@ -1609,7 +1609,7 @@ static void sign_get_placed_in_buf(buf_T *buf, linenr_T lnum, int sign_id, const
/// Get a list of signs placed in buffer 'buf'. If 'num' is non-zero, return the
/// sign placed at the line number. If 'lnum' is zero, return all the signs
/// placed in 'buf'. If 'buf' is NULL, return signs placed in all the buffers.
static void sign_get_placed(buf_T *buf, linenr_T lnum, int sign_id, const char_u *sign_group,
static void sign_get_placed(buf_T *buf, linenr_T lnum, int sign_id, const char *sign_group,
list_T *retlist)
{
if (buf != NULL) {
@@ -1629,12 +1629,12 @@ static void sign_list_defined(sign_T *sp)
smsg("sign %s", sp->sn_name);
if (sp->sn_icon != NULL) {
msg_puts(" icon=");
msg_outtrans((char *)sp->sn_icon);
msg_outtrans(sp->sn_icon);
msg_puts(_(" (not supported)"));
}
if (sp->sn_text != NULL) {
msg_puts(" text=");
msg_outtrans((char *)sp->sn_text);
msg_outtrans(sp->sn_text);
}
if (sp->sn_line_hl > 0) {
msg_puts(" linehl=");
@@ -1710,8 +1710,8 @@ static enum {
EXP_SIGN_GROUPS, // expand with name of placed sign groups
} expand_what;
// Return the n'th sign name (used for command line completion)
static char_u *get_nth_sign_name(int idx)
/// @return the n'th sign name (used for command line completion)
static char *get_nth_sign_name(int idx)
FUNC_ATTR_PURE FUNC_ATTR_WARN_UNUSED_RESULT
{
// Complete with name of signs already defined
@@ -1724,8 +1724,8 @@ static char_u *get_nth_sign_name(int idx)
return NULL;
}
// Return the n'th sign group name (used for command line completion)
static char_u *get_nth_sign_group_name(int idx)
/// @return the n'th sign group name (used for command line completion)
static char *get_nth_sign_group_name(int idx)
{
// Complete with name of sign groups already defined
int current_idx = 0;
@@ -1735,7 +1735,7 @@ static char_u *get_nth_sign_group_name(int idx)
todo--;
if (current_idx++ == idx) {
signgroup_T *const group = HI2SG(hi);
return group->sg_name;
return (char *)group->sg_name;
}
}
}
@@ -1768,28 +1768,28 @@ char *get_sign_name(expand_T *xp, int idx)
return unplace_arg[idx];
}
case EXP_SIGN_NAMES:
return (char *)get_nth_sign_name(idx);
return get_nth_sign_name(idx);
case EXP_SIGN_GROUPS:
return (char *)get_nth_sign_group_name(idx);
return get_nth_sign_group_name(idx);
default:
return NULL;
}
}
/// Handle command line completion for :sign command.
void set_context_in_sign_cmd(expand_T *xp, char_u *arg)
void set_context_in_sign_cmd(expand_T *xp, char *arg)
{
char_u *end_subcmd;
char_u *last;
char *end_subcmd;
char *last;
int cmd_idx;
char_u *begin_subcmd_args;
char *begin_subcmd_args;
// Default: expand subcommands.
xp->xp_context = EXPAND_SIGN;
expand_what = EXP_SUBCMD;
xp->xp_pattern = (char *)arg;
xp->xp_pattern = arg;
end_subcmd = (char_u *)skiptowhite((char *)arg);
end_subcmd = skiptowhite(arg);
if (*end_subcmd == NUL) {
// expand subcmd name
// :sign {subcmd}<CTRL-D>
@@ -1801,7 +1801,7 @@ void set_context_in_sign_cmd(expand_T *xp, char_u *arg)
// :sign {subcmd} {subcmd_args}
// |
// begin_subcmd_args
begin_subcmd_args = (char_u *)skipwhite((char *)end_subcmd);
begin_subcmd_args = skipwhite(end_subcmd);
// Expand last argument of subcmd.
//
@@ -1810,21 +1810,21 @@ void set_context_in_sign_cmd(expand_T *xp, char_u *arg)
// p
// Loop until reaching last argument.
char_u *p = begin_subcmd_args;
char *p = begin_subcmd_args;
do {
p = (char_u *)skipwhite((char *)p);
p = skipwhite(p);
last = p;
p = (char_u *)skiptowhite((char *)p);
p = skiptowhite(p);
} while (*p != NUL);
p = (char_u *)vim_strchr((char *)last, '=');
p = vim_strchr(last, '=');
// :sign define {name} {args}... {last}=
// | |
// last p
if (p == NULL) {
// Expand last argument name (before equal sign).
xp->xp_pattern = (char *)last;
xp->xp_pattern = last;
switch (cmd_idx) {
case SIGNCMD_DEFINE:
expand_what = EXP_DEFINE;
@@ -1854,7 +1854,7 @@ void set_context_in_sign_cmd(expand_T *xp, char_u *arg)
}
} else {
// Expand last argument value (after equal sign).
xp->xp_pattern = (char *)p + 1;
xp->xp_pattern = p + 1;
switch (cmd_idx) {
case SIGNCMD_DEFINE:
if (STRNCMP(last, "texthl", 6) == 0
@@ -1928,8 +1928,8 @@ static int sign_define_from_dict(const char *name_arg, dict_T *dict)
numhl = tv_dict_get_string(dict, "numhl", true);
}
if (sign_define_by_name((char_u *)name, (char_u *)icon, (char_u *)linehl,
(char_u *)text, (char_u *)texthl, (char_u *)culhl, numhl)
if (sign_define_by_name(name, icon, linehl,
text, texthl, culhl, numhl)
== OK) {
retval = 0;
}
@@ -2005,7 +2005,7 @@ void f_sign_getdefined(typval_T *argvars, typval_T *rettv, EvalFuncData fptr)
name = tv_get_string(&argvars[0]);
}
sign_getlist((const char_u *)name, rettv->vval.v_list);
sign_getlist(name, rettv->vval.v_list);
}
/// "sign_getplaced()" function
@@ -2062,8 +2062,7 @@ void f_sign_getplaced(typval_T *argvars, typval_T *rettv, EvalFuncData fptr)
}
}
sign_get_placed(buf, lnum, sign_id, (const char_u *)group,
rettv->vval.v_list);
sign_get_placed(buf, lnum, sign_id, group, rettv->vval.v_list);
}
/// "sign_jump()" function
@@ -2103,7 +2102,7 @@ void f_sign_jump(typval_T *argvars, typval_T *rettv, EvalFuncData fptr)
goto cleanup;
}
rettv->vval.v_number = sign_jump(sign_id, (char_u *)sign_group, buf);
rettv->vval.v_number = sign_jump(sign_id, sign_group, buf);
cleanup:
xfree(sign_group);
@@ -2115,8 +2114,8 @@ static int sign_place_from_dict(typval_T *id_tv, typval_T *group_tv, typval_T *n
typval_T *buf_tv, dict_T *dict)
{
int sign_id = 0;
char_u *group = NULL;
char_u *sign_name = NULL;
char *group = NULL;
char *sign_name = NULL;
buf_T *buf = NULL;
dictitem_T *di;
linenr_T lnum = 0;
@@ -2154,14 +2153,14 @@ static int sign_place_from_dict(typval_T *id_tv, typval_T *group_tv, typval_T *n
if (group_tv == NULL) {
group = NULL; // global group
} else {
group = (char_u *)tv_get_string_chk(group_tv);
group = (char *)tv_get_string_chk(group_tv);
if (group == NULL) {
goto cleanup;
}
if (group[0] == '\0') { // global sign group
group = NULL;
} else {
group = vim_strsave(group);
group = xstrdup(group);
}
}
@@ -2175,7 +2174,7 @@ static int sign_place_from_dict(typval_T *id_tv, typval_T *group_tv, typval_T *n
if (name_tv == NULL) {
goto cleanup;
}
sign_name = (char_u *)tv_get_string_chk(name_tv);
sign_name = (char *)tv_get_string_chk(name_tv);
if (sign_name == NULL) {
goto cleanup;
}
@@ -2269,13 +2268,13 @@ void f_sign_placelist(typval_T *argvars, typval_T *rettv, EvalFuncData fptr)
/// Undefine multiple signs
static void sign_undefine_multiple(list_T *l, list_T *retlist)
{
char_u *name;
char *name;
int retval;
TV_LIST_ITER_CONST(l, li, {
retval = -1;
name = (char_u *)tv_get_string_chk(TV_LIST_ITEM_TV(li));
if (name != NULL && (sign_undefine_by_name(name) == OK)) {
name = (char *)tv_get_string_chk(TV_LIST_ITEM_TV(li));
if (name != NULL && (sign_undefine_by_name((char *)name) == OK)) {
retval = 0;
}
tv_list_append_number(retlist, retval);
@@ -2308,7 +2307,7 @@ void f_sign_undefine(typval_T *argvars, typval_T *rettv, EvalFuncData fptr)
return;
}
if (sign_undefine_by_name((const char_u *)name) == OK) {
if (sign_undefine_by_name(name) == OK) {
rettv->vval.v_number = 0;
}
}
@@ -2321,20 +2320,20 @@ static int sign_unplace_from_dict(typval_T *group_tv, dict_T *dict)
dictitem_T *di;
int sign_id = 0;
buf_T *buf = NULL;
char_u *group = NULL;
char *group = NULL;
int retval = -1;
// sign group
if (group_tv != NULL) {
group = (char_u *)tv_get_string(group_tv);
group = (char *)tv_get_string(group_tv);
} else {
group = (char_u *)tv_dict_get_string(dict, "group", false);
group = tv_dict_get_string(dict, "group", false);
}
if (group != NULL) {
if (group[0] == '\0') { // global sign group
group = NULL;
} else {
group = vim_strsave(group);
group = xstrdup(group);
}
}