From c499ee233ec46fcbbbdfed81ab1f22496ad4a2e5 Mon Sep 17 00:00:00 2001 From: Oscar65 Date: Tue, 1 Jul 2025 20:13:30 +0200 Subject: [PATCH] Created new variable for input search Because getnstr hangs with input longer than 137 chars. --- hexedit.h | 1 + search.c | 8 ++++---- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/hexedit.h b/hexedit.h index dfaae43..3dcefbb 100644 --- a/hexedit.h +++ b/hexedit.h @@ -35,6 +35,7 @@ /*******************************************************************************/ #define BIGGEST_COPYING (1 * 1024 * 1024) #define BLOCK_SEARCH_SIZE (4 * 1024) +#define MAXLEN_SEARCH_STRING 137 #define SECTOR_SIZE ((INT) 512) #ifndef CTRL #define CTRL(c) ((c) & 0x1F) diff --git a/search.c b/search.c index f8bb95c..15d0147 100644 --- a/search.c +++ b/search.c @@ -58,11 +58,11 @@ static void searchB(INT loc, char *string) void search_forward(void) { - char *p, *string, tmp[BLOCK_SEARCH_SIZE], tmpstr[BLOCK_SEARCH_SIZE]; + char *p, *string, tmp[BLOCK_SEARCH_SIZE], tmpstr[BLOCK_SEARCH_SIZE], tmpInput[MAXLEN_SEARCH_STRING]; int quit, sizea, sizeb; INT blockstart; - if (!searchA(&string, &sizea, tmp, sizeof(tmp))) return; + if (!searchA(&string, &sizea, tmpInput, sizeof(tmpInput))) return; quit = -1; blockstart = base + cursor - BLOCK_SEARCH_SIZE + sizea; do { @@ -83,11 +83,11 @@ void search_forward(void) void search_backward(void) { - char *p, *string, tmp[BLOCK_SEARCH_SIZE], tmpstr[BLOCK_SEARCH_SIZE]; + char *p, *string, tmp[BLOCK_SEARCH_SIZE], tmpstr[MAXLEN_SEARCH_STRING], tmpInput[MAXLEN_SEARCH_STRING]; int quit, sizea, sizeb; INT blockstart; - if (!searchA(&string, &sizea, tmp, sizeof(tmp))) return; + if (!searchA(&string, &sizea, tmpInput, sizeof(tmpInput))) return; quit = -1; blockstart = base + cursor - sizea + 1; do {