tweaks: make tiny nano a teeny bit smaller

master
Benno Schulenberg 2016-09-01 09:36:47 +02:00
parent 244de605a7
commit 7b7d2bf7c9
5 changed files with 14 additions and 9 deletions

View File

@ -326,7 +326,9 @@ void add_to_funcs(void (*func)(void), int menus, const char *desc, const char *h
void add_to_sclist(int menus, const char *scstring, void (*func)(void), int toggle)
{
static sc *tailsc;
#ifndef NANO_TINY
static int counter = 0;
#endif
sc *s = (sc *)nmalloc(sizeof(sc));
/* Start the list, or tack on the next item. */
@ -340,9 +342,11 @@ void add_to_sclist(int menus, const char *scstring, void (*func)(void), int togg
/* Fill in the data. */
s->menus = menus;
s->scfunc = func;
#ifndef NANO_TINY
s->toggle = toggle;
if (toggle)
s->ordinal = ++counter;
#endif
assign_keyinfo(s, scstring);
#ifdef DEBUG
@ -1362,10 +1366,11 @@ const char *flagtostr(int flag)
* shortcut struct with the corresponding function filled in. */
sc *strtosc(const char *input)
{
sc *s;
sc *s = nmalloc(sizeof(sc));
s = (sc *)nmalloc(sizeof(sc));
#ifndef NANO_TINY
s->toggle = 0;
#endif
#ifndef DISABLE_HELP
if (!strcasecmp(input, "help"))

View File

@ -1434,13 +1434,13 @@ void do_toggle(int flag)
statusline(HUSH, "%s %s", _(flagtostr(flag)),
enabled ? _("enabled") : _("disabled"));
}
#endif /* !NANO_TINY */
/* Bleh. */
void do_toggle_void(void)
{
;
}
#endif /* !NANO_TINY */
/* Disable extended input and output processing in our terminal
* settings. */

View File

@ -451,11 +451,13 @@ typedef struct sc {
/* Which menus this applies to. */
void (*scfunc)(void);
/* The function we're going to run. */
#ifndef NANO_TINY
int toggle;
/* If a toggle, what we're toggling. */
int ordinal;
/* The how-manieth toggle this is, in order to be able to
* keep them in sequence. */
#endif
struct sc *next;
/* Next in the list. */
} sc;

View File

@ -482,13 +482,7 @@ RETSIGTYPE handle_sigwinch(int signal);
void regenerate_screen(void);
void allow_sigwinch(bool allow);
void do_toggle(int flag);
#endif
void do_toggle_void(void);
void disable_extended_io(void);
#ifdef USE_SLANG
void disable_signals(void);
#endif
#ifndef NANO_TINY
void enable_signals(void);
#endif
void disable_flow_control(void);

View File

@ -455,9 +455,11 @@ void parse_binding(char *ptr, bool dobind)
if (f->scfunc == newsc->scfunc)
mask = mask | f->menus;
#ifndef NANO_TINY
/* Handle the special case of the toggles. */
if (newsc->scfunc == do_toggle_void)
mask = MMAIN;
#endif
/* Now limit the given menu to those where the function exists. */
if (is_universal(newsc->scfunc))
@ -497,6 +499,7 @@ void parse_binding(char *ptr, bool dobind)
}
if (dobind) {
#ifndef NANO_TINY
/* If this is a toggle, copy its sequence number. */
if (newsc->scfunc == do_toggle_void) {
for (s = sclist; s != NULL; s = s->next)
@ -504,6 +507,7 @@ void parse_binding(char *ptr, bool dobind)
newsc->ordinal = s->ordinal;
} else
newsc->ordinal = 0;
#endif
/* Add the new shortcut at the start of the list. */
newsc->next = sclist;
sclist = newsc;