comparison src/ops.c @ 19477:2bb0e80fcd32 v8.2.0296

patch 8.2.0296: mixing up "long long" and __int64 may cause problems Commit: https://github.com/vim/vim/commit/f9706e9df0e37d214fb08eda30ba29627e97a607 Author: Bram Moolenaar <Bram@vim.org> Date: Sat Feb 22 14:27:04 2020 +0100 patch 8.2.0296: mixing up "long long" and __int64 may cause problems Problem: Mixing up "long long" and __int64 may cause problems. (John Marriott) Solution: Pass varnumber_T to vim_snprintf(). Add v:numbersize.
author Bram Moolenaar <Bram@vim.org>
date Sat, 22 Feb 2020 14:30:04 +0100
parents 2ef19eed524a
children b64343cbabc6
comparison
equal deleted inserted replaced
19476:381e5000c519 19477:2bb0e80fcd32
3362 buf2[i++] = ((n >> (bit - 1)) & 0x1) ? '1' : '0'; 3362 buf2[i++] = ((n >> (bit - 1)) & 0x1) ? '1' : '0';
3363 3363
3364 buf2[i] = '\0'; 3364 buf2[i] = '\0';
3365 } 3365 }
3366 else if (pre == 0) 3366 else if (pre == 0)
3367 vim_snprintf((char *)buf2, NUMBUFLEN, "%llu", 3367 vim_snprintf((char *)buf2, NUMBUFLEN, "%llu", (uvarnumber_T)n);
3368 (long_long_u_T)n);
3369 else if (pre == '0') 3368 else if (pre == '0')
3370 vim_snprintf((char *)buf2, NUMBUFLEN, "%llo", 3369 vim_snprintf((char *)buf2, NUMBUFLEN, "%llo", (uvarnumber_T)n);
3371 (long_long_u_T)n);
3372 else if (pre && hexupper) 3370 else if (pre && hexupper)
3373 vim_snprintf((char *)buf2, NUMBUFLEN, "%llX", 3371 vim_snprintf((char *)buf2, NUMBUFLEN, "%llX", (uvarnumber_T)n);
3374 (long_long_u_T)n);
3375 else 3372 else
3376 vim_snprintf((char *)buf2, NUMBUFLEN, "%llx", 3373 vim_snprintf((char *)buf2, NUMBUFLEN, "%llx", (uvarnumber_T)n);
3377 (long_long_u_T)n);
3378 length -= (int)STRLEN(buf2); 3374 length -= (int)STRLEN(buf2);
3379 3375
3380 /* 3376 /*
3381 * Adjust number of zeros to the new number of digits, so the 3377 * Adjust number of zeros to the new number of digits, so the
3382 * total length of the number remains the same. 3378 * total length of the number remains the same.
3771 && char_count == byte_count) 3767 && char_count == byte_count)
3772 vim_snprintf((char *)IObuff, IOSIZE, 3768 vim_snprintf((char *)IObuff, IOSIZE,
3773 _("Selected %s%ld of %ld Lines; %lld of %lld Words; %lld of %lld Bytes"), 3769 _("Selected %s%ld of %ld Lines; %lld of %lld Words; %lld of %lld Bytes"),
3774 buf1, line_count_selected, 3770 buf1, line_count_selected,
3775 (long)curbuf->b_ml.ml_line_count, 3771 (long)curbuf->b_ml.ml_line_count,
3776 (long_long_T)word_count_cursor, 3772 (varnumber_T)word_count_cursor,
3777 (long_long_T)word_count, 3773 (varnumber_T)word_count,
3778 (long_long_T)byte_count_cursor, 3774 (varnumber_T)byte_count_cursor,
3779 (long_long_T)byte_count); 3775 (varnumber_T)byte_count);
3780 else 3776 else
3781 vim_snprintf((char *)IObuff, IOSIZE, 3777 vim_snprintf((char *)IObuff, IOSIZE,
3782 _("Selected %s%ld of %ld Lines; %lld of %lld Words; %lld of %lld Chars; %lld of %lld Bytes"), 3778 _("Selected %s%ld of %ld Lines; %lld of %lld Words; %lld of %lld Chars; %lld of %lld Bytes"),
3783 buf1, line_count_selected, 3779 buf1, line_count_selected,
3784 (long)curbuf->b_ml.ml_line_count, 3780 (long)curbuf->b_ml.ml_line_count,
3785 (long_long_T)word_count_cursor, 3781 (varnumber_T)word_count_cursor,
3786 (long_long_T)word_count, 3782 (varnumber_T)word_count,
3787 (long_long_T)char_count_cursor, 3783 (varnumber_T)char_count_cursor,
3788 (long_long_T)char_count, 3784 (varnumber_T)char_count,
3789 (long_long_T)byte_count_cursor, 3785 (varnumber_T)byte_count_cursor,
3790 (long_long_T)byte_count); 3786 (varnumber_T)byte_count);
3791 } 3787 }
3792 else 3788 else
3793 { 3789 {
3794 p = ml_get_curline(); 3790 p = ml_get_curline();
3795 validate_virtcol(); 3791 validate_virtcol();
3803 vim_snprintf((char *)IObuff, IOSIZE, 3799 vim_snprintf((char *)IObuff, IOSIZE,
3804 _("Col %s of %s; Line %ld of %ld; Word %lld of %lld; Byte %lld of %lld"), 3800 _("Col %s of %s; Line %ld of %ld; Word %lld of %lld; Byte %lld of %lld"),
3805 (char *)buf1, (char *)buf2, 3801 (char *)buf1, (char *)buf2,
3806 (long)curwin->w_cursor.lnum, 3802 (long)curwin->w_cursor.lnum,
3807 (long)curbuf->b_ml.ml_line_count, 3803 (long)curbuf->b_ml.ml_line_count,
3808 (long_long_T)word_count_cursor, (long_long_T)word_count, 3804 (varnumber_T)word_count_cursor, (varnumber_T)word_count,
3809 (long_long_T)byte_count_cursor, (long_long_T)byte_count); 3805 (varnumber_T)byte_count_cursor, (varnumber_T)byte_count);
3810 else 3806 else
3811 vim_snprintf((char *)IObuff, IOSIZE, 3807 vim_snprintf((char *)IObuff, IOSIZE,
3812 _("Col %s of %s; Line %ld of %ld; Word %lld of %lld; Char %lld of %lld; Byte %lld of %lld"), 3808 _("Col %s of %s; Line %ld of %ld; Word %lld of %lld; Char %lld of %lld; Byte %lld of %lld"),
3813 (char *)buf1, (char *)buf2, 3809 (char *)buf1, (char *)buf2,
3814 (long)curwin->w_cursor.lnum, 3810 (long)curwin->w_cursor.lnum,
3815 (long)curbuf->b_ml.ml_line_count, 3811 (long)curbuf->b_ml.ml_line_count,
3816 (long_long_T)word_count_cursor, (long_long_T)word_count, 3812 (varnumber_T)word_count_cursor, (varnumber_T)word_count,
3817 (long_long_T)char_count_cursor, (long_long_T)char_count, 3813 (varnumber_T)char_count_cursor, (varnumber_T)char_count,
3818 (long_long_T)byte_count_cursor, (long_long_T)byte_count); 3814 (varnumber_T)byte_count_cursor, (varnumber_T)byte_count);
3819 } 3815 }
3820 } 3816 }
3821 3817
3822 bom_count = bomb_size(); 3818 bom_count = bomb_size();
3823 if (dict == NULL && bom_count > 0) 3819 if (dict == NULL && bom_count > 0)
3824 { 3820 {
3825 size_t len = STRLEN(IObuff); 3821 size_t len = STRLEN(IObuff);
3826 3822
3827 vim_snprintf((char *)IObuff + len, IOSIZE - len, 3823 vim_snprintf((char *)IObuff + len, IOSIZE - len,
3828 _("(+%lld for BOM)"), (long_long_T)bom_count); 3824 _("(+%lld for BOM)"), (varnumber_T)bom_count);
3829 } 3825 }
3830 if (dict == NULL) 3826 if (dict == NULL)
3831 { 3827 {
3832 // Don't shorten this message, the user asked for it. 3828 // Don't shorten this message, the user asked for it.
3833 p = p_shm; 3829 p = p_shm;