Skip to content

Commit

Permalink
Allow search to find text which follows a null byte,
Browse files Browse the repository at this point in the history
when using PCRE or no-regex (ctrl-R) searching.
  • Loading branch information
gwsw committed Mar 25, 2007
1 parent 93b634a commit 381c103
Show file tree
Hide file tree
Showing 6 changed files with 76 additions and 41 deletions.
3 changes: 3 additions & 0 deletions NEWS.VER
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,9 @@
* Allow "/dev/null" as synomym for "-" in LESSHISTFILE to indicate
that no history file should be used.

* Search can now find text which follows a null byte, if the PCRE
library is used, or if no-regex searching (ctrl-R) is used.

* Make -f work for directories.

* Support DESTDIR in Makefile.
Expand Down
10 changes: 8 additions & 2 deletions line.c
Original file line number Diff line number Diff line change
Expand Up @@ -1100,9 +1100,10 @@ null_line()
* {{ This is supposed to be more efficient than forw_line(). }}
*/
public POSITION
forw_raw_line(curr_pos, linep)
forw_raw_line(curr_pos, linep, line_lenp)
POSITION curr_pos;
char **linep;
int *line_lenp;
{
register int n;
register int c;
Expand Down Expand Up @@ -1138,6 +1139,8 @@ forw_raw_line(curr_pos, linep)
linebuf[n] = '\0';
if (linep != NULL)
*linep = linebuf;
if (line_lenp != NULL)
*line_lenp = n;
return (new_pos);
}

Expand All @@ -1146,9 +1149,10 @@ forw_raw_line(curr_pos, linep)
* {{ This is supposed to be more efficient than back_line(). }}
*/
public POSITION
back_raw_line(curr_pos, linep)
back_raw_line(curr_pos, linep, line_lenp)
POSITION curr_pos;
char **linep;
int *line_lenp;
{
register int n;
register int c;
Expand Down Expand Up @@ -1209,5 +1213,7 @@ back_raw_line(curr_pos, linep)
}
if (linep != NULL)
*linep = &linebuf[n];
if (line_lenp != NULL)
*line_lenp = size_linebuf - 1 - n;
return (new_pos);
}
8 changes: 4 additions & 4 deletions linenum.c
Original file line number Diff line number Diff line change
Expand Up @@ -314,7 +314,7 @@ find_linenum(pos)
/*
* Allow a signal to abort this loop.
*/
cpos = forw_raw_line(cpos, (char **)NULL);
cpos = forw_raw_line(cpos, (char **)NULL, (int *)NULL);
if (ABORT_SIGS() || cpos == NULL_POSITION)
return (0);
longish();
Expand Down Expand Up @@ -343,7 +343,7 @@ find_linenum(pos)
/*
* Allow a signal to abort this loop.
*/
cpos = back_raw_line(cpos, (char **)NULL);
cpos = back_raw_line(cpos, (char **)NULL, (int *)NULL);
if (ABORT_SIGS() || cpos == NULL_POSITION)
return (0);
longish();
Expand Down Expand Up @@ -398,7 +398,7 @@ find_pos(linenum)
/*
* Allow a signal to abort this loop.
*/
cpos = forw_raw_line(cpos, (char **)NULL);
cpos = forw_raw_line(cpos, (char **)NULL, (int *)NULL);
if (ABORT_SIGS() || cpos == NULL_POSITION)
return (NULL_POSITION);
}
Expand All @@ -414,7 +414,7 @@ find_pos(linenum)
/*
* Allow a signal to abort this loop.
*/
cpos = back_raw_line(cpos, (char **)NULL);
cpos = back_raw_line(cpos, (char **)NULL, (int *)NULL);
if (ABORT_SIGS() || cpos == NULL_POSITION)
return (NULL_POSITION);
}
Expand Down
Loading

0 comments on commit 381c103

Please sign in to comment.