in edit_add(), do minor cosmetic reformatting and remove unused int

searched_later_lines


git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@1722 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
master
David Lawrence Ramsey 2004-04-29 06:30:36 +00:00
parent d62b63492a
commit e5b2f83031
2 changed files with 28 additions and 30 deletions

View File

@ -63,6 +63,9 @@ CVS code -
never be negative. (DLR) never be negative. (DLR)
- Add proper support for the keypad values and escape sequences - Add proper support for the keypad values and escape sequences
generated by the NumLock glitch. (DLR) generated by the NumLock glitch. (DLR)
edit_add()
- Minor cosmetic reformatting. Also remove unused int
searched_later_lines. (DLR)
edit_refresh() edit_refresh()
- Remove apparently unneeded leaveok() calls. (David Benbennick) - Remove apparently unneeded leaveok() calls. (David Benbennick)
do_credits() do_credits()

View File

@ -1750,10 +1750,10 @@ void edit_add(const filestruct *fileptr, const char *converted, int
if (startmatch.rm_so <= startpos) if (startmatch.rm_so <= startpos)
x_start = 0; x_start = 0;
else else
x_start = strnlenpt(fileptr->data, startmatch.rm_so) x_start = strnlenpt(fileptr->data,
- start; startmatch.rm_so) - start;
paintlen = strnlenpt(fileptr->data, startmatch.rm_eo) paintlen = strnlenpt(fileptr->data,
- start - x_start; startmatch.rm_eo) - start - x_start;
if (paintlen > COLS - x_start) if (paintlen > COLS - x_start)
paintlen = COLS - x_start; paintlen = COLS - x_start;
@ -1781,17 +1781,14 @@ void edit_add(const filestruct *fileptr, const char *converted, int
regoff_t start_col; regoff_t start_col;
/* where it starts in that line */ /* where it starts in that line */
const filestruct *end_line; const filestruct *end_line;
int searched_later_lines = 0;
/* Used in step 2. Have we looked for an end on
* lines after fileptr? */
while (start_line != NULL && while (start_line != NULL &&
regexec(&tmpcolor->start, start_line->data, 1, regexec(&tmpcolor->start, start_line->data, 1,
&startmatch, 0) == REG_NOMATCH) { &startmatch, 0) == REG_NOMATCH) {
/* If there is an end on this line, there is no need /* If there is an end on this line, there is no need
* to look for starts on earlier lines. */ * to look for starts on earlier lines. */
if (regexec(tmpcolor->end, start_line->data, 0, NULL, 0) if (regexec(tmpcolor->end, start_line->data, 0,
== 0) NULL, 0) == 0)
goto step_two; goto step_two;
start_line = start_line->prev; start_line = start_line->prev;
} }
@ -1807,15 +1804,15 @@ void edit_add(const filestruct *fileptr, const char *converted, int
start_col += startmatch.rm_so; start_col += startmatch.rm_so;
startmatch.rm_eo -= startmatch.rm_so; startmatch.rm_eo -= startmatch.rm_so;
if (regexec(tmpcolor->end, if (regexec(tmpcolor->end,
start_line->data + start_col + startmatch.rm_eo, start_line->data + start_col + startmatch.rm_eo,
0, NULL, start_col + startmatch.rm_eo == 0 ? 0 : 0, NULL, start_col + startmatch.rm_eo == 0 ? 0 :
REG_NOTBOL) == REG_NOMATCH) REG_NOTBOL) == REG_NOMATCH)
/* No end found after this start. */ /* No end found after this start. */
break; break;
start_col++; start_col++;
if (regexec(&tmpcolor->start, if (regexec(&tmpcolor->start,
start_line->data + start_col, 1, &startmatch, start_line->data + start_col, 1,
REG_NOTBOL) == REG_NOMATCH) &startmatch, REG_NOTBOL) == REG_NOMATCH)
/* No later start on this line. */ /* No later start on this line. */
goto step_two; goto step_two;
} }
@ -1852,10 +1849,10 @@ void edit_add(const filestruct *fileptr, const char *converted, int
step_two: /* Second step, we look for starts on this line. */ step_two: /* Second step, we look for starts on this line. */
start_col = 0; start_col = 0;
while (start_col < endpos) { while (start_col < endpos) {
if (regexec(&tmpcolor->start, fileptr->data + start_col, 1, if (regexec(&tmpcolor->start,
&startmatch, start_col == 0 ? 0 : REG_NOTBOL) fileptr->data + start_col, 1, &startmatch,
== REG_NOMATCH || start_col + startmatch.rm_so >= start_col == 0 ? 0 : REG_NOTBOL) == REG_NOMATCH ||
endpos) start_col + startmatch.rm_so >= endpos)
/* No more starts on this line. */ /* No more starts on this line. */
break; break;
/* Translate the match to be relative to the /* Translate the match to be relative to the
@ -1866,11 +1863,11 @@ void edit_add(const filestruct *fileptr, const char *converted, int
if (startmatch.rm_so <= startpos) if (startmatch.rm_so <= startpos)
x_start = 0; x_start = 0;
else else
x_start = strnlenpt(fileptr->data, startmatch.rm_so) x_start = strnlenpt(fileptr->data,
- start; startmatch.rm_so) - start;
if (regexec(tmpcolor->end, fileptr->data + startmatch.rm_eo, if (regexec(tmpcolor->end,
1, &endmatch, startmatch.rm_eo == 0 ? 0 : fileptr->data + startmatch.rm_eo, 1, &endmatch,
REG_NOTBOL) == 0) { startmatch.rm_eo == 0 ? 0 : REG_NOTBOL) == 0) {
/* Translate the end match to be relative to the /* Translate the end match to be relative to the
* beginning of the line. */ * beginning of the line. */
endmatch.rm_so += startmatch.rm_eo; endmatch.rm_so += startmatch.rm_eo;
@ -1880,18 +1877,17 @@ void edit_add(const filestruct *fileptr, const char *converted, int
* zero characters long? */ * zero characters long? */
if (endmatch.rm_eo > startpos && if (endmatch.rm_eo > startpos &&
endmatch.rm_eo > startmatch.rm_so) { endmatch.rm_eo > startmatch.rm_so) {
paintlen = strnlenpt(fileptr->data, endmatch.rm_eo) paintlen = strnlenpt(fileptr->data,
- start - x_start; endmatch.rm_eo) - start - x_start;
if (x_start + paintlen > COLS) if (x_start + paintlen > COLS)
paintlen = COLS - x_start; paintlen = COLS - x_start;
assert(0 <= x_start && 0 < paintlen && assert(0 <= x_start && 0 < paintlen &&
x_start + paintlen <= COLS); x_start + paintlen <= COLS);
mvwaddnstr(edit, yval, x_start, mvwaddnstr(edit, yval, x_start,
converted + x_start, paintlen); converted + x_start, paintlen);
} }
} else if (!searched_later_lines) { } else {
searched_later_lines = 1;
/* There is no end on this line. But we haven't /* There is no end on this line. But we haven't
* yet looked for one on later lines. */ * yet looked for one on later lines. */
end_line = fileptr->next; end_line = fileptr->next;
@ -1902,8 +1898,7 @@ void edit_add(const filestruct *fileptr, const char *converted, int
if (end_line != NULL) { if (end_line != NULL) {
assert(0 <= x_start && x_start < COLS); assert(0 <= x_start && x_start < COLS);
mvwaddnstr(edit, yval, x_start, mvwaddnstr(edit, yval, x_start,
converted + x_start, converted + x_start, COLS - x_start);
COLS - x_start);
/* We painted to the end of the line, so /* We painted to the end of the line, so
* don't bother checking any more starts. */ * don't bother checking any more starts. */
break; break;
@ -1964,8 +1959,8 @@ void edit_add(const filestruct *fileptr, const char *converted, int
/* Otherwise, paintlen is the expanded location of the /* Otherwise, paintlen is the expanded location of the
* end of the mark minus the expanded location of the * end of the mark minus the expanded location of the
* beginning of the mark. */ * beginning of the mark. */
paintlen = strnlenpt(fileptr->data, bot_x) - (x_start + paintlen = strnlenpt(fileptr->data, bot_x)
start); - (x_start + start);
/* If x_start is before the beginning of the page, shift /* If x_start is before the beginning of the page, shift
* paintlen x_start characters to compensate, and put * paintlen x_start characters to compensate, and put