Mercurial > vim
comparison src/memline.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 | 58b125df3e9b |
children | dd725a8ab112 |
comparison
equal
deleted
inserted
replaced
15469:bc9b5261ed01 | 15470:55ccc2d353bd |
---|---|
6 * Do ":help credits" in Vim to see a list of people who contributed. | 6 * Do ":help credits" in Vim to see a list of people who contributed. |
7 * See README.txt for an overview of the Vim source code. | 7 * See README.txt for an overview of the Vim source code. |
8 */ | 8 */ |
9 | 9 |
10 /* for debugging */ | 10 /* for debugging */ |
11 /* #define CHECK(c, s) do { if (c) EMSG(s); } while (0) */ | 11 /* #define CHECK(c, s) do { if (c) emsg((s)); } while (0) */ |
12 #define CHECK(c, s) do { /**/ } while (0) | 12 #define CHECK(c, s) do { /**/ } while (0) |
13 | 13 |
14 /* | 14 /* |
15 * memline.c: Contains the functions for appending, deleting and changing the | 15 * memline.c: Contains the functions for appending, deleting and changing the |
16 * text lines. The memfile functions are used to store the information in | 16 * text lines. The memfile functions are used to store the information in |
326 */ | 326 */ |
327 if ((hp = mf_new(mfp, FALSE, 1)) == NULL) | 327 if ((hp = mf_new(mfp, FALSE, 1)) == NULL) |
328 goto error; | 328 goto error; |
329 if (hp->bh_bnum != 0) | 329 if (hp->bh_bnum != 0) |
330 { | 330 { |
331 IEMSG(_("E298: Didn't get block nr 0?")); | 331 iemsg(_("E298: Didn't get block nr 0?")); |
332 goto error; | 332 goto error; |
333 } | 333 } |
334 b0p = (ZERO_BL *)(hp->bh_data); | 334 b0p = (ZERO_BL *)(hp->bh_data); |
335 | 335 |
336 b0p->b0_id[0] = BLOCK0_ID0; | 336 b0p->b0_id[0] = BLOCK0_ID0; |
376 */ | 376 */ |
377 if ((hp = ml_new_ptr(mfp)) == NULL) | 377 if ((hp = ml_new_ptr(mfp)) == NULL) |
378 goto error; | 378 goto error; |
379 if (hp->bh_bnum != 1) | 379 if (hp->bh_bnum != 1) |
380 { | 380 { |
381 IEMSG(_("E298: Didn't get block nr 1?")); | 381 iemsg(_("E298: Didn't get block nr 1?")); |
382 goto error; | 382 goto error; |
383 } | 383 } |
384 pp = (PTR_BL *)(hp->bh_data); | 384 pp = (PTR_BL *)(hp->bh_data); |
385 pp->pb_count = 1; | 385 pp->pb_count = 1; |
386 pp->pb_pointer[0].pe_bnum = 2; | 386 pp->pb_pointer[0].pe_bnum = 2; |
394 */ | 394 */ |
395 if ((hp = ml_new_data(mfp, FALSE, 1)) == NULL) | 395 if ((hp = ml_new_data(mfp, FALSE, 1)) == NULL) |
396 goto error; | 396 goto error; |
397 if (hp->bh_bnum != 2) | 397 if (hp->bh_bnum != 2) |
398 { | 398 { |
399 IEMSG(_("E298: Didn't get block nr 2?")); | 399 iemsg(_("E298: Didn't get block nr 2?")); |
400 goto error; | 400 goto error; |
401 } | 401 } |
402 | 402 |
403 dp = (DATA_BL *)(hp->bh_data); | 403 dp = (DATA_BL *)(hp->bh_data); |
404 dp->db_index[0] = --dp->db_txt_start; /* at end of block */ | 404 dp->db_index[0] = --dp->db_txt_start; /* at end of block */ |
608 } | 608 } |
609 if (hp != NULL) | 609 if (hp != NULL) |
610 mf_put(mfp, hp, FALSE, FALSE); /* release previous block */ | 610 mf_put(mfp, hp, FALSE, FALSE); /* release previous block */ |
611 | 611 |
612 if (error > 0) | 612 if (error > 0) |
613 EMSG(_("E843: Error while updating swap file crypt")); | 613 emsg(_("E843: Error while updating swap file crypt")); |
614 } | 614 } |
615 | 615 |
616 mfp->mf_old_key = NULL; | 616 mfp->mf_old_key = NULL; |
617 } | 617 } |
618 #endif | 618 #endif |
706 { | 706 { |
707 mfp->mf_fd = mch_open((char *)mfp->mf_fname, O_RDWR | O_EXTRA, 0); | 707 mfp->mf_fd = mch_open((char *)mfp->mf_fname, O_RDWR | O_EXTRA, 0); |
708 if (mfp->mf_fd < 0) | 708 if (mfp->mf_fd < 0) |
709 { | 709 { |
710 /* could not (re)open the swap file, what can we do???? */ | 710 /* could not (re)open the swap file, what can we do???? */ |
711 EMSG(_("E301: Oops, lost the swap file!!!")); | 711 emsg(_("E301: Oops, lost the swap file!!!")); |
712 return; | 712 return; |
713 } | 713 } |
714 #ifdef HAVE_FD_CLOEXEC | 714 #ifdef HAVE_FD_CLOEXEC |
715 { | 715 { |
716 int fdflags = fcntl(mfp->mf_fd, F_GETFD); | 716 int fdflags = fcntl(mfp->mf_fd, F_GETFD); |
718 (void)fcntl(mfp->mf_fd, F_SETFD, fdflags | FD_CLOEXEC); | 718 (void)fcntl(mfp->mf_fd, F_SETFD, fdflags | FD_CLOEXEC); |
719 } | 719 } |
720 #endif | 720 #endif |
721 } | 721 } |
722 if (!success) | 722 if (!success) |
723 EMSG(_("E302: Could not rename swap file")); | 723 emsg(_("E302: Could not rename swap file")); |
724 } | 724 } |
725 | 725 |
726 /* | 726 /* |
727 * Open a file for the memfile for all buffers that are not readonly or have | 727 * Open a file for the memfile for all buffers that are not readonly or have |
728 * been modified. | 728 * been modified. |
809 | 809 |
810 if (mfp->mf_fname == NULL) /* Failed! */ | 810 if (mfp->mf_fname == NULL) /* Failed! */ |
811 { | 811 { |
812 need_wait_return = TRUE; /* call wait_return later */ | 812 need_wait_return = TRUE; /* call wait_return later */ |
813 ++no_wait_return; | 813 ++no_wait_return; |
814 (void)EMSG2(_("E303: Unable to open swap file for \"%s\", recovery impossible"), | 814 (void)semsg(_("E303: Unable to open swap file for \"%s\", recovery impossible"), |
815 buf_spname(buf) != NULL ? buf_spname(buf) : buf->b_fname); | 815 buf_spname(buf) != NULL ? buf_spname(buf) : buf->b_fname); |
816 --no_wait_return; | 816 --no_wait_return; |
817 } | 817 } |
818 | 818 |
819 /* don't try to open a swap file again */ | 819 /* don't try to open a swap file again */ |
944 return; | 944 return; |
945 } | 945 } |
946 | 946 |
947 b0p = (ZERO_BL *)(hp->bh_data); | 947 b0p = (ZERO_BL *)(hp->bh_data); |
948 if (ml_check_b0_id(b0p) == FAIL) | 948 if (ml_check_b0_id(b0p) == FAIL) |
949 IEMSG(_("E304: ml_upd_block0(): Didn't get block 0??")); | 949 iemsg(_("E304: ml_upd_block0(): Didn't get block 0??")); |
950 else | 950 else |
951 { | 951 { |
952 if (what == UB_FNAME) | 952 if (what == UB_FNAME) |
953 set_b0_fname(b0p, buf); | 953 set_b0_fname(b0p, buf); |
954 #ifdef FEAT_CRYPT | 954 #ifdef FEAT_CRYPT |
1162 | 1162 |
1163 /* count the number of matching swap files */ | 1163 /* count the number of matching swap files */ |
1164 len = recover_names(fname, FALSE, 0, NULL); | 1164 len = recover_names(fname, FALSE, 0, NULL); |
1165 if (len == 0) /* no swap files found */ | 1165 if (len == 0) /* no swap files found */ |
1166 { | 1166 { |
1167 EMSG2(_("E305: No swap file found for %s"), fname); | 1167 semsg(_("E305: No swap file found for %s"), fname); |
1168 goto theend; | 1168 goto theend; |
1169 } | 1169 } |
1170 if (len == 1) /* one swap file found, use it */ | 1170 if (len == 1) /* one swap file found, use it */ |
1171 i = 1; | 1171 i = 1; |
1172 else /* several swap files found, choose */ | 1172 else /* several swap files found, choose */ |
1219 mfp = mf_open(fname_used, O_RDONLY); | 1219 mfp = mf_open(fname_used, O_RDONLY); |
1220 fname_used = p; | 1220 fname_used = p; |
1221 if (mfp == NULL || mfp->mf_fd < 0) | 1221 if (mfp == NULL || mfp->mf_fd < 0) |
1222 { | 1222 { |
1223 if (fname_used != NULL) | 1223 if (fname_used != NULL) |
1224 EMSG2(_("E306: Cannot open %s"), fname_used); | 1224 semsg(_("E306: Cannot open %s"), fname_used); |
1225 goto theend; | 1225 goto theend; |
1226 } | 1226 } |
1227 buf->b_ml.ml_mfp = mfp; | 1227 buf->b_ml.ml_mfp = mfp; |
1228 #ifdef FEAT_CRYPT | 1228 #ifdef FEAT_CRYPT |
1229 mfp->mf_buffer = buf; | 1229 mfp->mf_buffer = buf; |
1261 msg_end(); | 1261 msg_end(); |
1262 goto theend; | 1262 goto theend; |
1263 } | 1263 } |
1264 if (ml_check_b0_id(b0p) == FAIL) | 1264 if (ml_check_b0_id(b0p) == FAIL) |
1265 { | 1265 { |
1266 EMSG2(_("E307: %s does not look like a Vim swap file"), mfp->mf_fname); | 1266 semsg(_("E307: %s does not look like a Vim swap file"), mfp->mf_fname); |
1267 goto theend; | 1267 goto theend; |
1268 } | 1268 } |
1269 if (b0_magic_wrong(b0p)) | 1269 if (b0_magic_wrong(b0p)) |
1270 { | 1270 { |
1271 msg_start(); | 1271 msg_start(); |
1295 mch_memmove(mfp->mf_seed, &b0p->b0_seed, MF_SEED_LEN); | 1295 mch_memmove(mfp->mf_seed, &b0p->b0_seed, MF_SEED_LEN); |
1296 crypt_set_cm_option(buf, b0_cm < 0 ? 0 : b0_cm); | 1296 crypt_set_cm_option(buf, b0_cm < 0 ? 0 : b0_cm); |
1297 #else | 1297 #else |
1298 if (b0p->b0_id[1] != BLOCK0_ID1) | 1298 if (b0p->b0_id[1] != BLOCK0_ID1) |
1299 { | 1299 { |
1300 EMSG2(_("E833: %s is encrypted and this version of Vim does not support encryption"), mfp->mf_fname); | 1300 semsg(_("E833: %s is encrypted and this version of Vim does not support encryption"), mfp->mf_fname); |
1301 goto theend; | 1301 goto theend; |
1302 } | 1302 } |
1303 #endif | 1303 #endif |
1304 | 1304 |
1305 /* | 1305 /* |
1345 if (setfname(curbuf, NameBuff, NULL, TRUE) == FAIL) | 1345 if (setfname(curbuf, NameBuff, NULL, TRUE) == FAIL) |
1346 goto theend; | 1346 goto theend; |
1347 } | 1347 } |
1348 | 1348 |
1349 home_replace(NULL, mfp->mf_fname, NameBuff, MAXPATHL, TRUE); | 1349 home_replace(NULL, mfp->mf_fname, NameBuff, MAXPATHL, TRUE); |
1350 smsg((char_u *)_("Using swap file \"%s\""), NameBuff); | 1350 smsg(_("Using swap file \"%s\""), NameBuff); |
1351 | 1351 |
1352 if (buf_spname(curbuf) != NULL) | 1352 if (buf_spname(curbuf) != NULL) |
1353 vim_strncpy(NameBuff, buf_spname(curbuf), MAXPATHL - 1); | 1353 vim_strncpy(NameBuff, buf_spname(curbuf), MAXPATHL - 1); |
1354 else | 1354 else |
1355 home_replace(NULL, curbuf->b_ffname, NameBuff, MAXPATHL, TRUE); | 1355 home_replace(NULL, curbuf->b_ffname, NameBuff, MAXPATHL, TRUE); |
1356 smsg((char_u *)_("Original file \"%s\""), NameBuff); | 1356 smsg(_("Original file \"%s\""), NameBuff); |
1357 msg_putchar('\n'); | 1357 msg_putchar('\n'); |
1358 | 1358 |
1359 /* | 1359 /* |
1360 * check date of swap file and original file | 1360 * check date of swap file and original file |
1361 */ | 1361 */ |
1364 && mch_stat((char *)curbuf->b_ffname, &org_stat) != -1 | 1364 && mch_stat((char *)curbuf->b_ffname, &org_stat) != -1 |
1365 && ((mch_stat((char *)mfp->mf_fname, &swp_stat) != -1 | 1365 && ((mch_stat((char *)mfp->mf_fname, &swp_stat) != -1 |
1366 && org_stat.st_mtime > swp_stat.st_mtime) | 1366 && org_stat.st_mtime > swp_stat.st_mtime) |
1367 || org_stat.st_mtime != mtime)) | 1367 || org_stat.st_mtime != mtime)) |
1368 { | 1368 { |
1369 EMSG(_("E308: Warning: Original file may have been changed")); | 1369 emsg(_("E308: Warning: Original file may have been changed")); |
1370 } | 1370 } |
1371 out_flush(); | 1371 out_flush(); |
1372 | 1372 |
1373 /* Get the 'fileformat' and 'fileencoding' from block zero. */ | 1373 /* Get the 'fileformat' and 'fileencoding' from block zero. */ |
1374 b0_ff = (b0p->b0_flags & B0_FF_MASK); | 1374 b0_ff = (b0p->b0_flags & B0_FF_MASK); |
1410 { | 1410 { |
1411 /* Need to ask the user for the crypt key. If this fails we continue | 1411 /* Need to ask the user for the crypt key. If this fails we continue |
1412 * without a key, will probably get garbage text. */ | 1412 * without a key, will probably get garbage text. */ |
1413 if (*curbuf->b_p_key != NUL) | 1413 if (*curbuf->b_p_key != NUL) |
1414 { | 1414 { |
1415 smsg((char_u *)_("Swap file is encrypted: \"%s\""), fname_used); | 1415 smsg(_("Swap file is encrypted: \"%s\""), fname_used); |
1416 MSG_PUTS(_("\nIf you entered a new crypt key but did not write the text file,")); | 1416 MSG_PUTS(_("\nIf you entered a new crypt key but did not write the text file,")); |
1417 MSG_PUTS(_("\nenter the new crypt key.")); | 1417 MSG_PUTS(_("\nenter the new crypt key.")); |
1418 MSG_PUTS(_("\nIf you wrote the text file after changing the crypt key press enter")); | 1418 MSG_PUTS(_("\nIf you wrote the text file after changing the crypt key press enter")); |
1419 MSG_PUTS(_("\nto use the same key for text file and swap file")); | 1419 MSG_PUTS(_("\nto use the same key for text file and swap file")); |
1420 } | 1420 } |
1421 else | 1421 else |
1422 smsg((char_u *)_(need_key_msg), fname_used); | 1422 smsg(_(need_key_msg), fname_used); |
1423 buf->b_p_key = crypt_get_key(FALSE, FALSE); | 1423 buf->b_p_key = crypt_get_key(FALSE, FALSE); |
1424 if (buf->b_p_key == NULL) | 1424 if (buf->b_p_key == NULL) |
1425 buf->b_p_key = curbuf->b_p_key; | 1425 buf->b_p_key = curbuf->b_p_key; |
1426 else if (*buf->b_p_key == NUL) | 1426 else if (*buf->b_p_key == NUL) |
1427 { | 1427 { |
1469 */ | 1469 */ |
1470 if ((hp = mf_get(mfp, (blocknr_T)bnum, page_count)) == NULL) | 1470 if ((hp = mf_get(mfp, (blocknr_T)bnum, page_count)) == NULL) |
1471 { | 1471 { |
1472 if (bnum == 1) | 1472 if (bnum == 1) |
1473 { | 1473 { |
1474 EMSG2(_("E309: Unable to read block 1 from %s"), mfp->mf_fname); | 1474 semsg(_("E309: Unable to read block 1 from %s"), mfp->mf_fname); |
1475 goto theend; | 1475 goto theend; |
1476 } | 1476 } |
1477 ++error; | 1477 ++error; |
1478 ml_append(lnum++, (char_u *)_("???MANY LINES MISSING"), | 1478 ml_append(lnum++, (char_u *)_("???MANY LINES MISSING"), |
1479 (colnr_T)0, TRUE); | 1479 (colnr_T)0, TRUE); |
1555 dp = (DATA_BL *)(hp->bh_data); | 1555 dp = (DATA_BL *)(hp->bh_data); |
1556 if (dp->db_id != DATA_ID) /* block id wrong */ | 1556 if (dp->db_id != DATA_ID) /* block id wrong */ |
1557 { | 1557 { |
1558 if (bnum == 1) | 1558 if (bnum == 1) |
1559 { | 1559 { |
1560 EMSG2(_("E310: Block 1 ID wrong (%s not a .swp file?)"), | 1560 semsg(_("E310: Block 1 ID wrong (%s not a .swp file?)"), |
1561 mfp->mf_fname); | 1561 mfp->mf_fname); |
1562 goto theend; | 1562 goto theend; |
1563 } | 1563 } |
1564 ++error; | 1564 ++error; |
1565 ml_append(lnum++, (char_u *)_("???BLOCK MISSING"), | 1565 ml_append(lnum++, (char_u *)_("???BLOCK MISSING"), |
1675 ml_delete(curbuf->b_ml.ml_line_count, FALSE); | 1675 ml_delete(curbuf->b_ml.ml_line_count, FALSE); |
1676 curbuf->b_flags |= BF_RECOVERED; | 1676 curbuf->b_flags |= BF_RECOVERED; |
1677 | 1677 |
1678 recoverymode = FALSE; | 1678 recoverymode = FALSE; |
1679 if (got_int) | 1679 if (got_int) |
1680 EMSG(_("E311: Recovery Interrupted")); | 1680 emsg(_("E311: Recovery Interrupted")); |
1681 else if (error) | 1681 else if (error) |
1682 { | 1682 { |
1683 ++no_wait_return; | 1683 ++no_wait_return; |
1684 MSG(">>>>>>>>>>>>>"); | 1684 MSG(">>>>>>>>>>>>>"); |
1685 EMSG(_("E312: Errors detected while recovering; look for lines starting with ???")); | 1685 emsg(_("E312: Errors detected while recovering; look for lines starting with ???")); |
1686 --no_wait_return; | 1686 --no_wait_return; |
1687 MSG(_("See \":help E312\" for more information.")); | 1687 MSG(_("See \":help E312\" for more information.")); |
1688 MSG(">>>>>>>>>>>>>"); | 1688 MSG(">>>>>>>>>>>>>"); |
1689 } | 1689 } |
1690 else | 1690 else |
2359 int got_int_save = got_int; | 2359 int got_int_save = got_int; |
2360 | 2360 |
2361 if (mfp == NULL || mfp->mf_fname == NULL) | 2361 if (mfp == NULL || mfp->mf_fname == NULL) |
2362 { | 2362 { |
2363 if (message) | 2363 if (message) |
2364 EMSG(_("E313: Cannot preserve, there is no swap file")); | 2364 emsg(_("E313: Cannot preserve, there is no swap file")); |
2365 return; | 2365 return; |
2366 } | 2366 } |
2367 | 2367 |
2368 /* We only want to stop when interrupted here, not when interrupted | 2368 /* We only want to stop when interrupted here, not when interrupted |
2369 * before. */ | 2369 * before. */ |
2414 if (message) | 2414 if (message) |
2415 { | 2415 { |
2416 if (status == OK) | 2416 if (status == OK) |
2417 MSG(_("File preserved")); | 2417 MSG(_("File preserved")); |
2418 else | 2418 else |
2419 EMSG(_("E314: Preserve failed")); | 2419 emsg(_("E314: Preserve failed")); |
2420 } | 2420 } |
2421 } | 2421 } |
2422 | 2422 |
2423 /* | 2423 /* |
2424 * NOTE: The pointer returned by the ml_get_*() functions only remains valid | 2424 * NOTE: The pointer returned by the ml_get_*() functions only remains valid |
2488 if (recursive == 0) | 2488 if (recursive == 0) |
2489 { | 2489 { |
2490 /* Avoid giving this message for a recursive call, may happen when | 2490 /* Avoid giving this message for a recursive call, may happen when |
2491 * the GUI redraws part of the text. */ | 2491 * the GUI redraws part of the text. */ |
2492 ++recursive; | 2492 ++recursive; |
2493 IEMSGN(_("E315: ml_get: invalid lnum: %ld"), lnum); | 2493 siemsg(_("E315: ml_get: invalid lnum: %ld"), lnum); |
2494 --recursive; | 2494 --recursive; |
2495 } | 2495 } |
2496 errorret: | 2496 errorret: |
2497 STRCPY(IObuff, "???"); | 2497 STRCPY(IObuff, "???"); |
2498 return IObuff; | 2498 return IObuff; |
2527 if (recursive == 0) | 2527 if (recursive == 0) |
2528 { | 2528 { |
2529 /* Avoid giving this message for a recursive call, may happen | 2529 /* Avoid giving this message for a recursive call, may happen |
2530 * when the GUI redraws part of the text. */ | 2530 * when the GUI redraws part of the text. */ |
2531 ++recursive; | 2531 ++recursive; |
2532 IEMSGN(_("E316: ml_get: cannot find line %ld"), lnum); | 2532 siemsg(_("E316: ml_get: cannot find line %ld"), lnum); |
2533 --recursive; | 2533 --recursive; |
2534 } | 2534 } |
2535 goto errorret; | 2535 goto errorret; |
2536 } | 2536 } |
2537 | 2537 |
3024 if ((hp = mf_get(mfp, ip->ip_bnum, 1)) == NULL) | 3024 if ((hp = mf_get(mfp, ip->ip_bnum, 1)) == NULL) |
3025 goto theend; | 3025 goto theend; |
3026 pp = (PTR_BL *)(hp->bh_data); /* must be pointer block */ | 3026 pp = (PTR_BL *)(hp->bh_data); /* must be pointer block */ |
3027 if (pp->pb_id != PTR_ID) | 3027 if (pp->pb_id != PTR_ID) |
3028 { | 3028 { |
3029 IEMSG(_("E317: pointer block id wrong 3")); | 3029 iemsg(_("E317: pointer block id wrong 3")); |
3030 mf_put(mfp, hp, FALSE, FALSE); | 3030 mf_put(mfp, hp, FALSE, FALSE); |
3031 goto theend; | 3031 goto theend; |
3032 } | 3032 } |
3033 /* | 3033 /* |
3034 * TODO: If the pointer block is full and we are adding at the end | 3034 * TODO: If the pointer block is full and we are adding at the end |
3166 /* | 3166 /* |
3167 * Safety check: fallen out of for loop? | 3167 * Safety check: fallen out of for loop? |
3168 */ | 3168 */ |
3169 if (stack_idx < 0) | 3169 if (stack_idx < 0) |
3170 { | 3170 { |
3171 IEMSG(_("E318: Updated too many blocks?")); | 3171 iemsg(_("E318: Updated too many blocks?")); |
3172 buf->b_ml.ml_stack_top = 0; /* invalidate stack */ | 3172 buf->b_ml.ml_stack_top = 0; /* invalidate stack */ |
3173 } | 3173 } |
3174 } | 3174 } |
3175 | 3175 |
3176 #ifdef FEAT_BYTEOFF | 3176 #ifdef FEAT_BYTEOFF |
3542 if ((hp = mf_get(mfp, ip->ip_bnum, 1)) == NULL) | 3542 if ((hp = mf_get(mfp, ip->ip_bnum, 1)) == NULL) |
3543 goto theend; | 3543 goto theend; |
3544 pp = (PTR_BL *)(hp->bh_data); /* must be pointer block */ | 3544 pp = (PTR_BL *)(hp->bh_data); /* must be pointer block */ |
3545 if (pp->pb_id != PTR_ID) | 3545 if (pp->pb_id != PTR_ID) |
3546 { | 3546 { |
3547 IEMSG(_("E317: pointer block id wrong 4")); | 3547 iemsg(_("E317: pointer block id wrong 4")); |
3548 mf_put(mfp, hp, FALSE, FALSE); | 3548 mf_put(mfp, hp, FALSE, FALSE); |
3549 goto theend; | 3549 goto theend; |
3550 } | 3550 } |
3551 count = --(pp->pb_count); | 3551 count = --(pp->pb_count); |
3552 if (count == 0) /* the pointer block becomes empty! */ | 3552 if (count == 0) /* the pointer block becomes empty! */ |
3768 lnum = buf->b_ml.ml_line_lnum; | 3768 lnum = buf->b_ml.ml_line_lnum; |
3769 new_line = buf->b_ml.ml_line_ptr; | 3769 new_line = buf->b_ml.ml_line_ptr; |
3770 | 3770 |
3771 hp = ml_find_line(buf, lnum, ML_FIND); | 3771 hp = ml_find_line(buf, lnum, ML_FIND); |
3772 if (hp == NULL) | 3772 if (hp == NULL) |
3773 IEMSGN(_("E320: Cannot find line %ld"), lnum); | 3773 siemsg(_("E320: Cannot find line %ld"), lnum); |
3774 else | 3774 else |
3775 { | 3775 { |
3776 dp = (DATA_BL *)(hp->bh_data); | 3776 dp = (DATA_BL *)(hp->bh_data); |
3777 idx = lnum - buf->b_ml.ml_locked_low; | 3777 idx = lnum - buf->b_ml.ml_locked_low; |
3778 start = ((dp->db_index[idx]) & DB_INDEX_MASK); | 3778 start = ((dp->db_index[idx]) & DB_INDEX_MASK); |
4010 } | 4010 } |
4011 | 4011 |
4012 pp = (PTR_BL *)(dp); /* must be pointer block */ | 4012 pp = (PTR_BL *)(dp); /* must be pointer block */ |
4013 if (pp->pb_id != PTR_ID) | 4013 if (pp->pb_id != PTR_ID) |
4014 { | 4014 { |
4015 IEMSG(_("E317: pointer block id wrong")); | 4015 iemsg(_("E317: pointer block id wrong")); |
4016 goto error_block; | 4016 goto error_block; |
4017 } | 4017 } |
4018 | 4018 |
4019 if ((top = ml_add_stack(buf)) < 0) /* add new entry to stack */ | 4019 if ((top = ml_add_stack(buf)) < 0) /* add new entry to stack */ |
4020 goto error_block; | 4020 goto error_block; |
4055 } | 4055 } |
4056 } | 4056 } |
4057 if (idx >= (int)pp->pb_count) /* past the end: something wrong! */ | 4057 if (idx >= (int)pp->pb_count) /* past the end: something wrong! */ |
4058 { | 4058 { |
4059 if (lnum > buf->b_ml.ml_line_count) | 4059 if (lnum > buf->b_ml.ml_line_count) |
4060 IEMSGN(_("E322: line number out of range: %ld past the end"), | 4060 siemsg(_("E322: line number out of range: %ld past the end"), |
4061 lnum - buf->b_ml.ml_line_count); | 4061 lnum - buf->b_ml.ml_line_count); |
4062 | 4062 |
4063 else | 4063 else |
4064 IEMSGN(_("E323: line count wrong in block %ld"), bnum); | 4064 siemsg(_("E323: line count wrong in block %ld"), bnum); |
4065 goto error_block; | 4065 goto error_block; |
4066 } | 4066 } |
4067 if (action == ML_DELETE) | 4067 if (action == ML_DELETE) |
4068 { | 4068 { |
4069 pp->pb_pointer[idx].pe_line_count--; | 4069 pp->pb_pointer[idx].pe_line_count--; |
4153 break; | 4153 break; |
4154 pp = (PTR_BL *)(hp->bh_data); /* must be pointer block */ | 4154 pp = (PTR_BL *)(hp->bh_data); /* must be pointer block */ |
4155 if (pp->pb_id != PTR_ID) | 4155 if (pp->pb_id != PTR_ID) |
4156 { | 4156 { |
4157 mf_put(mfp, hp, FALSE, FALSE); | 4157 mf_put(mfp, hp, FALSE, FALSE); |
4158 IEMSG(_("E317: pointer block id wrong 2")); | 4158 iemsg(_("E317: pointer block id wrong 2")); |
4159 break; | 4159 break; |
4160 } | 4160 } |
4161 pp->pb_pointer[ip->ip_index].pe_line_count += count; | 4161 pp->pb_pointer[ip->ip_index].pe_line_count += count; |
4162 ip->ip_high += count; | 4162 ip->ip_high += count; |
4163 mf_put(mfp, hp, TRUE, FALSE); | 4163 mf_put(mfp, hp, TRUE, FALSE); |
4188 for (;;) | 4188 for (;;) |
4189 { | 4189 { |
4190 /* Limit symlink depth to 100, catch recursive loops. */ | 4190 /* Limit symlink depth to 100, catch recursive loops. */ |
4191 if (++depth == 100) | 4191 if (++depth == 100) |
4192 { | 4192 { |
4193 EMSG2(_("E773: Symlink loop for \"%s\""), fname); | 4193 semsg(_("E773: Symlink loop for \"%s\""), fname); |
4194 return FAIL; | 4194 return FAIL; |
4195 } | 4195 } |
4196 | 4196 |
4197 ret = readlink((char *)tmp, (char *)buf, MAXPATHL - 1); | 4197 ret = readlink((char *)tmp, (char *)buf, MAXPATHL - 1); |
4198 if (ret <= 0) | 4198 if (ret <= 0) |
4370 stat_T st; | 4370 stat_T st; |
4371 time_t x, sx; | 4371 time_t x, sx; |
4372 char *p; | 4372 char *p; |
4373 | 4373 |
4374 ++no_wait_return; | 4374 ++no_wait_return; |
4375 (void)EMSG(_("E325: ATTENTION")); | 4375 (void)emsg(_("E325: ATTENTION")); |
4376 MSG_PUTS(_("\nFound a swap file by the name \"")); | 4376 MSG_PUTS(_("\nFound a swap file by the name \"")); |
4377 msg_home_replace(fname); | 4377 msg_home_replace(fname); |
4378 MSG_PUTS("\"\n"); | 4378 MSG_PUTS("\"\n"); |
4379 sx = swapfile_info(fname); | 4379 sx = swapfile_info(fname); |
4380 MSG_PUTS(_("While opening file \"")); | 4380 MSG_PUTS(_("While opening file \"")); |
4913 */ | 4913 */ |
4914 if (fname[n - 1] == 'a') /* ".s?a" */ | 4914 if (fname[n - 1] == 'a') /* ".s?a" */ |
4915 { | 4915 { |
4916 if (fname[n - 2] == 'a') /* ".saa": tried enough, give up */ | 4916 if (fname[n - 2] == 'a') /* ".saa": tried enough, give up */ |
4917 { | 4917 { |
4918 EMSG(_("E326: Too many swap files found")); | 4918 emsg(_("E326: Too many swap files found")); |
4919 VIM_CLEAR(fname); | 4919 VIM_CLEAR(fname); |
4920 break; | 4920 break; |
4921 } | 4921 } |
4922 --fname[n - 2]; /* ".svz", ".suz", etc. */ | 4922 --fname[n - 2]; /* ".svz", ".suz", etc. */ |
4923 fname[n - 1] = 'z' + 1; | 4923 fname[n - 1] = 'z' + 1; |