comparison src/ops.c @ 27426:41e0dcf38521 v8.2.4241

patch 8.2.4241: some type casts are redundant Commit: https://github.com/vim/vim/commit/420fabcd4ffeaf79082a6e43db91e1d363f88f27 Author: =?UTF-8?q?Dundar=20G=C3=B6c?= <gocdundar@gmail.com> Date: Fri Jan 28 15:28:04 2022 +0000 patch 8.2.4241: some type casts are redundant Problem: Some type casts are redundant. Solution: Remove the type casts. (closes https://github.com/vim/vim/issues/9643)
author Bram Moolenaar <Bram@vim.org>
date Fri, 28 Jan 2022 16:30:11 +0100
parents 93d4ee1e6113
children fb4c30606b4a
comparison
equal deleted inserted replaced
27425:b5bd6c851b8a 27426:41e0dcf38521
332 ++bd.textstart; 332 ++bd.textstart;
333 } 333 }
334 for ( ; VIM_ISWHITE(*bd.textstart); ) 334 for ( ; VIM_ISWHITE(*bd.textstart); )
335 { 335 {
336 // TODO: is passing bd.textstart for start of the line OK? 336 // TODO: is passing bd.textstart for start of the line OK?
337 incr = lbr_chartabsize_adv(bd.textstart, &bd.textstart, 337 incr = lbr_chartabsize_adv(bd.textstart, &bd.textstart, bd.start_vcol);
338 (colnr_T)(bd.start_vcol));
339 total += incr; 338 total += incr;
340 bd.start_vcol += incr; 339 bd.start_vcol += incr;
341 } 340 }
342 // OK, now total=all the VWS reqd, and textstart points at the 1st 341 // OK, now total=all the VWS reqd, and textstart points at the 1st
343 // non-ws char in the block. 342 // non-ws char in the block.
458 vim_memset(newp + (verbatim_copy_end - oldp), ' ', (size_t)fill); 457 vim_memset(newp + (verbatim_copy_end - oldp), ' ', (size_t)fill);
459 STRMOVE(newp + (verbatim_copy_end - oldp) + fill, non_white); 458 STRMOVE(newp + (verbatim_copy_end - oldp) + fill, non_white);
460 } 459 }
461 // replace the line 460 // replace the line
462 ml_replace(curwin->w_cursor.lnum, newp, FALSE); 461 ml_replace(curwin->w_cursor.lnum, newp, FALSE);
463 changed_bytes(curwin->w_cursor.lnum, (colnr_T)bd.textcol); 462 changed_bytes(curwin->w_cursor.lnum, bd.textcol);
464 State = oldstate; 463 State = oldstate;
465 curwin->w_cursor.col = oldcol; 464 curwin->w_cursor.col = oldcol;
466 #ifdef FEAT_RIGHTLEFT 465 #ifdef FEAT_RIGHTLEFT
467 p_ri = old_p_ri; 466 p_ri = old_p_ri;
468 #endif 467 #endif
2131 2130
2132 // If deleting more spaces than adding, the cursor moves no more than 2131 // If deleting more spaces than adding, the cursor moves no more than
2133 // what is added if it is inside these spaces. 2132 // what is added if it is inside these spaces.
2134 spaces_removed = (curr - curr_start) - spaces[t]; 2133 spaces_removed = (curr - curr_start) - spaces[t];
2135 2134
2136 mark_col_adjust(curwin->w_cursor.lnum + t, (colnr_T)0, (linenr_T)-t, 2135 mark_col_adjust(curwin->w_cursor.lnum + t, (colnr_T)0, -t,
2137 (long)(cend - newp - spaces_removed), spaces_removed); 2136 (long)(cend - newp - spaces_removed), spaces_removed);
2138 #ifdef FEAT_PROP_POPUP 2137 #ifdef FEAT_PROP_POPUP
2139 prepend_joined_props(newp + sumsize + 1, propcount, &props_remaining, 2138 prepend_joined_props(newp + sumsize + 1, propcount, &props_remaining,
2140 curwin->w_cursor.lnum + t, t == count - 1, 2139 curwin->w_cursor.lnum + t, t == count - 1,
2141 (long)(cend - newp), spaces_removed); 2140 (long)(cend - newp), spaces_removed);
2241 pstart = line; 2240 pstart = line;
2242 prev_pstart = line; 2241 prev_pstart = line;
2243 while (bdp->start_vcol < oap->start_vcol && *pstart) 2242 while (bdp->start_vcol < oap->start_vcol && *pstart)
2244 { 2243 {
2245 // Count a tab for what it's worth (if list mode not on) 2244 // Count a tab for what it's worth (if list mode not on)
2246 incr = lbr_chartabsize(line, pstart, (colnr_T)bdp->start_vcol); 2245 incr = lbr_chartabsize(line, pstart, bdp->start_vcol);
2247 bdp->start_vcol += incr; 2246 bdp->start_vcol += incr;
2248 if (VIM_ISWHITE(*pstart)) 2247 if (VIM_ISWHITE(*pstart))
2249 { 2248 {
2250 bdp->pre_whitesp += incr; 2249 bdp->pre_whitesp += incr;
2251 bdp->pre_whitesp_c++; 2250 bdp->pre_whitesp_c++;
2304 prev_pend = pend; 2303 prev_pend = pend;
2305 while (bdp->end_vcol <= oap->end_vcol && *pend != NUL) 2304 while (bdp->end_vcol <= oap->end_vcol && *pend != NUL)
2306 { 2305 {
2307 // Count a tab for what it's worth (if list mode not on) 2306 // Count a tab for what it's worth (if list mode not on)
2308 prev_pend = pend; 2307 prev_pend = pend;
2309 incr = lbr_chartabsize_adv(line, &pend, (colnr_T)bdp->end_vcol); 2308 incr = lbr_chartabsize_adv(line, &pend, bdp->end_vcol);
2310 bdp->end_vcol += incr; 2309 bdp->end_vcol += incr;
2311 } 2310 }
2312 if (bdp->end_vcol <= oap->end_vcol 2311 if (bdp->end_vcol <= oap->end_vcol
2313 && (!is_del 2312 && (!is_del
2314 || oap->op_type == OP_APPEND 2313 || oap->op_type == OP_APPEND
2864 buf2[i++] = ((n >> (bit - 1)) & 0x1) ? '1' : '0'; 2863 buf2[i++] = ((n >> (bit - 1)) & 0x1) ? '1' : '0';
2865 2864
2866 buf2[i] = '\0'; 2865 buf2[i] = '\0';
2867 } 2866 }
2868 else if (pre == 0) 2867 else if (pre == 0)
2869 vim_snprintf((char *)buf2, NUMBUFLEN, "%llu", (uvarnumber_T)n); 2868 vim_snprintf((char *)buf2, NUMBUFLEN, "%llu", n);
2870 else if (pre == '0') 2869 else if (pre == '0')
2871 vim_snprintf((char *)buf2, NUMBUFLEN, "%llo", (uvarnumber_T)n); 2870 vim_snprintf((char *)buf2, NUMBUFLEN, "%llo", n);
2872 else if (pre && hexupper) 2871 else if (pre && hexupper)
2873 vim_snprintf((char *)buf2, NUMBUFLEN, "%llX", (uvarnumber_T)n); 2872 vim_snprintf((char *)buf2, NUMBUFLEN, "%llX", n);
2874 else 2873 else
2875 vim_snprintf((char *)buf2, NUMBUFLEN, "%llx", (uvarnumber_T)n); 2874 vim_snprintf((char *)buf2, NUMBUFLEN, "%llx", n);
2876 length -= (int)STRLEN(buf2); 2875 length -= (int)STRLEN(buf2);
2877 2876
2878 /* 2877 /*
2879 * Adjust number of zeros to the new number of digits, so the 2878 * Adjust number of zeros to the new number of digits, so the
2880 * total length of the number remains the same. 2879 * total length of the number remains the same.
3189 && char_count == byte_count) 3188 && char_count == byte_count)
3190 vim_snprintf((char *)IObuff, IOSIZE, 3189 vim_snprintf((char *)IObuff, IOSIZE,
3191 _("Selected %s%ld of %ld Lines; %lld of %lld Words; %lld of %lld Bytes"), 3190 _("Selected %s%ld of %ld Lines; %lld of %lld Words; %lld of %lld Bytes"),
3192 buf1, line_count_selected, 3191 buf1, line_count_selected,
3193 (long)curbuf->b_ml.ml_line_count, 3192 (long)curbuf->b_ml.ml_line_count,
3194 (varnumber_T)word_count_cursor, 3193 word_count_cursor,
3195 (varnumber_T)word_count, 3194 word_count,
3196 (varnumber_T)byte_count_cursor, 3195 byte_count_cursor,
3197 (varnumber_T)byte_count); 3196 byte_count);
3198 else 3197 else
3199 vim_snprintf((char *)IObuff, IOSIZE, 3198 vim_snprintf((char *)IObuff, IOSIZE,
3200 _("Selected %s%ld of %ld Lines; %lld of %lld Words; %lld of %lld Chars; %lld of %lld Bytes"), 3199 _("Selected %s%ld of %ld Lines; %lld of %lld Words; %lld of %lld Chars; %lld of %lld Bytes"),
3201 buf1, line_count_selected, 3200 buf1, line_count_selected,
3202 (long)curbuf->b_ml.ml_line_count, 3201 (long)curbuf->b_ml.ml_line_count,
3203 (varnumber_T)word_count_cursor, 3202 word_count_cursor,
3204 (varnumber_T)word_count, 3203 word_count,
3205 (varnumber_T)char_count_cursor, 3204 char_count_cursor,
3206 (varnumber_T)char_count, 3205 char_count,
3207 (varnumber_T)byte_count_cursor, 3206 byte_count_cursor,
3208 (varnumber_T)byte_count); 3207 byte_count);
3209 } 3208 }
3210 else 3209 else
3211 { 3210 {
3212 p = ml_get_curline(); 3211 p = ml_get_curline();
3213 validate_virtcol(); 3212 validate_virtcol();
3221 vim_snprintf((char *)IObuff, IOSIZE, 3220 vim_snprintf((char *)IObuff, IOSIZE,
3222 _("Col %s of %s; Line %ld of %ld; Word %lld of %lld; Byte %lld of %lld"), 3221 _("Col %s of %s; Line %ld of %ld; Word %lld of %lld; Byte %lld of %lld"),
3223 (char *)buf1, (char *)buf2, 3222 (char *)buf1, (char *)buf2,
3224 (long)curwin->w_cursor.lnum, 3223 (long)curwin->w_cursor.lnum,
3225 (long)curbuf->b_ml.ml_line_count, 3224 (long)curbuf->b_ml.ml_line_count,
3226 (varnumber_T)word_count_cursor, (varnumber_T)word_count, 3225 word_count_cursor, word_count,
3227 (varnumber_T)byte_count_cursor, (varnumber_T)byte_count); 3226 byte_count_cursor, byte_count);
3228 else 3227 else
3229 vim_snprintf((char *)IObuff, IOSIZE, 3228 vim_snprintf((char *)IObuff, IOSIZE,
3230 _("Col %s of %s; Line %ld of %ld; Word %lld of %lld; Char %lld of %lld; Byte %lld of %lld"), 3229 _("Col %s of %s; Line %ld of %ld; Word %lld of %lld; Char %lld of %lld; Byte %lld of %lld"),
3231 (char *)buf1, (char *)buf2, 3230 (char *)buf1, (char *)buf2,
3232 (long)curwin->w_cursor.lnum, 3231 (long)curwin->w_cursor.lnum,
3233 (long)curbuf->b_ml.ml_line_count, 3232 (long)curbuf->b_ml.ml_line_count,
3234 (varnumber_T)word_count_cursor, (varnumber_T)word_count, 3233 word_count_cursor, word_count,
3235 (varnumber_T)char_count_cursor, (varnumber_T)char_count, 3234 char_count_cursor, char_count,
3236 (varnumber_T)byte_count_cursor, (varnumber_T)byte_count); 3235 byte_count_cursor, byte_count);
3237 } 3236 }
3238 } 3237 }
3239 3238
3240 bom_count = bomb_size(); 3239 bom_count = bomb_size();
3241 if (dict == NULL && bom_count > 0) 3240 if (dict == NULL && bom_count > 0)
3242 { 3241 {
3243 size_t len = STRLEN(IObuff); 3242 size_t len = STRLEN(IObuff);
3244 3243
3245 vim_snprintf((char *)IObuff + len, IOSIZE - len, 3244 vim_snprintf((char *)IObuff + len, IOSIZE - len,
3246 _("(+%lld for BOM)"), (varnumber_T)bom_count); 3245 _("(+%lld for BOM)"), bom_count);
3247 } 3246 }
3248 if (dict == NULL) 3247 if (dict == NULL)
3249 { 3248 {
3250 // Don't shorten this message, the user asked for it. 3249 // Don't shorten this message, the user asked for it.
3251 p = p_shm; 3250 p = p_shm;