aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorEliseo Martínez <eliseomarmol@gmail.com>2014-04-19 12:28:26 +0200
committerThiago de Arruda <tpadilha84@gmail.com>2014-04-23 06:56:32 -0300
commitfb94edf373418362b803e60bed67525bd5720916 (patch)
treec85dc6180294d90005e21d096ab737e9f65bd6bd /src
parentf916cf067d42d1dfd8ed477fdd5e3f0bda665eee (diff)
downloadrneovim-fb94edf373418362b803e60bed67525bd5720916.tar.gz
rneovim-fb94edf373418362b803e60bed67525bd5720916.tar.bz2
rneovim-fb94edf373418362b803e60bed67525bd5720916.zip
Use portable format specifiers: Case %ld - plain - sprintf.
Fix uses of plain "%ld" within sprintf(): - Replace "%ld" with "%" PRId64. - Cast corresponding argument to (int64_t).
Diffstat (limited to 'src')
-rw-r--r--src/eval.c12
-rw-r--r--src/ex_cmds.c3
-rw-r--r--src/ex_docmd.c8
-rw-r--r--src/fileio.c7
-rw-r--r--src/getchar.c2
-rw-r--r--src/message.c2
-rw-r--r--src/normal.c12
-rw-r--r--src/option.c2
-rw-r--r--src/quickfix.c8
-rw-r--r--src/search.c2
-rw-r--r--src/term.c2
-rw-r--r--src/window.c6
12 files changed, 34 insertions, 32 deletions
diff --git a/src/eval.c b/src/eval.c
index f3b874c7fe..5760efa9aa 100644
--- a/src/eval.c
+++ b/src/eval.c
@@ -1984,7 +1984,7 @@ static void list_buf_vars(int *first)
list_hashtable_vars(&curbuf->b_vars->dv_hashtab, (char_u *)"b:",
TRUE, first);
- sprintf((char *)numbuf, "%ld", (long)curbuf->b_changedtick);
+ sprintf((char *)numbuf, "%" PRId64, (int64_t)curbuf->b_changedtick);
list_one_var_a((char_u *)"b:", (char_u *)"changedtick", VAR_NUMBER,
numbuf, first);
}
@@ -7320,7 +7320,7 @@ call_func (
if (current_SID <= 0)
error = ERROR_SCRIPT;
else {
- sprintf((char *)fname_buf + 3, "%ld_", (long)current_SID);
+ sprintf((char *)fname_buf + 3, "%" PRId64 "_", (int64_t)current_SID);
i = (int)STRLEN(fname_buf);
}
}
@@ -9360,7 +9360,7 @@ static void f_function(typval_T *argvars, typval_T *rettv)
* also be called from another script. Using trans_function_name()
* would also work, but some plugins depend on the name being
* printable text. */
- sprintf(sid_buf, "<SNR>%ld_", (long)current_SID);
+ sprintf(sid_buf, "<SNR>%" PRId64 "_", (int64_t)current_SID);
rettv->vval.v_string =
alloc((int)(STRLEN(sid_buf) + STRLEN(s + off) + 1));
if (rettv->vval.v_string != NULL) {
@@ -9992,7 +9992,7 @@ static void f_getregtype(typval_T *argvars, typval_T *rettv)
case MCHAR: buf[0] = 'v'; break;
case MBLOCK:
buf[0] = Ctrl_V;
- sprintf((char *)buf + 1, "%ld", reglen + 1);
+ sprintf((char *)buf + 1, "%" PRId64, (int64_t)reglen + 1);
break;
}
rettv->v_type = VAR_STRING;
@@ -16431,7 +16431,7 @@ static char_u *get_tv_string_buf_chk(typval_T *varp, char_u *buf)
{
switch (varp->v_type) {
case VAR_NUMBER:
- sprintf((char *)buf, "%ld", (long)varp->vval.v_number);
+ sprintf((char *)buf, "%" PRId64, (int64_t)varp->vval.v_number);
return buf;
case VAR_FUNC:
EMSG(_("E729: using Funcref as a String"));
@@ -17998,7 +17998,7 @@ trans_function_name (
EMSG(_(e_usingsid));
goto theend;
}
- sprintf((char *)sid_buf, "%ld_", (long)current_SID);
+ sprintf((char *)sid_buf, "%" PRId64 "_", (int64_t)current_SID);
lead += (int)STRLEN(sid_buf);
}
} else if (!(flags & TFN_INT) && builtin_function(lv.ll_name)) {
diff --git a/src/ex_cmds.c b/src/ex_cmds.c
index b56b9f8867..a726ca1a79 100644
--- a/src/ex_cmds.c
+++ b/src/ex_cmds.c
@@ -6112,7 +6112,8 @@ void ex_sign(exarg_T *eap)
cmd = alloc((unsigned)STRLEN(buf->b_fname) + 25);
if (cmd == NULL)
return;
- sprintf((char *)cmd, "e +%ld %s", (long)lnum, buf->b_fname);
+ sprintf((char *)cmd, "e +%" PRId64 " %s",
+ (int64_t)lnum, buf->b_fname);
do_cmdline_cmd(cmd);
vim_free(cmd);
}
diff --git a/src/ex_docmd.c b/src/ex_docmd.c
index b5e56b203f..2572bbb810 100644
--- a/src/ex_docmd.c
+++ b/src/ex_docmd.c
@@ -4493,13 +4493,13 @@ static void uc_list(char_u *name, size_t name_len)
if (a & (RANGE|COUNT)) {
if (a & COUNT) {
/* -count=N */
- sprintf((char *)IObuff + len, "%ldc", cmd->uc_def);
+ sprintf((char *)IObuff + len, "%" PRId64 "c", (int64_t)cmd->uc_def);
len += (int)STRLEN(IObuff + len);
} else if (a & DFLALL)
IObuff[len++] = '%';
else if (cmd->uc_def >= 0) {
/* -range=N */
- sprintf((char *)IObuff + len, "%ld", cmd->uc_def);
+ sprintf((char *)IObuff + len, "%" PRId64 "", (int64_t)cmd->uc_def);
len += (int)STRLEN(IObuff + len);
} else
IObuff[len++] = '.';
@@ -4999,7 +4999,7 @@ uc_check_code (
(eap->addr_count > 0) ? eap->line2 : cmd->uc_def;
size_t num_len;
- sprintf(num_buf, "%ld", num);
+ sprintf(num_buf, "%" PRId64, (int64_t)num);
num_len = STRLEN(num_buf);
result = num_len;
@@ -8003,7 +8003,7 @@ eval_vars (
*errormsg = (char_u *)_("E842: no line number to use for \"<slnum>\"");
return NULL;
}
- sprintf((char *)strbuf, "%ld", (long)sourcing_lnum);
+ sprintf((char *)strbuf, "%" PRId64, (int64_t)sourcing_lnum);
result = strbuf;
break;
}
diff --git a/src/fileio.c b/src/fileio.c
index c09a82f613..abfde34a23 100644
--- a/src/fileio.c
+++ b/src/fileio.c
@@ -4147,7 +4147,8 @@ void msg_add_lines(int insert_space, long lnum, off_t nchars)
if (insert_space)
*p++ = ' ';
if (shortmess(SHM_LINES)) {
- sprintf((char *)p, "%ldL, %" PRId64 "C", lnum, (int64_t)nchars);
+ sprintf((char *)p, "%" PRId64 "L, %" PRId64 "C",
+ (int64_t)lnum, (int64_t)nchars);
}
else {
if (lnum == 1)
@@ -5696,7 +5697,7 @@ vim_tempname (
mode_t umask_save;
# endif
- sprintf((char *)itmp + itmplen, "v%ld", nr + off);
+ sprintf((char *)itmp + itmplen, "v%" PRId64, (int64_t)nr + off);
# ifndef EEXIST
/* If mkdir() does not set errno to EEXIST, check for
* existing file here. There is a race condition then,
@@ -5735,7 +5736,7 @@ vim_tempname (
if (vim_tempdir != NULL) {
/* There is no need to check if the file exists, because we own the
* directory and nobody else creates a file in it. */
- sprintf((char *)itmp, "%s%ld", vim_tempdir, temp_count++);
+ sprintf((char *)itmp, "%s%" PRId64, vim_tempdir, (int64_t)temp_count++);
return vim_strsave(itmp);
}
diff --git a/src/getchar.c b/src/getchar.c
index b0d3011aff..11522786b0 100644
--- a/src/getchar.c
+++ b/src/getchar.c
@@ -308,7 +308,7 @@ static void add_num_buff(buffheader_T *buf, long n)
{
char_u number[32];
- sprintf((char *)number, "%ld", n);
+ sprintf((char *)number, "%" PRId64, (int64_t)n);
add_buff(buf, number, -1L);
}
diff --git a/src/message.c b/src/message.c
index b0b13dfd4a..47143281fa 100644
--- a/src/message.c
+++ b/src/message.c
@@ -1064,7 +1064,7 @@ void msg_outnum(long n)
{
char_u buf[20];
- sprintf((char *)buf, "%ld", n);
+ sprintf((char *)buf, "%" PRId64, (int64_t)n);
msg_puts(buf);
}
diff --git a/src/normal.c b/src/normal.c
index 68964604dd..c3aebbc69e 100644
--- a/src/normal.c
+++ b/src/normal.c
@@ -3024,10 +3024,10 @@ void clear_showcmd(void)
p_sbr = empty_option;
getvcols(curwin, &curwin->w_cursor, &VIsual, &leftcol, &rightcol);
p_sbr = saved_sbr;
- sprintf((char *)showcmd_buf, "%ldx%ld", lines,
- (long)(rightcol - leftcol + 1));
+ sprintf((char *)showcmd_buf, "%" PRId64 "x%" PRId64,
+ (int64_t)lines, (int64_t)(rightcol - leftcol + 1));
} else if (VIsual_mode == 'V' || VIsual.lnum != curwin->w_cursor.lnum)
- sprintf((char *)showcmd_buf, "%ld", lines);
+ sprintf((char *)showcmd_buf, "%" PRId64, (int64_t)lines);
else {
char_u *s, *e;
int l;
@@ -4451,7 +4451,7 @@ static void nv_ident(cmdarg_T *cap)
isman = (STRCMP(kp, "man") == 0);
isman_s = (STRCMP(kp, "man -s") == 0);
if (cap->count0 != 0 && !(isman || isman_s))
- sprintf((char *)buf, ".,.+%ld", cap->count0 - 1);
+ sprintf((char *)buf, ".,.+%" PRId64, (int64_t)cap->count0 - 1);
STRCAT(buf, "! ");
if (cap->count0 == 0 && isman_s)
@@ -4460,7 +4460,7 @@ static void nv_ident(cmdarg_T *cap)
STRCAT(buf, kp);
STRCAT(buf, " ");
if (cap->count0 != 0 && (isman || isman_s)) {
- sprintf((char *)buf + STRLEN(buf), "%ld", cap->count0);
+ sprintf((char *)buf + STRLEN(buf), "%" PRId64, (int64_t)cap->count0);
STRCAT(buf, " ");
}
}
@@ -4482,7 +4482,7 @@ static void nv_ident(cmdarg_T *cap)
if (g_cmd)
STRCPY(buf, "tj ");
else
- sprintf((char *)buf, "%ldta ", cap->count0);
+ sprintf((char *)buf, "%" PRId64 "ta ", (int64_t)cap->count0);
}
}
diff --git a/src/option.c b/src/option.c
index 4e40440386..d3777a2cec 100644
--- a/src/option.c
+++ b/src/option.c
@@ -7535,7 +7535,7 @@ option_value2string (
else if (wc != 0)
STRCPY(NameBuff, transchar((int)wc));
else
- sprintf((char *)NameBuff, "%ld", *(long *)varp);
+ sprintf((char *)NameBuff, "%" PRId64, (int64_t)*(long *)varp);
} else { /* P_STRING */
varp = *(char_u **)(varp);
if (varp == NULL) /* just in case */
diff --git a/src/quickfix.c b/src/quickfix.c
index b032cbdc7c..60d7ea0235 100644
--- a/src/quickfix.c
+++ b/src/quickfix.c
@@ -1802,10 +1802,10 @@ void qf_list(exarg_T *eap)
if (qfp->qf_lnum == 0)
IObuff[0] = NUL;
else if (qfp->qf_col == 0)
- sprintf((char *)IObuff, ":%ld", qfp->qf_lnum);
+ sprintf((char *)IObuff, ":%" PRId64, (int64_t)qfp->qf_lnum);
else
- sprintf((char *)IObuff, ":%ld col %d",
- qfp->qf_lnum, qfp->qf_col);
+ sprintf((char *)IObuff, ":%" PRId64 " col %d",
+ (int64_t)qfp->qf_lnum, qfp->qf_col);
sprintf((char *)IObuff + STRLEN(IObuff), "%s:",
(char *)qf_types(qfp->qf_type, qfp->qf_nr));
msg_puts_attr(IObuff, hl_attr(HLF_N));
@@ -2357,7 +2357,7 @@ static void qf_fill_buffer(qf_info_T *qi)
IObuff[len++] = '|';
if (qfp->qf_lnum > 0) {
- sprintf((char *)IObuff + len, "%ld", qfp->qf_lnum);
+ sprintf((char *)IObuff + len, "%" PRId64, (int64_t)qfp->qf_lnum);
len += (int)STRLEN(IObuff + len);
if (qfp->qf_col > 0) {
diff --git a/src/search.c b/src/search.c
index f3eec5227d..3c863b534a 100644
--- a/src/search.c
+++ b/src/search.c
@@ -1074,7 +1074,7 @@ proftime_T *tm; /* timeout limit or NULL */
if (spats[0].off.off > 0 || spats[0].off.line)
*p++ = '+';
if (spats[0].off.off != 0 || spats[0].off.line)
- sprintf((char *)p, "%ld", spats[0].off.off);
+ sprintf((char *)p, "%" PRId64, (int64_t)spats[0].off.off);
else
*p = NUL;
}
diff --git a/src/term.c b/src/term.c
index 501c1488ce..d73d9fe6eb 100644
--- a/src/term.c
+++ b/src/term.c
@@ -4249,7 +4249,7 @@ replace_termcodes (
result[dlen++] = K_SPECIAL;
result[dlen++] = (int)KS_EXTRA;
result[dlen++] = (int)KE_SNR;
- sprintf((char *)result + dlen, "%ld", (long)current_SID);
+ sprintf((char *)result + dlen, "%" PRId64, (int64_t)current_SID);
dlen += (int)STRLEN(result + dlen);
result[dlen++] = '_';
continue;
diff --git a/src/window.c b/src/window.c
index 1a23a6aab9..0552ab4582 100644
--- a/src/window.c
+++ b/src/window.c
@@ -470,9 +470,9 @@ wingotofile:
* cursor in a new window.
*/
if (bt_quickfix(curbuf)) {
- sprintf((char *)cbuf, "split +%ld%s",
- (long)curwin->w_cursor.lnum,
- (curwin->w_llist_ref == NULL) ? "cc" : "ll");
+ sprintf((char *)cbuf, "split +%" PRId64 "%s",
+ (int64_t)curwin->w_cursor.lnum,
+ (curwin->w_llist_ref == NULL) ? "cc" : "ll");
do_cmdline_cmd(cbuf);
}
break;