Add a pointer to the tail of the functions list,
to simplify and speed up adding new items. git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@4815 35c25a1d-7b9e-4130-9fde-d3aeb78583b8master
parent
67e1387f04
commit
20b1e92857
|
@ -1,3 +1,8 @@
|
|||
2014-04-26 Benno Schulenberg <bensberg@justemail.net>
|
||||
* src/global.c (add_to_funcs): Add a pointer to the tail of the
|
||||
functions list, to simplify and speed up adding new items. And
|
||||
make use of it to remember the location of the Uncut item.
|
||||
|
||||
2014-04-24 Benno Schulenberg <bensberg@justemail.net>
|
||||
* doc/faq.html: Update a few URLs, delete some obsolete ones, update
|
||||
the section on configuration flags and on translating nano, a whole
|
||||
|
|
27
src/global.c
27
src/global.c
|
@ -167,9 +167,11 @@ int currmenu;
|
|||
/* The currently loaded menu. */
|
||||
|
||||
sc *sclist = NULL;
|
||||
/* Struct for the shortcut-key list. */
|
||||
/* Pointer to the start of the shortcuts list. */
|
||||
subnfunc *allfuncs = NULL;
|
||||
/* Struct for the function list. */
|
||||
/* Pointer to the start of the functions list. */
|
||||
subnfunc *tailfunc;
|
||||
/* Pointer to the last function in the list. */
|
||||
subnfunc *uncutfunc;
|
||||
/* Pointer to the special Uncut/Unjustify item. */
|
||||
|
||||
|
@ -284,17 +286,14 @@ function_type strtokeytype(const char *str)
|
|||
void add_to_funcs(void (*func)(void), int menus, const char *desc, const char *help,
|
||||
bool blank_after, bool viewok)
|
||||
{
|
||||
subnfunc *f;
|
||||
subnfunc *f = nmalloc(sizeof(subnfunc));
|
||||
|
||||
if (allfuncs == NULL)
|
||||
allfuncs = f;
|
||||
else
|
||||
tailfunc->next = f;
|
||||
tailfunc = f;
|
||||
|
||||
if (allfuncs == NULL) {
|
||||
allfuncs = (subnfunc *) nmalloc(sizeof(subnfunc));
|
||||
f = allfuncs;
|
||||
} else {
|
||||
for (f = allfuncs; f->next != NULL; f = f->next)
|
||||
;
|
||||
f->next = (subnfunc *)nmalloc(sizeof(subnfunc));
|
||||
f = f->next;
|
||||
}
|
||||
f->next = NULL;
|
||||
f->scfunc = func;
|
||||
f->menus = menus;
|
||||
|
@ -736,10 +735,8 @@ void shortcut_init(void)
|
|||
|
||||
add_to_funcs(do_uncut_text, MMAIN, uncut_tag, IFSCHELP(nano_uncut_msg),
|
||||
FALSE, NOVIEW);
|
||||
|
||||
/* Remember the entry for Uncut, to be able to replace it with Unjustify. */
|
||||
for (uncutfunc = allfuncs; uncutfunc->next != NULL; uncutfunc = uncutfunc->next)
|
||||
;
|
||||
uncutfunc = tailfunc;
|
||||
|
||||
#ifndef NANO_TINY
|
||||
add_to_funcs(do_cursorpos_void, MMAIN, N_("Cur Pos"), IFSCHELP(nano_cursorpos_msg),
|
||||
|
|
Loading…
Reference in New Issue