Mercurial > vim
comparison src/ex_getln.c @ 9272:f5d9eb512f8b v7.4.1919
commit https://github.com/vim/vim/commit/46bbb0c4ba27395859dfeaa26938483946bb4ec2
Author: Bram Moolenaar <Bram@vim.org>
Date: Sat Jun 11 21:04:39 2016 +0200
patch 7.4.1919
Problem: Register contents is not merged when writing viminfo.
Solution: Use timestamps for register contents.
author | Christian Brabandt <cb@256bit.org> |
---|---|
date | Sat, 11 Jun 2016 21:15:05 +0200 |
parents | 79cb08f0d812 |
children | af25a1a875db |
comparison
equal
deleted
inserted
replaced
9271:d10d373d488e | 9272:f5d9eb512f8b |
---|---|
5406 "input", | 5406 "input", |
5407 "debug", | 5407 "debug", |
5408 NULL | 5408 NULL |
5409 }; | 5409 }; |
5410 | 5410 |
5411 /* | |
5412 * Return the current time in seconds. Calls time(), unless test_settime() | |
5413 * was used. | |
5414 */ | |
5415 static time_t | |
5416 vim_time(void) | |
5417 { | |
5418 #ifdef FEAT_EVAL | |
5419 return time_for_testing == 0 ? time(NULL) : time_for_testing; | |
5420 #else | |
5421 return time(NULL); | |
5422 #endif | |
5423 } | |
5424 | |
5425 #if defined(FEAT_CMDL_COMPL) || defined(PROTO) | 5411 #if defined(FEAT_CMDL_COMPL) || defined(PROTO) |
5426 /* | 5412 /* |
5427 * Function given to ExpandGeneric() to obtain the possible first | 5413 * Function given to ExpandGeneric() to obtain the possible first |
5428 * arguments of the ":history command. | 5414 * arguments of the ":history command. |
5429 */ | 5415 */ |
6278 * Accept a new style history line from the viminfo, store it in the history | 6264 * Accept a new style history line from the viminfo, store it in the history |
6279 * array when it's new. | 6265 * array when it's new. |
6280 */ | 6266 */ |
6281 void | 6267 void |
6282 handle_viminfo_history( | 6268 handle_viminfo_history( |
6283 bval_T *values, | 6269 garray_T *values, |
6284 int count, | 6270 int writing) |
6285 int writing) | |
6286 { | 6271 { |
6287 int type; | 6272 int type; |
6288 long_u len; | 6273 long_u len; |
6289 char_u *val; | 6274 char_u *val; |
6290 char_u *p; | 6275 char_u *p; |
6276 bval_T *vp = (bval_T *)values->ga_data; | |
6291 | 6277 |
6292 /* Check the format: | 6278 /* Check the format: |
6293 * |{bartype},{histtype},{timestamp},{separator},"text" */ | 6279 * |{bartype},{histtype},{timestamp},{separator},"text" */ |
6294 if (count < 4 | 6280 if (values->ga_len < 4 |
6295 || values[0].bv_type != BVAL_NR | 6281 || vp[0].bv_type != BVAL_NR |
6296 || values[1].bv_type != BVAL_NR | 6282 || vp[1].bv_type != BVAL_NR |
6297 || (values[2].bv_type != BVAL_NR && values[2].bv_type != BVAL_EMPTY) | 6283 || (vp[2].bv_type != BVAL_NR && vp[2].bv_type != BVAL_EMPTY) |
6298 || values[3].bv_type != BVAL_STRING) | 6284 || vp[3].bv_type != BVAL_STRING) |
6299 return; | 6285 return; |
6300 | 6286 |
6301 type = values[0].bv_nr; | 6287 type = vp[0].bv_nr; |
6302 if (type >= HIST_COUNT) | 6288 if (type >= HIST_COUNT) |
6303 return; | 6289 return; |
6304 if (viminfo_hisidx[type] < viminfo_hislen[type]) | 6290 if (viminfo_hisidx[type] < viminfo_hislen[type]) |
6305 { | 6291 { |
6306 val = values[3].bv_string; | 6292 val = vp[3].bv_string; |
6307 if (val != NULL && *val != NUL) | 6293 if (val != NULL && *val != NUL) |
6308 { | 6294 { |
6309 int sep = type == HIST_SEARCH && values[2].bv_type == BVAL_NR | 6295 int sep = type == HIST_SEARCH && vp[2].bv_type == BVAL_NR |
6310 ? values[2].bv_nr : NUL; | 6296 ? vp[2].bv_nr : NUL; |
6311 int idx; | 6297 int idx; |
6312 int overwrite = FALSE; | 6298 int overwrite = FALSE; |
6313 | 6299 |
6314 if (!in_history(type, val, viminfo_add_at_front, sep, writing)) | 6300 if (!in_history(type, val, viminfo_add_at_front, sep, writing)) |
6315 { | 6301 { |
6327 } | 6313 } |
6328 | 6314 |
6329 if (!overwrite) | 6315 if (!overwrite) |
6330 { | 6316 { |
6331 /* Need to re-allocate to append the separator byte. */ | 6317 /* Need to re-allocate to append the separator byte. */ |
6332 len = values[3].bv_len; | 6318 len = vp[3].bv_len; |
6333 p = lalloc(len + 2, TRUE); | 6319 p = lalloc(len + 2, TRUE); |
6334 } | 6320 } |
6335 if (p != NULL) | 6321 if (p != NULL) |
6336 { | 6322 { |
6337 viminfo_history[type][idx].time_set = values[1].bv_nr; | 6323 viminfo_history[type][idx].time_set = vp[1].bv_nr; |
6338 if (!overwrite) | 6324 if (!overwrite) |
6339 { | 6325 { |
6340 mch_memmove(p, val, (size_t)len + 1); | 6326 mch_memmove(p, val, (size_t)len + 1); |
6341 /* Put the separator after the NUL. */ | 6327 /* Put the separator after the NUL. */ |
6342 p[len + 1] = sep; | 6328 p[len + 1] = sep; |