From 2980010b534f0180fa0edb7f308ed89fc2ad78df Mon Sep 17 00:00:00 2001 From: Andrew Borodin Date: Thu, 26 Dec 2024 11:00:29 +0300 Subject: [PATCH] search: change types of start and end search positions from gsize to off_t. editor: related changes. viewer: likewise. Signed-off-by: Andrew Borodin --- lib/search.h | 8 ++++---- lib/search/glob.c | 2 +- lib/search/hex.c | 2 +- lib/search/internal.h | 8 ++++---- lib/search/normal.c | 2 +- lib/search/regex.c | 4 ++-- lib/search/search.c | 2 +- src/editor/editsearch.c | 8 ++++---- src/editor/editsearch.h | 4 ++-- src/viewer/internal.h | 4 ++-- src/viewer/search.c | 6 +++--- 11 files changed, 25 insertions(+), 25 deletions(-) diff --git a/lib/search.h b/lib/search.h index 955733fbd..6ce4b189e 100644 --- a/lib/search.h +++ b/lib/search.h @@ -19,9 +19,9 @@ typedef enum mc_search_cbret_t mc_search_cbret_t; -typedef mc_search_cbret_t (*mc_search_fn) (const void *user_data, gsize char_offset, +typedef mc_search_cbret_t (*mc_search_fn) (const void *user_data, off_t char_offset, int *current_char); -typedef mc_search_cbret_t (*mc_update_fn) (const void *user_data, gsize char_offset); +typedef mc_search_cbret_t (*mc_update_fn) (const void *user_data, off_t char_offset); #define MC_SEARCH__NUM_REPLACE_ARGS 64 @@ -180,8 +180,8 @@ void mc_search_free (mc_search_t * lc_mc_search); gboolean mc_search_prepare (mc_search_t * mc_search); -gboolean mc_search_run (mc_search_t * mc_search, const void *user_data, gsize start_search, - gsize end_search, gsize * found_len); +gboolean mc_search_run (mc_search_t * mc_search, const void *user_data, off_t start_search, + off_t end_search, gsize * found_len); gboolean mc_search_is_type_avail (mc_search_type_t search_type); diff --git a/lib/search/glob.c b/lib/search/glob.c index 8e514e10a..45025711b 100644 --- a/lib/search/glob.c +++ b/lib/search/glob.c @@ -188,7 +188,7 @@ mc_search__cond_struct_new_init_glob (const char *charset, mc_search_t *lc_mc_se gboolean mc_search__run_glob (mc_search_t *lc_mc_search, const void *user_data, - gsize start_search, gsize end_search, gsize *found_len) + off_t start_search, off_t end_search, gsize *found_len) { return mc_search__run_regex (lc_mc_search, user_data, start_search, end_search, found_len); } diff --git a/lib/search/hex.c b/lib/search/hex.c index 61478c11d..c6010d20e 100644 --- a/lib/search/hex.c +++ b/lib/search/hex.c @@ -216,7 +216,7 @@ mc_search__cond_struct_new_init_hex (const char *charset, mc_search_t *lc_mc_sea gboolean mc_search__run_hex (mc_search_t *lc_mc_search, const void *user_data, - gsize start_search, gsize end_search, gsize *found_len) + off_t start_search, off_t end_search, gsize *found_len) { return mc_search__run_regex (lc_mc_search, user_data, start_search, end_search, found_len); } diff --git a/lib/search/internal.h b/lib/search/internal.h index 08cb019d5..88f19f3dd 100644 --- a/lib/search/internal.h +++ b/lib/search/internal.h @@ -54,7 +54,7 @@ GString *mc_search__toupper_case_str (const char *charset, const GString * str); void mc_search__cond_struct_new_init_regex (const char *charset, mc_search_t * lc_mc_search, mc_search_cond_t * mc_search_cond); gboolean mc_search__run_regex (mc_search_t * lc_mc_search, const void *user_data, - gsize start_search, gsize end_search, gsize * found_len); + off_t start_search, off_t end_search, gsize * found_len); GString *mc_search_regex_prepare_replace_str (mc_search_t * lc_mc_search, GString * replace_str); /* search/normal.c : */ @@ -62,7 +62,7 @@ GString *mc_search_regex_prepare_replace_str (mc_search_t * lc_mc_search, GStrin void mc_search__cond_struct_new_init_normal (const char *charset, mc_search_t * lc_mc_search, mc_search_cond_t * mc_search_cond); gboolean mc_search__run_normal (mc_search_t * lc_mc_search, const void *user_data, - gsize start_search, gsize end_search, gsize * found_len); + off_t start_search, off_t end_search, gsize * found_len); GString *mc_search_normal_prepare_replace_str (mc_search_t * lc_mc_search, GString * replace_str); /* search/glob.c : */ @@ -70,7 +70,7 @@ GString *mc_search_normal_prepare_replace_str (mc_search_t * lc_mc_search, GStri void mc_search__cond_struct_new_init_glob (const char *charset, mc_search_t * lc_mc_search, mc_search_cond_t * mc_search_cond); gboolean mc_search__run_glob (mc_search_t * lc_mc_search, const void *user_data, - gsize start_search, gsize end_search, gsize * found_len); + off_t start_search, off_t end_search, gsize * found_len); GString *mc_search_glob_prepare_replace_str (mc_search_t * lc_mc_search, GString * replace_str); /* search/hex.c : */ @@ -78,7 +78,7 @@ GString *mc_search_glob_prepare_replace_str (mc_search_t * lc_mc_search, GString void mc_search__cond_struct_new_init_hex (const char *charset, mc_search_t * lc_mc_search, mc_search_cond_t * mc_search_cond); gboolean mc_search__run_hex (mc_search_t * lc_mc_search, const void *user_data, - gsize start_search, gsize end_search, gsize * found_len); + off_t start_search, off_t end_search, gsize * found_len); GString *mc_search_hex_prepare_replace_str (mc_search_t * lc_mc_search, GString * replace_str); /*** inline functions ****************************************************************************/ diff --git a/lib/search/normal.c b/lib/search/normal.c index 9e788e63a..452de41f4 100644 --- a/lib/search/normal.c +++ b/lib/search/normal.c @@ -94,7 +94,7 @@ mc_search__cond_struct_new_init_normal (const char *charset, mc_search_t *lc_mc_ gboolean mc_search__run_normal (mc_search_t *lc_mc_search, const void *user_data, - gsize start_search, gsize end_search, gsize *found_len) + off_t start_search, off_t end_search, gsize *found_len) { return mc_search__run_regex (lc_mc_search, user_data, start_search, end_search, found_len); } diff --git a/lib/search/regex.c b/lib/search/regex.c index 2a58b2523..761ebdbfe 100644 --- a/lib/search/regex.c +++ b/lib/search/regex.c @@ -905,10 +905,10 @@ mc_search__cond_struct_new_init_regex (const char *charset, mc_search_t *lc_mc_s gboolean mc_search__run_regex (mc_search_t *lc_mc_search, const void *user_data, - gsize start_search, gsize end_search, gsize *found_len) + off_t start_search, off_t end_search, gsize *found_len) { mc_search_cbret_t ret = MC_SEARCH_CB_NOTFOUND; - gsize current_pos, virtual_pos; + off_t current_pos, virtual_pos; gint start_pos; gint end_pos; diff --git a/lib/search/search.c b/lib/search/search.c index 0c7343fdf..61be19da1 100644 --- a/lib/search/search.c +++ b/lib/search/search.c @@ -273,7 +273,7 @@ mc_search_prepare (mc_search_t *lc_mc_search) */ gboolean mc_search_run (mc_search_t *lc_mc_search, const void *user_data, - gsize start_search, gsize end_search, gsize *found_len) + off_t start_search, off_t end_search, gsize *found_len) { gboolean ret = FALSE; diff --git a/src/editor/editsearch.c b/src/editor/editsearch.c index ca66540dc..65d7eda52 100644 --- a/src/editor/editsearch.c +++ b/src/editor/editsearch.c @@ -704,11 +704,11 @@ edit_search_deinit (WEdit *edit) /* --------------------------------------------------------------------------------------------- */ mc_search_cbret_t -edit_search_cmd_callback (const void *user_data, gsize char_offset, int *current_char) +edit_search_cmd_callback (const void *user_data, off_t char_offset, int *current_char) { WEdit *edit = ((const edit_search_status_msg_t *) user_data)->edit; - *current_char = edit_buffer_get_byte (&edit->buffer, (off_t) char_offset); + *current_char = edit_buffer_get_byte (&edit->buffer, char_offset); return MC_SEARCH_CB_OK; } @@ -716,11 +716,11 @@ edit_search_cmd_callback (const void *user_data, gsize char_offset, int *current /* --------------------------------------------------------------------------------------------- */ mc_search_cbret_t -edit_search_update_callback (const void *user_data, gsize char_offset) +edit_search_update_callback (const void *user_data, off_t char_offset) { status_msg_t *sm = STATUS_MSG (user_data); - ((edit_search_status_msg_t *) sm)->offset = (off_t) char_offset; + ((edit_search_status_msg_t *) sm)->offset = char_offset; return (sm->update (sm) == B_CANCEL ? MC_SEARCH_CB_ABORT : MC_SEARCH_CB_OK); } diff --git a/src/editor/editsearch.h b/src/editor/editsearch.h index 5fc3932f0..e291092fb 100644 --- a/src/editor/editsearch.h +++ b/src/editor/editsearch.h @@ -23,9 +23,9 @@ typedef struct gboolean edit_search_init (WEdit * edit, const char *s); void edit_search_deinit (WEdit * edit); -mc_search_cbret_t edit_search_cmd_callback (const void *user_data, gsize char_offset, +mc_search_cbret_t edit_search_cmd_callback (const void *user_data, off_t char_offset, int *current_char); -mc_search_cbret_t edit_search_update_callback (const void *user_data, gsize char_offset); +mc_search_cbret_t edit_search_update_callback (const void *user_data, off_t char_offset); int edit_search_status_update_cb (status_msg_t * sm); void edit_search_cmd (WEdit * edit, gboolean again); diff --git a/src/viewer/internal.h b/src/viewer/internal.h index 214af9650..439700831 100644 --- a/src/viewer/internal.h +++ b/src/viewer/internal.h @@ -327,9 +327,9 @@ int mcview_nroff_seq_prev (mcview_nroff_t * nroff); /* search.c: */ gboolean mcview_search_init (WView * view); void mcview_search_deinit (WView * view); -mc_search_cbret_t mcview_search_cmd_callback (const void *user_data, gsize char_offset, +mc_search_cbret_t mcview_search_cmd_callback (const void *user_data, off_t char_offset, int *current_char); -mc_search_cbret_t mcview_search_update_cmd_callback (const void *user_data, gsize char_offset); +mc_search_cbret_t mcview_search_update_cmd_callback (const void *user_data, off_t char_offset); void mcview_search (WView * view, gboolean start_search); /* --------------------------------------------------------------------------------------------- */ diff --git a/src/viewer/search.c b/src/viewer/search.c index 9c7bc7141..4e9876d47 100644 --- a/src/viewer/search.c +++ b/src/viewer/search.c @@ -424,7 +424,7 @@ mcview_search_deinit (WView *view) /* --------------------------------------------------------------------------------------------- */ mc_search_cbret_t -mcview_search_cmd_callback (const void *user_data, gsize char_offset, int *current_char) +mcview_search_cmd_callback (const void *user_data, off_t char_offset, int *current_char) { WView *view = ((const mcview_search_status_msg_t *) user_data)->view; @@ -479,7 +479,7 @@ mcview_search_cmd_callback (const void *user_data, gsize char_offset, int *curre /* --------------------------------------------------------------------------------------------- */ mc_search_cbret_t -mcview_search_update_cmd_callback (const void *user_data, gsize char_offset) +mcview_search_update_cmd_callback (const void *user_data, off_t char_offset) { status_msg_t *sm = STATUS_MSG (user_data); mcview_search_status_msg_t *vsm = (mcview_search_status_msg_t *) user_data; @@ -487,7 +487,7 @@ mcview_search_update_cmd_callback (const void *user_data, gsize char_offset) gboolean do_update = FALSE; mc_search_cbret_t result = MC_SEARCH_CB_OK; - vsm->offset = (off_t) char_offset; + vsm->offset = char_offset; if (mcview_search_options.backwards) {