tweaks: frob some comments plus miscellaneous other stuff

master
Benno Schulenberg 2018-03-22 19:54:20 +01:00
parent 30fc197b66
commit b7f8d4819b
4 changed files with 18 additions and 19 deletions

View File

@ -2420,8 +2420,8 @@ char **username_tab_completion(const char *buf, size_t *num_matches,
/* We consider the first buf_len characters of buf for filename tab
* completion. */
char **cwd_tab_completion(const char *buf, bool allow_files, size_t
*num_matches, size_t buf_len)
char **cwd_tab_completion(const char *buf, bool allow_files,
size_t *num_matches, size_t buf_len)
{
char *dirname = mallocstrcpy(NULL, buf);
char *slash, *filename;

View File

@ -1013,8 +1013,7 @@ void shortcut_init(void)
N_("Backup File"), WITHORSANS(backup_gist), BLANKAFTER, NOVIEW);
}
/* If we're using restricted mode, file insertion is disabled, and
* thus command execution and the multibuffer toggle have no place. */
/* Command execution is only available when not in restricted mode. */
if (!ISSET(RESTRICTED)) {
add_to_funcs(flip_execute, MINSERTFILE,
N_("Execute Command"), WITHORSANS(execute_gist), TOGETHER, NOVIEW);
@ -1024,12 +1023,14 @@ void shortcut_init(void)
}
#endif /* !NANO_TINY */
#ifdef ENABLE_MULTIBUFFER
/* Multiple buffers are only available when not in restricted mode. */
if (!ISSET(RESTRICTED))
add_to_funcs(flip_newbuffer, MINSERTFILE|MEXTCMD,
N_("New Buffer"), WITHORSANS(newbuffer_gist), TOGETHER, NOVIEW);
#endif
#ifdef ENABLE_BROWSER
/* The file browser is only available when not in restricted mode. */
if (!ISSET(RESTRICTED))
add_to_funcs(to_files_void, MWRITEFILE|MINSERTFILE,
N_("To Files"), WITHORSANS(tofiles_gist), TOGETHER, VIEW);
@ -1311,8 +1312,8 @@ void shortcut_init(void)
#ifndef NANO_TINY
add_to_sclist(MWRITEFILE, "M-D", 0, dos_format_void, 0);
add_to_sclist(MWRITEFILE, "M-M", 0, mac_format_void, 0);
/* In restricted mode, don't allow Appending, Prepending, nor making
* backups, nor executing a command, nor opening a new buffer. */
/* Only when not in restricted mode, allow Appending, Prepending,
* making backups, and executing a command. */
if (!ISSET(RESTRICTED)) {
add_to_sclist(MWRITEFILE, "M-A", 0, append_void, 0);
add_to_sclist(MWRITEFILE, "M-P", 0, prepend_void, 0);
@ -1321,11 +1322,12 @@ void shortcut_init(void)
}
#endif
#ifdef ENABLE_MULTIBUFFER
/* Only when not in restricted mode, allow multiple buffers. */
if (!ISSET(RESTRICTED))
add_to_sclist(MINSERTFILE|MEXTCMD, "M-F", 0, flip_newbuffer, 0);
#endif
#ifdef ENABLE_BROWSER
/* In restricted mode, don't allow entering the file browser. */
/* Only when not in restricted mode, allow entering the file browser. */
if (!ISSET(RESTRICTED))
add_to_sclist(MWRITEFILE|MINSERTFILE, "^T", 0, to_files_void, 0);
#endif

View File

@ -69,8 +69,7 @@ static struct sigaction act;
static bool input_was_aborted = FALSE;
/* Whether reading from standard input was aborted via ^C. */
/* Create a new linestruct node. Note that we do not set prevnode->next
* to the new line. */
/* Create a new linestruct node. Note that we do not set prevnode->next. */
filestruct *make_new_node(filestruct *prevnode)
{
filestruct *newnode = nmalloc(sizeof(filestruct));
@ -1647,7 +1646,7 @@ bool okay_for_view(const sc *shortcut)
{
const subnfunc *func = sctofunc(shortcut);
return (func && func->viewok);
return (func != NULL && func->viewok);
}
/* Read in a keystroke. Act on the keystroke if it is a shortcut or a toggle;

View File

@ -187,27 +187,25 @@ void do_statusbar_output(int *the_input, size_t input_len,
{
char *output = charalloc(input_len + 1);
char onechar[MAXCHARLEN];
size_t char_len, i;
size_t char_len, i, j = 0;
/* Copy the typed stuff so it can be treated. */
for (i = 0; i < input_len; i++)
output[i] = (char)the_input[i];
output[i] = '\0';
i = 0;
while (i < input_len) {
while (j < input_len) {
/* Encode any NUL byte as 0x0A. */
if (output[i] == '\0')
output[i] = '\n';
if (output[j] == '\0')
output[j] = '\n';
/* Interpret the next multibyte character. */
char_len = parse_mbchar(output + i, onechar, NULL);
char_len = parse_mbchar(output + j, onechar, NULL);
i += char_len;
j += char_len;
/* When filtering, skip any ASCII control character. */
if (filtering && is_ascii_cntrl_char(*(output + i - char_len)))
if (filtering && is_ascii_cntrl_char(*(output + j - char_len)))
continue;
/* Insert the typed character into the existing answer string. */