tweaks: chuck a bunch of asserts -- they have lost their usefulness
parent
8d229cb712
commit
ffc550521c
48
src/text.c
48
src/text.c
|
@ -92,9 +92,6 @@ void do_deletion(undo_type action)
|
||||||
size_t old_amount = 0;
|
size_t old_amount = 0;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
assert(openfile->current != NULL && openfile->current->data != NULL &&
|
|
||||||
openfile->current_x <= strlen(openfile->current->data));
|
|
||||||
|
|
||||||
openfile->placewewant = xplustabs();
|
openfile->placewewant = xplustabs();
|
||||||
|
|
||||||
if (openfile->current->data[openfile->current_x] != '\0') {
|
if (openfile->current->data[openfile->current_x] != '\0') {
|
||||||
|
@ -104,8 +101,6 @@ void do_deletion(undo_type action)
|
||||||
size_t line_len = strlen(openfile->current->data +
|
size_t line_len = strlen(openfile->current->data +
|
||||||
openfile->current_x);
|
openfile->current_x);
|
||||||
|
|
||||||
assert(openfile->current_x < strlen(openfile->current->data));
|
|
||||||
|
|
||||||
#ifndef NANO_TINY
|
#ifndef NANO_TINY
|
||||||
update_undo(action);
|
update_undo(action);
|
||||||
|
|
||||||
|
@ -133,8 +128,6 @@ void do_deletion(undo_type action)
|
||||||
* this line with the next. */
|
* this line with the next. */
|
||||||
filestruct *joining = openfile->current->next;
|
filestruct *joining = openfile->current->next;
|
||||||
|
|
||||||
assert(openfile->current_x == strlen(openfile->current->data));
|
|
||||||
|
|
||||||
/* If there is a magic line, and we're before it: don't eat it. */
|
/* If there is a magic line, and we're before it: don't eat it. */
|
||||||
if (joining == openfile->filebot && openfile->current_x != 0 &&
|
if (joining == openfile->filebot && openfile->current_x != 0 &&
|
||||||
!ISSET(NO_NEWLINES)) {
|
!ISSET(NO_NEWLINES)) {
|
||||||
|
@ -466,8 +459,6 @@ void do_comment(void)
|
||||||
size_t top_x, bot_x;
|
size_t top_x, bot_x;
|
||||||
bool empty, all_empty = TRUE;
|
bool empty, all_empty = TRUE;
|
||||||
|
|
||||||
assert(openfile->current != NULL && openfile->current->data != NULL);
|
|
||||||
|
|
||||||
#ifndef DISABLE_COLOR
|
#ifndef DISABLE_COLOR
|
||||||
if (openfile->syntax)
|
if (openfile->syntax)
|
||||||
comment_seq = openfile->syntax->comment;
|
comment_seq = openfile->syntax->comment;
|
||||||
|
@ -1357,7 +1348,6 @@ fprintf(stderr, " >> Updating... action = %d, openfile->last_action = %d, openf
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
assert(openfile->undotop != NULL);
|
|
||||||
u = openfile->undotop;
|
u = openfile->undotop;
|
||||||
|
|
||||||
u->newsize = openfile->totsize;
|
u->newsize = openfile->totsize;
|
||||||
|
@ -1481,7 +1471,7 @@ void wrap_reset(void)
|
||||||
/* Try wrapping the given line. Return TRUE if wrapped, FALSE otherwise. */
|
/* Try wrapping the given line. Return TRUE if wrapped, FALSE otherwise. */
|
||||||
bool do_wrap(filestruct *line)
|
bool do_wrap(filestruct *line)
|
||||||
{
|
{
|
||||||
size_t line_len;
|
size_t line_len = strlen(line->data);
|
||||||
/* The length of the line we wrap. */
|
/* The length of the line we wrap. */
|
||||||
ssize_t wrap_loc;
|
ssize_t wrap_loc;
|
||||||
/* The index of line->data where we wrap. */
|
/* The index of line->data where we wrap. */
|
||||||
|
@ -1510,10 +1500,6 @@ bool do_wrap(filestruct *line)
|
||||||
* of the line while trying to find one, we should return without
|
* of the line while trying to find one, we should return without
|
||||||
* wrapping. Note that if autoindent is turned on, we don't break
|
* wrapping. Note that if autoindent is turned on, we don't break
|
||||||
* at the end of it! */
|
* at the end of it! */
|
||||||
assert(line != NULL && line->data != NULL);
|
|
||||||
|
|
||||||
/* Save the length of the line. */
|
|
||||||
line_len = strlen(line->data);
|
|
||||||
|
|
||||||
/* Find the last blank where we can break the line. */
|
/* Find the last blank where we can break the line. */
|
||||||
wrap_loc = break_line(line->data, fill, FALSE);
|
wrap_loc = break_line(line->data, fill, FALSE);
|
||||||
|
@ -1551,8 +1537,6 @@ bool do_wrap(filestruct *line)
|
||||||
after_break = line->data + wrap_loc;
|
after_break = line->data + wrap_loc;
|
||||||
after_break_len = line_len - wrap_loc;
|
after_break_len = line_len - wrap_loc;
|
||||||
|
|
||||||
assert(strlen(after_break) == after_break_len);
|
|
||||||
|
|
||||||
/* We prepend the wrapped text to the next line, if the prepend_wrap
|
/* We prepend the wrapped text to the next line, if the prepend_wrap
|
||||||
* flag is set, there is a next line, and prepending would not make
|
* flag is set, there is a next line, and prepending would not make
|
||||||
* the line too long. */
|
* the line too long. */
|
||||||
|
@ -1734,12 +1718,6 @@ void justify_format(filestruct *paragraph, size_t skip)
|
||||||
size_t mark_shift = 0;
|
size_t mark_shift = 0;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* These four asserts are assumptions about the input data. */
|
|
||||||
assert(paragraph != NULL);
|
|
||||||
assert(paragraph->data != NULL);
|
|
||||||
assert(skip < strlen(paragraph->data));
|
|
||||||
assert(!is_blank_mbchar(paragraph->data + skip));
|
|
||||||
|
|
||||||
end = paragraph->data + skip;
|
end = paragraph->data + skip;
|
||||||
new_paragraph_data = charalloc(strlen(paragraph->data) + 1);
|
new_paragraph_data = charalloc(strlen(paragraph->data) + 1);
|
||||||
strncpy(new_paragraph_data, paragraph->data, skip);
|
strncpy(new_paragraph_data, paragraph->data, skip);
|
||||||
|
@ -1840,8 +1818,6 @@ void justify_format(filestruct *paragraph, size_t skip)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
assert(*end == '\0');
|
|
||||||
|
|
||||||
*new_end = *end;
|
*new_end = *end;
|
||||||
|
|
||||||
/* If there are spaces at the end of the line, remove them. */
|
/* If there are spaces at the end of the line, remove them. */
|
||||||
|
@ -1891,11 +1867,8 @@ size_t quote_length(const char *line)
|
||||||
bool quotes_match(const char *a_line, size_t a_quote, const char
|
bool quotes_match(const char *a_line, size_t a_quote, const char
|
||||||
*b_line)
|
*b_line)
|
||||||
{
|
{
|
||||||
/* Here is the assumption about a_quote. */
|
|
||||||
assert(a_quote == quote_length(a_line));
|
|
||||||
|
|
||||||
return (a_quote == quote_length(b_line) &&
|
return (a_quote == quote_length(b_line) &&
|
||||||
strncmp(a_line, b_line, a_quote) == 0);
|
strncmp(a_line, b_line, a_quote) == 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* We assume a_line and b_line have no quote part. Then, we return
|
/* We assume a_line and b_line have no quote part. Then, we return
|
||||||
|
@ -1903,11 +1876,8 @@ bool quotes_match(const char *a_line, size_t a_quote, const char
|
||||||
bool indents_match(const char *a_line, size_t a_indent, const char
|
bool indents_match(const char *a_line, size_t a_indent, const char
|
||||||
*b_line, size_t b_indent)
|
*b_line, size_t b_indent)
|
||||||
{
|
{
|
||||||
assert(a_indent == indent_length(a_line));
|
|
||||||
assert(b_indent == indent_length(b_line));
|
|
||||||
|
|
||||||
return (b_indent <= a_indent &&
|
return (b_indent <= a_indent &&
|
||||||
strncmp(a_line, b_line, b_indent) == 0);
|
strncmp(a_line, b_line, b_indent) == 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Is foo the beginning of a paragraph?
|
/* Is foo the beginning of a paragraph?
|
||||||
|
@ -2008,12 +1978,6 @@ void backup_lines(filestruct *first_line, size_t par_len)
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* par_len will be one greater than the number of lines between
|
|
||||||
* current and filebot if filebot is the last line in the
|
|
||||||
* paragraph. */
|
|
||||||
assert(par_len > 0 && openfile->current->lineno + par_len <=
|
|
||||||
openfile->filebot->lineno + 1);
|
|
||||||
|
|
||||||
/* Move bot down par_len lines to the line after the last line of
|
/* Move bot down par_len lines to the line after the last line of
|
||||||
* the paragraph, if there is one. */
|
* the paragraph, if there is one. */
|
||||||
for (i = par_len; i > 0 && bot != openfile->filebot; i--)
|
for (i = par_len; i > 0 && bot != openfile->filebot; i--)
|
||||||
|
@ -2087,8 +2051,6 @@ bool find_paragraph(size_t *const quote, size_t *const par)
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
assert(openfile->current != NULL);
|
|
||||||
|
|
||||||
/* If we're at the end of the last line of the file, it means that
|
/* If we're at the end of the last line of the file, it means that
|
||||||
* there aren't any paragraphs left, so get out. */
|
* there aren't any paragraphs left, so get out. */
|
||||||
if (openfile->current == openfile->filebot && openfile->current_x ==
|
if (openfile->current == openfile->filebot && openfile->current_x ==
|
||||||
|
@ -2139,8 +2101,6 @@ bool find_paragraph(size_t *const quote, size_t *const par)
|
||||||
openfile->current = current_save;
|
openfile->current = current_save;
|
||||||
|
|
||||||
/* Save the values of quote_len and par_len. */
|
/* Save the values of quote_len and par_len. */
|
||||||
assert(quote != NULL && par != NULL);
|
|
||||||
|
|
||||||
*quote = quote_len;
|
*quote = quote_len;
|
||||||
*par = par_len;
|
*par = par_len;
|
||||||
|
|
||||||
|
@ -2359,8 +2319,6 @@ void do_justify(bool full_justify)
|
||||||
* just after the space. */
|
* just after the space. */
|
||||||
break_pos += indent_len + 1;
|
break_pos += indent_len + 1;
|
||||||
|
|
||||||
assert(break_pos <= line_len);
|
|
||||||
|
|
||||||
/* If this paragraph is non-quoted, and autoindent isn't
|
/* If this paragraph is non-quoted, and autoindent isn't
|
||||||
* turned on, set the indentation length to zero so that the
|
* turned on, set the indentation length to zero so that the
|
||||||
* indentation is treated as part of the line. */
|
* indentation is treated as part of the line. */
|
||||||
|
|
Loading…
Reference in New Issue