Lines Matching refs:uhp
103 static void u_unch_branch(u_header_T *uhp);
109 static void u_freeheader(buf_T *buf, u_header_T *uhp, u_header_T **uhpp);
110 static void u_freebranch(buf_T *buf, u_header_T *uhp, u_header_T **uhpp);
111 static void u_freeentries(buf_T *buf, u_header_T *uhp, u_header_T **uhpp);
150 u_check_tree(u_header_T *uhp, in u_check_tree() argument
156 if (uhp == NULL) in u_check_tree()
159 if (uhp == curbuf->b_u_curhead && ++seen_b_u_curhead > 1) in u_check_tree()
164 if (uhp == curbuf->b_u_newhead && ++seen_b_u_newhead > 1) in u_check_tree()
170 if (uhp->uh_magic != UH_MAGIC) in u_check_tree()
175 if (uhp->uh_next.ptr != exp_uh_next) in u_check_tree()
179 exp_uh_next, uhp->uh_next.ptr); in u_check_tree()
181 if (uhp->uh_alt_prev.ptr != exp_uh_alt_prev) in u_check_tree()
185 exp_uh_alt_prev, uhp->uh_alt_prev.ptr); in u_check_tree()
189 for (uep = uhp->uh_entry; uep != NULL; uep = uep->ue_next) in u_check_tree()
199 u_check_tree(uhp->uh_alt_next.ptr, uhp->uh_next.ptr, uhp); in u_check_tree()
202 u_check_tree(uhp->uh_prev.ptr, uhp, NULL); in u_check_tree()
419 u_header_T *uhp; in u_savecommon() local
511 uhp = U_ALLOC_LINE(sizeof(u_header_T)); in u_savecommon()
512 if (uhp == NULL) in u_savecommon()
515 uhp->uh_magic = UH_MAGIC; in u_savecommon()
519 uhp = NULL; in u_savecommon()
558 if (uhp == NULL) // no undo at all in u_savecommon()
566 uhp->uh_prev.ptr = NULL; in u_savecommon()
567 uhp->uh_next.ptr = curbuf->b_u_newhead; in u_savecommon()
568 uhp->uh_alt_next.ptr = old_curhead; in u_savecommon()
571 uhp->uh_alt_prev.ptr = old_curhead->uh_alt_prev.ptr; in u_savecommon()
572 if (uhp->uh_alt_prev.ptr != NULL) in u_savecommon()
573 uhp->uh_alt_prev.ptr->uh_alt_next.ptr = uhp; in u_savecommon()
574 old_curhead->uh_alt_prev.ptr = uhp; in u_savecommon()
576 curbuf->b_u_oldhead = uhp; in u_savecommon()
579 uhp->uh_alt_prev.ptr = NULL; in u_savecommon()
581 curbuf->b_u_newhead->uh_prev.ptr = uhp; in u_savecommon()
583 uhp->uh_seq = ++curbuf->b_u_seq_last; in u_savecommon()
584 curbuf->b_u_seq_cur = uhp->uh_seq; in u_savecommon()
585 uhp->uh_time = vim_time(); in u_savecommon()
586 uhp->uh_save_nr = 0; in u_savecommon()
587 curbuf->b_u_time_cur = uhp->uh_time + 1; in u_savecommon()
589 uhp->uh_walk = 0; in u_savecommon()
590 uhp->uh_entry = NULL; in u_savecommon()
591 uhp->uh_getbot_entry = NULL; in u_savecommon()
592 uhp->uh_cursor = curwin->w_cursor; // save cursor pos. for undo in u_savecommon()
594 uhp->uh_cursor_vcol = getviscol(); in u_savecommon()
596 uhp->uh_cursor_vcol = -1; in u_savecommon()
599 uhp->uh_flags = (curbuf->b_changed ? UH_CHANGED : 0) + in u_savecommon()
603 mch_memmove(uhp->uh_namedm, curbuf->b_namedm, sizeof(pos_T) * NMARKS); in u_savecommon()
604 uhp->uh_visual = curbuf->b_visual; in u_savecommon()
606 curbuf->b_u_newhead = uhp; in u_savecommon()
608 curbuf->b_u_oldhead = uhp; in u_savecommon()
907 u_free_uhp(u_header_T *uhp) in u_free_uhp() argument
912 uep = uhp->uh_entry; in u_free_uhp()
919 vim_free(uhp); in u_free_uhp()
1034 put_header_ptr(bufinfo_T *bi, u_header_T *uhp) in put_header_ptr() argument
1036 undo_write_bytes(bi, (long_u)(uhp != NULL ? uhp->uh_seq : 0), 4); in put_header_ptr()
1281 serialize_uhp(bufinfo_T *bi, u_header_T *uhp) in serialize_uhp() argument
1290 put_header_ptr(bi, uhp->uh_next.ptr); in serialize_uhp()
1291 put_header_ptr(bi, uhp->uh_prev.ptr); in serialize_uhp()
1292 put_header_ptr(bi, uhp->uh_alt_next.ptr); in serialize_uhp()
1293 put_header_ptr(bi, uhp->uh_alt_prev.ptr); in serialize_uhp()
1294 undo_write_bytes(bi, uhp->uh_seq, 4); in serialize_uhp()
1295 serialize_pos(bi, uhp->uh_cursor); in serialize_uhp()
1296 undo_write_bytes(bi, (long_u)uhp->uh_cursor_vcol, 4); in serialize_uhp()
1297 undo_write_bytes(bi, (long_u)uhp->uh_flags, 2); in serialize_uhp()
1300 serialize_pos(bi, uhp->uh_namedm[i]); in serialize_uhp()
1301 serialize_visualinfo(bi, &uhp->uh_visual); in serialize_uhp()
1302 time_to_bytes(uhp->uh_time, time_buf); in serialize_uhp()
1308 undo_write_bytes(bi, (long_u)uhp->uh_save_nr, 4); in serialize_uhp()
1313 for (uep = uhp->uh_entry; uep != NULL; uep = uep->ue_next) in serialize_uhp()
1326 u_header_T *uhp; in unserialize_uhp() local
1332 uhp = U_ALLOC_LINE(sizeof(u_header_T)); in unserialize_uhp()
1333 if (uhp == NULL) in unserialize_uhp()
1335 CLEAR_POINTER(uhp); in unserialize_uhp()
1337 uhp->uh_magic = UH_MAGIC; in unserialize_uhp()
1339 uhp->uh_next.seq = undo_read_4c(bi); in unserialize_uhp()
1340 uhp->uh_prev.seq = undo_read_4c(bi); in unserialize_uhp()
1341 uhp->uh_alt_next.seq = undo_read_4c(bi); in unserialize_uhp()
1342 uhp->uh_alt_prev.seq = undo_read_4c(bi); in unserialize_uhp()
1343 uhp->uh_seq = undo_read_4c(bi); in unserialize_uhp()
1344 if (uhp->uh_seq <= 0) in unserialize_uhp()
1347 vim_free(uhp); in unserialize_uhp()
1350 unserialize_pos(bi, &uhp->uh_cursor); in unserialize_uhp()
1351 uhp->uh_cursor_vcol = undo_read_4c(bi); in unserialize_uhp()
1352 uhp->uh_flags = undo_read_2c(bi); in unserialize_uhp()
1354 unserialize_pos(bi, &uhp->uh_namedm[i]); in unserialize_uhp()
1355 unserialize_visualinfo(bi, &uhp->uh_visual); in unserialize_uhp()
1356 uhp->uh_time = undo_read_time(bi); in unserialize_uhp()
1367 u_free_uhp(uhp); in unserialize_uhp()
1376 uhp->uh_save_nr = undo_read_4c(bi); in unserialize_uhp()
1392 uhp->uh_entry = uep; in unserialize_uhp()
1398 u_free_uhp(uhp); in unserialize_uhp()
1405 u_free_uhp(uhp); in unserialize_uhp()
1409 return uhp; in unserialize_uhp()
1562 u_header_T *uhp; in u_write_undo() local
1745 uhp = buf->b_u_oldhead; in u_write_undo()
1746 while (uhp != NULL) in u_write_undo()
1749 if (uhp->uh_walk != mark) in u_write_undo()
1751 uhp->uh_walk = mark; in u_write_undo()
1755 if (serialize_uhp(&bi, uhp) == FAIL) in u_write_undo()
1760 if (uhp->uh_prev.ptr != NULL && uhp->uh_prev.ptr->uh_walk != mark) in u_write_undo()
1761 uhp = uhp->uh_prev.ptr; in u_write_undo()
1762 else if (uhp->uh_alt_next.ptr != NULL in u_write_undo()
1763 && uhp->uh_alt_next.ptr->uh_walk != mark) in u_write_undo()
1764 uhp = uhp->uh_alt_next.ptr; in u_write_undo()
1765 else if (uhp->uh_next.ptr != NULL && uhp->uh_alt_prev.ptr == NULL in u_write_undo()
1766 && uhp->uh_next.ptr->uh_walk != mark) in u_write_undo()
1767 uhp = uhp->uh_next.ptr; in u_write_undo()
1768 else if (uhp->uh_alt_prev.ptr != NULL) in u_write_undo()
1769 uhp = uhp->uh_alt_prev.ptr; in u_write_undo()
1771 uhp = uhp->uh_next.ptr; in u_write_undo()
1853 u_header_T *uhp; in u_read_undo() local
2051 uhp = unserialize_uhp(&bi, file_name); in u_read_undo()
2052 if (uhp == NULL) in u_read_undo()
2054 uhp_table[num_read_uhps++] = uhp; in u_read_undo()
2080 uhp = uhp_table[i]; in u_read_undo()
2081 if (uhp == NULL) in u_read_undo()
2092 && uhp_table[j]->uh_seq == uhp->uh_next.seq) in u_read_undo()
2094 uhp->uh_next.ptr = uhp_table[j]; in u_read_undo()
2100 && uhp_table[j]->uh_seq == uhp->uh_prev.seq) in u_read_undo()
2102 uhp->uh_prev.ptr = uhp_table[j]; in u_read_undo()
2108 && uhp_table[j]->uh_seq == uhp->uh_alt_next.seq) in u_read_undo()
2110 uhp->uh_alt_next.ptr = uhp_table[j]; in u_read_undo()
2116 && uhp_table[j]->uh_seq == uhp->uh_alt_prev.seq) in u_read_undo()
2118 uhp->uh_alt_prev.ptr = uhp_table[j]; in u_read_undo()
2122 if (old_header_seq > 0 && old_idx < 0 && uhp->uh_seq == old_header_seq) in u_read_undo()
2127 if (new_header_seq > 0 && new_idx < 0 && uhp->uh_seq == new_header_seq) in u_read_undo()
2132 if (cur_header_seq > 0 && cur_idx < 0 && uhp->uh_seq == cur_header_seq) in u_read_undo()
2325 u_header_T *uhp = NULL; in undo_time() local
2362 uhp = curbuf->b_u_curhead; in undo_time()
2363 if (uhp != NULL) in undo_time()
2364 uhp = uhp->uh_next.ptr; in undo_time()
2366 uhp = curbuf->b_u_newhead; in undo_time()
2367 if (uhp != NULL && uhp->uh_save_nr != 0) in undo_time()
2440 uhp = curbuf->b_u_newhead; in undo_time()
2442 uhp = curbuf->b_u_curhead; in undo_time()
2444 while (uhp != NULL) in undo_time()
2446 uhp->uh_walk = mark; in undo_time()
2448 val = (long)(uhp->uh_time); in undo_time()
2450 val = uhp->uh_save_nr; in undo_time()
2452 val = uhp->uh_seq; in undo_time()
2460 if ((step < 0 ? uhp->uh_seq <= curbuf->b_u_seq_cur in undo_time()
2461 : uhp->uh_seq > curbuf->b_u_seq_cur) in undo_time()
2464 ? uhp->uh_seq < closest_seq in undo_time()
2465 : uhp->uh_seq > closest_seq) in undo_time()
2476 closest_seq = uhp->uh_seq; in undo_time()
2484 target = uhp->uh_seq; in undo_time()
2489 if (uhp->uh_prev.ptr != NULL && uhp->uh_prev.ptr->uh_walk != nomark in undo_time()
2490 && uhp->uh_prev.ptr->uh_walk != mark) in undo_time()
2491 uhp = uhp->uh_prev.ptr; in undo_time()
2494 else if (uhp->uh_alt_next.ptr != NULL in undo_time()
2495 && uhp->uh_alt_next.ptr->uh_walk != nomark in undo_time()
2496 && uhp->uh_alt_next.ptr->uh_walk != mark) in undo_time()
2497 uhp = uhp->uh_alt_next.ptr; in undo_time()
2501 else if (uhp->uh_next.ptr != NULL && uhp->uh_alt_prev.ptr == NULL in undo_time()
2502 && uhp->uh_next.ptr->uh_walk != nomark in undo_time()
2503 && uhp->uh_next.ptr->uh_walk != mark) in undo_time()
2506 if (uhp == curbuf->b_u_curhead) in undo_time()
2507 uhp->uh_walk = nomark; in undo_time()
2508 uhp = uhp->uh_next.ptr; in undo_time()
2514 uhp->uh_walk = nomark; in undo_time()
2515 if (uhp->uh_alt_prev.ptr != NULL) in undo_time()
2516 uhp = uhp->uh_alt_prev.ptr; in undo_time()
2518 uhp = uhp->uh_next.ptr; in undo_time()
2522 if (uhp != NULL) // found it in undo_time()
2549 if (uhp != NULL || target == 0) in undo_time()
2559 uhp = curbuf->b_u_curhead; in undo_time()
2560 if (uhp == NULL) in undo_time()
2561 uhp = curbuf->b_u_newhead; in undo_time()
2563 uhp = uhp->uh_next.ptr; in undo_time()
2564 if (uhp == NULL || (target > 0 && uhp->uh_walk != mark) in undo_time()
2565 || (uhp->uh_seq == target && !above)) in undo_time()
2567 curbuf->b_u_curhead = uhp; in undo_time()
2570 uhp->uh_walk = nomark; // don't go back down here in undo_time()
2584 uhp = curbuf->b_u_curhead; in undo_time()
2585 if (uhp == NULL) in undo_time()
2589 while (uhp->uh_alt_prev.ptr != NULL in undo_time()
2590 && uhp->uh_alt_prev.ptr->uh_walk == mark) in undo_time()
2591 uhp = uhp->uh_alt_prev.ptr; in undo_time()
2594 last = uhp; in undo_time()
2598 if (last != uhp) in undo_time()
2602 while (uhp->uh_alt_prev.ptr != NULL) in undo_time()
2603 uhp = uhp->uh_alt_prev.ptr; in undo_time()
2610 last->uh_alt_next.ptr = uhp; in undo_time()
2611 uhp->uh_alt_prev.ptr = last; in undo_time()
2613 if (curbuf->b_u_oldhead == uhp) in undo_time()
2615 uhp = last; in undo_time()
2616 if (uhp->uh_next.ptr != NULL) in undo_time()
2617 uhp->uh_next.ptr->uh_prev.ptr = uhp; in undo_time()
2619 curbuf->b_u_curhead = uhp; in undo_time()
2621 if (uhp->uh_walk != mark) in undo_time()
2626 if (uhp->uh_seq == target && above) in undo_time()
2636 if (uhp->uh_prev.ptr == NULL) in undo_time()
2637 curbuf->b_u_newhead = uhp; in undo_time()
2638 curbuf->b_u_curhead = uhp->uh_prev.ptr; in undo_time()
2641 if (uhp->uh_seq == target) // found it! in undo_time()
2644 uhp = uhp->uh_prev.ptr; in undo_time()
2645 if (uhp == NULL || uhp->uh_walk != mark) in undo_time()
2972 u_header_T *uhp; in u_undo_end() local
3010 uhp = curbuf->b_u_curhead->uh_next.ptr; in u_undo_end()
3014 uhp = curbuf->b_u_curhead; in u_undo_end()
3016 uhp = curbuf->b_u_curhead->uh_next.ptr; in u_undo_end()
3019 uhp = curbuf->b_u_newhead; in u_undo_end()
3021 if (uhp == NULL) in u_undo_end()
3024 add_time(msgbuf, sizeof(msgbuf), uhp->uh_time); in u_undo_end()
3042 uhp == NULL ? 0L : uhp->uh_seq, in u_undo_end()
3076 u_header_T *uhp; in ex_undolist() local
3091 uhp = curbuf->b_u_oldhead; in ex_undolist()
3092 while (uhp != NULL) in ex_undolist()
3094 if (uhp->uh_prev.ptr == NULL && uhp->uh_walk != nomark in ex_undolist()
3095 && uhp->uh_walk != mark) in ex_undolist()
3100 uhp->uh_seq, changes); in ex_undolist()
3102 uhp->uh_time); in ex_undolist()
3103 if (uhp->uh_save_nr > 0) in ex_undolist()
3108 " %3ld", uhp->uh_save_nr); in ex_undolist()
3113 uhp->uh_walk = mark; in ex_undolist()
3116 if (uhp->uh_prev.ptr != NULL && uhp->uh_prev.ptr->uh_walk != nomark in ex_undolist()
3117 && uhp->uh_prev.ptr->uh_walk != mark) in ex_undolist()
3119 uhp = uhp->uh_prev.ptr; in ex_undolist()
3124 else if (uhp->uh_alt_next.ptr != NULL in ex_undolist()
3125 && uhp->uh_alt_next.ptr->uh_walk != nomark in ex_undolist()
3126 && uhp->uh_alt_next.ptr->uh_walk != mark) in ex_undolist()
3127 uhp = uhp->uh_alt_next.ptr; in ex_undolist()
3131 else if (uhp->uh_next.ptr != NULL && uhp->uh_alt_prev.ptr == NULL in ex_undolist()
3132 && uhp->uh_next.ptr->uh_walk != nomark in ex_undolist()
3133 && uhp->uh_next.ptr->uh_walk != mark) in ex_undolist()
3135 uhp = uhp->uh_next.ptr; in ex_undolist()
3142 uhp->uh_walk = nomark; in ex_undolist()
3143 if (uhp->uh_alt_prev.ptr != NULL) in ex_undolist()
3144 uhp = uhp->uh_alt_prev.ptr; in ex_undolist()
3147 uhp = uhp->uh_next.ptr; in ex_undolist()
3215 u_header_T *uhp = curbuf->b_u_newhead; in u_find_first_changed() local
3219 if (curbuf->b_u_curhead != NULL || uhp == NULL) in u_find_first_changed()
3223 uep = uhp->uh_entry; in u_find_first_changed()
3235 CLEAR_POS(&(uhp->uh_cursor)); in u_find_first_changed()
3236 uhp->uh_cursor.lnum = lnum; in u_find_first_changed()
3243 CLEAR_POS(&(uhp->uh_cursor)); in u_find_first_changed()
3244 uhp->uh_cursor.lnum = lnum; in u_find_first_changed()
3255 u_header_T *uhp; in u_update_save_nr() local
3259 uhp = buf->b_u_curhead; in u_update_save_nr()
3260 if (uhp != NULL) in u_update_save_nr()
3261 uhp = uhp->uh_next.ptr; in u_update_save_nr()
3263 uhp = buf->b_u_newhead; in u_update_save_nr()
3264 if (uhp != NULL) in u_update_save_nr()
3265 uhp->uh_save_nr = buf->b_u_save_nr_last; in u_update_save_nr()
3269 u_unch_branch(u_header_T *uhp) in u_unch_branch() argument
3273 for (uh = uhp; uh != NULL; uh = uh->uh_prev.ptr) in u_unch_branch()
3341 u_header_T *uhp, in u_freeheader() argument
3348 if (uhp->uh_alt_next.ptr != NULL) in u_freeheader()
3349 u_freebranch(buf, uhp->uh_alt_next.ptr, uhpp); in u_freeheader()
3351 if (uhp->uh_alt_prev.ptr != NULL) in u_freeheader()
3352 uhp->uh_alt_prev.ptr->uh_alt_next.ptr = NULL; in u_freeheader()
3355 if (uhp->uh_next.ptr == NULL) in u_freeheader()
3356 buf->b_u_oldhead = uhp->uh_prev.ptr; in u_freeheader()
3358 uhp->uh_next.ptr->uh_prev.ptr = uhp->uh_prev.ptr; in u_freeheader()
3360 if (uhp->uh_prev.ptr == NULL) in u_freeheader()
3361 buf->b_u_newhead = uhp->uh_next.ptr; in u_freeheader()
3363 for (uhap = uhp->uh_prev.ptr; uhap != NULL; in u_freeheader()
3365 uhap->uh_next.ptr = uhp->uh_next.ptr; in u_freeheader()
3367 u_freeentries(buf, uhp, uhpp); in u_freeheader()
3376 u_header_T *uhp, in u_freebranch() argument
3383 if (uhp == buf->b_u_oldhead) in u_freebranch()
3390 if (uhp->uh_alt_prev.ptr != NULL) in u_freebranch()
3391 uhp->uh_alt_prev.ptr->uh_alt_next.ptr = NULL; in u_freebranch()
3393 next = uhp; in u_freebranch()
3411 u_header_T *uhp, in u_freeentries() argument
3417 if (buf->b_u_curhead == uhp) in u_freeentries()
3419 if (buf->b_u_newhead == uhp) in u_freeentries()
3421 if (uhpp != NULL && uhp == *uhpp) in u_freeentries()
3424 for (uep = uhp->uh_entry; uep != NULL; uep = nuep) in u_freeentries()
3431 uhp->uh_magic = 0; in u_freeentries()
3433 vim_free((char_u *)uhp); in u_freeentries()
3614 u_header_T *uhp = first_uhp; in u_eval_tree() local
3617 while (uhp != NULL) in u_eval_tree()
3622 dict_add_number(dict, "seq", uhp->uh_seq); in u_eval_tree()
3623 dict_add_number(dict, "time", (long)uhp->uh_time); in u_eval_tree()
3624 if (uhp == curbuf->b_u_newhead) in u_eval_tree()
3626 if (uhp == curbuf->b_u_curhead) in u_eval_tree()
3628 if (uhp->uh_save_nr > 0) in u_eval_tree()
3629 dict_add_number(dict, "save", uhp->uh_save_nr); in u_eval_tree()
3631 if (uhp->uh_alt_next.ptr != NULL) in u_eval_tree()
3638 u_eval_tree(uhp->uh_alt_next.ptr, alt_list); in u_eval_tree()
3644 uhp = uhp->uh_prev.ptr; in u_eval_tree()