Mercurial > vim
comparison src/diff.c @ 15470:55ccc2d353bd v8.1.0743
patch 8.1.0743: giving error messages is not flexible
commit https://github.com/vim/vim/commit/f9e3e09fdc93be9f0d47afbc6c7df1188c2a5a0d
Author: Bram Moolenaar <Bram@vim.org>
Date: Sun Jan 13 23:38:42 2019 +0100
patch 8.1.0743: giving error messages is not flexible
Problem: Giving error messages is not flexible.
Solution: Add semsg(). Change argument from "char_u *" to "char *", also
for msg() and get rid of most MSG macros. (Ozaki Kiichi, closes
#3302) Also make emsg() accept a "char *" argument. Get rid of
an enormous number of type casts.
author | Bram Moolenaar <Bram@vim.org> |
---|---|
date | Sun, 13 Jan 2019 23:45:08 +0100 |
parents | 9339601e7a31 |
children | 98c35d312987 |
comparison
equal
deleted
inserted
replaced
15469:bc9b5261ed01 | 15470:55ccc2d353bd |
---|---|
171 curtab->tp_diff_invalid = TRUE; | 171 curtab->tp_diff_invalid = TRUE; |
172 diff_redraw(TRUE); | 172 diff_redraw(TRUE); |
173 return; | 173 return; |
174 } | 174 } |
175 | 175 |
176 EMSGN(_("E96: Cannot diff more than %ld buffers"), DB_COUNT); | 176 semsg(_("E96: Cannot diff more than %ld buffers"), DB_COUNT); |
177 } | 177 } |
178 | 178 |
179 /* | 179 /* |
180 * Remove all buffers to make diffs for. | 180 * Remove all buffers to make diffs for. |
181 */ | 181 */ |
722 // will be retried with external diff. The flag is never reset. | 722 // will be retried with external diff. The flag is never reset. |
723 buf->b_diff_failed = TRUE; | 723 buf->b_diff_failed = TRUE; |
724 if (p_verbose > 0) | 724 if (p_verbose > 0) |
725 { | 725 { |
726 verbose_enter(); | 726 verbose_enter(); |
727 smsg((char_u *) | 727 smsg(_("Not enough memory to use internal diff for buffer \"%s\""), |
728 _("Not enough memory to use internal diff for buffer \"%s\""), | |
729 buf->b_fname); | 728 buf->b_fname); |
730 verbose_leave(); | 729 verbose_leave(); |
731 } | 730 } |
732 return FAIL; | 731 return FAIL; |
733 } | 732 } |
1048 break; | 1047 break; |
1049 } | 1048 } |
1050 if (!ok) | 1049 if (!ok) |
1051 { | 1050 { |
1052 if (io_error) | 1051 if (io_error) |
1053 EMSG(_("E810: Cannot read or write temp files")); | 1052 emsg(_("E810: Cannot read or write temp files")); |
1054 EMSG(_("E97: Cannot create diffs")); | 1053 emsg(_("E97: Cannot create diffs")); |
1055 diff_a_works = MAYBE; | 1054 diff_a_works = MAYBE; |
1056 #if defined(MSWIN) | 1055 #if defined(MSWIN) |
1057 diff_bin_works = MAYBE; | 1056 diff_bin_works = MAYBE; |
1058 #endif | 1057 #endif |
1059 return FAIL; | 1058 return FAIL; |
1091 emit_cb.outf = xdiff_out; | 1090 emit_cb.outf = xdiff_out; |
1092 if (xdl_diff(&diffio->dio_orig.din_mmfile, | 1091 if (xdl_diff(&diffio->dio_orig.din_mmfile, |
1093 &diffio->dio_new.din_mmfile, | 1092 &diffio->dio_new.din_mmfile, |
1094 ¶m, &emit_cfg, &emit_cb) < 0) | 1093 ¶m, &emit_cfg, &emit_cb) < 0) |
1095 { | 1094 { |
1096 EMSG(_("E960: Problem creating the internal diff")); | 1095 emsg(_("E960: Problem creating the internal diff")); |
1097 return FAIL; | 1096 return FAIL; |
1098 } | 1097 } |
1099 return OK; | 1098 return OK; |
1100 } | 1099 } |
1101 | 1100 |
1271 | 1270 |
1272 #ifdef UNIX | 1271 #ifdef UNIX |
1273 if (dirbuf[0] != NUL) | 1272 if (dirbuf[0] != NUL) |
1274 { | 1273 { |
1275 if (mch_chdir((char *)dirbuf) != 0) | 1274 if (mch_chdir((char *)dirbuf) != 0) |
1276 EMSG(_(e_prev_dir)); | 1275 emsg(_(e_prev_dir)); |
1277 shorten_fnames(TRUE); | 1276 shorten_fnames(TRUE); |
1278 } | 1277 } |
1279 #endif | 1278 #endif |
1280 | 1279 |
1281 /* patch probably has written over the screen */ | 1280 /* patch probably has written over the screen */ |
1289 STRCAT(buf, ".rej"); | 1288 STRCAT(buf, ".rej"); |
1290 mch_remove(buf); | 1289 mch_remove(buf); |
1291 | 1290 |
1292 /* Only continue if the output file was created. */ | 1291 /* Only continue if the output file was created. */ |
1293 if (mch_stat((char *)tmp_new, &st) < 0 || st.st_size == 0) | 1292 if (mch_stat((char *)tmp_new, &st) < 0 || st.st_size == 0) |
1294 EMSG(_("E816: Cannot read patch output")); | 1293 emsg(_("E816: Cannot read patch output")); |
1295 else | 1294 else |
1296 { | 1295 { |
1297 if (curbuf->b_fname != NULL) | 1296 if (curbuf->b_fname != NULL) |
1298 { | 1297 { |
1299 newname = vim_strnsave(curbuf->b_fname, | 1298 newname = vim_strnsave(curbuf->b_fname, |
1594 else | 1593 else |
1595 { | 1594 { |
1596 fd = mch_fopen((char *)dout->dout_fname, "r"); | 1595 fd = mch_fopen((char *)dout->dout_fname, "r"); |
1597 if (fd == NULL) | 1596 if (fd == NULL) |
1598 { | 1597 { |
1599 EMSG(_("E98: Cannot read diff output")); | 1598 emsg(_("E98: Cannot read diff output")); |
1600 return; | 1599 return; |
1601 } | 1600 } |
1602 } | 1601 } |
1603 | 1602 |
1604 for (;;) | 1603 for (;;) |
1660 &lnum_new, &count_new) == FAIL) | 1659 &lnum_new, &count_new) == FAIL) |
1661 continue; | 1660 continue; |
1662 } | 1661 } |
1663 else | 1662 else |
1664 { | 1663 { |
1665 EMSG(_("E959: Invalid diff format.")); | 1664 emsg(_("E959: Invalid diff format.")); |
1666 break; | 1665 break; |
1667 } | 1666 } |
1668 | 1667 |
1669 // Go over blocks before the change, for which orig and new are equal. | 1668 // Go over blocks before the change, for which orig and new are equal. |
1670 // Copy blocks from orig to new. | 1669 // Copy blocks from orig to new. |
2570 | 2569 |
2571 /* Find the current buffer in the list of diff buffers. */ | 2570 /* Find the current buffer in the list of diff buffers. */ |
2572 idx_cur = diff_buf_idx(curbuf); | 2571 idx_cur = diff_buf_idx(curbuf); |
2573 if (idx_cur == DB_COUNT) | 2572 if (idx_cur == DB_COUNT) |
2574 { | 2573 { |
2575 EMSG(_("E99: Current buffer is not in diff mode")); | 2574 emsg(_("E99: Current buffer is not in diff mode")); |
2576 return; | 2575 return; |
2577 } | 2576 } |
2578 | 2577 |
2579 if (*eap->arg == NUL) | 2578 if (*eap->arg == NUL) |
2580 { | 2579 { |
2589 found_not_ma = TRUE; | 2588 found_not_ma = TRUE; |
2590 } | 2589 } |
2591 if (idx_other == DB_COUNT) | 2590 if (idx_other == DB_COUNT) |
2592 { | 2591 { |
2593 if (found_not_ma) | 2592 if (found_not_ma) |
2594 EMSG(_("E793: No other buffer in diff mode is modifiable")); | 2593 emsg(_("E793: No other buffer in diff mode is modifiable")); |
2595 else | 2594 else |
2596 EMSG(_("E100: No other buffer in diff mode")); | 2595 emsg(_("E100: No other buffer in diff mode")); |
2597 return; | 2596 return; |
2598 } | 2597 } |
2599 | 2598 |
2600 /* Check that there isn't a third buffer in the list */ | 2599 /* Check that there isn't a third buffer in the list */ |
2601 for (i = idx_other + 1; i < DB_COUNT; ++i) | 2600 for (i = idx_other + 1; i < DB_COUNT; ++i) |
2602 if (curtab->tp_diffbuf[i] != curbuf | 2601 if (curtab->tp_diffbuf[i] != curbuf |
2603 && curtab->tp_diffbuf[i] != NULL | 2602 && curtab->tp_diffbuf[i] != NULL |
2604 && (eap->cmdidx != CMD_diffput || curtab->tp_diffbuf[i]->b_p_ma)) | 2603 && (eap->cmdidx != CMD_diffput || curtab->tp_diffbuf[i]->b_p_ma)) |
2605 { | 2604 { |
2606 EMSG(_("E101: More than two buffers in diff mode, don't know which one to use")); | 2605 emsg(_("E101: More than two buffers in diff mode, don't know which one to use")); |
2607 return; | 2606 return; |
2608 } | 2607 } |
2609 } | 2608 } |
2610 else | 2609 else |
2611 { | 2610 { |
2624 return; /* error message already given */ | 2623 return; /* error message already given */ |
2625 } | 2624 } |
2626 buf = buflist_findnr(i); | 2625 buf = buflist_findnr(i); |
2627 if (buf == NULL) | 2626 if (buf == NULL) |
2628 { | 2627 { |
2629 EMSG2(_("E102: Can't find buffer \"%s\""), eap->arg); | 2628 semsg(_("E102: Can't find buffer \"%s\""), eap->arg); |
2630 return; | 2629 return; |
2631 } | 2630 } |
2632 if (buf == curbuf) | 2631 if (buf == curbuf) |
2633 return; /* nothing to do */ | 2632 return; /* nothing to do */ |
2634 idx_other = diff_buf_idx(buf); | 2633 idx_other = diff_buf_idx(buf); |
2635 if (idx_other == DB_COUNT) | 2634 if (idx_other == DB_COUNT) |
2636 { | 2635 { |
2637 EMSG2(_("E103: Buffer \"%s\" is not in diff mode"), eap->arg); | 2636 semsg(_("E103: Buffer \"%s\" is not in diff mode"), eap->arg); |
2638 return; | 2637 return; |
2639 } | 2638 } |
2640 } | 2639 } |
2641 | 2640 |
2642 diff_busy = TRUE; | 2641 diff_busy = TRUE; |
2676 if (!curbuf->b_changed) | 2675 if (!curbuf->b_changed) |
2677 { | 2676 { |
2678 change_warning(0); | 2677 change_warning(0); |
2679 if (diff_buf_idx(curbuf) != idx_to) | 2678 if (diff_buf_idx(curbuf) != idx_to) |
2680 { | 2679 { |
2681 EMSG(_("E787: Buffer changed unexpectedly")); | 2680 emsg(_("E787: Buffer changed unexpectedly")); |
2682 goto theend; | 2681 goto theend; |
2683 } | 2682 } |
2684 } | 2683 } |
2685 | 2684 |
2686 dprev = NULL; | 2685 dprev = NULL; |