per DB's patch, convert nano.c to use bools wherever needed, add a few
efficiency tweaks, and fix a few minor bugs in help_init() where "Up" and "Space" might not be displayed properly and the help browser wouldn't work if fewer than 24 columns were available git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@1885 35c25a1d-7b9e-4130-9fde-d3aeb78583b8master
parent
73cd1a5ded
commit
ce62e82a93
|
@ -1,8 +1,8 @@
|
||||||
CVS code -
|
CVS code -
|
||||||
- General:
|
- General:
|
||||||
- More minor comment cleanups. (DLR)
|
- More minor comment cleanups. (DLR)
|
||||||
- Convert more ints using 0 and 1 to bools using TRUE and FALSE.
|
- Convert more ints and functions using 0 and 1 to bools using
|
||||||
(David Benbennick and DLR)
|
TRUE and FALSE. (David Benbennick and DLR)
|
||||||
- Change more instances of ints that have large enough upper
|
- Change more instances of ints that have large enough upper
|
||||||
bounds and which can never be negative to size_t's, and
|
bounds and which can never be negative to size_t's, and
|
||||||
convert nano to handle them properly. (DLR)
|
convert nano to handle them properly. (DLR)
|
||||||
|
@ -102,6 +102,11 @@ CVS code -
|
||||||
thanks_for_all_the_fish()
|
thanks_for_all_the_fish()
|
||||||
- Delete topwin, edit, and bottomwin. (David Benbennick)
|
- Delete topwin, edit, and bottomwin. (David Benbennick)
|
||||||
- nano.c:
|
- nano.c:
|
||||||
|
help_init()
|
||||||
|
- Fix the display of the translated key descriptions "Up" and
|
||||||
|
"Space" under all circumstances, and make the help browser
|
||||||
|
work properly when there are fewer than 24 columns available.
|
||||||
|
(David Benbennick)
|
||||||
usage()
|
usage()
|
||||||
- Don't translate the option strings for -Z/--restricted.
|
- Don't translate the option strings for -Z/--restricted.
|
||||||
(David Benbennick)
|
(David Benbennick)
|
||||||
|
|
143
src/nano.c
143
src/nano.c
|
@ -61,7 +61,7 @@ static ssize_t fill = 0; /* Fill - where to wrap lines,
|
||||||
basically */
|
basically */
|
||||||
#endif
|
#endif
|
||||||
#ifndef DISABLE_WRAPPING
|
#ifndef DISABLE_WRAPPING
|
||||||
static int same_line_wrap = FALSE; /* Whether wrapped text should
|
static bool same_line_wrap = FALSE; /* Whether wrapped text should
|
||||||
be prepended to the next
|
be prepended to the next
|
||||||
line */
|
line */
|
||||||
#endif
|
#endif
|
||||||
|
@ -159,7 +159,7 @@ void die(const char *msg, ...)
|
||||||
void die_save_file(const char *die_filename)
|
void die_save_file(const char *die_filename)
|
||||||
{
|
{
|
||||||
char *ret;
|
char *ret;
|
||||||
int i = -1;
|
bool failed = TRUE;
|
||||||
|
|
||||||
/* If we're using restricted mode, don't write any emergency backup
|
/* If we're using restricted mode, don't write any emergency backup
|
||||||
* files, since that would allow reading from or writing to files
|
* files, since that would allow reading from or writing to files
|
||||||
|
@ -180,9 +180,9 @@ void die_save_file(const char *die_filename)
|
||||||
free(buf);
|
free(buf);
|
||||||
}
|
}
|
||||||
if (ret[0] != '\0')
|
if (ret[0] != '\0')
|
||||||
i = write_file(ret, TRUE, FALSE, TRUE);
|
failed = -1 == write_file(ret, TRUE, FALSE, TRUE);
|
||||||
|
|
||||||
if (i != -1)
|
if (!failed)
|
||||||
fprintf(stderr, _("\nBuffer written to %s\n"), ret);
|
fprintf(stderr, _("\nBuffer written to %s\n"), ret);
|
||||||
else
|
else
|
||||||
fprintf(stderr, _("\nNo %s written (too many backup files?)\n"), ret);
|
fprintf(stderr, _("\nNo %s written (too many backup files?)\n"), ret);
|
||||||
|
@ -203,8 +203,8 @@ void print_view_warning(void)
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Initialize global variables -- no better way for now. If
|
/* Initialize global variables -- no better way for now. If
|
||||||
* save_cutbuffer is nonzero, don't set cutbuffer to NULL. */
|
* save_cutbuffer is TRUE, don't set cutbuffer to NULL. */
|
||||||
void global_init(int save_cutbuffer)
|
void global_init(bool save_cutbuffer)
|
||||||
{
|
{
|
||||||
current_x = 0;
|
current_x = 0;
|
||||||
current_y = 0;
|
current_y = 0;
|
||||||
|
@ -393,12 +393,12 @@ void help_init(void)
|
||||||
|
|
||||||
/* The space needed for the shortcut lists, at most COLS characters,
|
/* The space needed for the shortcut lists, at most COLS characters,
|
||||||
* plus '\n'. */
|
* plus '\n'. */
|
||||||
allocsize += (COLS + 1) * length_of_list(currshortcut);
|
allocsize += (COLS < 21 ? 21 : COLS + 1) * length_of_list(currshortcut);
|
||||||
|
|
||||||
#ifndef NANO_SMALL
|
#ifndef NANO_SMALL
|
||||||
/* If we're on the main list, we also count the toggle help text.
|
/* If we're on the main list, we also count the toggle help text.
|
||||||
* Each line has "M-%c\t\t\t", which fills 24 columns, plus at most
|
* Each line has "M-%c\t\t\t", which fills 24 columns, plus a space,
|
||||||
* COLS - 24 characters, plus '\n'.*/
|
* plus translated text, plus '\n'. */
|
||||||
if (currshortcut == main_list) {
|
if (currshortcut == main_list) {
|
||||||
size_t endislen = strlen(_("enable/disable"));
|
size_t endislen = strlen(_("enable/disable"));
|
||||||
|
|
||||||
|
@ -420,18 +420,18 @@ void help_init(void)
|
||||||
|
|
||||||
/* Now add our shortcut info. */
|
/* Now add our shortcut info. */
|
||||||
for (s = currshortcut; s != NULL; s = s->next) {
|
for (s = currshortcut; s != NULL; s = s->next) {
|
||||||
int meta_shortcut = FALSE;
|
bool meta_shortcut = FALSE;
|
||||||
/* TRUE if the character in s->metaval is shown in the
|
/* TRUE if the character in s->metaval is shown in the
|
||||||
* first column. */
|
* first column. */
|
||||||
|
|
||||||
if (s->ctrlval != NANO_NO_KEY) {
|
if (s->ctrlval != NANO_NO_KEY) {
|
||||||
#ifndef NANO_SMALL
|
#ifndef NANO_SMALL
|
||||||
if (s->ctrlval == NANO_HISTORY_KEY)
|
if (s->ctrlval == NANO_HISTORY_KEY)
|
||||||
ptr += sprintf(ptr, "%.2s", _("Up"));
|
ptr += sprintf(ptr, "%.7s", _("Up"));
|
||||||
else
|
else
|
||||||
#endif
|
#endif
|
||||||
if (s->ctrlval == NANO_CONTROL_SPACE)
|
if (s->ctrlval == NANO_CONTROL_SPACE)
|
||||||
ptr += sprintf(ptr, "^%.5s", _("Space"));
|
ptr += sprintf(ptr, "^%.6s", _("Space"));
|
||||||
else if (s->ctrlval == NANO_CONTROL_8)
|
else if (s->ctrlval == NANO_CONTROL_8)
|
||||||
ptr += sprintf(ptr, "^?");
|
ptr += sprintf(ptr, "^?");
|
||||||
else
|
else
|
||||||
|
@ -441,7 +441,7 @@ void help_init(void)
|
||||||
else if (s->metaval != NANO_NO_KEY) {
|
else if (s->metaval != NANO_NO_KEY) {
|
||||||
meta_shortcut = TRUE;
|
meta_shortcut = TRUE;
|
||||||
if (s->metaval == NANO_ALT_SPACE)
|
if (s->metaval == NANO_ALT_SPACE)
|
||||||
ptr += snprintf(ptr, 8, "M-%.5s", _("Space"));
|
ptr += sprintf(ptr, "M-%.5s", _("Space"));
|
||||||
else
|
else
|
||||||
ptr += sprintf(ptr, "M-%c", toupper(s->metaval));
|
ptr += sprintf(ptr, "M-%c", toupper(s->metaval));
|
||||||
}
|
}
|
||||||
|
@ -794,26 +794,26 @@ RETSIGTYPE cancel_fork(int signal)
|
||||||
nperror("kill");
|
nperror("kill");
|
||||||
}
|
}
|
||||||
|
|
||||||
int open_pipe(const char *command)
|
/* Return TRUE on success. */
|
||||||
|
bool open_pipe(const char *command)
|
||||||
{
|
{
|
||||||
int fd[2];
|
int fd[2];
|
||||||
FILE *f;
|
FILE *f;
|
||||||
struct sigaction oldaction, newaction;
|
struct sigaction oldaction, newaction;
|
||||||
/* Original and temporary handlers for
|
/* Original and temporary handlers for
|
||||||
* SIGINT. */
|
* SIGINT. */
|
||||||
int cancel_sigs = 0;
|
bool sig_failed = FALSE;
|
||||||
/* cancel_sigs == 1 means that sigaction() failed without changing
|
/* sig_failed means that sigaction() failed without changing the
|
||||||
* the signal handlers. cancel_sigs == 2 means the signal handler
|
* signal handlers.
|
||||||
* was changed, but the tcsetattr() didn't succeed.
|
|
||||||
*
|
*
|
||||||
* I use this variable since it is important to put things back when
|
* We use this variable since it is important to put things back
|
||||||
* we finish, even if we get errors. */
|
* when we finish, even if we get errors. */
|
||||||
|
|
||||||
/* Make our pipes. */
|
/* Make our pipes. */
|
||||||
|
|
||||||
if (pipe(fd) == -1) {
|
if (pipe(fd) == -1) {
|
||||||
statusbar(_("Could not pipe"));
|
statusbar(_("Could not pipe"));
|
||||||
return 1;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Fork a child. */
|
/* Fork a child. */
|
||||||
|
@ -823,7 +823,7 @@ int open_pipe(const char *command)
|
||||||
dup2(fd[1], fileno(stdout));
|
dup2(fd[1], fileno(stdout));
|
||||||
dup2(fd[1], fileno(stderr));
|
dup2(fd[1], fileno(stderr));
|
||||||
/* If execl() returns at all, there was an error. */
|
/* If execl() returns at all, there was an error. */
|
||||||
|
|
||||||
execl("/bin/sh", "sh", "-c", command, 0);
|
execl("/bin/sh", "sh", "-c", command, 0);
|
||||||
exit(0);
|
exit(0);
|
||||||
}
|
}
|
||||||
|
@ -835,7 +835,7 @@ int open_pipe(const char *command)
|
||||||
if (pid == -1) {
|
if (pid == -1) {
|
||||||
close(fd[0]);
|
close(fd[0]);
|
||||||
statusbar(_("Could not fork"));
|
statusbar(_("Could not fork"));
|
||||||
return 1;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Before we start reading the forked command's output, we set
|
/* Before we start reading the forked command's output, we set
|
||||||
|
@ -846,12 +846,12 @@ int open_pipe(const char *command)
|
||||||
enable_signals();
|
enable_signals();
|
||||||
|
|
||||||
if (sigaction(SIGINT, NULL, &newaction) == -1) {
|
if (sigaction(SIGINT, NULL, &newaction) == -1) {
|
||||||
cancel_sigs = 1;
|
sig_failed = TRUE;
|
||||||
nperror("sigaction");
|
nperror("sigaction");
|
||||||
} else {
|
} else {
|
||||||
newaction.sa_handler = cancel_fork;
|
newaction.sa_handler = cancel_fork;
|
||||||
if (sigaction(SIGINT, &newaction, &oldaction) == -1) {
|
if (sigaction(SIGINT, &newaction, &oldaction) == -1) {
|
||||||
cancel_sigs = 1;
|
sig_failed = TRUE;
|
||||||
nperror("sigaction");
|
nperror("sigaction");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -860,9 +860,9 @@ int open_pipe(const char *command)
|
||||||
|
|
||||||
f = fdopen(fd[0], "rb");
|
f = fdopen(fd[0], "rb");
|
||||||
if (f == NULL)
|
if (f == NULL)
|
||||||
nperror("fdopen");
|
nperror("fdopen");
|
||||||
|
|
||||||
read_file(f, "stdin", 0);
|
read_file(f, "stdin", FALSE);
|
||||||
/* If multibuffer mode is on, we could be here in view mode. If so,
|
/* If multibuffer mode is on, we could be here in view mode. If so,
|
||||||
* don't set the modification flag. */
|
* don't set the modification flag. */
|
||||||
if (!ISSET(VIEW_MODE))
|
if (!ISSET(VIEW_MODE))
|
||||||
|
@ -871,14 +871,14 @@ int open_pipe(const char *command)
|
||||||
if (wait(NULL) == -1)
|
if (wait(NULL) == -1)
|
||||||
nperror("wait");
|
nperror("wait");
|
||||||
|
|
||||||
if (cancel_sigs != 1 && sigaction(SIGINT, &oldaction, NULL) == -1)
|
if (!sig_failed && sigaction(SIGINT, &oldaction, NULL) == -1)
|
||||||
nperror("sigaction");
|
nperror("sigaction");
|
||||||
|
|
||||||
/* Disable interpretation of the special control keys so that we can
|
/* Disable interpretation of the special control keys so that we can
|
||||||
* use Ctrl-C for other things. */
|
* use Ctrl-C for other things. */
|
||||||
disable_signals();
|
disable_signals();
|
||||||
|
|
||||||
return 0;
|
return TRUE;
|
||||||
}
|
}
|
||||||
#endif /* !NANO_SMALL */
|
#endif /* !NANO_SMALL */
|
||||||
|
|
||||||
|
@ -891,7 +891,7 @@ void do_mouse(void)
|
||||||
/* Click in the edit window to move the cursor, but only when
|
/* Click in the edit window to move the cursor, but only when
|
||||||
we're not in a subfunction. */
|
we're not in a subfunction. */
|
||||||
if (wenclose(edit, mouse_y, mouse_x) && currshortcut == main_list) {
|
if (wenclose(edit, mouse_y, mouse_x) && currshortcut == main_list) {
|
||||||
int sameline;
|
bool sameline;
|
||||||
/* Did they click on the line with the cursor? If they
|
/* Did they click on the line with the cursor? If they
|
||||||
clicked on the cursor, we set the mark. */
|
clicked on the cursor, we set the mark. */
|
||||||
size_t xcur;
|
size_t xcur;
|
||||||
|
@ -938,7 +938,7 @@ void do_char(char ch)
|
||||||
{
|
{
|
||||||
size_t current_len = strlen(current->data);
|
size_t current_len = strlen(current->data);
|
||||||
#if !defined(DISABLE_WRAPPING) || defined(ENABLE_COLOR)
|
#if !defined(DISABLE_WRAPPING) || defined(ENABLE_COLOR)
|
||||||
int do_refresh = FALSE;
|
bool do_refresh = FALSE;
|
||||||
/* Do we have to call edit_refresh(), or can we get away with
|
/* Do we have to call edit_refresh(), or can we get away with
|
||||||
* update_line()? */
|
* update_line()? */
|
||||||
#endif
|
#endif
|
||||||
|
@ -1026,7 +1026,7 @@ void do_backspace(void)
|
||||||
|
|
||||||
void do_delete(void)
|
void do_delete(void)
|
||||||
{
|
{
|
||||||
int do_refresh = FALSE;
|
bool do_refresh = FALSE;
|
||||||
/* Do we have to call edit_refresh(), or can we get away with
|
/* Do we have to call edit_refresh(), or can we get away with
|
||||||
* update_line()? */
|
* update_line()? */
|
||||||
|
|
||||||
|
@ -1248,7 +1248,7 @@ void wrap_reset(void)
|
||||||
/* We wrap the given line. Precondition: we assume the cursor has been
|
/* We wrap the given line. Precondition: we assume the cursor has been
|
||||||
* moved forward since the last typed character. Return value: whether
|
* moved forward since the last typed character. Return value: whether
|
||||||
* we wrapped. */
|
* we wrapped. */
|
||||||
int do_wrap(filestruct *inptr)
|
bool do_wrap(filestruct *inptr)
|
||||||
{
|
{
|
||||||
size_t len = strlen(inptr->data);
|
size_t len = strlen(inptr->data);
|
||||||
/* Length of the line we wrap. */
|
/* Length of the line we wrap. */
|
||||||
|
@ -1264,7 +1264,7 @@ int do_wrap(filestruct *inptr)
|
||||||
#endif
|
#endif
|
||||||
const char *after_break; /* Text after the wrap point. */
|
const char *after_break; /* Text after the wrap point. */
|
||||||
size_t after_break_len; /* strlen(after_break) */
|
size_t after_break_len; /* strlen(after_break) */
|
||||||
int wrapping = FALSE; /* Do we prepend to the next line? */
|
bool wrapping = FALSE; /* Do we prepend to the next line? */
|
||||||
const char *wrap_line = NULL;
|
const char *wrap_line = NULL;
|
||||||
/* The next line, minus indentation. */
|
/* The next line, minus indentation. */
|
||||||
size_t wrap_line_len = 0; /* strlen(wrap_line) */
|
size_t wrap_line_len = 0; /* strlen(wrap_line) */
|
||||||
|
@ -1447,8 +1447,8 @@ int do_wrap(filestruct *inptr)
|
||||||
|
|
||||||
#ifndef DISABLE_SPELLER
|
#ifndef DISABLE_SPELLER
|
||||||
/* A word is misspelled in the file. Let the user replace it. We
|
/* A word is misspelled in the file. Let the user replace it. We
|
||||||
* return zero if the user cancels. */
|
* return FALSE if the user cancels. */
|
||||||
int do_int_spell_fix(const char *word)
|
bool do_int_spell_fix(const char *word)
|
||||||
{
|
{
|
||||||
char *save_search;
|
char *save_search;
|
||||||
char *save_replace;
|
char *save_replace;
|
||||||
|
@ -1456,12 +1456,12 @@ int do_int_spell_fix(const char *word)
|
||||||
filestruct *current_save = current;
|
filestruct *current_save = current;
|
||||||
filestruct *edittop_save = edittop;
|
filestruct *edittop_save = edittop;
|
||||||
/* Save where we are. */
|
/* Save where we are. */
|
||||||
int i = 0;
|
bool accepted = TRUE;
|
||||||
/* The return value. */
|
/* The return value. */
|
||||||
int reverse_search_set = ISSET(REVERSE_SEARCH);
|
bool reverse_search_set = ISSET(REVERSE_SEARCH);
|
||||||
#ifndef NANO_SMALL
|
#ifndef NANO_SMALL
|
||||||
int case_sens_set = ISSET(CASE_SENSITIVE);
|
bool case_sens_set = ISSET(CASE_SENSITIVE);
|
||||||
int mark_set = ISSET(MARK_ISSET);
|
bool mark_set = ISSET(MARK_ISSET);
|
||||||
|
|
||||||
SET(CASE_SENSITIVE);
|
SET(CASE_SENSITIVE);
|
||||||
/* Make sure the marking highlight is off during spell-check. */
|
/* Make sure the marking highlight is off during spell-check. */
|
||||||
|
@ -1493,7 +1493,7 @@ int do_int_spell_fix(const char *word)
|
||||||
do_replace_highlight(TRUE, word);
|
do_replace_highlight(TRUE, word);
|
||||||
|
|
||||||
/* Allow the replace word to be corrected. */
|
/* Allow the replace word to be corrected. */
|
||||||
i = statusq(FALSE, spell_list, word,
|
accepted = -1 != statusq(FALSE, spell_list, word,
|
||||||
#ifndef NANO_SMALL
|
#ifndef NANO_SMALL
|
||||||
NULL,
|
NULL,
|
||||||
#endif
|
#endif
|
||||||
|
@ -1501,7 +1501,7 @@ int do_int_spell_fix(const char *word)
|
||||||
|
|
||||||
do_replace_highlight(FALSE, word);
|
do_replace_highlight(FALSE, word);
|
||||||
|
|
||||||
if (i != -1 && strcmp(word, answer) != 0) {
|
if (accepted && strcmp(word, answer) != 0) {
|
||||||
search_last_line = FALSE;
|
search_last_line = FALSE;
|
||||||
current_x--;
|
current_x--;
|
||||||
do_replace_loop(word, current_save, ¤t_x_save, TRUE);
|
do_replace_loop(word, current_save, ¤t_x_save, TRUE);
|
||||||
|
@ -1534,12 +1534,12 @@ int do_int_spell_fix(const char *word)
|
||||||
SET(MARK_ISSET);
|
SET(MARK_ISSET);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
return i != -1;
|
return accepted;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Integrated spell checking using 'spell' program. Return value: NULL
|
/* Integrated spell checking using 'spell' program. Return value: NULL
|
||||||
* for normal termination, otherwise the error string. */
|
* for normal termination, otherwise the error string. */
|
||||||
const char *do_int_speller(char *tempfile_name)
|
const char *do_int_speller(const char *tempfile_name)
|
||||||
{
|
{
|
||||||
char *read_buff, *read_buff_ptr, *read_buff_word;
|
char *read_buff, *read_buff_ptr, *read_buff_word;
|
||||||
size_t pipe_buff_size, read_buff_size, read_buff_read, bytesread;
|
size_t pipe_buff_size, read_buff_size, read_buff_read, bytesread;
|
||||||
|
@ -1735,7 +1735,7 @@ const char *do_alt_speller(char *tempfile_name)
|
||||||
static int arglen = 3;
|
static int arglen = 3;
|
||||||
static char **spellargs = (char **)NULL;
|
static char **spellargs = (char **)NULL;
|
||||||
#ifndef NANO_SMALL
|
#ifndef NANO_SMALL
|
||||||
int mark_set = ISSET(MARK_ISSET);
|
bool mark_set = ISSET(MARK_ISSET);
|
||||||
int mbb_lineno_cur = 0;
|
int mbb_lineno_cur = 0;
|
||||||
/* We're going to close the current file, and open the output of
|
/* We're going to close the current file, and open the output of
|
||||||
* the alternate spell command. The line that mark_beginbuf
|
* the alternate spell command. The line that mark_beginbuf
|
||||||
|
@ -1791,23 +1791,22 @@ const char *do_alt_speller(char *tempfile_name)
|
||||||
}
|
}
|
||||||
|
|
||||||
refresh();
|
refresh();
|
||||||
#ifndef NANO_SMALL
|
|
||||||
if (!mark_set) {
|
|
||||||
/* Only reload the temp file if it isn't a marked selection. */
|
|
||||||
#endif
|
|
||||||
free_filestruct(fileage);
|
|
||||||
terminal_init();
|
|
||||||
global_init(TRUE);
|
|
||||||
open_file(tempfile_name, FALSE, TRUE);
|
|
||||||
#ifndef NANO_SMALL
|
|
||||||
}
|
|
||||||
|
|
||||||
|
#ifndef NANO_SMALL
|
||||||
if (mark_set) {
|
if (mark_set) {
|
||||||
do_gotopos(mbb_lineno_cur, mark_beginx, y_cur, 0);
|
do_gotopos(mbb_lineno_cur, mark_beginx, y_cur, 0);
|
||||||
mark_beginbuf = current;
|
mark_beginbuf = current;
|
||||||
/* In case the line got shorter, assign mark_beginx. */
|
/* In case the line got shorter, assign mark_beginx. */
|
||||||
mark_beginx = current_x;
|
mark_beginx = current_x;
|
||||||
SET(MARK_ISSET);
|
SET(MARK_ISSET);
|
||||||
|
} else {
|
||||||
|
#endif
|
||||||
|
/* Only reload the temp file if it isn't a marked selection. */
|
||||||
|
free_filestruct(fileage);
|
||||||
|
terminal_init();
|
||||||
|
global_init(TRUE);
|
||||||
|
open_file(tempfile_name, FALSE, TRUE);
|
||||||
|
#ifndef NANO_SMALL
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
@ -1856,11 +1855,10 @@ void do_spell(void)
|
||||||
unlink(temp);
|
unlink(temp);
|
||||||
free(temp);
|
free(temp);
|
||||||
|
|
||||||
if (spell_msg != NULL) {
|
if (spell_msg != NULL)
|
||||||
statusbar(_("Spell checking failed: %s: %s"), spell_msg,
|
statusbar(_("Spell checking failed: %s: %s"), spell_msg,
|
||||||
strerror(errno));
|
strerror(errno));
|
||||||
return;
|
else
|
||||||
} else
|
|
||||||
statusbar(_("Finished checking spelling"));
|
statusbar(_("Finished checking spelling"));
|
||||||
}
|
}
|
||||||
#endif /* !DISABLE_SPELLER */
|
#endif /* !DISABLE_SPELLER */
|
||||||
|
@ -1904,7 +1902,7 @@ void justify_format(filestruct *line, size_t skip)
|
||||||
|
|
||||||
back = line->data + skip;
|
back = line->data + skip;
|
||||||
for (front = back; ; front++) {
|
for (front = back; ; front++) {
|
||||||
int remove_space = FALSE;
|
bool remove_space = FALSE;
|
||||||
/* Do we want to remove this space? */
|
/* Do we want to remove this space? */
|
||||||
|
|
||||||
if (*front == '\t')
|
if (*front == '\t')
|
||||||
|
@ -1987,7 +1985,8 @@ 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. */
|
||||||
int quotes_match(const char *a_line, size_t a_quote, const char *b_line)
|
bool quotes_match(const char *a_line, size_t a_quote, const char
|
||||||
|
*b_line)
|
||||||
{
|
{
|
||||||
/* Here is the assumption about a_quote: */
|
/* Here is the assumption about a_quote: */
|
||||||
assert(a_quote == quote_length(a_line));
|
assert(a_quote == quote_length(a_line));
|
||||||
|
@ -1997,7 +1996,7 @@ int quotes_match(const char *a_line, size_t a_quote, const char *b_line)
|
||||||
|
|
||||||
/* 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
|
||||||
* whether b_line could follow a_line in a paragraph. */
|
* whether b_line could follow a_line in a paragraph. */
|
||||||
size_t 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(a_indent == indent_length(a_line));
|
||||||
|
@ -2153,13 +2152,13 @@ filestruct *backup_lines(filestruct *first_line, size_t par_len, size_t
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Is it possible to break line at or before goal? */
|
/* Is it possible to break line at or before goal? */
|
||||||
int breakable(const char *line, int goal)
|
bool breakable(const char *line, int goal)
|
||||||
{
|
{
|
||||||
for (; *line != '\0' && goal >= 0; line++) {
|
for (; *line != '\0' && goal >= 0; line++) {
|
||||||
if (isblank(*line))
|
if (isblank(*line))
|
||||||
return TRUE;
|
return TRUE;
|
||||||
|
|
||||||
if (is_cntrl_char(*line) != 0)
|
if (is_cntrl_char(*line))
|
||||||
goal -= 2;
|
goal -= 2;
|
||||||
else
|
else
|
||||||
goal -= 1;
|
goal -= 1;
|
||||||
|
@ -2171,10 +2170,10 @@ int breakable(const char *line, int goal)
|
||||||
|
|
||||||
/* We are trying to break a chunk off line. We find the last space such
|
/* We are trying to break a chunk off line. We find the last space such
|
||||||
* that the display length to there is at most goal + 1. If there is no
|
* that the display length to there is at most goal + 1. If there is no
|
||||||
* such space, and force is not 0, then we find the first space.
|
* such space, and force is TRUE, then we find the first space. Anyway,
|
||||||
* Anyway, we then take the last space in that group of spaces. The
|
* we then take the last space in that group of spaces. The terminating
|
||||||
* terminating '\0' counts as a space. */
|
* '\0' counts as a space. */
|
||||||
int break_line(const char *line, int goal, int force)
|
int break_line(const char *line, int goal, bool force)
|
||||||
{
|
{
|
||||||
/* Note that we use int instead of size_t, since goal is at most
|
/* Note that we use int instead of size_t, since goal is at most
|
||||||
* COLS, the screen width, which will always be reasonably small. */
|
* COLS, the screen width, which will always be reasonably small. */
|
||||||
|
@ -2333,7 +2332,7 @@ bool do_para_search(size_t *const quote, size_t *const par)
|
||||||
|
|
||||||
/* If full_justify is TRUE, justify the entire file. Otherwise, justify
|
/* If full_justify is TRUE, justify the entire file. Otherwise, justify
|
||||||
* the current paragraph. */
|
* the current paragraph. */
|
||||||
void do_justify(int full_justify)
|
void do_justify(bool full_justify)
|
||||||
{
|
{
|
||||||
filestruct *first_par_line = NULL;
|
filestruct *first_par_line = NULL;
|
||||||
/* Will be the first line of the resulting justified paragraph.
|
/* Will be the first line of the resulting justified paragraph.
|
||||||
|
@ -2881,7 +2880,7 @@ void handle_sigwinch(int s)
|
||||||
siglongjmp(jmpbuf, 1);
|
siglongjmp(jmpbuf, 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
void allow_pending_sigwinch(int allow)
|
void allow_pending_sigwinch(bool allow)
|
||||||
{
|
{
|
||||||
sigset_t winch;
|
sigset_t winch;
|
||||||
sigemptyset(&winch);
|
sigemptyset(&winch);
|
||||||
|
@ -2896,7 +2895,7 @@ void allow_pending_sigwinch(int allow)
|
||||||
#ifndef NANO_SMALL
|
#ifndef NANO_SMALL
|
||||||
void do_toggle(const toggle *which)
|
void do_toggle(const toggle *which)
|
||||||
{
|
{
|
||||||
int enabled;
|
bool enabled;
|
||||||
|
|
||||||
/* Even easier! */
|
/* Even easier! */
|
||||||
TOGGLE(which->flag);
|
TOGGLE(which->flag);
|
||||||
|
@ -3006,9 +3005,9 @@ int main(int argc, char *argv[])
|
||||||
{
|
{
|
||||||
int optchr;
|
int optchr;
|
||||||
int startline = 0; /* Line to try and start at */
|
int startline = 0; /* Line to try and start at */
|
||||||
int fill_flag_used = FALSE; /* Was the fill option used? */
|
bool fill_flag_used = FALSE; /* Was the fill option used? */
|
||||||
const shortcut *s;
|
const shortcut *s;
|
||||||
int keyhandled = FALSE; /* Have we handled the keystroke yet? */
|
bool keyhandled = FALSE; /* Have we handled the keystroke yet? */
|
||||||
int kbinput; /* Input from keyboard */
|
int kbinput; /* Input from keyboard */
|
||||||
int meta_key;
|
int meta_key;
|
||||||
|
|
||||||
|
|
23
src/proto.h
23
src/proto.h
|
@ -265,7 +265,7 @@ void die(const char *msg, ...);
|
||||||
void die_save_file(const char *die_filename);
|
void die_save_file(const char *die_filename);
|
||||||
void die_too_small(void);
|
void die_too_small(void);
|
||||||
void print_view_warning(void);
|
void print_view_warning(void);
|
||||||
void global_init(int save_cutbuffer);
|
void global_init(bool save_cutbuffer);
|
||||||
void window_init(void);
|
void window_init(void);
|
||||||
#ifndef DISABLE_MOUSE
|
#ifndef DISABLE_MOUSE
|
||||||
void mouse_init(void);
|
void mouse_init(void);
|
||||||
|
@ -291,7 +291,7 @@ int no_help(void);
|
||||||
void nano_disabled_msg(void);
|
void nano_disabled_msg(void);
|
||||||
#ifndef NANO_SMALL
|
#ifndef NANO_SMALL
|
||||||
RETSIGTYPE cancel_fork(int signal);
|
RETSIGTYPE cancel_fork(int signal);
|
||||||
int open_pipe(const char *command);
|
bool open_pipe(const char *command);
|
||||||
#endif
|
#endif
|
||||||
#ifndef DISABLE_MOUSE
|
#ifndef DISABLE_MOUSE
|
||||||
void do_mouse(void);
|
void do_mouse(void);
|
||||||
|
@ -309,11 +309,11 @@ void do_mark(void);
|
||||||
#endif
|
#endif
|
||||||
#ifndef DISABLE_WRAPPING
|
#ifndef DISABLE_WRAPPING
|
||||||
void wrap_reset(void);
|
void wrap_reset(void);
|
||||||
int do_wrap(filestruct *inptr);
|
bool do_wrap(filestruct *inptr);
|
||||||
#endif
|
#endif
|
||||||
#ifndef DISABLE_SPELLER
|
#ifndef DISABLE_SPELLER
|
||||||
int do_int_spell_fix(const char *word);
|
bool do_int_spell_fix(const char *word);
|
||||||
const char *do_int_speller(char *tempfile_name);
|
const char *do_int_speller(const char *tempfile_name);
|
||||||
const char *do_alt_speller(char *tempfile_name);
|
const char *do_alt_speller(char *tempfile_name);
|
||||||
void do_spell(void);
|
void do_spell(void);
|
||||||
#endif
|
#endif
|
||||||
|
@ -323,8 +323,9 @@ size_t indent_length(const char *line);
|
||||||
#ifndef DISABLE_JUSTIFY
|
#ifndef DISABLE_JUSTIFY
|
||||||
void justify_format(filestruct *line, size_t skip);
|
void justify_format(filestruct *line, size_t skip);
|
||||||
size_t quote_length(const char *line);
|
size_t quote_length(const char *line);
|
||||||
int quotes_match(const char *a_line, size_t a_quote, const char *b_line);
|
bool quotes_match(const char *a_line, size_t a_quote, const char
|
||||||
size_t indents_match(const char *a_line, size_t a_indent, const char
|
*b_line);
|
||||||
|
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);
|
||||||
bool begpar(const filestruct *const foo);
|
bool begpar(const filestruct *const foo);
|
||||||
void do_para_begin(void);
|
void do_para_begin(void);
|
||||||
|
@ -332,10 +333,10 @@ bool inpar(const char *str);
|
||||||
void do_para_end(void);
|
void do_para_end(void);
|
||||||
filestruct *backup_lines(filestruct *first_line, size_t par_len, size_t
|
filestruct *backup_lines(filestruct *first_line, size_t par_len, size_t
|
||||||
quote_len);
|
quote_len);
|
||||||
int breakable(const char *line, int goal);
|
bool breakable(const char *line, int goal);
|
||||||
int break_line(const char *line, int goal, int force);
|
int break_line(const char *line, int goal, bool force);
|
||||||
bool do_para_search(size_t *const quote, size_t *const par);
|
bool do_para_search(size_t *const quote, size_t *const par);
|
||||||
void do_justify(int full_justify);
|
void do_justify(bool full_justify);
|
||||||
void do_justify_void(void);
|
void do_justify_void(void);
|
||||||
void do_full_justify(void);
|
void do_full_justify(void);
|
||||||
#endif /* !DISABLE_JUSTIFY */
|
#endif /* !DISABLE_JUSTIFY */
|
||||||
|
@ -346,7 +347,7 @@ RETSIGTYPE do_suspend(int signal);
|
||||||
RETSIGTYPE do_cont(int signal);
|
RETSIGTYPE do_cont(int signal);
|
||||||
#ifndef NANO_SMALL
|
#ifndef NANO_SMALL
|
||||||
void handle_sigwinch(int s);
|
void handle_sigwinch(int s);
|
||||||
void allow_pending_sigwinch(int allow);
|
void allow_pending_sigwinch(bool allow);
|
||||||
#endif
|
#endif
|
||||||
#ifndef NANO_SMALL
|
#ifndef NANO_SMALL
|
||||||
void do_toggle(const toggle *which);
|
void do_toggle(const toggle *which);
|
||||||
|
|
Loading…
Reference in New Issue