mirror of
https://github.com/neovim/neovim.git
synced 2025-10-05 09:26:30 +00:00
shada: Fix all linter errors in src/nvim/shada.*
This commit is an example of fixing incorrect code which previously passed through linter.
This commit is contained in:
305
src/nvim/shada.c
305
src/nvim/shada.c
@@ -205,11 +205,11 @@ enum SRNIFlags {
|
|||||||
kSDReadHeader = (1 << kSDItemHeader), ///< Determines whether header should
|
kSDReadHeader = (1 << kSDItemHeader), ///< Determines whether header should
|
||||||
///< be read (it is usually ignored).
|
///< be read (it is usually ignored).
|
||||||
kSDReadUndisableableData = (
|
kSDReadUndisableableData = (
|
||||||
(1 << kSDItemSearchPattern)
|
(1 << kSDItemSearchPattern)
|
||||||
| (1 << kSDItemSubString)
|
| (1 << kSDItemSubString)
|
||||||
| (1 << kSDItemJump)), ///< Data reading which cannot be disabled by &shada
|
| (1 << kSDItemJump)), ///< Data reading which cannot be disabled by
|
||||||
///< or other options except for disabling reading
|
///< &shada or other options except for disabling
|
||||||
///< ShaDa as a whole.
|
///< reading ShaDa as a whole.
|
||||||
kSDReadRegisters = (1 << kSDItemRegister), ///< Determines whether registers
|
kSDReadRegisters = (1 << kSDItemRegister), ///< Determines whether registers
|
||||||
///< should be read (may only be
|
///< should be read (may only be
|
||||||
///< disabled when writing, but
|
///< disabled when writing, but
|
||||||
@@ -446,7 +446,7 @@ typedef struct sd_write_def {
|
|||||||
.attr = { __VA_ARGS__ } \
|
.attr = { __VA_ARGS__ } \
|
||||||
} \
|
} \
|
||||||
}
|
}
|
||||||
#define DEFAULT_POS {1, 0, 0}
|
#define DEFAULT_POS { 1, 0, 0 }
|
||||||
static const pos_T default_pos = DEFAULT_POS;
|
static const pos_T default_pos = DEFAULT_POS;
|
||||||
static const ShadaEntry sd_default_values[] = {
|
static const ShadaEntry sd_default_values[] = {
|
||||||
[kSDItemMissing] = { .type = kSDItemMissing, .timestamp = 0 },
|
[kSDItemMissing] = { .type = kSDItemMissing, .timestamp = 0 },
|
||||||
@@ -533,11 +533,14 @@ static inline void hmll_init(HMLList *const hmll, const size_t size)
|
|||||||
///
|
///
|
||||||
/// @param hmll Pointer to the list.
|
/// @param hmll Pointer to the list.
|
||||||
/// @param cur_entry Name of the variable to iterate over.
|
/// @param cur_entry Name of the variable to iterate over.
|
||||||
|
/// @param code Code to execute on each iteration.
|
||||||
///
|
///
|
||||||
/// @return `for` cycle header (use `HMLL_FORALL(hmll, cur_entry) {body}`).
|
/// @return `for` cycle header (use `HMLL_FORALL(hmll, cur_entry) {body}`).
|
||||||
#define HMLL_FORALL(hmll, cur_entry) \
|
#define HMLL_FORALL(hmll, cur_entry, code) \
|
||||||
for (HMLListEntry *cur_entry = (hmll)->first; cur_entry != NULL; \
|
for (HMLListEntry *cur_entry = (hmll)->first; cur_entry != NULL; \
|
||||||
cur_entry = cur_entry->next)
|
cur_entry = cur_entry->next) { \
|
||||||
|
code \
|
||||||
|
} \
|
||||||
|
|
||||||
/// Remove entry from the linked list
|
/// Remove entry from the linked list
|
||||||
///
|
///
|
||||||
@@ -633,11 +636,14 @@ static inline void hmll_insert(HMLList *const hmll,
|
|||||||
/// @param hmll Pointer to the list.
|
/// @param hmll Pointer to the list.
|
||||||
/// @param cur_entry Name of the variable to iterate over, must be already
|
/// @param cur_entry Name of the variable to iterate over, must be already
|
||||||
/// defined.
|
/// defined.
|
||||||
|
/// @param code Code to execute on each iteration.
|
||||||
///
|
///
|
||||||
/// @return `for` cycle header (use `HMLL_FORALL(hmll, cur_entry) {body}`).
|
/// @return `for` cycle header (use `HMLL_FORALL(hmll, cur_entry) {body}`).
|
||||||
#define HMLL_ITER_BACK(hmll, cur_entry) \
|
#define HMLL_ITER_BACK(hmll, cur_entry, code) \
|
||||||
for (cur_entry = (hmll)->last; cur_entry != NULL; \
|
for (cur_entry = (hmll)->last; cur_entry != NULL; \
|
||||||
cur_entry = cur_entry->prev)
|
cur_entry = cur_entry->prev) { \
|
||||||
|
code \
|
||||||
|
}
|
||||||
|
|
||||||
/// Free linked list
|
/// Free linked list
|
||||||
///
|
///
|
||||||
@@ -959,11 +965,11 @@ static int shada_read_file(const char *const file, const int flags)
|
|||||||
if (p_verbose > 0) {
|
if (p_verbose > 0) {
|
||||||
verbose_enter();
|
verbose_enter();
|
||||||
smsg(_("Reading ShaDa file \"%s\"%s%s%s"),
|
smsg(_("Reading ShaDa file \"%s\"%s%s%s"),
|
||||||
fname,
|
fname,
|
||||||
(flags & kShaDaWantInfo) ? _(" info") : "",
|
(flags & kShaDaWantInfo) ? _(" info") : "",
|
||||||
(flags & kShaDaWantMarks) ? _(" marks") : "",
|
(flags & kShaDaWantMarks) ? _(" marks") : "",
|
||||||
(flags & kShaDaGetOldfiles) ? _(" oldfiles") : "",
|
(flags & kShaDaGetOldfiles) ? _(" oldfiles") : "",
|
||||||
of_ret != 0 ? _(" FAILED") : "");
|
of_ret != 0 ? _(" FAILED") : "");
|
||||||
verbose_leave();
|
verbose_leave();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1011,8 +1017,8 @@ static const void *shada_hist_iter(const void *const iter,
|
|||||||
.histtype = history_type,
|
.histtype = history_type,
|
||||||
.string = (char *) hist_he.hisstr,
|
.string = (char *) hist_he.hisstr,
|
||||||
.sep = (char) (history_type == HIST_SEARCH
|
.sep = (char) (history_type == HIST_SEARCH
|
||||||
? (char) hist_he.hisstr[STRLEN(hist_he.hisstr) + 1]
|
? (char) hist_he.hisstr[STRLEN(hist_he.hisstr) + 1]
|
||||||
: 0),
|
: 0),
|
||||||
.additional_elements = hist_he.additional_elements,
|
.additional_elements = hist_he.additional_elements,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1074,11 +1080,11 @@ static void hms_insert(HistoryMergerState *const hms_p, const ShadaEntry entry,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
HMLListEntry *insert_after;
|
HMLListEntry *insert_after;
|
||||||
HMLL_ITER_BACK(hmll, insert_after) {
|
HMLL_ITER_BACK(hmll, insert_after, {
|
||||||
if (insert_after->data.timestamp <= entry.timestamp) {
|
if (insert_after->data.timestamp <= entry.timestamp) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
})
|
||||||
hmll_insert(hmll, insert_after, entry, can_free_entry);
|
hmll_insert(hmll, insert_after, entry, can_free_entry);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1136,14 +1142,14 @@ static inline void hms_to_he_array(const HistoryMergerState *const hms_p,
|
|||||||
FUNC_ATTR_NONNULL_ALL
|
FUNC_ATTR_NONNULL_ALL
|
||||||
{
|
{
|
||||||
histentry_T *hist = hist_array;
|
histentry_T *hist = hist_array;
|
||||||
HMLL_FORALL(&hms_p->hmll, cur_entry) {
|
HMLL_FORALL(&hms_p->hmll, cur_entry, {
|
||||||
hist->timestamp = cur_entry->data.timestamp;
|
hist->timestamp = cur_entry->data.timestamp;
|
||||||
hist->hisnum = (int) (hist - hist_array) + 1;
|
hist->hisnum = (int) (hist - hist_array) + 1;
|
||||||
hist->hisstr = (char_u *) cur_entry->data.data.history_item.string;
|
hist->hisstr = (char_u *) cur_entry->data.data.history_item.string;
|
||||||
hist->additional_elements =
|
hist->additional_elements =
|
||||||
cur_entry->data.data.history_item.additional_elements;
|
cur_entry->data.data.history_item.additional_elements;
|
||||||
hist++;
|
hist++;
|
||||||
}
|
})
|
||||||
*new_hisnum = (int) (hist - hist_array);
|
*new_hisnum = (int) (hist - hist_array);
|
||||||
*new_hisidx = *new_hisnum - 1;
|
*new_hisidx = *new_hisnum - 1;
|
||||||
}
|
}
|
||||||
@@ -1161,10 +1167,11 @@ static inline void hms_dealloc(HistoryMergerState *const hms_p)
|
|||||||
///
|
///
|
||||||
/// @param[in] hms_p Merger structure to iterate over.
|
/// @param[in] hms_p Merger structure to iterate over.
|
||||||
/// @param[out] cur_entry Name of the iterator variable.
|
/// @param[out] cur_entry Name of the iterator variable.
|
||||||
|
/// @param code Code to execute on each iteration.
|
||||||
///
|
///
|
||||||
/// @return for cycle header. Use `HMS_ITER(hms_p, cur_entry) {body}`.
|
/// @return for cycle header. Use `HMS_ITER(hms_p, cur_entry) {body}`.
|
||||||
#define HMS_ITER(hms_p, cur_entry) \
|
#define HMS_ITER(hms_p, cur_entry, code) \
|
||||||
HMLL_FORALL(&((hms_p)->hmll), cur_entry)
|
HMLL_FORALL(&((hms_p)->hmll), cur_entry, code)
|
||||||
|
|
||||||
/// Find buffer for given buffer name (cached)
|
/// Find buffer for given buffer name (cached)
|
||||||
///
|
///
|
||||||
@@ -1341,18 +1348,18 @@ static void shada_read(ShaDaReadDef *const sd_reader, const int flags)
|
|||||||
(cur_entry.data.search_pattern.is_substitute_pattern
|
(cur_entry.data.search_pattern.is_substitute_pattern
|
||||||
? &set_substitute_pattern
|
? &set_substitute_pattern
|
||||||
: &set_search_pattern)((SearchPattern) {
|
: &set_search_pattern)((SearchPattern) {
|
||||||
.magic = cur_entry.data.search_pattern.magic,
|
.magic = cur_entry.data.search_pattern.magic,
|
||||||
.no_scs = !cur_entry.data.search_pattern.smartcase,
|
.no_scs = !cur_entry.data.search_pattern.smartcase,
|
||||||
.off = {
|
.off = {
|
||||||
.dir = cur_entry.data.search_pattern.search_backward ? '?' : '/',
|
.dir = cur_entry.data.search_pattern.search_backward ? '?' : '/',
|
||||||
.line = cur_entry.data.search_pattern.has_line_offset,
|
.line = cur_entry.data.search_pattern.has_line_offset,
|
||||||
.end = cur_entry.data.search_pattern.place_cursor_at_end,
|
.end = cur_entry.data.search_pattern.place_cursor_at_end,
|
||||||
.off = cur_entry.data.search_pattern.offset,
|
.off = cur_entry.data.search_pattern.offset,
|
||||||
},
|
},
|
||||||
.pat = (char_u *) cur_entry.data.search_pattern.pat,
|
.pat = (char_u *) cur_entry.data.search_pattern.pat,
|
||||||
.additional_data = cur_entry.data.search_pattern.additional_data,
|
.additional_data = cur_entry.data.search_pattern.additional_data,
|
||||||
.timestamp = cur_entry.timestamp,
|
.timestamp = cur_entry.timestamp,
|
||||||
});
|
});
|
||||||
if (cur_entry.data.search_pattern.is_last_used) {
|
if (cur_entry.data.search_pattern.is_last_used) {
|
||||||
set_last_used_pattern(
|
set_last_used_pattern(
|
||||||
cur_entry.data.search_pattern.is_substitute_pattern);
|
cur_entry.data.search_pattern.is_substitute_pattern);
|
||||||
@@ -2430,13 +2437,13 @@ static ShaDaWriteResult shada_write(ShaDaWriteDef *const sd_writer,
|
|||||||
}
|
}
|
||||||
|
|
||||||
const unsigned srni_flags = (unsigned) (
|
const unsigned srni_flags = (unsigned) (
|
||||||
kSDReadUndisableableData
|
kSDReadUndisableableData
|
||||||
| kSDReadUnknown
|
| kSDReadUnknown
|
||||||
| (dump_history ? kSDReadHistory : 0)
|
| (dump_history ? kSDReadHistory : 0)
|
||||||
| (dump_registers ? kSDReadRegisters : 0)
|
| (dump_registers ? kSDReadRegisters : 0)
|
||||||
| (dump_global_vars ? kSDReadVariables : 0)
|
| (dump_global_vars ? kSDReadVariables : 0)
|
||||||
| (dump_global_marks ? kSDReadGlobalMarks : 0)
|
| (dump_global_marks ? kSDReadGlobalMarks : 0)
|
||||||
| (num_marked_files ? kSDReadLocalMarks | kSDReadChanges : 0));
|
| (num_marked_files ? kSDReadLocalMarks | kSDReadChanges : 0));
|
||||||
|
|
||||||
msgpack_packer *const packer = msgpack_packer_new(sd_writer,
|
msgpack_packer *const packer = msgpack_packer_new(sd_writer,
|
||||||
&msgpack_sd_writer_write);
|
&msgpack_sd_writer_write);
|
||||||
@@ -2895,16 +2902,16 @@ static ShaDaWriteResult shada_write(ShaDaWriteDef *const sd_writer,
|
|||||||
for (size_t i = 0; i < HIST_COUNT; i++) {
|
for (size_t i = 0; i < HIST_COUNT; i++) {
|
||||||
if (dump_one_history[i]) {
|
if (dump_one_history[i]) {
|
||||||
hms_insert_whole_neovim_history(&wms->hms[i]);
|
hms_insert_whole_neovim_history(&wms->hms[i]);
|
||||||
HMS_ITER(&wms->hms[i], cur_entry) {
|
HMS_ITER(&wms->hms[i], cur_entry, {
|
||||||
if (!shada_pack_encoded_entry(
|
if (!shada_pack_encoded_entry(
|
||||||
packer, &sd_writer->sd_conv, (PossiblyFreedShadaEntry) {
|
packer, &sd_writer->sd_conv, (PossiblyFreedShadaEntry) {
|
||||||
.data = cur_entry->data,
|
.data = cur_entry->data,
|
||||||
.can_free_entry = cur_entry->can_free_entry,
|
.can_free_entry = cur_entry->can_free_entry,
|
||||||
}, max_kbyte)) {
|
}, max_kbyte)) {
|
||||||
ret = kSDWriteFailed;
|
ret = kSDWriteFailed;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
})
|
||||||
hms_dealloc(&wms->hms[i]);
|
hms_dealloc(&wms->hms[i]);
|
||||||
if (ret == kSDWriteFailed) {
|
if (ret == kSDWriteFailed) {
|
||||||
goto shada_write_exit;
|
goto shada_write_exit;
|
||||||
@@ -3355,8 +3362,8 @@ static inline char *get_converted_string(const vimconv_T *const sd_conv,
|
|||||||
entry_name " entry at position %" PRIu64 " " \
|
entry_name " entry at position %" PRIu64 " " \
|
||||||
error_desc
|
error_desc
|
||||||
#define CHECK_KEY(key, expected) ( \
|
#define CHECK_KEY(key, expected) ( \
|
||||||
key.via.str.size == sizeof(expected) - 1 \
|
key.via.str.size == sizeof(expected) - 1 \
|
||||||
&& STRNCMP(key.via.str.ptr, expected, sizeof(expected) - 1) == 0)
|
&& STRNCMP(key.via.str.ptr, expected, sizeof(expected) - 1) == 0)
|
||||||
#define CLEAR_GA_AND_ERROR_OUT(ga) \
|
#define CLEAR_GA_AND_ERROR_OUT(ga) \
|
||||||
do { \
|
do { \
|
||||||
ga_clear(&ga); \
|
ga_clear(&ga); \
|
||||||
@@ -3379,18 +3386,17 @@ static inline char *get_converted_string(const vimconv_T *const sd_conv,
|
|||||||
tgt = proc(obj.via.attr); \
|
tgt = proc(obj.via.attr); \
|
||||||
} while (0)
|
} while (0)
|
||||||
#define CHECK_KEY_IS_STR(entry_name) \
|
#define CHECK_KEY_IS_STR(entry_name) \
|
||||||
do { \
|
if (unpacked.data.via.map.ptr[i].key.type != MSGPACK_OBJECT_STR) { \
|
||||||
if (unpacked.data.via.map.ptr[i].key.type != MSGPACK_OBJECT_STR) { \
|
emsgu(_(READERR(entry_name, "has key which is not a string")), \
|
||||||
emsgu(_(READERR(entry_name, "has key which is not a string")), \
|
initial_fpos); \
|
||||||
initial_fpos); \
|
CLEAR_GA_AND_ERROR_OUT(ad_ga); \
|
||||||
CLEAR_GA_AND_ERROR_OUT(ad_ga); \
|
} else if (unpacked.data.via.map.ptr[i].key.via.str.size == 0) { \
|
||||||
} else if (unpacked.data.via.map.ptr[i].key.via.str.size == 0) { \
|
emsgu(_(READERR(entry_name, "has empty key")), initial_fpos); \
|
||||||
emsgu(_(READERR(entry_name, "has empty key")), initial_fpos); \
|
CLEAR_GA_AND_ERROR_OUT(ad_ga); \
|
||||||
CLEAR_GA_AND_ERROR_OUT(ad_ga); \
|
}
|
||||||
} \
|
|
||||||
} while (0)
|
|
||||||
#define CHECKED_KEY(entry_name, name, error_desc, tgt, condition, attr, proc) \
|
#define CHECKED_KEY(entry_name, name, error_desc, tgt, condition, attr, proc) \
|
||||||
if (CHECK_KEY(unpacked.data.via.map.ptr[i].key, name)) { \
|
else if (CHECK_KEY( /* NOLINT(readability/braces) */ \
|
||||||
|
unpacked.data.via.map.ptr[i].key, name)) { \
|
||||||
CHECKED_ENTRY( \
|
CHECKED_ENTRY( \
|
||||||
condition, "has " name " key value " error_desc, \
|
condition, "has " name " key value " error_desc, \
|
||||||
entry_name, unpacked.data.via.map.ptr[i].val, \
|
entry_name, unpacked.data.via.map.ptr[i].val, \
|
||||||
@@ -3410,17 +3416,17 @@ static inline char *get_converted_string(const vimconv_T *const sd_conv,
|
|||||||
#define INT_KEY(entry_name, name, tgt, proc) \
|
#define INT_KEY(entry_name, name, tgt, proc) \
|
||||||
CHECKED_KEY( \
|
CHECKED_KEY( \
|
||||||
entry_name, name, "which is not an integer", tgt, \
|
entry_name, name, "which is not an integer", tgt, \
|
||||||
(unpacked.data.via.map.ptr[i].val.type \
|
((unpacked.data.via.map.ptr[i].val.type \
|
||||||
== MSGPACK_OBJECT_POSITIVE_INTEGER \
|
== MSGPACK_OBJECT_POSITIVE_INTEGER) \
|
||||||
|| unpacked.data.via.map.ptr[i].val.type \
|
|| (unpacked.data.via.map.ptr[i].val.type \
|
||||||
== MSGPACK_OBJECT_NEGATIVE_INTEGER), \
|
== MSGPACK_OBJECT_NEGATIVE_INTEGER)), \
|
||||||
i64, proc)
|
i64, proc)
|
||||||
#define INTEGER_KEY(entry_name, name, tgt) \
|
#define INTEGER_KEY(entry_name, name, tgt) \
|
||||||
INT_KEY(entry_name, name, tgt, TOINT)
|
INT_KEY(entry_name, name, tgt, TOINT)
|
||||||
#define LONG_KEY(entry_name, name, tgt) \
|
#define LONG_KEY(entry_name, name, tgt) \
|
||||||
INT_KEY(entry_name, name, tgt, TOLONG)
|
INT_KEY(entry_name, name, tgt, TOLONG)
|
||||||
#define ADDITIONAL_KEY \
|
#define ADDITIONAL_KEY \
|
||||||
{ \
|
else { /* NOLINT(readability/braces) */ \
|
||||||
ga_grow(&ad_ga, 1); \
|
ga_grow(&ad_ga, 1); \
|
||||||
memcpy(((char *)ad_ga.ga_data) + ((size_t) ad_ga.ga_len \
|
memcpy(((char *)ad_ga.ga_data) + ((size_t) ad_ga.ga_len \
|
||||||
* sizeof(*unpacked.data.via.map.ptr)), \
|
* sizeof(*unpacked.data.via.map.ptr)), \
|
||||||
@@ -3429,9 +3435,9 @@ static inline char *get_converted_string(const vimconv_T *const sd_conv,
|
|||||||
ad_ga.ga_len++; \
|
ad_ga.ga_len++; \
|
||||||
}
|
}
|
||||||
#define CONVERTED(str, len) ( \
|
#define CONVERTED(str, len) ( \
|
||||||
sd_reader->sd_conv.vc_type != CONV_NONE \
|
sd_reader->sd_conv.vc_type != CONV_NONE \
|
||||||
? get_converted_string(&sd_reader->sd_conv, (str), (len)) \
|
? get_converted_string(&sd_reader->sd_conv, (str), (len)) \
|
||||||
: xmemdupz((str), (len)))
|
: xmemdupz((str), (len)))
|
||||||
#define BIN_CONVERTED(b) CONVERTED(b.ptr, b.size)
|
#define BIN_CONVERTED(b) CONVERTED(b.ptr, b.size)
|
||||||
#define SET_ADDITIONAL_DATA(tgt, name) \
|
#define SET_ADDITIONAL_DATA(tgt, name) \
|
||||||
do { \
|
do { \
|
||||||
@@ -3625,38 +3631,28 @@ shada_read_next_item_start:
|
|||||||
garray_T ad_ga;
|
garray_T ad_ga;
|
||||||
ga_init(&ad_ga, sizeof(*(unpacked.data.via.map.ptr)), 1);
|
ga_init(&ad_ga, sizeof(*(unpacked.data.via.map.ptr)), 1);
|
||||||
for (size_t i = 0; i < unpacked.data.via.map.size; i++) {
|
for (size_t i = 0; i < unpacked.data.via.map.size; i++) {
|
||||||
CHECK_KEY_IS_STR("search pattern");
|
CHECK_KEY_IS_STR("search pattern")
|
||||||
BOOLEAN_KEY("search pattern", SEARCH_KEY_MAGIC,
|
BOOLEAN_KEY("search pattern", SEARCH_KEY_MAGIC,
|
||||||
entry->data.search_pattern.magic)
|
entry->data.search_pattern.magic)
|
||||||
else
|
BOOLEAN_KEY("search pattern", SEARCH_KEY_SMARTCASE,
|
||||||
BOOLEAN_KEY("search pattern", SEARCH_KEY_SMARTCASE,
|
entry->data.search_pattern.smartcase)
|
||||||
entry->data.search_pattern.smartcase)
|
BOOLEAN_KEY("search pattern", SEARCH_KEY_HAS_LINE_OFFSET,
|
||||||
else
|
entry->data.search_pattern.has_line_offset)
|
||||||
BOOLEAN_KEY("search pattern", SEARCH_KEY_HAS_LINE_OFFSET,
|
BOOLEAN_KEY("search pattern", SEARCH_KEY_PLACE_CURSOR_AT_END,
|
||||||
entry->data.search_pattern.has_line_offset)
|
entry->data.search_pattern.place_cursor_at_end)
|
||||||
else
|
BOOLEAN_KEY("search pattern", SEARCH_KEY_IS_LAST_USED,
|
||||||
BOOLEAN_KEY("search pattern", SEARCH_KEY_PLACE_CURSOR_AT_END,
|
entry->data.search_pattern.is_last_used)
|
||||||
entry->data.search_pattern.place_cursor_at_end)
|
BOOLEAN_KEY("search pattern", SEARCH_KEY_IS_SUBSTITUTE_PATTERN,
|
||||||
else
|
entry->data.search_pattern.is_substitute_pattern)
|
||||||
BOOLEAN_KEY("search pattern", SEARCH_KEY_IS_LAST_USED,
|
BOOLEAN_KEY("search pattern", SEARCH_KEY_HIGHLIGHTED,
|
||||||
entry->data.search_pattern.is_last_used)
|
entry->data.search_pattern.highlighted)
|
||||||
else
|
BOOLEAN_KEY("search pattern", SEARCH_KEY_BACKWARD,
|
||||||
BOOLEAN_KEY("search pattern", SEARCH_KEY_IS_SUBSTITUTE_PATTERN,
|
entry->data.search_pattern.search_backward)
|
||||||
entry->data.search_pattern.is_substitute_pattern)
|
INTEGER_KEY("search pattern", SEARCH_KEY_OFFSET,
|
||||||
else
|
entry->data.search_pattern.offset)
|
||||||
BOOLEAN_KEY("search pattern", SEARCH_KEY_HIGHLIGHTED,
|
CONVERTED_STRING_KEY("search pattern", SEARCH_KEY_PAT,
|
||||||
entry->data.search_pattern.highlighted)
|
entry->data.search_pattern.pat)
|
||||||
else
|
ADDITIONAL_KEY
|
||||||
BOOLEAN_KEY("search pattern", SEARCH_KEY_BACKWARD,
|
|
||||||
entry->data.search_pattern.search_backward)
|
|
||||||
else
|
|
||||||
INTEGER_KEY("search pattern", SEARCH_KEY_OFFSET,
|
|
||||||
entry->data.search_pattern.offset)
|
|
||||||
else
|
|
||||||
CONVERTED_STRING_KEY("search pattern", SEARCH_KEY_PAT,
|
|
||||||
entry->data.search_pattern.pat)
|
|
||||||
else
|
|
||||||
ADDITIONAL_KEY
|
|
||||||
}
|
}
|
||||||
if (entry->data.search_pattern.pat == NULL) {
|
if (entry->data.search_pattern.pat == NULL) {
|
||||||
emsgu(_(READERR("search pattern", "has no pattern")), initial_fpos);
|
emsgu(_(READERR("search pattern", "has no pattern")), initial_fpos);
|
||||||
@@ -3677,7 +3673,7 @@ shada_read_next_item_start:
|
|||||||
garray_T ad_ga;
|
garray_T ad_ga;
|
||||||
ga_init(&ad_ga, sizeof(*(unpacked.data.via.map.ptr)), 1);
|
ga_init(&ad_ga, sizeof(*(unpacked.data.via.map.ptr)), 1);
|
||||||
for (size_t i = 0; i < unpacked.data.via.map.size; i++) {
|
for (size_t i = 0; i < unpacked.data.via.map.size; i++) {
|
||||||
CHECK_KEY_IS_STR("mark");
|
CHECK_KEY_IS_STR("mark")
|
||||||
if (CHECK_KEY(unpacked.data.via.map.ptr[i].key, KEY_NAME_CHAR)) {
|
if (CHECK_KEY(unpacked.data.via.map.ptr[i].key, KEY_NAME_CHAR)) {
|
||||||
if (type_u64 == kSDItemJump || type_u64 == kSDItemChange) {
|
if (type_u64 == kSDItemJump || type_u64 == kSDItemChange) {
|
||||||
emsgu(_(READERR("mark", "has n key which is only valid for "
|
emsgu(_(READERR("mark", "has n key which is only valid for "
|
||||||
@@ -3690,15 +3686,11 @@ shada_read_next_item_start:
|
|||||||
"has n key value which is not an unsigned integer",
|
"has n key value which is not an unsigned integer",
|
||||||
"mark", unpacked.data.via.map.ptr[i].val,
|
"mark", unpacked.data.via.map.ptr[i].val,
|
||||||
entry->data.filemark.name, u64, TOCHAR);
|
entry->data.filemark.name, u64, TOCHAR);
|
||||||
} else {
|
|
||||||
LONG_KEY("mark", KEY_LNUM, entry->data.filemark.mark.lnum)
|
|
||||||
else
|
|
||||||
INTEGER_KEY("mark", KEY_COL, entry->data.filemark.mark.col)
|
|
||||||
else
|
|
||||||
STRING_KEY("mark", KEY_FILE, entry->data.filemark.fname)
|
|
||||||
else
|
|
||||||
ADDITIONAL_KEY
|
|
||||||
}
|
}
|
||||||
|
LONG_KEY("mark", KEY_LNUM, entry->data.filemark.mark.lnum)
|
||||||
|
INTEGER_KEY("mark", KEY_COL, entry->data.filemark.mark.col)
|
||||||
|
STRING_KEY("mark", KEY_FILE, entry->data.filemark.fname)
|
||||||
|
ADDITIONAL_KEY
|
||||||
}
|
}
|
||||||
if (entry->data.filemark.fname == NULL) {
|
if (entry->data.filemark.fname == NULL) {
|
||||||
emsgu(_(READERR("mark", "is missing file name")), initial_fpos);
|
emsgu(_(READERR("mark", "is missing file name")), initial_fpos);
|
||||||
@@ -3723,48 +3715,44 @@ shada_read_next_item_start:
|
|||||||
garray_T ad_ga;
|
garray_T ad_ga;
|
||||||
ga_init(&ad_ga, sizeof(*(unpacked.data.via.map.ptr)), 1);
|
ga_init(&ad_ga, sizeof(*(unpacked.data.via.map.ptr)), 1);
|
||||||
for (size_t i = 0; i < unpacked.data.via.map.size; i++) {
|
for (size_t i = 0; i < unpacked.data.via.map.size; i++) {
|
||||||
CHECK_KEY_IS_STR("register");
|
CHECK_KEY_IS_STR("register")
|
||||||
|
if (CHECK_KEY(unpacked.data.via.map.ptr[i].key,
|
||||||
|
REG_KEY_CONTENTS)) {
|
||||||
|
if (unpacked.data.via.map.ptr[i].val.type != MSGPACK_OBJECT_ARRAY) {
|
||||||
|
emsgu(_(READERR("register",
|
||||||
|
"has " REG_KEY_CONTENTS
|
||||||
|
" key with non-array value")),
|
||||||
|
initial_fpos);
|
||||||
|
CLEAR_GA_AND_ERROR_OUT(ad_ga);
|
||||||
|
}
|
||||||
|
if (unpacked.data.via.map.ptr[i].val.via.array.size == 0) {
|
||||||
|
emsgu(_(READERR("register",
|
||||||
|
"has " REG_KEY_CONTENTS " key with empty array")),
|
||||||
|
initial_fpos);
|
||||||
|
CLEAR_GA_AND_ERROR_OUT(ad_ga);
|
||||||
|
}
|
||||||
|
const msgpack_object_array arr =
|
||||||
|
unpacked.data.via.map.ptr[i].val.via.array;
|
||||||
|
for (size_t i = 0; i < arr.size; i++) {
|
||||||
|
if (arr.ptr[i].type != MSGPACK_OBJECT_BIN) {
|
||||||
|
emsgu(_(READERR("register", "has " REG_KEY_CONTENTS " array "
|
||||||
|
"with non-binary value")), initial_fpos);
|
||||||
|
CLEAR_GA_AND_ERROR_OUT(ad_ga);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
entry->data.reg.contents_size = arr.size;
|
||||||
|
entry->data.reg.contents = xmalloc(arr.size * sizeof(char *));
|
||||||
|
for (size_t i = 0; i < arr.size; i++) {
|
||||||
|
entry->data.reg.contents[i] = BIN_CONVERTED(arr.ptr[i].via.bin);
|
||||||
|
}
|
||||||
|
}
|
||||||
TYPED_KEY("register", REG_KEY_TYPE, "an unsigned integer",
|
TYPED_KEY("register", REG_KEY_TYPE, "an unsigned integer",
|
||||||
entry->data.reg.type, POSITIVE_INTEGER, u64, TOU8)
|
entry->data.reg.type, POSITIVE_INTEGER, u64, TOU8)
|
||||||
else
|
TYPED_KEY("register", KEY_NAME_CHAR, "an unsigned integer",
|
||||||
TYPED_KEY("register", KEY_NAME_CHAR, "an unsigned integer",
|
entry->data.reg.name, POSITIVE_INTEGER, u64, TOCHAR)
|
||||||
entry->data.reg.name, POSITIVE_INTEGER, u64, TOCHAR)
|
TYPED_KEY("register", REG_KEY_WIDTH, "an unsigned integer",
|
||||||
else
|
entry->data.reg.width, POSITIVE_INTEGER, u64, TOSIZE)
|
||||||
TYPED_KEY("register", REG_KEY_WIDTH, "an unsigned integer",
|
ADDITIONAL_KEY
|
||||||
entry->data.reg.width, POSITIVE_INTEGER, u64, TOSIZE)
|
|
||||||
else
|
|
||||||
if (CHECK_KEY(unpacked.data.via.map.ptr[i].key,
|
|
||||||
REG_KEY_CONTENTS)) {
|
|
||||||
if (unpacked.data.via.map.ptr[i].val.type != MSGPACK_OBJECT_ARRAY) {
|
|
||||||
emsgu(_(READERR(
|
|
||||||
"register",
|
|
||||||
"has " REG_KEY_CONTENTS " key with non-array value")),
|
|
||||||
initial_fpos);
|
|
||||||
CLEAR_GA_AND_ERROR_OUT(ad_ga);
|
|
||||||
}
|
|
||||||
if (unpacked.data.via.map.ptr[i].val.via.array.size == 0) {
|
|
||||||
emsgu(_(READERR("register",
|
|
||||||
"has " REG_KEY_CONTENTS " key with empty array")),
|
|
||||||
initial_fpos);
|
|
||||||
CLEAR_GA_AND_ERROR_OUT(ad_ga);
|
|
||||||
}
|
|
||||||
const msgpack_object_array arr =
|
|
||||||
unpacked.data.via.map.ptr[i].val.via.array;
|
|
||||||
for (size_t i = 0; i < arr.size; i++) {
|
|
||||||
if (arr.ptr[i].type != MSGPACK_OBJECT_BIN) {
|
|
||||||
emsgu(_(READERR("register", "has " REG_KEY_CONTENTS " array "
|
|
||||||
"with non-binary value")), initial_fpos);
|
|
||||||
CLEAR_GA_AND_ERROR_OUT(ad_ga);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
entry->data.reg.contents_size = arr.size;
|
|
||||||
entry->data.reg.contents = xmalloc(arr.size * sizeof(char *));
|
|
||||||
for (size_t i = 0; i < arr.size; i++) {
|
|
||||||
entry->data.reg.contents[i] = BIN_CONVERTED(arr.ptr[i].via.bin);
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
ADDITIONAL_KEY
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
if (entry->data.reg.contents == NULL) {
|
if (entry->data.reg.contents == NULL) {
|
||||||
emsgu(_(READERR("register", "has missing " REG_KEY_CONTENTS " array")),
|
emsgu(_(READERR("register", "has missing " REG_KEY_CONTENTS " array")),
|
||||||
@@ -3832,8 +3820,8 @@ shada_read_next_item_hist_no_conv:
|
|||||||
+ 1); // Separator character
|
+ 1); // Separator character
|
||||||
entry->data.history_item.string = xmalloc(strsize);
|
entry->data.history_item.string = xmalloc(strsize);
|
||||||
memcpy(entry->data.history_item.string,
|
memcpy(entry->data.history_item.string,
|
||||||
unpacked.data.via.array.ptr[1].via.bin.ptr,
|
unpacked.data.via.array.ptr[1].via.bin.ptr,
|
||||||
unpacked.data.via.array.ptr[1].via.bin.size);
|
unpacked.data.via.array.ptr[1].via.bin.size);
|
||||||
} else {
|
} else {
|
||||||
size_t len = unpacked.data.via.array.ptr[1].via.bin.size;
|
size_t len = unpacked.data.via.array.ptr[1].via.bin.size;
|
||||||
char *const converted = string_convert(
|
char *const converted = string_convert(
|
||||||
@@ -3953,17 +3941,14 @@ shada_read_next_item_hist_no_conv:
|
|||||||
const size_t j = i;
|
const size_t j = i;
|
||||||
{
|
{
|
||||||
for (size_t i = 0; i < unpacked.data.via.map.size; i++) {
|
for (size_t i = 0; i < unpacked.data.via.map.size; i++) {
|
||||||
CHECK_KEY_IS_STR("buffer list entry");
|
CHECK_KEY_IS_STR("buffer list entry")
|
||||||
LONG_KEY("buffer list entry", KEY_LNUM,
|
LONG_KEY("buffer list entry", KEY_LNUM,
|
||||||
entry->data.buffer_list.buffers[j].pos.lnum)
|
entry->data.buffer_list.buffers[j].pos.lnum)
|
||||||
else
|
INTEGER_KEY("buffer list entry", KEY_COL,
|
||||||
INTEGER_KEY("buffer list entry", KEY_COL,
|
entry->data.buffer_list.buffers[j].pos.col)
|
||||||
entry->data.buffer_list.buffers[j].pos.col)
|
STRING_KEY("buffer list entry", KEY_FILE,
|
||||||
else
|
entry->data.buffer_list.buffers[j].fname)
|
||||||
STRING_KEY("buffer list entry", KEY_FILE,
|
ADDITIONAL_KEY
|
||||||
entry->data.buffer_list.buffers[j].fname)
|
|
||||||
else
|
|
||||||
ADDITIONAL_KEY
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user