Commit dd29c569 authored by Benno Schulenberg's avatar Benno Schulenberg
Browse files

Rewriting the loop, and constifying the input of sctofunc().

git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@5530 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
No related merge requests found
Showing with 8 additions and 7 deletions
+8 -7
2016-01-04 Benno Schulenberg <bensberg@justemail.net> 2016-01-04 Benno Schulenberg <bensberg@justemail.net>
* src/global.c (shortcut_init): Nowadays the functions are defined * src/global.c (shortcut_init): Nowadays the functions are defined
only once, so there is no longer any need to free existing ones. only once, so there is no longer any need to free existing ones.
* src/global.c (sctofunc): Rewrite the loop, and constify the input.
2016-01-04 Mike Frysinger <vapier@gentoo.org> 2016-01-04 Mike Frysinger <vapier@gentoo.org>
* src/global.c (strtosc, strtomenu): Constify the input parameter. * src/global.c (strtosc, strtomenu): Constify the input parameter.
......
...@@ -1260,12 +1260,12 @@ void set_spell_shortcuts(void) ...@@ -1260,12 +1260,12 @@ void set_spell_shortcuts(void)
} }
#endif #endif
const subnfunc *sctofunc(sc *s) const subnfunc *sctofunc(const sc *s)
{ {
subnfunc *f; subnfunc *f = allfuncs;
for (f = allfuncs; f != NULL && s->scfunc != f->scfunc; f = f->next) while (f != NULL && f->scfunc != s->scfunc)
; f = f->next;
return f; return f;
} }
......
...@@ -1702,7 +1702,7 @@ int do_input(bool allow_funcs) ...@@ -1702,7 +1702,7 @@ int do_input(bool allow_funcs)
} }
if (have_shortcut) { if (have_shortcut) {
const subnfunc *f = sctofunc((sc *)s); const subnfunc *f = sctofunc(s);
/* If the function associated with this shortcut is /* If the function associated with this shortcut is
* cutting or copying text, remember this. */ * cutting or copying text, remember this. */
if (s->scfunc == do_cut_text_void if (s->scfunc == do_cut_text_void
......
...@@ -210,7 +210,7 @@ int do_statusbar_input(bool *ran_func, bool *finished, ...@@ -210,7 +210,7 @@ int do_statusbar_input(bool *ran_func, bool *finished,
* functions and setting finished to TRUE to indicate * functions and setting finished to TRUE to indicate
* that we're done after running or trying to run their * that we're done after running or trying to run their
* associated functions. */ * associated functions. */
f = sctofunc((sc *) s); f = sctofunc(s);
if (s->scfunc != NULL) { if (s->scfunc != NULL) {
*ran_func = TRUE; *ran_func = TRUE;
if (f && (!ISSET(VIEW_MODE) || f->viewok) && if (f && (!ISSET(VIEW_MODE) || f->viewok) &&
......
...@@ -370,7 +370,7 @@ void shortcut_init(void); ...@@ -370,7 +370,7 @@ void shortcut_init(void);
void set_lint_or_format_shortcuts(void); void set_lint_or_format_shortcuts(void);
void set_spell_shortcuts(void); void set_spell_shortcuts(void);
#endif #endif
const subnfunc *sctofunc(sc *s); const subnfunc *sctofunc(const sc *s);
const char *flagtostr(int flag); const char *flagtostr(int flag);
sc *strtosc(const char *input); sc *strtosc(const char *input);
int strtomenu(const char *input); int strtomenu(const char *input);
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment