Use portable format specifiers: Case %ld - localized - vim_snprintf.

Fix uses of localized "%ld" within vim_snprintf():
- Replace "%ld" with "%" PRId64.
- Cast corresponding argument to (int64_t).
This commit is contained in:
Eliseo Martínez
2014-04-20 14:37:11 +02:00
committed by Thiago de Arruda
parent 3f8061f16c
commit 22dd4f62d3
8 changed files with 52 additions and 47 deletions

View File

@@ -2184,8 +2184,8 @@ void buflist_list(exarg_T *eap)
IObuff[len++] = ' ';
} while (--i > 0 && len < IOSIZE - 18);
vim_snprintf((char *)IObuff + len, (size_t)(IOSIZE - len),
_("line %ld"), buf == curbuf ? curwin->w_cursor.lnum
: (long)buflist_findlnum(buf));
_("line %" PRId64), buf == curbuf ? (int64_t)curwin->w_cursor.lnum
: (int64_t)buflist_findlnum(buf));
msg_outtrans(IObuff);
out_flush(); /* output one line at a time */
ui_breakcheck();
@@ -2574,8 +2574,8 @@ fileinfo (
if (curbuf->b_ml.ml_line_count == 1)
vim_snprintf_add((char *)buffer, IOSIZE, _("1 line --%d%%--"), n);
else
vim_snprintf_add((char *)buffer, IOSIZE, _("%ld lines --%d%%--"),
(long)curbuf->b_ml.ml_line_count, n);
vim_snprintf_add((char *)buffer, IOSIZE, _("%" PRId64 " lines --%d%%--"),
(int64_t)curbuf->b_ml.ml_line_count, n);
} else {
vim_snprintf_add((char *)buffer, IOSIZE,
_("line %ld of %ld --%d%%-- col "),
@@ -4595,8 +4595,8 @@ void sign_list_placed(buf_T *rbuf)
msg_putchar('\n');
}
for (p = buf->b_signlist; p != NULL && !got_int; p = p->next) {
vim_snprintf(lbuf, BUFSIZ, _(" line=%ld id=%d name=%s"),
(long)p->lnum, p->id, sign_typenr2name(p->typenr));
vim_snprintf(lbuf, BUFSIZ, _(" line=%" PRId64 " id=%d name=%s"),
(int64_t)p->lnum, p->id, sign_typenr2name(p->typenr));
MSG_PUTS(lbuf);
msg_putchar('\n');
}

View File

@@ -1190,7 +1190,7 @@ do_filter (
if (linecount > p_report) {
if (do_in) {
vim_snprintf((char *)msg_buf, sizeof(msg_buf),
_("%ld lines filtered"), (long)linecount);
_("%" PRId64 " lines filtered"), (int64_t)linecount);
if (msg(msg_buf) && !msg_scroll)
/* save message to display it after redraw */
set_keep_msg(msg_buf, 0);

View File

@@ -602,8 +602,8 @@ static void catch_exception(except_T *excp)
set_vim_var_string(VV_EXCEPTION, excp->value, -1);
if (*excp->throw_name != NUL) {
if (excp->throw_lnum != 0)
vim_snprintf((char *)IObuff, IOSIZE, _("%s, line %ld"),
excp->throw_name, (long)excp->throw_lnum);
vim_snprintf((char *)IObuff, IOSIZE, _("%s, line %" PRId64),
excp->throw_name, (int64_t)excp->throw_lnum);
else
vim_snprintf((char *)IObuff, IOSIZE, "%s", excp->throw_name);
set_vim_var_string(VV_THROWPOINT, IObuff, -1);
@@ -648,8 +648,8 @@ static void finish_exception(except_T *excp)
if (*caught_stack->throw_name != NUL) {
if (caught_stack->throw_lnum != 0)
vim_snprintf((char *)IObuff, IOSIZE,
_("%s, line %ld"), caught_stack->throw_name,
(long)caught_stack->throw_lnum);
_("%s, line %" PRId64), caught_stack->throw_name,
(int64_t)caught_stack->throw_lnum);
else
vim_snprintf((char *)IObuff, IOSIZE, "%s",
caught_stack->throw_name);

View File

@@ -3749,9 +3749,9 @@ restore_backup:
errmsg_allocated = TRUE;
errmsg = alloc(300);
vim_snprintf((char *)errmsg, 300,
_(
"E513: write error, conversion failed in line %ld (make 'fenc' empty to override)"),
(long)write_info.bw_conv_error_lnum);
_("E513: write error, conversion failed in line %" PRId64
" (make 'fenc' empty to override)"),
(int64_t)write_info.bw_conv_error_lnum);
}
} else if (got_int)
errmsg = (char_u *)_(e_interr);
@@ -3817,8 +3817,8 @@ restore_backup:
STRCAT(IObuff, _(" CONVERSION ERROR"));
c = TRUE;
if (write_info.bw_conv_error_lnum != 0)
vim_snprintf_add((char *)IObuff, IOSIZE, _(" in line %ld;"),
(long)write_info.bw_conv_error_lnum);
vim_snprintf_add((char *)IObuff, IOSIZE, _(" in line %" PRId64 ";"),
(int64_t)write_info.bw_conv_error_lnum);
} else if (notconverted) {
STRCAT(IObuff, _("[NOT converted]"));
c = TRUE;

View File

@@ -1813,8 +1813,8 @@ static void inc_msg_scrolled(void)
else {
len = (int)STRLEN(p) + 40;
tofree = alloc(len);
vim_snprintf((char *)tofree, len, _("%s line %ld"),
p, (long)sourcing_lnum);
vim_snprintf((char *)tofree, len, _("%s line %" PRId64),
p, (int64_t)sourcing_lnum);
p = tofree;
}
set_vim_var_string(VV_SCROLLSTART, p, -1);

View File

@@ -2604,10 +2604,10 @@ void msgmore(long n)
} else {
if (n > 0)
vim_snprintf((char *)msg_buf, MSG_BUF_LEN,
_("%ld more lines"), pn);
_("%" PRId64 " more lines"), (int64_t)pn);
else
vim_snprintf((char *)msg_buf, MSG_BUF_LEN,
_("%ld fewer lines"), pn);
_("%" PRId64 " fewer lines"), (int64_t)pn);
}
if (got_int)
vim_strcat(msg_buf, (char_u *)_(" (Interrupted)"), MSG_BUF_LEN);

View File

@@ -5141,28 +5141,30 @@ void cursor_pos_info(void)
if (VIsual_mode == Ctrl_V && curwin->w_curswant < MAXCOL) {
getvcols(curwin, &min_pos, &max_pos, &min_pos.col,
&max_pos.col);
vim_snprintf((char *)buf1, sizeof(buf1), _("%ld Cols; "),
(long)(oparg.end_vcol - oparg.start_vcol + 1));
vim_snprintf((char *)buf1, sizeof(buf1), _("%" PRId64 " Cols; "),
(int64_t)(oparg.end_vcol - oparg.start_vcol + 1));
} else
buf1[0] = NUL;
if (char_count_cursor == byte_count_cursor
&& char_count == byte_count)
vim_snprintf((char *)IObuff, IOSIZE,
_("Selected %s%ld of %ld Lines; %ld of %ld Words; %ld of %ld Bytes"),
buf1, line_count_selected,
(long)curbuf->b_ml.ml_line_count,
word_count_cursor, word_count,
byte_count_cursor, byte_count);
_("Selected %s%" PRId64 " of %" PRId64 " Lines; %" PRId64
" of %" PRId64 " Words; %" PRId64 " of %" PRId64 " Bytes"),
buf1, (int64_t)line_count_selected,
(int64_t)curbuf->b_ml.ml_line_count,
(int64_t)word_count_cursor, (int64_t)word_count,
(int64_t)byte_count_cursor, (int64_t)byte_count);
else
vim_snprintf((char *)IObuff, IOSIZE,
_(
"Selected %s%ld of %ld Lines; %ld of %ld Words; %ld of %ld Chars; %ld of %ld Bytes"),
buf1, line_count_selected,
(long)curbuf->b_ml.ml_line_count,
word_count_cursor, word_count,
char_count_cursor, char_count,
byte_count_cursor, byte_count);
_("Selected %s%" PRId64 " of %" PRId64 " Lines; %" PRId64
" of %" PRId64 " Words; %" PRId64 " of %" PRId64
" Chars; %" PRId64 " of %" PRId64 " Bytes"),
buf1, (int64_t)line_count_selected,
(int64_t)curbuf->b_ml.ml_line_count,
(int64_t)word_count_cursor, (int64_t)word_count,
(int64_t)char_count_cursor, (int64_t)char_count,
(int64_t)byte_count_cursor, (int64_t)byte_count);
} else {
p = ml_get_curline();
validate_virtcol();
@@ -5173,22 +5175,25 @@ void cursor_pos_info(void)
if (char_count_cursor == byte_count_cursor
&& char_count == byte_count)
vim_snprintf((char *)IObuff, IOSIZE,
_("Col %s of %s; Line %ld of %ld; Word %ld of %ld; Byte %ld of %ld"),
_("Col %s of %s; Line %" PRId64 " of %" PRId64 "; Word %" PRId64
" of %" PRId64 "; Byte %" PRId64 " of %" PRId64 ""),
(char *)buf1, (char *)buf2,
(long)curwin->w_cursor.lnum,
(long)curbuf->b_ml.ml_line_count,
word_count_cursor, word_count,
byte_count_cursor, byte_count);
(int64_t)curwin->w_cursor.lnum,
(int64_t)curbuf->b_ml.ml_line_count,
(int64_t)word_count_cursor, (int64_t)word_count,
(int64_t)byte_count_cursor, (int64_t)byte_count);
else
vim_snprintf((char *)IObuff, IOSIZE,
_(
"Col %s of %s; Line %ld of %ld; Word %ld of %ld; Char %ld of %ld; Byte %ld of %ld"),
"Col %s of %s; Line %" PRId64 " of %" PRId64 "; Word %" PRId64
" of %" PRId64 "; Char %" PRId64 " of %" PRId64
"; Byte %" PRId64 " of %" PRId64 ""),
(char *)buf1, (char *)buf2,
(long)curwin->w_cursor.lnum,
(long)curbuf->b_ml.ml_line_count,
word_count_cursor, word_count,
char_count_cursor, char_count,
byte_count_cursor, byte_count);
(int64_t)curwin->w_cursor.lnum,
(int64_t)curbuf->b_ml.ml_line_count,
(int64_t)word_count_cursor, (int64_t)word_count,
(int64_t)char_count_cursor, (int64_t)char_count,
(int64_t)byte_count_cursor, (int64_t)byte_count);
}
byte_count = bomb_size();

View File

@@ -2465,8 +2465,8 @@ static void u_add_time(char_u *buf, size_t buflen, time_t tt)
/* longer ago */
(void)strftime((char *)buf, buflen, "%Y/%m/%d %H:%M:%S", curtime);
} else
vim_snprintf((char *)buf, buflen, _("%ld seconds ago"),
(long)(time(NULL) - tt));
vim_snprintf((char *)buf, buflen, _("%" PRId64 " seconds ago"),
(int64_t)(time(NULL) - tt));
}
/*