aboutsummaryrefslogtreecommitdiff
path: root/src/nvim/shada.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/nvim/shada.c')
-rw-r--r--src/nvim/shada.c36
1 files changed, 29 insertions, 7 deletions
diff --git a/src/nvim/shada.c b/src/nvim/shada.c
index 6e80b550d8..d2f1b39ca4 100644
--- a/src/nvim/shada.c
+++ b/src/nvim/shada.c
@@ -16,11 +16,12 @@
#include "nvim/ascii.h"
#include "nvim/buffer.h"
#include "nvim/buffer_defs.h"
+#include "nvim/cmdhist.h"
#include "nvim/eval/decode.h"
#include "nvim/eval/encode.h"
#include "nvim/eval/typval.h"
+#include "nvim/ex_cmds.h"
#include "nvim/ex_docmd.h"
-#include "nvim/ex_getln.h"
#include "nvim/fileio.h"
#include "nvim/garray.h"
#include "nvim/globals.h"
@@ -1476,7 +1477,7 @@ static char *shada_filename(const char *file)
// because various expansions must have already be done by the shell.
// If shell is not performing them then they should be done in main.c
// where arguments are parsed, *not here*.
- expand_env((char_u *)file, &(NameBuff[0]), MAXPATHL);
+ expand_env((char *)file, &(NameBuff[0]), MAXPATHL);
file = (const char *)&(NameBuff[0]);
}
}
@@ -2188,7 +2189,7 @@ static inline ShaDaWriteResult shada_read_when_writing(ShaDaReadDef *const sd_re
k = kh_put(file_marks, &wms->file_marks, fname, &kh_ret);
FileMarks *const filemarks = &kh_val(&wms->file_marks, k);
if (kh_ret > 0) {
- memset(filemarks, 0, sizeof(*filemarks));
+ CLEAR_POINTER(filemarks);
}
if (entry.timestamp > filemarks->greatest_timestamp) {
filemarks->greatest_timestamp = entry.timestamp;
@@ -2451,6 +2452,27 @@ static inline void find_removable_bufs(khash_t(bufset) *removable_bufs)
}
}
+/// Translate a history type number to the associated character
+static int hist_type2char(const int type)
+ FUNC_ATTR_CONST
+{
+ switch (type) {
+ case HIST_CMD:
+ return ':';
+ case HIST_SEARCH:
+ return '/';
+ case HIST_EXPR:
+ return '=';
+ case HIST_INPUT:
+ return '@';
+ case HIST_DEBUG:
+ return '>';
+ default:
+ abort();
+ }
+ return NUL;
+}
+
/// Write ShaDa file
///
/// @param[in] sd_writer Structure containing file writer definition.
@@ -2730,7 +2752,7 @@ static ShaDaWriteResult shada_write(ShaDaWriteDef *const sd_writer, ShaDaReadDef
k = kh_put(file_marks, &wms->file_marks, fname, &kh_ret);
FileMarks *const filemarks = &kh_val(&wms->file_marks, k);
if (kh_ret > 0) {
- memset(filemarks, 0, sizeof(*filemarks));
+ CLEAR_POINTER(filemarks);
}
do {
fmark_T fm;
@@ -3001,7 +3023,7 @@ shada_write_file_nomerge: {}
if (tail != fname) {
const char tail_save = *tail;
*tail = NUL;
- if (!os_isdir((char_u *)fname)) {
+ if (!os_isdir(fname)) {
int ret;
char *failed_dir;
if ((ret = os_mkdir_recurse(fname, 0700, &failed_dir)) != 0) {
@@ -3456,7 +3478,7 @@ shada_read_next_item_start:
// data union are NULL so they are safe to xfree(). This is needed in case
// somebody calls goto shada_read_next_item_error before anything is set in
// the switch.
- memset(entry, 0, sizeof(*entry));
+ CLEAR_POINTER(entry);
if (sd_reader->eof) {
return kSDReadStatusFinished;
}
@@ -3974,7 +3996,7 @@ static bool shada_removable(const char *name)
bool retval = false;
char *new_name = home_replace_save(NULL, (char *)name);
- for (p = (char *)p_shada; *p;) {
+ for (p = p_shada; *p;) {
(void)copy_option_part(&p, part, ARRAY_SIZE(part), ", ");
if (part[0] == 'r') {
home_replace(NULL, part + 1, (char *)NameBuff, MAXPATHL, true);