commit 785efc208784aaa0235203136aa8b445ae44c896
parent 557ad827f9f340c80c13ce355c6e9b56b88262f8
Author: Benno Schulenberg <bensberg@telfort.nl>
Date: Wed, 9 Oct 2019 18:58:30 +0200
tweaks: make a function do a check so its calls don't need to
Diffstat:
4 files changed, 13 insertions(+), 17 deletions(-)
diff --git a/src/files.c b/src/files.c
@@ -1212,9 +1212,7 @@ void do_insertfile(void)
/* If the current mode of operation allows it, go insert a file. */
void do_insertfile_void(void)
{
- if (ISSET(RESTRICTED))
- show_restricted_warning();
- else
+ if (!in_restricted_mode())
do_insertfile();
}
diff --git a/src/nano.c b/src/nano.c
@@ -463,11 +463,15 @@ void print_view_warning(void)
statusbar(_("Key is invalid in view mode"));
}
-/* Indicate that something is disabled in restricted mode. */
-void show_restricted_warning(void)
+/* When in restricted mode, show a warning and return TRUE. */
+bool in_restricted_mode(void)
{
- statusbar(_("This function is disabled in restricted mode"));
- beep();
+ if (ISSET(RESTRICTED)) {
+ statusbar(_("This function is disabled in restricted mode"));
+ beep();
+ return TRUE;
+ } else
+ return FALSE;
}
#ifndef ENABLE_HELP
@@ -1340,10 +1344,8 @@ void do_toggle(int flag)
{
bool enabled;
- if (flag == SUSPEND && ISSET(RESTRICTED)) {
- show_restricted_warning();
+ if (flag == SUSPEND && in_restricted_mode())
return;
- }
TOGGLE(flag);
focusing = FALSE;
diff --git a/src/proto.h b/src/proto.h
@@ -408,7 +408,7 @@ void extract(linestruct *top, size_t top_x, linestruct *bot, size_t bot_x);
void ingraft_buffer(linestruct *somebuffer);
void copy_from_buffer(linestruct *somebuffer);
void print_view_warning(void);
-void show_restricted_warning(void);
+bool in_restricted_mode(void);
#ifndef ENABLE_HELP
void say_there_is_no_help(void);
#endif
diff --git a/src/text.c b/src/text.c
@@ -2640,10 +2640,8 @@ void do_spell(void)
/* A storage place for the current flag settings. */
const char *result_msg;
- if (ISSET(RESTRICTED)) {
- show_restricted_warning();
+ if (in_restricted_mode())
return;
- }
temp = safe_tempfile(&temp_file);
@@ -2712,10 +2710,8 @@ void do_linter(void)
lintstruct *lints = NULL, *tmplint = NULL, *curlint = NULL;
time_t last_wait = 0;
- if (ISSET(RESTRICTED)) {
- show_restricted_warning();
+ if (in_restricted_mode())
return;
- }
if (!openfile->syntax || !openfile->syntax->linter) {
statusbar(_("No linter defined for this type of file!"));