1
1

slightly simplify paragraph searching code

git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@1539 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
Этот коммит содержится в:
David Lawrence Ramsey 2003-09-04 23:22:47 +00:00
родитель 8faf305d0c
Коммит 74ea836fcc

54
nano.c
Просмотреть файл

@ -2436,25 +2436,25 @@ int do_para_operation(int operation)
} }
#ifdef HAVE_REGEX_H #ifdef HAVE_REGEX_H
/* We no longer need to check quotation, unless we're searching for /* We no longer need to check quotation, unless we're searching for
the beginning of the paragraph. */ * the beginning of the paragraph. */
if (operation != 1) if (operation != 1)
regfree(&qreg); regfree(&qreg);
#endif #endif
/* Now par_len is the number of lines in this paragraph. Should never /* Now par_len is the number of lines in this paragraph. Should never
* call quotes_match() or quote_length() again. */ * call quotes_match() or quote_length() again. */
/* If operation is nonzero, skip the justification, since we're only /* If we're searching for the beginning of the paragraph, skip the
* searching through the paragraph. If operation is 2, move down the * justification. If we're searching for the end of the paragraph,
* number of lines in the paragraph, so that we end up at the * move down the number of lines in the paragraph and skip the
* paragraph's end. */ * justification. */
if (operation != 0) { if (operation == 1)
if (operation == 2) { goto skip_justify;
else if (operation == 2) {
while (par_len > 0) { while (par_len > 0) {
current = current->next; current = current->next;
current_y++; current_y++;
par_len--; par_len--;
} }
}
goto skip_justify; goto skip_justify;
} }
@ -2629,21 +2629,16 @@ int do_para_operation(int operation)
} }
skip_justify: skip_justify:
if (operation != 0) { if (operation == 1) {
switch (operation) { /* We're on the same line we started on. Search for the first
case 1: * non-"blank" line before the line we're on (if there is one),
/* We're on the same line we started on. Search for the * continually restart that search from the current position
* first non-"blank" line before the line we're on (if * until we find a line that's part of a paragraph, and then
* there is one), continually restart that search from * search once more from there, so that we end up on the first
* the current position until we find a line that's part * line of that paragraph. In the process, skip over lines
* of a paragraph, and then search once more from there, * consisting only of spacing characters, as searching for the
* so that we end up on the first line of that * end of the paragraph does. Then update the screen. */
* paragraph. In the process, skip over lines if (current != fileage && current == current_save && !no_restart) {
* consisting only of spacing characters, as searching
* for the end of the paragraph does. Then update the
* screen. */
if (current != fileage && current == current_save &&
!no_restart) {
while (current->prev != NULL) { while (current->prev != NULL) {
int j, j_space = 0; int j, j_space = 0;
current = current->prev; current = current->prev;
@ -2668,24 +2663,21 @@ int do_para_operation(int operation)
no_restart = 0; no_restart = 0;
#ifdef HAVE_REGEX_H #ifdef HAVE_REGEX_H
/* We no longer need to check quotation, if we were /* We no longer need to check quotation, if we were
searching for the beginning of the paragraph. */ * searching for the beginning of the paragraph. */
regfree(&qreg); regfree(&qreg);
#endif #endif
if (current_y < 0) if (current_y < 0)
edit_update(current, CENTER); edit_update(current, CENTER);
else else
edit_refresh(); edit_refresh();
break; return 0;
case 2: } else if (operation == 2) {
/* We've already moved to the end of the paragraph. /* We've already moved to the end of the paragraph. Update the
* Update the screen. */ * screen. */
if (current_y > editwinrows - 1) if (current_y > editwinrows - 1)
edit_update(current, CENTER); edit_update(current, CENTER);
else else
edit_refresh(); edit_refresh();
break;
}
if (operation != 0)
return 0; return 0;
} }