tweaks: rewrap some lines and some comments, and trim two others

master
Benno Schulenberg 2017-12-10 20:03:51 +01:00
parent 03783a7d1b
commit bcd187d7d6
2 changed files with 18 additions and 33 deletions

View File

@ -216,10 +216,8 @@ size_t move_mbright(const char *buf, size_t pos);
int mbstrcasecmp(const char *s1, const char *s2); int mbstrcasecmp(const char *s1, const char *s2);
int mbstrncasecmp(const char *s1, const char *s2, size_t n); int mbstrncasecmp(const char *s1, const char *s2, size_t n);
char *mbstrcasestr(const char *haystack, const char *needle); char *mbstrcasestr(const char *haystack, const char *needle);
char *revstrstr(const char *haystack, const char *needle, char *revstrstr(const char *haystack, const char *needle, const char *index);
const char *index); char *mbrevstrcasestr(const char *haystack, const char *needle, const char *index);
char *mbrevstrcasestr(const char *haystack, const char *needle,
const char *index);
size_t mbstrlen(const char *s); size_t mbstrlen(const char *s);
size_t mbstrnlen(const char *s, size_t maxlen); size_t mbstrnlen(const char *s, size_t maxlen);
#if !defined(NANO_TINY) || defined(ENABLE_JUSTIFY) #if !defined(NANO_TINY) || defined(ENABLE_JUSTIFY)
@ -266,6 +264,7 @@ void do_uncut_text(void);
/* Most functions in files.c. */ /* Most functions in files.c. */
void initialize_buffer_text(void); void initialize_buffer_text(void);
void set_modified(void);
bool open_buffer(const char *filename, bool undoable); bool open_buffer(const char *filename, bool undoable);
#ifdef ENABLE_SPELLER #ifdef ENABLE_SPELLER
void replace_buffer(const char *filename); void replace_buffer(const char *filename);
@ -450,8 +449,7 @@ void do_output(char *output, size_t output_len, bool allow_cntrls);
#ifdef ENABLE_MOUSE #ifdef ENABLE_MOUSE
int do_statusbar_mouse(void); int do_statusbar_mouse(void);
#endif #endif
void do_statusbar_output(int *the_input, size_t input_len, void do_statusbar_output(int *the_input, size_t input_len, bool filtering);
bool filtering);
void do_statusbar_home(void); void do_statusbar_home(void);
void do_statusbar_end(void); void do_statusbar_end(void);
void do_statusbar_left(void); void do_statusbar_left(void);
@ -646,7 +644,6 @@ void blank_bottombars(void);
void check_statusblank(void); void check_statusblank(void);
char *display_string(const char *buf, size_t column, size_t span, bool isdata); char *display_string(const char *buf, size_t column, size_t span, bool isdata);
void titlebar(const char *path); void titlebar(const char *path);
extern void set_modified(void);
void statusbar(const char *msg); void statusbar(const char *msg);
void warn_and_shortly_pause(const char *msg); void warn_and_shortly_pause(const char *msg);
void statusline(message_type importance, const char *msg, ...); void statusline(message_type importance, const char *msg, ...);

View File

@ -1888,8 +1888,7 @@ void justify_format(filestruct *paragraph, size_t skip)
*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. */
while (new_end > new_paragraph_data + skip && while (new_end > new_paragraph_data + skip && *(new_end - 1) == ' ') {
*(new_end - 1) == ' ') {
new_end--; new_end--;
shift++; shift++;
} }
@ -1931,8 +1930,7 @@ size_t quote_length(const char *line)
/* a_line and b_line are lines of text. The quotation part of a_line is /* a_line and b_line are lines of text. The quotation part of a_line is
* the first a_quote characters. Check that the quotation part of * the first a_quote characters. Check that the quotation part of
* b_line is the same. */ * b_line is the same. */
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)
{ {
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);
@ -1943,8 +1941,7 @@ 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)
{ {
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?
@ -2029,7 +2026,6 @@ void backup_lines(filestruct *first_line, size_t par_len)
filestruct *bot = first_line; filestruct *bot = first_line;
/* The bottom of the paragraph we're backing up. */ /* The bottom of the paragraph we're backing up. */
size_t i; size_t i;
/* Generic loop variable. */
size_t current_x_save = openfile->current_x; size_t current_x_save = openfile->current_x;
ssize_t fl_lineno_save = first_line->lineno; ssize_t fl_lineno_save = first_line->lineno;
ssize_t edittop_lineno_save = openfile->edittop->lineno; ssize_t edittop_lineno_save = openfile->edittop->lineno;
@ -2153,10 +2149,9 @@ bool find_paragraph(size_t *const quote, size_t *const par)
do_para_end(FALSE); do_para_end(FALSE);
par_len = openfile->current->lineno - current_save->lineno; par_len = openfile->current->lineno - current_save->lineno;
/* If we end up past the beginning of the line, it means that we're /* If we end up past the beginning of the line, it means that we're at
* at the end of the last line of the file, and the line isn't * the end of the last line of the file, and the line isn't blank, in
* blank, in which case the last line of the file is part of the * which case the last line of the file is part of the paragraph. */
* paragraph. */
if (openfile->current_x > 0) if (openfile->current_x > 0)
par_len++; par_len++;
openfile->current = current_save; openfile->current = current_save;
@ -2179,15 +2174,13 @@ void do_justify(bool full_justify)
/* Will be the line after the last line of the justified /* Will be the line after the last line of the justified
* paragraph(s), if any. Also for restoring after unjustify. */ * paragraph(s), if any. Also for restoring after unjustify. */
bool filebot_inpar = FALSE; bool filebot_inpar = FALSE;
/* Whether the text at filebot is part of the current /* Whether the text at filebot is part of the current paragraph. */
* paragraph. */
int kbinput; int kbinput;
/* The first keystroke after a justification. */ /* The first keystroke after a justification. */
functionptrtype func; functionptrtype func;
/* The function associated with that keystroke. */ /* The function associated with that keystroke. */
/* We save these variables to be restored if the user /* We save these variables to be restored if the user unjustifies. */
* unjustifies. */
filestruct *edittop_save = openfile->edittop; filestruct *edittop_save = openfile->edittop;
size_t firstcolumn_save = openfile->firstcolumn; size_t firstcolumn_save = openfile->firstcolumn;
filestruct *current_save = openfile->current; filestruct *current_save = openfile->current;
@ -2213,11 +2206,9 @@ void do_justify(bool full_justify)
filestruct *curr_first_par_line; filestruct *curr_first_par_line;
/* The first line of the current paragraph. */ /* The first line of the current paragraph. */
size_t quote_len; size_t quote_len;
/* Length of the initial quotation of the current /* Length of the initial quotation of the current paragraph. */
* paragraph. */
size_t indent_len; size_t indent_len;
/* Length of the initial indentation of the current /* Length of the initial indentation of the current paragraph. */
* paragraph. */
size_t par_len; size_t par_len;
/* Number of lines in the current paragraph. */ /* Number of lines in the current paragraph. */
ssize_t break_pos; ssize_t break_pos;
@ -2356,9 +2347,8 @@ void do_justify(bool full_justify)
par_len--; par_len--;
} }
/* Call justify_format() on the paragraph, which will remove /* Call justify_format() on the paragraph, which will remove excess
* excess spaces from it and change all blank characters to * spaces from it and change all blank characters to spaces. */
* spaces. */
justify_format(openfile->current, quote_len + justify_format(openfile->current, quote_len +
indent_length(openfile->current->data + quote_len)); indent_length(openfile->current->data + quote_len));
@ -2427,15 +2417,13 @@ void do_justify(bool full_justify)
par_len--; par_len--;
} }
/* We're done breaking lines, so we don't need indent_string
* anymore. */
free(indent_string); free(indent_string);
/* Go to the next line, if possible. If there is no next line, /* Go to the next line, if possible. If there is no next line,
* move to the end of the current line. */ * move to the end of the current line. */
if (openfile->current != openfile->filebot) { if (openfile->current != openfile->filebot)
openfile->current = openfile->current->next; openfile->current = openfile->current->next;
} else else
openfile->current_x = strlen(openfile->current->data); openfile->current_x = strlen(openfile->current->data);
/* Renumber the now-justified paragraph, since both refreshing the /* Renumber the now-justified paragraph, since both refreshing the