diff options
author | Eliseo Martínez <eliseomarmol@gmail.com> | 2014-04-25 12:59:27 +0200 |
---|---|---|
committer | Thiago de Arruda <tpadilha84@gmail.com> | 2014-04-28 07:59:25 -0300 |
commit | e1943248855756174c445870716cc98ebf16b30e (patch) | |
tree | c91b252241aecf5f25641ea3c6249dc8a08d1dae /src | |
parent | b8520b8ee403388f94fda7306f1713bfa1ffae8a (diff) | |
download | rneovim-e1943248855756174c445870716cc98ebf16b30e.tar.gz rneovim-e1943248855756174c445870716cc98ebf16b30e.tar.bz2 rneovim-e1943248855756174c445870716cc98ebf16b30e.zip |
Use portable format specifiers: Clarify some casted expressions.
Though correct (to my understanding), some of the casts introduced in
previous commits could lead to confusion, by casting only the first
expression component instead of the whole expression.
This fixes that, parenthesizing casted expressions, except where
operator precedence rules make it unneccesary.
Diffstat (limited to 'src')
-rw-r--r-- | src/eval.c | 2 | ||||
-rw-r--r-- | src/ex_docmd.c | 14 | ||||
-rw-r--r-- | src/fileio.c | 2 | ||||
-rw-r--r-- | src/fold.c | 8 | ||||
-rw-r--r-- | src/hashtab.c | 2 | ||||
-rw-r--r-- | src/normal.c | 2 | ||||
-rw-r--r-- | src/screen.c | 2 |
7 files changed, 16 insertions, 16 deletions
diff --git a/src/eval.c b/src/eval.c index 87a79c022d..fe93527a36 100644 --- a/src/eval.c +++ b/src/eval.c @@ -9965,7 +9965,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, "%" PRId64, (int64_t)reglen + 1); + sprintf((char *)buf + 1, "%" PRId64, (int64_t)(reglen + 1)); break; } rettv->v_type = VAR_STRING; diff --git a/src/ex_docmd.c b/src/ex_docmd.c index f6f40aa21c..c0ff3c853c 100644 --- a/src/ex_docmd.c +++ b/src/ex_docmd.c @@ -8456,7 +8456,7 @@ static int ses_winsizes(FILE *fd, int restore_size, win_T *tab_firstwin) "exe '%dresize ' . ((&lines * %" PRId64 " + %" PRId64 ") / %" PRId64 ")", n, (int64_t)wp->w_height, - (int64_t)Rows / 2, (int64_t)Rows) < 0 + (int64_t)(Rows / 2), (int64_t)Rows) < 0 || put_eol(fd) == FAIL)) return FAIL; @@ -8464,7 +8464,7 @@ static int ses_winsizes(FILE *fd, int restore_size, win_T *tab_firstwin) if (wp->w_width < Columns && (fprintf(fd, "exe 'vert %dresize ' . ((&columns * %" PRId64 " + %" PRId64 ") / %" PRId64 ")", - n, (int64_t)wp->w_width, (int64_t)Columns / 2, + n, (int64_t)wp->w_width, (int64_t)(Columns / 2), (int64_t)Columns) < 0 || put_eol(fd) == FAIL)) return FAIL; @@ -8609,7 +8609,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, "%" PRId64 "argu", (int64_t)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; @@ -8696,7 +8696,7 @@ put_view ( " * 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 / 2), (int64_t)wp->w_height) < 0 || put_eol(fd) == FAIL || put_line(fd, "if s:l < 1 | let s:l = 1 | endif") == FAIL @@ -8713,14 +8713,14 @@ put_view ( if (!wp->w_p_wrap && wp->w_leftcol > 0 && 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 + 1), (int64_t)(wp->w_virtcol - wp->w_leftcol), - (int64_t)wp->w_width / 2, + (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' . %" PRId64 " . '|'", - (int64_t)wp->w_virtcol + 1) < 0 + (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/fileio.c b/src/fileio.c index 8591c20562..e1542cf1f1 100644 --- a/src/fileio.c +++ b/src/fileio.c @@ -5702,7 +5702,7 @@ vim_tempname ( mode_t umask_save; # endif - sprintf((char *)itmp + itmplen, "v%" PRId64, (int64_t)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, diff --git a/src/fold.c b/src/fold.c index 275e6c6d6a..38432a79aa 100644 --- a/src/fold.c +++ b/src/fold.c @@ -2958,8 +2958,8 @@ static int put_folds_recurse(FILE *fd, garray_T *gap, linenr_T off) if (put_folds_recurse(fd, &fp->fd_nested, off + fp->fd_top) == FAIL) return FAIL; if (fprintf(fd, "%" PRId64 ",%" PRId64 "fold", - (int64_t)fp->fd_top + off, - (int64_t)fp->fd_top + off + fp->fd_len - 1) < 0 + (int64_t)(fp->fd_top + off), + (int64_t)(fp->fd_top + off + fp->fd_len - 1)) < 0 || put_eol(fd) == FAIL) return FAIL; ++fp; @@ -2983,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, "%" PRId64, (int64_t)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; @@ -3020,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, "%" PRId64, (int64_t)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 a43180d6cb..1d3587b3ea 100644 --- a/src/hashtab.c +++ b/src/hashtab.c @@ -172,7 +172,7 @@ void hash_debug_results(void) 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); + (int64_t)(hash_count_perturb * 100 / hash_count_lookup)); #endif // ifdef HT_DEBUG } diff --git a/src/normal.c b/src/normal.c index c3aebbc69e..0d6410f3a9 100644 --- a/src/normal.c +++ b/src/normal.c @@ -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, ".,.+%" PRId64, (int64_t)cap->count0 - 1); + sprintf((char *)buf, ".,.+%" PRId64, (int64_t)(cap->count0 - 1)); STRCAT(buf, "! "); if (cap->count0 == 0 && isman_s) diff --git a/src/screen.c b/src/screen.c index e06da2124a..be26b6993d 100644 --- a/src/screen.c +++ b/src/screen.c @@ -7899,7 +7899,7 @@ static void win_redr_ruler(win_T *wp, int always) vim_snprintf((char *)buffer, RULER_BUF_LEN, "%" PRId64 ",", (wp->w_buffer->b_ml.ml_flags & ML_EMPTY) ? (int64_t)0L - : (int64_t)(wp->w_cursor.lnum)); + : (int64_t)wp->w_cursor.lnum); len = STRLEN(buffer); col_print(buffer + len, RULER_BUF_LEN - len, empty_line ? 0 : (int)wp->w_cursor.col + 1, |