Improving a few comments.
git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@5322 35c25a1d-7b9e-4130-9fde-d3aeb78583b8master
parent
f7e8861770
commit
17ab9a2dba
|
@ -6,6 +6,7 @@
|
|||
new bindable functions, 'findnext' and 'findprevious', which repeat
|
||||
the last search command in a fixed direction without prompting.
|
||||
* src/global.c (shortcut_init): Tweak a string.
|
||||
* src/search.c, src/move.c: Improve a few of the comments.
|
||||
|
||||
2015-07-25 Benno Schulenberg <bensberg@justemail.net>
|
||||
* src/global.c (shortcut_init, strtosc), src/files.c (savefile),
|
||||
|
|
10
src/move.c
10
src/move.c
|
@ -52,9 +52,8 @@ void do_page_up(void)
|
|||
{
|
||||
int i, skipped = 0;
|
||||
|
||||
/* If there's less than a page of text left on the screen, put the
|
||||
* cursor at the beginning of the first line of the file, and then
|
||||
* update the edit window. */
|
||||
/* If the cursor is less than a page away from the top of the file,
|
||||
* put it at the beginning of the first line. */
|
||||
if (openfile->current->lineno == 1 || (
|
||||
#ifndef NANO_TINY
|
||||
!ISSET(SOFTWRAP) &&
|
||||
|
@ -106,9 +105,8 @@ void do_page_down(void)
|
|||
{
|
||||
int i;
|
||||
|
||||
/* If there's less than a page of text left on the screen, put the
|
||||
* cursor at the beginning of the last line of the file, and then
|
||||
* update the edit window. */
|
||||
/* If the cursor is less than a page away from the bottom of the file,
|
||||
* put it at the end of the last line. */
|
||||
if (openfile->current->lineno + maxrows - 2 >=
|
||||
openfile->filebot->lineno) {
|
||||
do_last_line();
|
||||
|
|
21
src/search.c
21
src/search.c
|
@ -547,12 +547,11 @@ void do_research(void)
|
|||
#endif /* !NANO_TINY */
|
||||
|
||||
#ifdef HAVE_REGEX_H
|
||||
/* Calculate the size of the replacement line, taking possible
|
||||
* subexpressions \1 to \9 into account. Return the replacement
|
||||
* text in the passed string only when create is TRUE. */
|
||||
int replace_regexp(char *string, bool create)
|
||||
{
|
||||
/* We have a split personality here. If create is FALSE, just
|
||||
* calculate the size of the replacement line (necessary because of
|
||||
* subexpressions \1 to \9 in the replaced text). */
|
||||
|
||||
const char *c = last_replace;
|
||||
size_t search_match_count = regmatches[0].rm_eo -
|
||||
regmatches[0].rm_so;
|
||||
|
@ -596,12 +595,13 @@ int replace_regexp(char *string, bool create)
|
|||
}
|
||||
#endif /* HAVE_REGEX_H */
|
||||
|
||||
/* Return a copy of the current line with one needle replaced. */
|
||||
char *replace_line(const char *needle)
|
||||
{
|
||||
char *copy;
|
||||
size_t new_line_size, search_match_count;
|
||||
|
||||
/* Calculate the size of the new line. */
|
||||
/* First calculate the size of the new line. */
|
||||
#ifdef HAVE_REGEX_H
|
||||
if (ISSET(USE_REGEXP)) {
|
||||
search_match_count = regmatches[0].rm_eo - regmatches[0].rm_so;
|
||||
|
@ -618,10 +618,10 @@ char *replace_line(const char *needle)
|
|||
/* Create the buffer. */
|
||||
copy = charalloc(new_line_size);
|
||||
|
||||
/* The head of the original line. */
|
||||
/* Copy the head of the original line. */
|
||||
strncpy(copy, openfile->current->data, openfile->current_x);
|
||||
|
||||
/* The replacement text. */
|
||||
/* Add the replacement text. */
|
||||
#ifdef HAVE_REGEX_H
|
||||
if (ISSET(USE_REGEXP))
|
||||
replace_regexp(copy + openfile->current_x, TRUE);
|
||||
|
@ -629,9 +629,9 @@ char *replace_line(const char *needle)
|
|||
#endif
|
||||
strcpy(copy + openfile->current_x, answer);
|
||||
|
||||
/* The tail of the original line. */
|
||||
assert(openfile->current_x + search_match_count <= strlen(openfile->current->data));
|
||||
|
||||
/* Copy the tail of the original line. */
|
||||
strcat(copy, openfile->current->data + openfile->current_x +
|
||||
search_match_count);
|
||||
|
||||
|
@ -797,9 +797,8 @@ ssize_t do_replace_loop(
|
|||
#endif
|
||||
openfile->current_x += match_len + length_change - 1;
|
||||
|
||||
/* Clean up. */
|
||||
openfile->totsize += mbstrlen(copy) -
|
||||
mbstrlen(openfile->current->data);
|
||||
/* Update the file size, and put the changed line into place. */
|
||||
openfile->totsize += mbstrlen(copy) - mbstrlen(openfile->current->data);
|
||||
free(openfile->current->data);
|
||||
openfile->current->data = copy;
|
||||
|
||||
|
|
Loading…
Reference in New Issue