aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorEliseo Martínez <eliseomarmol@gmail.com>2014-04-20 04:09:35 +0200
committerThiago de Arruda <tpadilha84@gmail.com>2014-04-23 06:56:32 -0300
commit1bffe66508ff986a61c0e08caddc92b7f3ace81e (patch)
treef62bca74d7217f73b966e57991efa7e209efeb14 /src
parentb536c22550db16836726b38494faa9be2f55e738 (diff)
downloadrneovim-1bffe66508ff986a61c0e08caddc92b7f3ace81e.tar.gz
rneovim-1bffe66508ff986a61c0e08caddc92b7f3ace81e.tar.bz2
rneovim-1bffe66508ff986a61c0e08caddc92b7f3ace81e.zip
Use portable format specifiers: Case %ld - plain - fprintf.
Fix uses of plain "%ld" within fprintf(): - Replace "%ld" with "%" PRId64. - Cast corresponding argument to (int64_t).
Diffstat (limited to 'src')
-rw-r--r--src/ex_docmd.c62
-rw-r--r--src/fold.c9
-rw-r--r--src/hashtab.c10
-rw-r--r--src/mark.c7
-rw-r--r--src/option.c2
-rw-r--r--src/regexp.c7
-rw-r--r--src/search.c4
7 files changed, 58 insertions, 43 deletions
diff --git a/src/ex_docmd.c b/src/ex_docmd.c
index 2572bbb810..19a297928a 100644
--- a/src/ex_docmd.c
+++ b/src/ex_docmd.c
@@ -8249,8 +8249,10 @@ makeopens (
&& !(buf->b_help && !(ssop_flags & SSOP_HELP))
&& buf->b_fname != NULL
&& buf->b_p_bl) {
- if (fprintf(fd, "badd +%ld ", buf->b_wininfo == NULL ? 1L
- : buf->b_wininfo->wi_fpos.lnum) < 0
+ if (fprintf(fd, "badd +%" PRId64 " ",
+ buf->b_wininfo == NULL ?
+ (int64_t)1L :
+ (int64_t)buf->b_wininfo->wi_fpos.lnum) < 0
|| ses_fname(fd, buf, &ssop_flags) == FAIL)
return FAIL;
}
@@ -8264,7 +8266,8 @@ makeopens (
if (ssop_flags & SSOP_RESIZE) {
/* Note: after the restore we still check it worked!*/
- if (fprintf(fd, "set lines=%ld columns=%ld", Rows, Columns) < 0
+ if (fprintf(fd, "set lines=%" PRId64 " columns=%" PRId64,
+ (int64_t)Rows, (int64_t)Columns) < 0
|| put_eol(fd) == FAIL)
return FAIL;
}
@@ -8422,8 +8425,9 @@ makeopens (
return FAIL;
/* Re-apply 'winheight', 'winwidth' and 'shortmess'. */
- if (fprintf(fd, "set winheight=%ld winwidth=%ld shortmess=%s",
- p_wh, p_wiw, p_shm) < 0 || put_eol(fd) == FAIL)
+ if (fprintf(fd, "set winheight=%" PRId64 " winwidth=%" PRId64 " shortmess=%s",
+ (int64_t)p_wh, (int64_t)p_wiw, p_shm) < 0
+ || put_eol(fd) == FAIL)
return FAIL;
/*
@@ -8452,17 +8456,20 @@ static int ses_winsizes(FILE *fd, int restore_size, win_T *tab_firstwin)
/* restore height when not full height */
if (wp->w_height + wp->w_status_height < topframe->fr_height
&& (fprintf(fd,
- "exe '%dresize ' . ((&lines * %ld + %ld) / %ld)",
- n, (long)wp->w_height, Rows / 2, Rows) < 0
+ "exe '%dresize ' . ((&lines * %" PRId64
+ " + %" PRId64 ") / %" PRId64 ")",
+ n, (int64_t)wp->w_height,
+ (int64_t)Rows / 2, (int64_t)Rows) < 0
|| put_eol(fd) == FAIL))
return FAIL;
/* restore width when not full width */
- if (wp->w_width < Columns && (fprintf(fd,
- "exe 'vert %dresize ' . ((&columns * %ld + %ld) / %ld)",
- n, (long)wp->w_width, Columns / 2,
- Columns) < 0
- || put_eol(fd) == FAIL))
+ if (wp->w_width < Columns
+ && (fprintf(fd, "exe 'vert %dresize ' . ((&columns * %" PRId64
+ " + %" PRId64 ") / %" PRId64 ")",
+ n, (int64_t)wp->w_width, (int64_t)Columns / 2,
+ (int64_t)Columns) < 0
+ || put_eol(fd) == FAIL))
return FAIL;
}
} else {
@@ -8605,7 +8612,7 @@ put_view (
* arguments may have been deleted, check if the index is valid. */
if (wp->w_arg_idx != current_arg_idx && wp->w_arg_idx < WARGCOUNT(wp)
&& flagp == &ssop_flags) {
- if (fprintf(fd, "%ldargu", (long)wp->w_arg_idx + 1) < 0
+ if (fprintf(fd, "%" PRId64 "argu", (int64_t)wp->w_arg_idx + 1) < 0
|| put_eol(fd) == FAIL)
return FAIL;
did_next = TRUE;
@@ -8687,15 +8694,18 @@ put_view (
/* Restore the cursor line in the file and relatively in the
* window. Don't use "G", it changes the jumplist. */
- if (fprintf(fd, "let s:l = %ld - ((%ld * winheight(0) + %ld) / %ld)",
- (long)wp->w_cursor.lnum,
- (long)(wp->w_cursor.lnum - wp->w_topline),
- (long)wp->w_height / 2, (long)wp->w_height) < 0
+ if (fprintf(fd,
+ "let s:l = %" PRId64 " - ((%" PRId64
+ " * winheight(0) + %" PRId64 ") / %" PRId64 ")",
+ (int64_t)wp->w_cursor.lnum,
+ (int64_t)(wp->w_cursor.lnum - wp->w_topline),
+ (int64_t)wp->w_height / 2,
+ (int64_t)wp->w_height) < 0
|| put_eol(fd) == FAIL
|| put_line(fd, "if s:l < 1 | let s:l = 1 | endif") == FAIL
|| put_line(fd, "exe s:l") == FAIL
|| put_line(fd, "normal! zt") == FAIL
- || fprintf(fd, "%ld", (long)wp->w_cursor.lnum) < 0
+ || fprintf(fd, "%" PRId64, (int64_t)wp->w_cursor.lnum) < 0
|| put_eol(fd) == FAIL)
return FAIL;
/* Restore the cursor column and left offset when not wrapping. */
@@ -8704,16 +8714,16 @@ put_view (
return FAIL;
} else {
if (!wp->w_p_wrap && wp->w_leftcol > 0 && wp->w_width > 0) {
- if (fprintf(fd,
- "let s:c = %ld - ((%ld * winwidth(0) + %ld) / %ld)",
- (long)wp->w_virtcol + 1,
- (long)(wp->w_virtcol - wp->w_leftcol),
- (long)wp->w_width / 2, (long)wp->w_width) < 0
+ if (fprintf(fd, "let s:c = %" PRId64 " - ((%" PRId64
+ " * winwidth(0) + %" PRId64 ") / %" PRId64 ")",
+ (int64_t)wp->w_virtcol + 1,
+ (int64_t)(wp->w_virtcol - wp->w_leftcol),
+ (int64_t)wp->w_width / 2,
+ (int64_t)wp->w_width) < 0
|| put_eol(fd) == FAIL
|| put_line(fd, "if s:c > 0") == FAIL
- || fprintf(fd,
- " exe 'normal! ' . s:c . '|zs' . %ld . '|'",
- (long)wp->w_virtcol + 1) < 0
+ || fprintf(fd, " exe 'normal! ' . s:c . '|zs' . %" PRId64 " . '|'",
+ (int64_t)wp->w_virtcol + 1) < 0
|| put_eol(fd) == FAIL
|| put_line(fd, "else") == FAIL
|| fprintf(fd, " normal! 0%d|", wp->w_virtcol + 1) < 0
diff --git a/src/fold.c b/src/fold.c
index 959f3cd39c..275e6c6d6a 100644
--- a/src/fold.c
+++ b/src/fold.c
@@ -2957,8 +2957,9 @@ static int put_folds_recurse(FILE *fd, garray_T *gap, linenr_T off)
/* Do nested folds first, they will be created closed. */
if (put_folds_recurse(fd, &fp->fd_nested, off + fp->fd_top) == FAIL)
return FAIL;
- if (fprintf(fd, "%ld,%ldfold", fp->fd_top + off,
- fp->fd_top + off + fp->fd_len - 1) < 0
+ if (fprintf(fd, "%" PRId64 ",%" PRId64 "fold",
+ (int64_t)fp->fd_top + off,
+ (int64_t)fp->fd_top + off + fp->fd_len - 1) < 0
|| put_eol(fd) == FAIL)
return FAIL;
++fp;
@@ -2982,7 +2983,7 @@ static int put_foldopen_recurse(FILE *fd, win_T *wp, garray_T *gap, linenr_T off
if (fp->fd_flags != FD_LEVEL) {
if (fp->fd_nested.ga_len > 0) {
/* open nested folds while this fold is open */
- if (fprintf(fd, "%ld", fp->fd_top + off) < 0
+ if (fprintf(fd, "%" PRId64, (int64_t)fp->fd_top + off) < 0
|| put_eol(fd) == FAIL
|| put_line(fd, "normal! zo") == FAIL)
return FAIL;
@@ -3019,7 +3020,7 @@ static int put_foldopen_recurse(FILE *fd, win_T *wp, garray_T *gap, linenr_T off
*/
static int put_fold_open_close(FILE *fd, fold_T *fp, linenr_T off)
{
- if (fprintf(fd, "%ld", fp->fd_top + off) < 0
+ if (fprintf(fd, "%" PRId64, (int64_t)fp->fd_top + off) < 0
|| put_eol(fd) == FAIL
|| fprintf(fd, "normal! z%c",
fp->fd_flags == FD_CLOSED ? 'c' : 'o') < 0
diff --git a/src/hashtab.c b/src/hashtab.c
index 5ce33219bb..b84b56278f 100644
--- a/src/hashtab.c
+++ b/src/hashtab.c
@@ -167,10 +167,12 @@ void hash_debug_results(void)
{
#ifdef HT_DEBUG
fprintf(stderr, "\r\n\r\n\r\n\r\n");
- fprintf(stderr, "Number of hashtable lookups: %ld\r\n", hash_count_lookup);
- fprintf(stderr, "Number of perturb loops: %ld\r\n", hash_count_perturb);
- fprintf(stderr, "Percentage of perturb loops: %ld%%\r\n",
- hash_count_perturb * 100 / hash_count_lookup);
+ fprintf(stderr, "Number of hashtable lookups: %" PRId64 "\r\n",
+ (int64_t)hash_count_lookup);
+ fprintf(stderr, "Number of perturb loops: %" PRId64 "\r\n",
+ (int64_t)hash_count_perturb);
+ fprintf(stderr, "Percentage of perturb loops: %" PRId64 "%%\r\n",
+ (int64_t)hash_count_perturb * 100 / hash_count_lookup);
#endif // ifdef HT_DEBUG
}
diff --git a/src/mark.c b/src/mark.c
index 41a35705c1..eb066535f5 100644
--- a/src/mark.c
+++ b/src/mark.c
@@ -1294,8 +1294,8 @@ static void write_one_filemark(FILE *fp, xfmark_T *fm, int c1, int c2)
else
name = fm->fname; /* use name from .viminfo */
if (name != NULL && *name != NUL) {
- fprintf(fp, "%c%c %ld %ld ", c1, c2, (long)fm->fmark.mark.lnum,
- (long)fm->fmark.mark.col);
+ fprintf(fp, "%c%c %" PRId64 " %" PRId64 " ",
+ c1, c2, (int64_t)fm->fmark.mark.lnum, (int64_t)fm->fmark.mark.col);
viminfo_writestring(fp, name);
}
@@ -1393,7 +1393,8 @@ int write_viminfo_marks(FILE *fp_out)
static void write_one_mark(FILE *fp_out, int c, pos_T *pos)
{
if (pos->lnum != 0)
- fprintf(fp_out, "\t%c\t%ld\t%d\n", c, (long)pos->lnum, (int)pos->col);
+ fprintf(fp_out, "\t%c\t%" PRId64 "\t%d\n", c,
+ (int64_t)pos->lnum, (int)pos->col);
}
/*
diff --git a/src/option.c b/src/option.c
index d3777a2cec..3f8d037833 100644
--- a/src/option.c
+++ b/src/option.c
@@ -6447,7 +6447,7 @@ static int put_setnum(FILE *fd, char *cmd, char *name, long *valuep)
/* print 'wildchar' and 'wildcharm' as a key name */
if (fputs((char *)get_special_key_name((int)wc, 0), fd) < 0)
return FAIL;
- } else if (fprintf(fd, "%ld", *valuep) < 0)
+ } else if (fprintf(fd, "%" PRId64, (int64_t)*valuep) < 0)
return FAIL;
if (put_eol(fd) < 0)
return FAIL;
diff --git a/src/regexp.c b/src/regexp.c
index f4e7661b8c..d72c104c7d 100644
--- a/src/regexp.c
+++ b/src/regexp.c
@@ -5770,15 +5770,16 @@ static void regdump(char_u *pattern, bt_regprog_T *r)
end = next;
if (op == BRACE_LIMITS) {
/* Two ints */
- fprintf(f, " minval %ld, maxval %ld", OPERAND_MIN(s), OPERAND_MAX(s));
+ fprintf(f, " minval %" PRId64 ", maxval %" PRId64,
+ (int64_t)OPERAND_MIN(s), (int64_t)OPERAND_MAX(s));
s += 8;
} else if (op == BEHIND || op == NOBEHIND) {
/* one int */
- fprintf(f, " count %ld", OPERAND_MIN(s));
+ fprintf(f, " count %" PRId64, (int64_t)OPERAND_MIN(s));
s += 4;
} else if (op == RE_LNUM || op == RE_COL || op == RE_VCOL) {
/* one int plus comperator */
- fprintf(f, " count %ld", OPERAND_MIN(s));
+ fprintf(f, " count %" PRId64, (int64_t)OPERAND_MIN(s));
s += 5;
}
s += 3;
diff --git a/src/search.c b/src/search.c
index 3c863b534a..2c33c3f6ab 100644
--- a/src/search.c
+++ b/src/search.c
@@ -4702,12 +4702,12 @@ wvsp_one (
if (spats[idx].pat != NULL) {
fprintf(fp, _("\n# Last %sSearch Pattern:\n~"), s);
/* off.dir is not stored, it's reset to forward */
- fprintf(fp, "%c%c%c%c%ld%s%c",
+ fprintf(fp, "%c%c%c%c%" PRId64 "%s%c",
spats[idx].magic ? 'M' : 'm', /* magic */
spats[idx].no_scs ? 's' : 'S', /* smartcase */
spats[idx].off.line ? 'L' : 'l', /* line offset */
spats[idx].off.end ? 'E' : 'e', /* offset from end */
- spats[idx].off.off, /* offset */
+ (int64_t)spats[idx].off.off, /* offset */
last_idx == idx ? "~" : "", /* last used pat */
sc);
viminfo_writestring(fp, spats[idx].pat);