diff options
author | Eliseo Martínez <eliseomarmol@gmail.com> | 2014-04-25 11:47:25 +0200 |
---|---|---|
committer | Thiago de Arruda <tpadilha84@gmail.com> | 2014-04-28 07:49:14 -0300 |
commit | 6e2cb1bddbc8e24428ba7ce86f0b66c85f6738e5 (patch) | |
tree | 1b09c1d48d1eaccbfe29d6584a9f352b9aeeaabb /src | |
parent | c79ff046a01e905a40a97cb9a6dbfc12a4f2cf53 (diff) | |
download | rneovim-6e2cb1bddbc8e24428ba7ce86f0b66c85f6738e5.tar.gz rneovim-6e2cb1bddbc8e24428ba7ce86f0b66c85f6738e5.tar.bz2 rneovim-6e2cb1bddbc8e24428ba7ce86f0b66c85f6738e5.zip |
Use portable format specifiers: Case %ld - plain - sscanf.
Fix uses of plain "%ld" within sscanf():
- Replace "%ld" with "%" SCNd64.
- Create (int64_t) local variable and sscanf into that.
- Safely downcast into previous type (introduce assertion, to be removed
when variable type refactored).
Diffstat (limited to 'src')
-rw-r--r-- | src/mark.c | 7 |
1 files changed, 5 insertions, 2 deletions
diff --git a/src/mark.c b/src/mark.c index eb066535f5..d5dd868167 100644 --- a/src/mark.c +++ b/src/mark.c @@ -1493,9 +1493,12 @@ void copy_viminfo_marks(vir_T *virp, FILE *fp_out, int count, int eof, int flags while (!(eof = viminfo_readline(virp)) && line[0] == TAB) { if (load_marks) { if (line[1] != NUL) { + int64_t lnum_64; unsigned u; - - sscanf((char *)line + 2, "%ld %u", &pos.lnum, &u); + sscanf((char *)line + 2, "%" SCNd64 "%u", &lnum_64, &u); + // safely downcast to linenr_T (long); remove when linenr_T refactored + assert(lnum_64 <= LONG_MAX); + pos.lnum = (linenr_T)lnum_64; pos.col = u; switch (line[1]) { case '"': curbuf->b_last_cursor = pos; break; |