comparison src/undo.c @ 2217:120502692d82 vim73

Improve the MS-Windows installer.
author Bram Moolenaar <bram@vim.org>
date Mon, 24 May 2010 21:34:22 +0200
parents cccb71c2c5c1
children 695ceebf17ca
comparison
equal deleted inserted replaced
2216:ef150ab31dda 2217:120502692d82
80 * for errors in the debug information. */ 80 * for errors in the debug information. */
81 /* #define U_DEBUG 1 */ 81 /* #define U_DEBUG 1 */
82 #define UH_MAGIC 0x18dade /* value for uh_magic when in use */ 82 #define UH_MAGIC 0x18dade /* value for uh_magic when in use */
83 #define UE_MAGIC 0xabc123 /* value for ue_magic when in use */ 83 #define UE_MAGIC 0xabc123 /* value for ue_magic when in use */
84 84
85 #if defined(MSDOS) || defined(WIN16) || defined(WIN32) || defined(_WIN64)
86 # include "vimio.h" /* for vim_read(), must be before vim.h */
87 #endif
88
85 #include "vim.h" 89 #include "vim.h"
86 90
87 /* See below: use malloc()/free() for memory management. */ 91 /* See below: use malloc()/free() for memory management. */
88 #define U_USE_MALLOC 1 92 #define U_USE_MALLOC 1
89 93
683 687
684 sha256_start(&ctx); 688 sha256_start(&ctx);
685 for (lnum = 1; lnum < curbuf->b_ml.ml_line_count; ++lnum) 689 for (lnum = 1; lnum < curbuf->b_ml.ml_line_count; ++lnum)
686 { 690 {
687 p = ml_get(lnum); 691 p = ml_get(lnum);
688 sha256_update(&ctx, p, STRLEN(p) + 1); 692 sha256_update(&ctx, p, (UINT32_T)(STRLEN(p) + 1));
689 } 693 }
690 sha256_finish(&ctx, hash); 694 sha256_finish(&ctx, hash);
691 } 695 }
692 696
693 /* 697 /*
762 dir_len = copy_option_part(&dirp, dir_name, IOSIZE, ","); 766 dir_len = copy_option_part(&dirp, dir_name, IOSIZE, ",");
763 if (dir_len == 1 && dir_name[0] == '.') 767 if (dir_len == 1 && dir_name[0] == '.')
764 { 768 {
765 /* Use same directory as the ffname, 769 /* Use same directory as the ffname,
766 * "dir/name" -> "dir/.name.un~" */ 770 * "dir/name" -> "dir/.name.un~" */
767 undo_file_name = vim_strnsave(ffname, STRLEN(ffname) + 5); 771 undo_file_name = vim_strnsave(ffname, (int)(STRLEN(ffname) + 5));
768 if (undo_file_name == NULL) 772 if (undo_file_name == NULL)
769 break; 773 break;
770 p = gettail(undo_file_name); 774 p = gettail(undo_file_name);
771 mch_memmove(p + 1, p, STRLEN(p) + 1); 775 mch_memmove(p + 1, p, STRLEN(p) + 1);
772 *p = '.'; 776 *p = '.';
821 linenr_T line_lnum; 825 linenr_T line_lnum;
822 colnr_T line_colnr; 826 colnr_T line_colnr;
823 linenr_T line_count; 827 linenr_T line_count;
824 int uep_len; 828 int uep_len;
825 int line_len; 829 int line_len;
826 int num_head; 830 int num_head = 0;
827 long old_header_seq, new_header_seq, cur_header_seq; 831 long old_header_seq, new_header_seq, cur_header_seq;
828 long seq_last, seq_cur; 832 long seq_last, seq_cur;
829 short old_idx = -1, new_idx = -1, cur_idx = -1; 833 short old_idx = -1, new_idx = -1, cur_idx = -1;
830 long num_read_uhps = 0; 834 long num_read_uhps = 0;
831 time_t seq_time; 835 time_t seq_time;
927 goto error; 931 goto error;
928 vim_memset(uhp, 0, sizeof(u_header_T)); 932 vim_memset(uhp, 0, sizeof(u_header_T));
929 /* We're not actually trying to store pointers here. We're just storing 933 /* We're not actually trying to store pointers here. We're just storing
930 * IDs so we can swizzle them into pointers later - hence the type 934 * IDs so we can swizzle them into pointers later - hence the type
931 * cast. */ 935 * cast. */
932 uhp->uh_next = (u_header_T *)(long)get4c(fp); 936 uhp->uh_next = (u_header_T *)get4c(fp);
933 uhp->uh_prev = (u_header_T *)(long)get4c(fp); 937 uhp->uh_prev = (u_header_T *)get4c(fp);
934 uhp->uh_alt_next = (u_header_T *)(long)get4c(fp); 938 uhp->uh_alt_next = (u_header_T *)get4c(fp);
935 uhp->uh_alt_prev = (u_header_T *)(long)get4c(fp); 939 uhp->uh_alt_prev = (u_header_T *)get4c(fp);
936 uhp->uh_seq = get4c(fp); 940 uhp->uh_seq = get4c(fp);
937 if (uhp->uh_seq <= 0) 941 if (uhp->uh_seq <= 0)
938 { 942 {
939 EMSG2(_("E825: Undo file corruption: invalid uh_seq.: %s"), 943 EMSG2(_("E825: Undo file corruption: invalid uh_seq.: %s"),
940 file_name); 944 file_name);
1137 int uep_len; 1141 int uep_len;
1138 int *entry_lens; 1142 int *entry_lens;
1139 1143
1140 if (uep->ue_size > 0) 1144 if (uep->ue_size > 0)
1141 entry_lens = (int *)alloc(uep->ue_size * sizeof(int)); 1145 entry_lens = (int *)alloc(uep->ue_size * sizeof(int));
1146 else
1147 entry_lens = NULL;
1142 1148
1143 /* Define uep_len to be the size of the entire uep minus the size of its 1149 /* Define uep_len to be the size of the entire uep minus the size of its
1144 * component strings, in bytes. The sizes of the component strings 1150 * component strings, in bytes. The sizes of the component strings
1145 * are written before each individual string. 1151 * are written before each individual string.
1146 * We have 4 entries each of 4 bytes, plus ue_size * 4 bytes 1152 * We have 4 entries each of 4 bytes, plus ue_size * 4 bytes
1333 if (fwrite(hash, (size_t)UNDO_HASH_SIZE, (size_t)1, fp) != 1) 1339 if (fwrite(hash, (size_t)UNDO_HASH_SIZE, (size_t)1, fp) != 1)
1334 goto write_error; 1340 goto write_error;
1335 put_bytes(fp, (long_u)buf->b_ml.ml_line_count, 4); 1341 put_bytes(fp, (long_u)buf->b_ml.ml_line_count, 4);
1336 1342
1337 /* Begin undo data for U */ 1343 /* Begin undo data for U */
1338 str_len = buf->b_u_line_ptr != NULL ? STRLEN(buf->b_u_line_ptr) : 0; 1344 str_len = buf->b_u_line_ptr != NULL ? (int)STRLEN(buf->b_u_line_ptr) : 0;
1339 put_bytes(fp, (long_u)str_len, 4); 1345 put_bytes(fp, (long_u)str_len, 4);
1340 if (str_len > 0 && fwrite(buf->b_u_line_ptr, (size_t)str_len, 1346 if (str_len > 0 && fwrite(buf->b_u_line_ptr, (size_t)str_len,
1341 (size_t)1, fp) != 1) 1347 (size_t)1, fp) != 1)
1342 goto write_error; 1348 goto write_error;
1343 1349