comparison src/memline.c @ 26909:aa65d1808bd0 v8.2.3983

patch 8.2.3983: error messages are spread out Commit: https://github.com/vim/vim/commit/eaaac014a01ce37c1f86dbda054c01a5c6f034e7 Author: Bram Moolenaar <Bram@vim.org> Date: Sun Jan 2 17:00:40 2022 +0000 patch 8.2.3983: error messages are spread out Problem: Error messages are spread out. Solution: Move more error messages to errors.h.
author Bram Moolenaar <Bram@vim.org>
date Sun, 02 Jan 2022 18:15:04 +0100
parents d02d40f0261c
children d92e0d85923f
comparison
equal deleted inserted replaced
26908:006aa45685f9 26909:aa65d1808bd0
717 { 717 {
718 mfp->mf_fd = mch_open((char *)mfp->mf_fname, O_RDWR | O_EXTRA, 0); 718 mfp->mf_fd = mch_open((char *)mfp->mf_fname, O_RDWR | O_EXTRA, 0);
719 if (mfp->mf_fd < 0) 719 if (mfp->mf_fd < 0)
720 { 720 {
721 // could not (re)open the swap file, what can we do???? 721 // could not (re)open the swap file, what can we do????
722 emsg(_("E301: Oops, lost the swap file!!!")); 722 emsg(_(e_oops_lost_the_swap_file));
723 return; 723 return;
724 } 724 }
725 #ifdef HAVE_FD_CLOEXEC 725 #ifdef HAVE_FD_CLOEXEC
726 { 726 {
727 int fdflags = fcntl(mfp->mf_fd, F_GETFD); 727 int fdflags = fcntl(mfp->mf_fd, F_GETFD);
729 (void)fcntl(mfp->mf_fd, F_SETFD, fdflags | FD_CLOEXEC); 729 (void)fcntl(mfp->mf_fd, F_SETFD, fdflags | FD_CLOEXEC);
730 } 730 }
731 #endif 731 #endif
732 } 732 }
733 if (!success) 733 if (!success)
734 emsg(_("E302: Could not rename swap file")); 734 emsg(_(e_could_not_rename_swap_file));
735 } 735 }
736 736
737 /* 737 /*
738 * Open a file for the memfile for all buffers that are not readonly or have 738 * Open a file for the memfile for all buffers that are not readonly or have
739 * been modified. 739 * been modified.
821 821
822 if (*p_dir != NUL && mfp->mf_fname == NULL) 822 if (*p_dir != NUL && mfp->mf_fname == NULL)
823 { 823 {
824 need_wait_return = TRUE; // call wait_return later 824 need_wait_return = TRUE; // call wait_return later
825 ++no_wait_return; 825 ++no_wait_return;
826 (void)semsg(_("E303: Unable to open swap file for \"%s\", recovery impossible"), 826 (void)semsg(_(e_unable_to_open_swap_file_for_str_recovery_impossible),
827 buf_spname(buf) != NULL ? buf_spname(buf) : buf->b_fname); 827 buf_spname(buf) != NULL ? buf_spname(buf) : buf->b_fname);
828 --no_wait_return; 828 --no_wait_return;
829 } 829 }
830 830
831 // don't try to open a swap file again 831 // don't try to open a swap file again
957 return; 957 return;
958 } 958 }
959 959
960 b0p = (ZERO_BL *)(hp->bh_data); 960 b0p = (ZERO_BL *)(hp->bh_data);
961 if (ml_check_b0_id(b0p) == FAIL) 961 if (ml_check_b0_id(b0p) == FAIL)
962 iemsg(_("E304: ml_upd_block0(): Didn't get block 0??")); 962 iemsg(_(e_ml_upd_block0_didnt_get_block_zero));
963 else 963 else
964 { 964 {
965 if (what == UB_FNAME) 965 if (what == UB_FNAME)
966 set_b0_fname(b0p, buf); 966 set_b0_fname(b0p, buf);
967 #ifdef FEAT_CRYPT 967 #ifdef FEAT_CRYPT
1207 1207
1208 // count the number of matching swap files 1208 // count the number of matching swap files
1209 len = recover_names(fname, FALSE, 0, NULL); 1209 len = recover_names(fname, FALSE, 0, NULL);
1210 if (len == 0) // no swap files found 1210 if (len == 0) // no swap files found
1211 { 1211 {
1212 semsg(_("E305: No swap file found for %s"), fname); 1212 semsg(_(e_no_swap_file_found_for_str), fname);
1213 goto theend; 1213 goto theend;
1214 } 1214 }
1215 if (len == 1) // one swap file found, use it 1215 if (len == 1) // one swap file found, use it
1216 i = 1; 1216 i = 1;
1217 else // several swap files found, choose 1217 else // several swap files found, choose
1264 mfp = mf_open(fname_used, O_RDONLY); 1264 mfp = mf_open(fname_used, O_RDONLY);
1265 fname_used = p; 1265 fname_used = p;
1266 if (mfp == NULL || mfp->mf_fd < 0) 1266 if (mfp == NULL || mfp->mf_fd < 0)
1267 { 1267 {
1268 if (fname_used != NULL) 1268 if (fname_used != NULL)
1269 semsg(_("E306: Cannot open %s"), fname_used); 1269 semsg(_(e_cannot_open_str), fname_used);
1270 goto theend; 1270 goto theend;
1271 } 1271 }
1272 buf->b_ml.ml_mfp = mfp; 1272 buf->b_ml.ml_mfp = mfp;
1273 #ifdef FEAT_CRYPT 1273 #ifdef FEAT_CRYPT
1274 mfp->mf_buffer = buf; 1274 mfp->mf_buffer = buf;
1306 msg_end(); 1306 msg_end();
1307 goto theend; 1307 goto theend;
1308 } 1308 }
1309 if (ml_check_b0_id(b0p) == FAIL) 1309 if (ml_check_b0_id(b0p) == FAIL)
1310 { 1310 {
1311 semsg(_("E307: %s does not look like a Vim swap file"), mfp->mf_fname); 1311 semsg(_(e_str_does_not_look_like_vim_swap_file), mfp->mf_fname);
1312 goto theend; 1312 goto theend;
1313 } 1313 }
1314 if (b0_magic_wrong(b0p)) 1314 if (b0_magic_wrong(b0p))
1315 { 1315 {
1316 msg_start(); 1316 msg_start();
1408 if (curbuf->b_ffname != NULL 1408 if (curbuf->b_ffname != NULL
1409 && mch_stat((char *)curbuf->b_ffname, &org_stat) != -1 1409 && mch_stat((char *)curbuf->b_ffname, &org_stat) != -1
1410 && ((mch_stat((char *)mfp->mf_fname, &swp_stat) != -1 1410 && ((mch_stat((char *)mfp->mf_fname, &swp_stat) != -1
1411 && org_stat.st_mtime > swp_stat.st_mtime) 1411 && org_stat.st_mtime > swp_stat.st_mtime)
1412 || org_stat.st_mtime != mtime)) 1412 || org_stat.st_mtime != mtime))
1413 emsg(_("E308: Warning: Original file may have been changed")); 1413 emsg(_(e_warning_original_file_may_have_been_changed));
1414 out_flush(); 1414 out_flush();
1415 1415
1416 // Get the 'fileformat' and 'fileencoding' from block zero. 1416 // Get the 'fileformat' and 'fileencoding' from block zero.
1417 b0_ff = (b0p->b0_flags & B0_FF_MASK); 1417 b0_ff = (b0p->b0_flags & B0_FF_MASK);
1418 if (b0p->b0_flags & B0_HAS_FENC) 1418 if (b0p->b0_flags & B0_HAS_FENC)
1512 */ 1512 */
1513 if ((hp = mf_get(mfp, (blocknr_T)bnum, page_count)) == NULL) 1513 if ((hp = mf_get(mfp, (blocknr_T)bnum, page_count)) == NULL)
1514 { 1514 {
1515 if (bnum == 1) 1515 if (bnum == 1)
1516 { 1516 {
1517 semsg(_("E309: Unable to read block 1 from %s"), mfp->mf_fname); 1517 semsg(_(e_unable_to_read_block_one_from_str), mfp->mf_fname);
1518 goto theend; 1518 goto theend;
1519 } 1519 }
1520 ++error; 1520 ++error;
1521 ml_append(lnum++, (char_u *)_("???MANY LINES MISSING"), 1521 ml_append(lnum++, (char_u *)_("???MANY LINES MISSING"),
1522 (colnr_T)0, TRUE); 1522 (colnr_T)0, TRUE);
1598 dp = (DATA_BL *)(hp->bh_data); 1598 dp = (DATA_BL *)(hp->bh_data);
1599 if (dp->db_id != DATA_ID) // block id wrong 1599 if (dp->db_id != DATA_ID) // block id wrong
1600 { 1600 {
1601 if (bnum == 1) 1601 if (bnum == 1)
1602 { 1602 {
1603 semsg(_("E310: Block 1 ID wrong (%s not a .swp file?)"), 1603 semsg(_(e_block_one_id_wrong_str_not_swp_file),
1604 mfp->mf_fname); 1604 mfp->mf_fname);
1605 goto theend; 1605 goto theend;
1606 } 1606 }
1607 ++error; 1607 ++error;
1608 ml_append(lnum++, (char_u *)_("???BLOCK MISSING"), 1608 ml_append(lnum++, (char_u *)_("???BLOCK MISSING"),
1719 curbuf->b_flags |= BF_RECOVERED; 1719 curbuf->b_flags |= BF_RECOVERED;
1720 check_cursor(); 1720 check_cursor();
1721 1721
1722 recoverymode = FALSE; 1722 recoverymode = FALSE;
1723 if (got_int) 1723 if (got_int)
1724 emsg(_("E311: Recovery Interrupted")); 1724 emsg(_(e_recovery_interrupted));
1725 else if (error) 1725 else if (error)
1726 { 1726 {
1727 ++no_wait_return; 1727 ++no_wait_return;
1728 msg(">>>>>>>>>>>>>"); 1728 msg(">>>>>>>>>>>>>");
1729 emsg(_("E312: Errors detected while recovering; look for lines starting with ???")); 1729 emsg(_(e_errors_detected_while_recovering_look_for_lines_starting_with_questions));
1730 --no_wait_return; 1730 --no_wait_return;
1731 msg(_("See \":help E312\" for more information.")); 1731 msg(_("See \":help E312\" for more information."));
1732 msg(">>>>>>>>>>>>>"); 1732 msg(">>>>>>>>>>>>>");
1733 } 1733 }
1734 else 1734 else
2483 int got_int_save = got_int; 2483 int got_int_save = got_int;
2484 2484
2485 if (mfp == NULL || mfp->mf_fname == NULL) 2485 if (mfp == NULL || mfp->mf_fname == NULL)
2486 { 2486 {
2487 if (message) 2487 if (message)
2488 emsg(_("E313: Cannot preserve, there is no swap file")); 2488 emsg(_(e_cannot_preserve_there_is_no_swap_file));
2489 return; 2489 return;
2490 } 2490 }
2491 2491
2492 // We only want to stop when interrupted here, not when interrupted 2492 // We only want to stop when interrupted here, not when interrupted
2493 // before. 2493 // before.
2538 if (message) 2538 if (message)
2539 { 2539 {
2540 if (status == OK) 2540 if (status == OK)
2541 msg(_("File preserved")); 2541 msg(_("File preserved"));
2542 else 2542 else
2543 emsg(_("E314: Preserve failed")); 2543 emsg(_(e_preserve_failed));
2544 } 2544 }
2545 } 2545 }
2546 2546
2547 /* 2547 /*
2548 * NOTE: The pointer returned by the ml_get_*() functions only remains valid 2548 * NOTE: The pointer returned by the ml_get_*() functions only remains valid
2613 if (recursive == 0) 2613 if (recursive == 0)
2614 { 2614 {
2615 // Avoid giving this message for a recursive call, may happen when 2615 // Avoid giving this message for a recursive call, may happen when
2616 // the GUI redraws part of the text. 2616 // the GUI redraws part of the text.
2617 ++recursive; 2617 ++recursive;
2618 siemsg(_("E315: ml_get: invalid lnum: %ld"), lnum); 2618 siemsg(_(e_ml_get_invalid_lnum_nr), lnum);
2619 --recursive; 2619 --recursive;
2620 } 2620 }
2621 errorret: 2621 errorret:
2622 STRCPY(questions, "???"); 2622 STRCPY(questions, "???");
2623 buf->b_ml.ml_line_len = 4; 2623 buf->b_ml.ml_line_len = 4;
2658 // Avoid giving this message for a recursive call, may happen 2658 // Avoid giving this message for a recursive call, may happen
2659 // when the GUI redraws part of the text. 2659 // when the GUI redraws part of the text.
2660 ++recursive; 2660 ++recursive;
2661 get_trans_bufname(buf); 2661 get_trans_bufname(buf);
2662 shorten_dir(NameBuff); 2662 shorten_dir(NameBuff);
2663 siemsg(_("E316: ml_get: cannot find line %ld in buffer %d %s"), 2663 siemsg(_(e_ml_get_cannot_find_line_nr_in_buffer_nr_str),
2664 lnum, buf->b_fnum, NameBuff); 2664 lnum, buf->b_fnum, NameBuff);
2665 --recursive; 2665 --recursive;
2666 } 2666 }
2667 goto errorret; 2667 goto errorret;
2668 } 2668 }
3112 if ((hp = mf_get(mfp, ip->ip_bnum, 1)) == NULL) 3112 if ((hp = mf_get(mfp, ip->ip_bnum, 1)) == NULL)
3113 goto theend; 3113 goto theend;
3114 pp = (PTR_BL *)(hp->bh_data); // must be pointer block 3114 pp = (PTR_BL *)(hp->bh_data); // must be pointer block
3115 if (pp->pb_id != PTR_ID) 3115 if (pp->pb_id != PTR_ID)
3116 { 3116 {
3117 iemsg(_("E317: pointer block id wrong 3")); 3117 iemsg(_(e_pointer_block_id_wrong_three));
3118 mf_put(mfp, hp, FALSE, FALSE); 3118 mf_put(mfp, hp, FALSE, FALSE);
3119 goto theend; 3119 goto theend;
3120 } 3120 }
3121 /* 3121 /*
3122 * TODO: If the pointer block is full and we are adding at the end 3122 * TODO: If the pointer block is full and we are adding at the end
3254 /* 3254 /*
3255 * Safety check: fallen out of for loop? 3255 * Safety check: fallen out of for loop?
3256 */ 3256 */
3257 if (stack_idx < 0) 3257 if (stack_idx < 0)
3258 { 3258 {
3259 iemsg(_("E318: Updated too many blocks?")); 3259 iemsg(_(e_updated_too_many_blocks));
3260 buf->b_ml.ml_stack_top = 0; // invalidate stack 3260 buf->b_ml.ml_stack_top = 0; // invalidate stack
3261 } 3261 }
3262 } 3262 }
3263 3263
3264 #ifdef FEAT_BYTEOFF 3264 #ifdef FEAT_BYTEOFF
3711 if ((hp = mf_get(mfp, ip->ip_bnum, 1)) == NULL) 3711 if ((hp = mf_get(mfp, ip->ip_bnum, 1)) == NULL)
3712 goto theend; 3712 goto theend;
3713 pp = (PTR_BL *)(hp->bh_data); // must be pointer block 3713 pp = (PTR_BL *)(hp->bh_data); // must be pointer block
3714 if (pp->pb_id != PTR_ID) 3714 if (pp->pb_id != PTR_ID)
3715 { 3715 {
3716 iemsg(_("E317: pointer block id wrong 4")); 3716 iemsg(_(e_pointer_block_id_wrong_four));
3717 mf_put(mfp, hp, FALSE, FALSE); 3717 mf_put(mfp, hp, FALSE, FALSE);
3718 goto theend; 3718 goto theend;
3719 } 3719 }
3720 count = --(pp->pb_count); 3720 count = --(pp->pb_count);
3721 if (count == 0) // the pointer block becomes empty! 3721 if (count == 0) // the pointer block becomes empty!
3976 lnum = buf->b_ml.ml_line_lnum; 3976 lnum = buf->b_ml.ml_line_lnum;
3977 new_line = buf->b_ml.ml_line_ptr; 3977 new_line = buf->b_ml.ml_line_ptr;
3978 3978
3979 hp = ml_find_line(buf, lnum, ML_FIND); 3979 hp = ml_find_line(buf, lnum, ML_FIND);
3980 if (hp == NULL) 3980 if (hp == NULL)
3981 siemsg(_("E320: Cannot find line %ld"), lnum); 3981 siemsg(_(e_cannot_find_line_nr), lnum);
3982 else 3982 else
3983 { 3983 {
3984 dp = (DATA_BL *)(hp->bh_data); 3984 dp = (DATA_BL *)(hp->bh_data);
3985 idx = lnum - buf->b_ml.ml_locked_low; 3985 idx = lnum - buf->b_ml.ml_locked_low;
3986 start = ((dp->db_index[idx]) & DB_INDEX_MASK); 3986 start = ((dp->db_index[idx]) & DB_INDEX_MASK);
4236 } 4236 }
4237 4237
4238 pp = (PTR_BL *)(dp); // must be pointer block 4238 pp = (PTR_BL *)(dp); // must be pointer block
4239 if (pp->pb_id != PTR_ID) 4239 if (pp->pb_id != PTR_ID)
4240 { 4240 {
4241 iemsg(_("E317: pointer block id wrong")); 4241 iemsg(_(e_pointer_block_id_wrong));
4242 goto error_block; 4242 goto error_block;
4243 } 4243 }
4244 4244
4245 if ((top = ml_add_stack(buf)) < 0) // add new entry to stack 4245 if ((top = ml_add_stack(buf)) < 0) // add new entry to stack
4246 goto error_block; 4246 goto error_block;
4281 } 4281 }
4282 } 4282 }
4283 if (idx >= (int)pp->pb_count) // past the end: something wrong! 4283 if (idx >= (int)pp->pb_count) // past the end: something wrong!
4284 { 4284 {
4285 if (lnum > buf->b_ml.ml_line_count) 4285 if (lnum > buf->b_ml.ml_line_count)
4286 siemsg(_("E322: line number out of range: %ld past the end"), 4286 siemsg(_(e_line_number_out_of_range_nr_past_the_end),
4287 lnum - buf->b_ml.ml_line_count); 4287 lnum - buf->b_ml.ml_line_count);
4288 4288
4289 else 4289 else
4290 siemsg(_("E323: line count wrong in block %ld"), bnum); 4290 siemsg(_(e_line_count_wrong_in_block_nr), bnum);
4291 goto error_block; 4291 goto error_block;
4292 } 4292 }
4293 if (action == ML_DELETE) 4293 if (action == ML_DELETE)
4294 { 4294 {
4295 pp->pb_pointer[idx].pe_line_count--; 4295 pp->pb_pointer[idx].pe_line_count--;
4378 break; 4378 break;
4379 pp = (PTR_BL *)(hp->bh_data); // must be pointer block 4379 pp = (PTR_BL *)(hp->bh_data); // must be pointer block
4380 if (pp->pb_id != PTR_ID) 4380 if (pp->pb_id != PTR_ID)
4381 { 4381 {
4382 mf_put(mfp, hp, FALSE, FALSE); 4382 mf_put(mfp, hp, FALSE, FALSE);
4383 iemsg(_("E317: pointer block id wrong 2")); 4383 iemsg(_(e_pointer_block_id_wrong_two));
4384 break; 4384 break;
4385 } 4385 }
4386 pp->pb_pointer[ip->ip_index].pe_line_count += count; 4386 pp->pb_pointer[ip->ip_index].pe_line_count += count;
4387 ip->ip_high += count; 4387 ip->ip_high += count;
4388 mf_put(mfp, hp, TRUE, FALSE); 4388 mf_put(mfp, hp, TRUE, FALSE);
4592 { 4592 {
4593 stat_T st; 4593 stat_T st;
4594 time_t swap_mtime; 4594 time_t swap_mtime;
4595 4595
4596 ++no_wait_return; 4596 ++no_wait_return;
4597 (void)emsg(_("E325: ATTENTION")); 4597 (void)emsg(_(e_attention));
4598 msg_puts(_("\nFound a swap file by the name \"")); 4598 msg_puts(_("\nFound a swap file by the name \""));
4599 msg_home_replace(fname); 4599 msg_home_replace(fname);
4600 msg_puts("\"\n"); 4600 msg_puts("\"\n");
4601 swap_mtime = swapfile_info(fname); 4601 swap_mtime = swapfile_info(fname);
4602 msg_puts(_("While opening file \"")); 4602 msg_puts(_("While opening file \""));
5139 */ 5139 */
5140 if (fname[n - 1] == 'a') // ".s?a" 5140 if (fname[n - 1] == 'a') // ".s?a"
5141 { 5141 {
5142 if (fname[n - 2] == 'a') // ".saa": tried enough, give up 5142 if (fname[n - 2] == 'a') // ".saa": tried enough, give up
5143 { 5143 {
5144 emsg(_("E326: Too many swap files found")); 5144 emsg(_(e_too_many_swap_files_found));
5145 VIM_CLEAR(fname); 5145 VIM_CLEAR(fname);
5146 break; 5146 break;
5147 } 5147 }
5148 --fname[n - 2]; // ".svz", ".suz", etc. 5148 --fname[n - 2]; // ".svz", ".suz", etc.
5149 fname[n - 1] = 'z' + 1; 5149 fname[n - 1] = 'z' + 1;