comparison src/ops.c @ 13610:e76499e85744 v8.0.1677

patch 8.0.1677: no compiler warning for wrong format in vim_snprintf() commit https://github.com/vim/vim/commit/ea39176baab52b646d1e2676e662def718ddd365 Author: Bram Moolenaar <Bram@vim.org> Date: Sun Apr 8 13:07:22 2018 +0200 patch 8.0.1677: no compiler warning for wrong format in vim_snprintf() Problem: No compiler warning for wrong format in vim_snprintf(). Solution: Add printf attribute for gcc. Fix reported problems.
author Christian Brabandt <cb@256bit.org>
date Sun, 08 Apr 2018 13:15:07 +0200
parents bb789ed5113a
children 87e5629fc915
comparison
equal deleted inserted replaced
13609:67cb9088e452 13610:e76499e85744
5974 buf2[i++] = ((n >> (bit - 1)) & 0x1) ? '1' : '0'; 5974 buf2[i++] = ((n >> (bit - 1)) & 0x1) ? '1' : '0';
5975 5975
5976 buf2[i] = '\0'; 5976 buf2[i] = '\0';
5977 } 5977 }
5978 else if (pre == 0) 5978 else if (pre == 0)
5979 vim_snprintf((char *)buf2, NUMBUFLEN, "%llu", n); 5979 vim_snprintf((char *)buf2, NUMBUFLEN, "%llu",
5980 (long long unsigned)n);
5980 else if (pre == '0') 5981 else if (pre == '0')
5981 vim_snprintf((char *)buf2, NUMBUFLEN, "%llo", n); 5982 vim_snprintf((char *)buf2, NUMBUFLEN, "%llo",
5983 (long long unsigned)n);
5982 else if (pre && hexupper) 5984 else if (pre && hexupper)
5983 vim_snprintf((char *)buf2, NUMBUFLEN, "%llX", n); 5985 vim_snprintf((char *)buf2, NUMBUFLEN, "%llX",
5986 (long long unsigned)n);
5984 else 5987 else
5985 vim_snprintf((char *)buf2, NUMBUFLEN, "%llx", n); 5988 vim_snprintf((char *)buf2, NUMBUFLEN, "%llx",
5989 (long long unsigned)n);
5986 length -= (int)STRLEN(buf2); 5990 length -= (int)STRLEN(buf2);
5987 5991
5988 /* 5992 /*
5989 * Adjust number of zeros to the new number of digits, so the 5993 * Adjust number of zeros to the new number of digits, so the
5990 * total length of the number remains the same. 5994 * total length of the number remains the same.
7499 && char_count == byte_count) 7503 && char_count == byte_count)
7500 vim_snprintf((char *)IObuff, IOSIZE, 7504 vim_snprintf((char *)IObuff, IOSIZE,
7501 _("Selected %s%ld of %ld Lines; %lld of %lld Words; %lld of %lld Bytes"), 7505 _("Selected %s%ld of %ld Lines; %lld of %lld Words; %lld of %lld Bytes"),
7502 buf1, line_count_selected, 7506 buf1, line_count_selected,
7503 (long)curbuf->b_ml.ml_line_count, 7507 (long)curbuf->b_ml.ml_line_count,
7504 word_count_cursor, word_count, 7508 (long long)word_count_cursor,
7505 byte_count_cursor, byte_count); 7509 (long long)word_count,
7510 (long long)byte_count_cursor,
7511 (long long)byte_count);
7506 else 7512 else
7507 vim_snprintf((char *)IObuff, IOSIZE, 7513 vim_snprintf((char *)IObuff, IOSIZE,
7508 _("Selected %s%ld of %ld Lines; %lld of %lld Words; %lld of %lld Chars; %lld of %lld Bytes"), 7514 _("Selected %s%ld of %ld Lines; %lld of %lld Words; %lld of %lld Chars; %lld of %lld Bytes"),
7509 buf1, line_count_selected, 7515 buf1, line_count_selected,
7510 (long)curbuf->b_ml.ml_line_count, 7516 (long)curbuf->b_ml.ml_line_count,
7511 word_count_cursor, word_count, 7517 (long long)word_count_cursor,
7512 char_count_cursor, char_count, 7518 (long long)word_count,
7513 byte_count_cursor, byte_count); 7519 (long long)char_count_cursor,
7520 (long long)char_count,
7521 (long long)byte_count_cursor,
7522 (long long)byte_count);
7514 } 7523 }
7515 else 7524 else
7516 { 7525 {
7517 p = ml_get_curline(); 7526 p = ml_get_curline();
7518 validate_virtcol(); 7527 validate_virtcol();
7526 vim_snprintf((char *)IObuff, IOSIZE, 7535 vim_snprintf((char *)IObuff, IOSIZE,
7527 _("Col %s of %s; Line %ld of %ld; Word %lld of %lld; Byte %lld of %lld"), 7536 _("Col %s of %s; Line %ld of %ld; Word %lld of %lld; Byte %lld of %lld"),
7528 (char *)buf1, (char *)buf2, 7537 (char *)buf1, (char *)buf2,
7529 (long)curwin->w_cursor.lnum, 7538 (long)curwin->w_cursor.lnum,
7530 (long)curbuf->b_ml.ml_line_count, 7539 (long)curbuf->b_ml.ml_line_count,
7531 word_count_cursor, word_count, 7540 (long long)word_count_cursor, (long long)word_count,
7532 byte_count_cursor, byte_count); 7541 (long long)byte_count_cursor, (long long)byte_count);
7533 else 7542 else
7534 vim_snprintf((char *)IObuff, IOSIZE, 7543 vim_snprintf((char *)IObuff, IOSIZE,
7535 _("Col %s of %s; Line %ld of %ld; Word %lld of %lld; Char %lld of %lld; Byte %lld of %lld"), 7544 _("Col %s of %s; Line %ld of %ld; Word %lld of %lld; Char %lld of %lld; Byte %lld of %lld"),
7536 (char *)buf1, (char *)buf2, 7545 (char *)buf1, (char *)buf2,
7537 (long)curwin->w_cursor.lnum, 7546 (long)curwin->w_cursor.lnum,
7538 (long)curbuf->b_ml.ml_line_count, 7547 (long)curbuf->b_ml.ml_line_count,
7539 word_count_cursor, word_count, 7548 (long long)word_count_cursor, (long long)word_count,
7540 char_count_cursor, char_count, 7549 (long long)char_count_cursor, (long long)char_count,
7541 byte_count_cursor, byte_count); 7550 (long long)byte_count_cursor, (long long)byte_count);
7542 } 7551 }
7543 } 7552 }
7544 7553
7545 #ifdef FEAT_MBYTE 7554 #ifdef FEAT_MBYTE
7546 bom_count = bomb_size(); 7555 bom_count = bomb_size();