+2014-07-27 Benno Schulenberg <bensberg@justemail.net>
+ * src/global.c (add_to_sclist): Remove the now unused and unneeded
+ addition ability from this builder function of the shortcut list.
+
2014-07-24 Jordi Mallach <jordi@gnu.org>
* doc/texinfo/nano.texi, doc/man/nanorc.5: Typo fix.
return NULL;
}
-
-/* Add a string to the shortcut list.
- * Allows updates to existing entries in the list. */
+/* Add a key combo to the shortcut list. */
void add_to_sclist(int menu, const char *scstring, void (*func)(void), int toggle)
{
- sc *s;
-
- if (sclist == NULL) {
- sclist = (sc *)nmalloc(sizeof(sc));
- s = sclist;
- s->next = NULL;
- } else {
- for (s = sclist; s->next != NULL; s = s->next)
- if (s->menu == menu && s->keystr == scstring)
- break;
+ static sc *tailsc;
+ sc *s = (sc *)nmalloc(sizeof(sc));
- if (s->menu != menu || s->keystr != scstring) { /* i.e. this is not a replace... */
-#ifdef DEBUG
- fprintf(stderr, "No match found...\n");
-#endif
- s->next = (sc *)nmalloc(sizeof(sc));
- s = s->next;
- s->next = NULL;
- }
- }
+ /* Start the list, or tack on the next item. */
+ if (sclist == NULL)
+ sclist = s;
+ else
+ tailsc->next = s;
+ tailsc = s;
+ s->next = NULL;
- s->type = strtokeytype(scstring);
+ /* Fill in the data. */
s->menu = menu;
+ s->scfunc = func;
s->toggle = toggle;
s->keystr = (char *) scstring;
- s->scfunc = func;
+ s->type = strtokeytype(scstring);
assign_keyinfo(s);
#ifdef DEBUG