+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
/* 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. */
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;
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),