Mercurial > vim
comparison src/spell.c @ 16764:ef00b6bc186b v8.1.1384
patch 8.1.1384: using "int" for alloc() often results in compiler warnings
commit https://github.com/vim/vim/commit/964b3746b9c81e65887e2ac9a335f181db2bb592
Author: Bram Moolenaar <Bram@vim.org>
Date: Fri May 24 18:54:09 2019 +0200
patch 8.1.1384: using "int" for alloc() often results in compiler warnings
Problem: Using "int" for alloc() often results in compiler warnings.
Solution: Use "size_t" and remove type casts. Remove alloc_check(), Vim
only works with 32 bit ints anyway.
author | Bram Moolenaar <Bram@vim.org> |
---|---|
date | Fri, 24 May 2019 19:00:07 +0200 |
parents | b52ea9c5f1db |
children | 695d9ef00b03 |
comparison
equal
deleted
inserted
replaced
16763:fccf84413b53 | 16764:ef00b6bc186b |
---|---|
2081 | 2081 |
2082 hash = hash_hash(p); | 2082 hash = hash_hash(p); |
2083 hi = hash_lookup(&lp->sl_wordcount, p, hash); | 2083 hi = hash_lookup(&lp->sl_wordcount, p, hash); |
2084 if (HASHITEM_EMPTY(hi)) | 2084 if (HASHITEM_EMPTY(hi)) |
2085 { | 2085 { |
2086 wc = (wordcount_T *)alloc((unsigned)(sizeof(wordcount_T) + STRLEN(p))); | 2086 wc = (wordcount_T *)alloc(sizeof(wordcount_T) + STRLEN(p)); |
2087 if (wc == NULL) | 2087 if (wc == NULL) |
2088 return; | 2088 return; |
2089 STRCPY(wc->wc_word, p); | 2089 STRCPY(wc->wc_word, p); |
2090 wc->wc_count = count; | 2090 wc->wc_count = count; |
2091 hash_add_item(&lp->sl_wordcount, hi, wc->wc_word, hash); | 2091 hash_add_item(&lp->sl_wordcount, hi, wc->wc_word, hash); |
3430 repl_from = vim_strnsave(sug.su_badptr, stp->st_orglen); | 3430 repl_from = vim_strnsave(sug.su_badptr, stp->st_orglen); |
3431 repl_to = vim_strsave(stp->st_word); | 3431 repl_to = vim_strsave(stp->st_word); |
3432 } | 3432 } |
3433 | 3433 |
3434 /* Replace the word. */ | 3434 /* Replace the word. */ |
3435 p = alloc((unsigned)STRLEN(line) - stp->st_orglen | 3435 p = alloc(STRLEN(line) - stp->st_orglen + stp->st_wordlen + 1); |
3436 + stp->st_wordlen + 1); | |
3437 if (p != NULL) | 3436 if (p != NULL) |
3438 { | 3437 { |
3439 c = (int)(sug.su_badptr - line); | 3438 c = (int)(sug.su_badptr - line); |
3440 mch_memmove(p, line, c); | 3439 mch_memmove(p, line, c); |
3441 STRCPY(p + c, stp->st_word); | 3440 STRCPY(p + c, stp->st_word); |
3550 emsg(_("E752: No previous spell replacement")); | 3549 emsg(_("E752: No previous spell replacement")); |
3551 return; | 3550 return; |
3552 } | 3551 } |
3553 addlen = (int)(STRLEN(repl_to) - STRLEN(repl_from)); | 3552 addlen = (int)(STRLEN(repl_to) - STRLEN(repl_from)); |
3554 | 3553 |
3555 frompat = alloc((unsigned)STRLEN(repl_from) + 7); | 3554 frompat = alloc(STRLEN(repl_from) + 7); |
3556 if (frompat == NULL) | 3555 if (frompat == NULL) |
3557 return; | 3556 return; |
3558 sprintf((char *)frompat, "\\V\\<%s\\>", repl_from); | 3557 sprintf((char *)frompat, "\\V\\<%s\\>", repl_from); |
3559 p_ws = FALSE; | 3558 p_ws = FALSE; |
3560 | 3559 |
3571 * when changing "etc" to "etc.". */ | 3570 * when changing "etc" to "etc.". */ |
3572 line = ml_get_curline(); | 3571 line = ml_get_curline(); |
3573 if (addlen <= 0 || STRNCMP(line + curwin->w_cursor.col, | 3572 if (addlen <= 0 || STRNCMP(line + curwin->w_cursor.col, |
3574 repl_to, STRLEN(repl_to)) != 0) | 3573 repl_to, STRLEN(repl_to)) != 0) |
3575 { | 3574 { |
3576 p = alloc((unsigned)STRLEN(line) + addlen + 1); | 3575 p = alloc(STRLEN(line) + addlen + 1); |
3577 if (p == NULL) | 3576 if (p == NULL) |
3578 break; | 3577 break; |
3579 mch_memmove(p, line, curwin->w_cursor.col); | 3578 mch_memmove(p, line, curwin->w_cursor.col); |
3580 STRCPY(p + curwin->w_cursor.col, repl_to); | 3579 STRCPY(p + curwin->w_cursor.col, repl_to); |
3581 STRCAT(p, line + curwin->w_cursor.col + STRLEN(repl_from)); | 3580 STRCAT(p, line + curwin->w_cursor.col + STRLEN(repl_from)); |
6222 */ | 6221 */ |
6223 hash = hash_hash(goodword); | 6222 hash = hash_hash(goodword); |
6224 hi = hash_lookup(&slang->sl_sounddone, goodword, hash); | 6223 hi = hash_lookup(&slang->sl_sounddone, goodword, hash); |
6225 if (HASHITEM_EMPTY(hi)) | 6224 if (HASHITEM_EMPTY(hi)) |
6226 { | 6225 { |
6227 sft = (sftword_T *)alloc((unsigned)(sizeof(sftword_T) | 6226 sft = (sftword_T *)alloc(sizeof(sftword_T) + STRLEN(goodword)); |
6228 + STRLEN(goodword))); | |
6229 if (sft != NULL) | 6227 if (sft != NULL) |
6230 { | 6228 { |
6231 sft->sft_score = score; | 6229 sft->sft_score = score; |
6232 STRCPY(sft->sft_word, goodword); | 6230 STRCPY(sft->sft_word, goodword); |
6233 hash_add_item(&slang->sl_sounddone, hi, sft->sft_word, hash); | 6231 hash_add_item(&slang->sl_sounddone, hi, sft->sft_word, hash); |