Mercurial > vim
comparison src/undo.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 | 00aa76a735e7 |
children | dd725a8ab112 |
comparison
equal
deleted
inserted
replaced
15469:bc9b5261ed01 | 15470:55ccc2d353bd |
---|---|
156 if (uhp == NULL) | 156 if (uhp == NULL) |
157 return; | 157 return; |
158 ++header_count; | 158 ++header_count; |
159 if (uhp == curbuf->b_u_curhead && ++seen_b_u_curhead > 1) | 159 if (uhp == curbuf->b_u_curhead && ++seen_b_u_curhead > 1) |
160 { | 160 { |
161 EMSG("b_u_curhead found twice (looping?)"); | 161 emsg("b_u_curhead found twice (looping?)"); |
162 return; | 162 return; |
163 } | 163 } |
164 if (uhp == curbuf->b_u_newhead && ++seen_b_u_newhead > 1) | 164 if (uhp == curbuf->b_u_newhead && ++seen_b_u_newhead > 1) |
165 { | 165 { |
166 EMSG("b_u_newhead found twice (looping?)"); | 166 emsg("b_u_newhead found twice (looping?)"); |
167 return; | 167 return; |
168 } | 168 } |
169 | 169 |
170 if (uhp->uh_magic != UH_MAGIC) | 170 if (uhp->uh_magic != UH_MAGIC) |
171 EMSG("uh_magic wrong (may be using freed memory)"); | 171 emsg("uh_magic wrong (may be using freed memory)"); |
172 else | 172 else |
173 { | 173 { |
174 /* Check pointers back are correct. */ | 174 /* Check pointers back are correct. */ |
175 if (uhp->uh_next.ptr != exp_uh_next) | 175 if (uhp->uh_next.ptr != exp_uh_next) |
176 { | 176 { |
177 EMSG("uh_next wrong"); | 177 emsg("uh_next wrong"); |
178 smsg((char_u *)"expected: 0x%x, actual: 0x%x", | 178 smsg("expected: 0x%x, actual: 0x%x", |
179 exp_uh_next, uhp->uh_next.ptr); | 179 exp_uh_next, uhp->uh_next.ptr); |
180 } | 180 } |
181 if (uhp->uh_alt_prev.ptr != exp_uh_alt_prev) | 181 if (uhp->uh_alt_prev.ptr != exp_uh_alt_prev) |
182 { | 182 { |
183 EMSG("uh_alt_prev wrong"); | 183 emsg("uh_alt_prev wrong"); |
184 smsg((char_u *)"expected: 0x%x, actual: 0x%x", | 184 smsg("expected: 0x%x, actual: 0x%x", |
185 exp_uh_alt_prev, uhp->uh_alt_prev.ptr); | 185 exp_uh_alt_prev, uhp->uh_alt_prev.ptr); |
186 } | 186 } |
187 | 187 |
188 /* Check the undo tree at this header. */ | 188 /* Check the undo tree at this header. */ |
189 for (uep = uhp->uh_entry; uep != NULL; uep = uep->ue_next) | 189 for (uep = uhp->uh_entry; uep != NULL; uep = uep->ue_next) |
190 { | 190 { |
191 if (uep->ue_magic != UE_MAGIC) | 191 if (uep->ue_magic != UE_MAGIC) |
192 { | 192 { |
193 EMSG("ue_magic wrong (may be using freed memory)"); | 193 emsg("ue_magic wrong (may be using freed memory)"); |
194 break; | 194 break; |
195 } | 195 } |
196 } | 196 } |
197 | 197 |
198 /* Check the next alt tree. */ | 198 /* Check the next alt tree. */ |
212 | 212 |
213 u_check_tree(curbuf->b_u_oldhead, NULL, NULL); | 213 u_check_tree(curbuf->b_u_oldhead, NULL, NULL); |
214 | 214 |
215 if (seen_b_u_newhead == 0 && curbuf->b_u_oldhead != NULL | 215 if (seen_b_u_newhead == 0 && curbuf->b_u_oldhead != NULL |
216 && !(newhead_may_be_NULL && curbuf->b_u_newhead == NULL)) | 216 && !(newhead_may_be_NULL && curbuf->b_u_newhead == NULL)) |
217 EMSGN("b_u_newhead invalid: 0x%x", curbuf->b_u_newhead); | 217 semsg("b_u_newhead invalid: 0x%x", curbuf->b_u_newhead); |
218 if (curbuf->b_u_curhead != NULL && seen_b_u_curhead == 0) | 218 if (curbuf->b_u_curhead != NULL && seen_b_u_curhead == 0) |
219 EMSGN("b_u_curhead invalid: 0x%x", curbuf->b_u_curhead); | 219 semsg("b_u_curhead invalid: 0x%x", curbuf->b_u_curhead); |
220 if (header_count != curbuf->b_u_numhead) | 220 if (header_count != curbuf->b_u_numhead) |
221 { | 221 { |
222 EMSG("b_u_numhead invalid"); | 222 emsg("b_u_numhead invalid"); |
223 smsg((char_u *)"expected: %ld, actual: %ld", | 223 smsg("expected: %ld, actual: %ld", |
224 (long)header_count, (long)curbuf->b_u_numhead); | 224 (long)header_count, (long)curbuf->b_u_numhead); |
225 } | 225 } |
226 } | 226 } |
227 #endif | 227 #endif |
228 | 228 |
314 undo_allowed(void) | 314 undo_allowed(void) |
315 { | 315 { |
316 /* Don't allow changes when 'modifiable' is off. */ | 316 /* Don't allow changes when 'modifiable' is off. */ |
317 if (!curbuf->b_p_ma) | 317 if (!curbuf->b_p_ma) |
318 { | 318 { |
319 EMSG(_(e_modifiable)); | 319 emsg(_(e_modifiable)); |
320 return FALSE; | 320 return FALSE; |
321 } | 321 } |
322 | 322 |
323 #ifdef HAVE_SANDBOX | 323 #ifdef HAVE_SANDBOX |
324 /* In the sandbox it's not allowed to change the text. */ | 324 /* In the sandbox it's not allowed to change the text. */ |
325 if (sandbox != 0) | 325 if (sandbox != 0) |
326 { | 326 { |
327 EMSG(_(e_sandbox)); | 327 emsg(_(e_sandbox)); |
328 return FALSE; | 328 return FALSE; |
329 } | 329 } |
330 #endif | 330 #endif |
331 | 331 |
332 /* Don't allow changes in the buffer while editing the cmdline. The | 332 /* Don't allow changes in the buffer while editing the cmdline. The |
333 * caller of getcmdline() may get confused. */ | 333 * caller of getcmdline() may get confused. */ |
334 if (textlock != 0) | 334 if (textlock != 0) |
335 { | 335 { |
336 EMSG(_(e_secure)); | 336 emsg(_(e_secure)); |
337 return FALSE; | 337 return FALSE; |
338 } | 338 } |
339 | 339 |
340 return TRUE; | 340 return TRUE; |
341 } | 341 } |
411 */ | 411 */ |
412 if (netbeans_active()) | 412 if (netbeans_active()) |
413 { | 413 { |
414 if (netbeans_is_guarded(top, bot)) | 414 if (netbeans_is_guarded(top, bot)) |
415 { | 415 { |
416 EMSG(_(e_guarded)); | 416 emsg(_(e_guarded)); |
417 return FAIL; | 417 return FAIL; |
418 } | 418 } |
419 if (curbuf->b_p_ro) | 419 if (curbuf->b_p_ro) |
420 { | 420 { |
421 EMSG(_(e_nbreadonly)); | 421 emsg(_(e_nbreadonly)); |
422 return FAIL; | 422 return FAIL; |
423 } | 423 } |
424 } | 424 } |
425 #endif | 425 #endif |
426 #ifdef FEAT_TERMINAL | 426 #ifdef FEAT_TERMINAL |
437 change_warning(0); | 437 change_warning(0); |
438 if (bot > curbuf->b_ml.ml_line_count + 1) | 438 if (bot > curbuf->b_ml.ml_line_count + 1) |
439 { | 439 { |
440 /* This happens when the FileChangedRO autocommand changes the | 440 /* This happens when the FileChangedRO autocommand changes the |
441 * file in a way it becomes shorter. */ | 441 * file in a way it becomes shorter. */ |
442 EMSG(_("E881: Line count changed unexpectedly")); | 442 emsg(_("E881: Line count changed unexpectedly")); |
443 return FAIL; | 443 return FAIL; |
444 } | 444 } |
445 } | 445 } |
446 | 446 |
447 #ifdef U_DEBUG | 447 #ifdef U_DEBUG |
859 } | 859 } |
860 | 860 |
861 static void | 861 static void |
862 corruption_error(char *mesg, char_u *file_name) | 862 corruption_error(char *mesg, char_u *file_name) |
863 { | 863 { |
864 EMSG3(_("E825: Corrupted undo file (%s): %s"), mesg, file_name); | 864 semsg(_("E825: Corrupted undo file (%s): %s"), mesg, file_name); |
865 } | 865 } |
866 | 866 |
867 static void | 867 static void |
868 u_free_uhp(u_header_T *uhp) | 868 u_free_uhp(u_header_T *uhp) |
869 { | 869 { |
1551 if (file_name == NULL) | 1551 if (file_name == NULL) |
1552 { | 1552 { |
1553 if (p_verbose > 0) | 1553 if (p_verbose > 0) |
1554 { | 1554 { |
1555 verbose_enter(); | 1555 verbose_enter(); |
1556 smsg((char_u *) | 1556 smsg( |
1557 _("Cannot write undo file in any directory in 'undodir'")); | 1557 _("Cannot write undo file in any directory in 'undodir'")); |
1558 verbose_leave(); | 1558 verbose_leave(); |
1559 } | 1559 } |
1560 return; | 1560 return; |
1561 } | 1561 } |
1599 { | 1599 { |
1600 if (name != NULL || p_verbose > 0) | 1600 if (name != NULL || p_verbose > 0) |
1601 { | 1601 { |
1602 if (name == NULL) | 1602 if (name == NULL) |
1603 verbose_enter(); | 1603 verbose_enter(); |
1604 smsg((char_u *) | 1604 smsg( |
1605 _("Will not overwrite with undo file, cannot read: %s"), | 1605 _("Will not overwrite with undo file, cannot read: %s"), |
1606 file_name); | 1606 file_name); |
1607 if (name == NULL) | 1607 if (name == NULL) |
1608 verbose_leave(); | 1608 verbose_leave(); |
1609 } | 1609 } |
1621 { | 1621 { |
1622 if (name != NULL || p_verbose > 0) | 1622 if (name != NULL || p_verbose > 0) |
1623 { | 1623 { |
1624 if (name == NULL) | 1624 if (name == NULL) |
1625 verbose_enter(); | 1625 verbose_enter(); |
1626 smsg((char_u *) | 1626 smsg( |
1627 _("Will not overwrite, this is not an undo file: %s"), | 1627 _("Will not overwrite, this is not an undo file: %s"), |
1628 file_name); | 1628 file_name); |
1629 if (name == NULL) | 1629 if (name == NULL) |
1630 verbose_leave(); | 1630 verbose_leave(); |
1631 } | 1631 } |
1647 | 1647 |
1648 fd = mch_open((char *)file_name, | 1648 fd = mch_open((char *)file_name, |
1649 O_CREAT|O_EXTRA|O_WRONLY|O_EXCL|O_NOFOLLOW, perm); | 1649 O_CREAT|O_EXTRA|O_WRONLY|O_EXCL|O_NOFOLLOW, perm); |
1650 if (fd < 0) | 1650 if (fd < 0) |
1651 { | 1651 { |
1652 EMSG2(_(e_not_open), file_name); | 1652 semsg(_(e_not_open), file_name); |
1653 goto theend; | 1653 goto theend; |
1654 } | 1654 } |
1655 (void)mch_setperm(file_name, perm); | 1655 (void)mch_setperm(file_name, perm); |
1656 if (p_verbose > 0) | 1656 if (p_verbose > 0) |
1657 { | 1657 { |
1658 verbose_enter(); | 1658 verbose_enter(); |
1659 smsg((char_u *)_("Writing undo file: %s"), file_name); | 1659 smsg(_("Writing undo file: %s"), file_name); |
1660 verbose_leave(); | 1660 verbose_leave(); |
1661 } | 1661 } |
1662 | 1662 |
1663 #ifdef U_DEBUG | 1663 #ifdef U_DEBUG |
1664 /* Check there is no problem in undo info before writing. */ | 1664 /* Check there is no problem in undo info before writing. */ |
1686 #endif | 1686 #endif |
1687 | 1687 |
1688 fp = fdopen(fd, "w"); | 1688 fp = fdopen(fd, "w"); |
1689 if (fp == NULL) | 1689 if (fp == NULL) |
1690 { | 1690 { |
1691 EMSG2(_(e_not_open), file_name); | 1691 semsg(_(e_not_open), file_name); |
1692 close(fd); | 1692 close(fd); |
1693 mch_remove(file_name); | 1693 mch_remove(file_name); |
1694 goto theend; | 1694 goto theend; |
1695 } | 1695 } |
1696 | 1696 |
1741 if (undo_write_bytes(&bi, (long_u)UF_HEADER_END_MAGIC, 2) == OK) | 1741 if (undo_write_bytes(&bi, (long_u)UF_HEADER_END_MAGIC, 2) == OK) |
1742 write_ok = TRUE; | 1742 write_ok = TRUE; |
1743 #ifdef U_DEBUG | 1743 #ifdef U_DEBUG |
1744 if (headers_written != buf->b_u_numhead) | 1744 if (headers_written != buf->b_u_numhead) |
1745 { | 1745 { |
1746 EMSGN("Written %ld headers, ...", headers_written); | 1746 semsg("Written %ld headers, ...", headers_written); |
1747 EMSGN("... but numhead is %ld", buf->b_u_numhead); | 1747 semsg("... but numhead is %ld", buf->b_u_numhead); |
1748 } | 1748 } |
1749 #endif | 1749 #endif |
1750 | 1750 |
1751 #ifdef FEAT_CRYPT | 1751 #ifdef FEAT_CRYPT |
1752 if (bi.bi_state != NULL && undo_flush(&bi) == FAIL) | 1752 if (bi.bi_state != NULL && undo_flush(&bi) == FAIL) |
1754 #endif | 1754 #endif |
1755 | 1755 |
1756 write_error: | 1756 write_error: |
1757 fclose(fp); | 1757 fclose(fp); |
1758 if (!write_ok) | 1758 if (!write_ok) |
1759 EMSG2(_("E829: write error in undo file: %s"), file_name); | 1759 semsg(_("E829: write error in undo file: %s"), file_name); |
1760 | 1760 |
1761 #if defined(WIN3264) | 1761 #if defined(WIN3264) |
1762 /* Copy file attributes; for systems where this can only be done after | 1762 /* Copy file attributes; for systems where this can only be done after |
1763 * closing the file. */ | 1763 * closing the file. */ |
1764 if (buf->b_ffname != NULL) | 1764 if (buf->b_ffname != NULL) |
1844 && st_undo.st_uid != getuid()) | 1844 && st_undo.st_uid != getuid()) |
1845 { | 1845 { |
1846 if (p_verbose > 0) | 1846 if (p_verbose > 0) |
1847 { | 1847 { |
1848 verbose_enter(); | 1848 verbose_enter(); |
1849 smsg((char_u *)_("Not reading undo file, owner differs: %s"), | 1849 smsg(_("Not reading undo file, owner differs: %s"), |
1850 file_name); | 1850 file_name); |
1851 verbose_leave(); | 1851 verbose_leave(); |
1852 } | 1852 } |
1853 return; | 1853 return; |
1854 } | 1854 } |
1858 file_name = name; | 1858 file_name = name; |
1859 | 1859 |
1860 if (p_verbose > 0) | 1860 if (p_verbose > 0) |
1861 { | 1861 { |
1862 verbose_enter(); | 1862 verbose_enter(); |
1863 smsg((char_u *)_("Reading undo file: %s"), file_name); | 1863 smsg(_("Reading undo file: %s"), file_name); |
1864 verbose_leave(); | 1864 verbose_leave(); |
1865 } | 1865 } |
1866 | 1866 |
1867 fp = mch_fopen((char *)file_name, "r"); | 1867 fp = mch_fopen((char *)file_name, "r"); |
1868 if (fp == NULL) | 1868 if (fp == NULL) |
1869 { | 1869 { |
1870 if (name != NULL || p_verbose > 0) | 1870 if (name != NULL || p_verbose > 0) |
1871 EMSG2(_("E822: Cannot open undo file for reading: %s"), file_name); | 1871 semsg(_("E822: Cannot open undo file for reading: %s"), file_name); |
1872 goto error; | 1872 goto error; |
1873 } | 1873 } |
1874 bi.bi_buf = curbuf; | 1874 bi.bi_buf = curbuf; |
1875 bi.bi_fp = fp; | 1875 bi.bi_fp = fp; |
1876 | 1876 |
1878 * Read the undo file header. | 1878 * Read the undo file header. |
1879 */ | 1879 */ |
1880 if (fread(magic_buf, UF_START_MAGIC_LEN, 1, fp) != 1 | 1880 if (fread(magic_buf, UF_START_MAGIC_LEN, 1, fp) != 1 |
1881 || memcmp(magic_buf, UF_START_MAGIC, UF_START_MAGIC_LEN) != 0) | 1881 || memcmp(magic_buf, UF_START_MAGIC, UF_START_MAGIC_LEN) != 0) |
1882 { | 1882 { |
1883 EMSG2(_("E823: Not an undo file: %s"), file_name); | 1883 semsg(_("E823: Not an undo file: %s"), file_name); |
1884 goto error; | 1884 goto error; |
1885 } | 1885 } |
1886 version = get2c(fp); | 1886 version = get2c(fp); |
1887 if (version == UF_VERSION_CRYPT) | 1887 if (version == UF_VERSION_CRYPT) |
1888 { | 1888 { |
1889 #ifdef FEAT_CRYPT | 1889 #ifdef FEAT_CRYPT |
1890 if (*curbuf->b_p_key == NUL) | 1890 if (*curbuf->b_p_key == NUL) |
1891 { | 1891 { |
1892 EMSG2(_("E832: Non-encrypted file has encrypted undo file: %s"), | 1892 semsg(_("E832: Non-encrypted file has encrypted undo file: %s"), |
1893 file_name); | 1893 file_name); |
1894 goto error; | 1894 goto error; |
1895 } | 1895 } |
1896 bi.bi_state = crypt_create_from_file(fp, curbuf->b_p_key); | 1896 bi.bi_state = crypt_create_from_file(fp, curbuf->b_p_key); |
1897 if (bi.bi_state == NULL) | 1897 if (bi.bi_state == NULL) |
1898 { | 1898 { |
1899 EMSG2(_("E826: Undo file decryption failed: %s"), file_name); | 1899 semsg(_("E826: Undo file decryption failed: %s"), file_name); |
1900 goto error; | 1900 goto error; |
1901 } | 1901 } |
1902 if (crypt_whole_undofile(bi.bi_state->method_nr)) | 1902 if (crypt_whole_undofile(bi.bi_state->method_nr)) |
1903 { | 1903 { |
1904 bi.bi_buffer = alloc(CRYPT_BUF_SIZE); | 1904 bi.bi_buffer = alloc(CRYPT_BUF_SIZE); |
1910 } | 1910 } |
1911 bi.bi_avail = 0; | 1911 bi.bi_avail = 0; |
1912 bi.bi_used = 0; | 1912 bi.bi_used = 0; |
1913 } | 1913 } |
1914 #else | 1914 #else |
1915 EMSG2(_("E827: Undo file is encrypted: %s"), file_name); | 1915 semsg(_("E827: Undo file is encrypted: %s"), file_name); |
1916 goto error; | 1916 goto error; |
1917 #endif | 1917 #endif |
1918 } | 1918 } |
1919 else if (version != UF_VERSION) | 1919 else if (version != UF_VERSION) |
1920 { | 1920 { |
1921 EMSG2(_("E824: Incompatible undo file: %s"), file_name); | 1921 semsg(_("E824: Incompatible undo file: %s"), file_name); |
1922 goto error; | 1922 goto error; |
1923 } | 1923 } |
1924 | 1924 |
1925 if (undo_read(&bi, read_hash, (size_t)UNDO_HASH_SIZE) == FAIL) | 1925 if (undo_read(&bi, read_hash, (size_t)UNDO_HASH_SIZE) == FAIL) |
1926 { | 1926 { |
2120 vim_free(uhp_table); | 2120 vim_free(uhp_table); |
2121 | 2121 |
2122 #ifdef U_DEBUG | 2122 #ifdef U_DEBUG |
2123 for (i = 0; i < num_head; ++i) | 2123 for (i = 0; i < num_head; ++i) |
2124 if (uhp_table_used[i] == 0) | 2124 if (uhp_table_used[i] == 0) |
2125 EMSGN("uhp_table entry %ld not used, leaking memory", i); | 2125 semsg("uhp_table entry %ld not used, leaking memory", i); |
2126 vim_free(uhp_table_used); | 2126 vim_free(uhp_table_used); |
2127 u_check(TRUE); | 2127 u_check(TRUE); |
2128 #endif | 2128 #endif |
2129 | 2129 |
2130 if (name != NULL) | 2130 if (name != NULL) |
2131 smsg((char_u *)_("Finished reading undo file %s"), file_name); | 2131 smsg(_("Finished reading undo file %s"), file_name); |
2132 goto theend; | 2132 goto theend; |
2133 | 2133 |
2134 error: | 2134 error: |
2135 vim_free(line_ptr.ul_line); | 2135 vim_free(line_ptr.ul_line); |
2136 if (uhp_table != NULL) | 2136 if (uhp_table != NULL) |
2486 if (uhp != NULL) /* found it */ | 2486 if (uhp != NULL) /* found it */ |
2487 break; | 2487 break; |
2488 | 2488 |
2489 if (absolute) | 2489 if (absolute) |
2490 { | 2490 { |
2491 EMSGN(_("E830: Undo number %ld not found"), step); | 2491 semsg(_("E830: Undo number %ld not found"), step); |
2492 return; | 2492 return; |
2493 } | 2493 } |
2494 | 2494 |
2495 if (closest == closest_start) | 2495 if (closest == closest_start) |
2496 { | 2496 { |
2676 bot = curbuf->b_ml.ml_line_count + 1; | 2676 bot = curbuf->b_ml.ml_line_count + 1; |
2677 if (top > curbuf->b_ml.ml_line_count || top >= bot | 2677 if (top > curbuf->b_ml.ml_line_count || top >= bot |
2678 || bot > curbuf->b_ml.ml_line_count + 1) | 2678 || bot > curbuf->b_ml.ml_line_count + 1) |
2679 { | 2679 { |
2680 unblock_autocmds(); | 2680 unblock_autocmds(); |
2681 IEMSG(_("E438: u_undo: line numbers wrong")); | 2681 iemsg(_("E438: u_undo: line numbers wrong")); |
2682 changed(); /* don't want UNCHANGED now */ | 2682 changed(); /* don't want UNCHANGED now */ |
2683 return; | 2683 return; |
2684 } | 2684 } |
2685 | 2685 |
2686 oldsize = bot - top - 1; /* number of lines before undo */ | 2686 oldsize = bot - top - 1; /* number of lines before undo */ |
2986 redraw_win_later(wp, NOT_VALID); | 2986 redraw_win_later(wp, NOT_VALID); |
2987 } | 2987 } |
2988 } | 2988 } |
2989 #endif | 2989 #endif |
2990 | 2990 |
2991 smsg_attr_keep(0, (char_u *)_("%ld %s; %s #%ld %s"), | 2991 smsg_attr_keep(0, _("%ld %s; %s #%ld %s"), |
2992 u_oldcount < 0 ? -u_oldcount : u_oldcount, | 2992 u_oldcount < 0 ? -u_oldcount : u_oldcount, |
2993 _(msgstr), | 2993 _(msgstr), |
2994 did_undo ? _("before") : _("after"), | 2994 did_undo ? _("before") : _("after"), |
2995 uhp == NULL ? 0L : uhp->uh_seq, | 2995 uhp == NULL ? 0L : uhp->uh_seq, |
2996 msgbuf); | 2996 msgbuf); |
3163 { | 3163 { |
3164 if (curbuf->b_u_newhead == NULL) | 3164 if (curbuf->b_u_newhead == NULL) |
3165 return; /* nothing changed before */ | 3165 return; /* nothing changed before */ |
3166 if (curbuf->b_u_curhead != NULL) | 3166 if (curbuf->b_u_curhead != NULL) |
3167 { | 3167 { |
3168 EMSG(_("E790: undojoin is not allowed after undo")); | 3168 emsg(_("E790: undojoin is not allowed after undo")); |
3169 return; | 3169 return; |
3170 } | 3170 } |
3171 if (!curbuf->b_u_synced) | 3171 if (!curbuf->b_u_synced) |
3172 return; /* already unsynced */ | 3172 return; /* already unsynced */ |
3173 if (get_undolevel() < 0) | 3173 if (get_undolevel() < 0) |
3268 static u_entry_T * | 3268 static u_entry_T * |
3269 u_get_headentry(void) | 3269 u_get_headentry(void) |
3270 { | 3270 { |
3271 if (curbuf->b_u_newhead == NULL || curbuf->b_u_newhead->uh_entry == NULL) | 3271 if (curbuf->b_u_newhead == NULL || curbuf->b_u_newhead->uh_entry == NULL) |
3272 { | 3272 { |
3273 IEMSG(_("E439: undo list corrupt")); | 3273 iemsg(_("E439: undo list corrupt")); |
3274 return NULL; | 3274 return NULL; |
3275 } | 3275 } |
3276 return curbuf->b_u_newhead->uh_entry; | 3276 return curbuf->b_u_newhead->uh_entry; |
3277 } | 3277 } |
3278 | 3278 |
3300 */ | 3300 */ |
3301 extra = curbuf->b_ml.ml_line_count - uep->ue_lcount; | 3301 extra = curbuf->b_ml.ml_line_count - uep->ue_lcount; |
3302 uep->ue_bot = uep->ue_top + uep->ue_size + 1 + extra; | 3302 uep->ue_bot = uep->ue_top + uep->ue_size + 1 + extra; |
3303 if (uep->ue_bot < 1 || uep->ue_bot > curbuf->b_ml.ml_line_count) | 3303 if (uep->ue_bot < 1 || uep->ue_bot > curbuf->b_ml.ml_line_count) |
3304 { | 3304 { |
3305 IEMSG(_("E440: undo line missing")); | 3305 iemsg(_("E440: undo line missing")); |
3306 uep->ue_bot = uep->ue_top + 1; /* assume all lines deleted, will | 3306 uep->ue_bot = uep->ue_top + 1; /* assume all lines deleted, will |
3307 * get all the old lines back | 3307 * get all the old lines back |
3308 * without deleting the current | 3308 * without deleting the current |
3309 * ones */ | 3309 * ones */ |
3310 } | 3310 } |