Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions hexedit.h
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
8 changes: 4 additions & 4 deletions search.c
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand All @@ -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];
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

tmpstr size does not need any change, does it?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why 137? why not LINE_MAX ?

ncurses 6.2 uses LINE_MAX or a larger (system-dependent) value provided by sysconf(3). If neither LINE_MAX nor sysconf is available, ncurses uses the POSIX minimum value for LINE_MAX (2048). In either case, it reserves a byte for the terminating null character.

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 {
Expand Down