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

View File

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

View File

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

View File

@ -482,13 +482,7 @@ RETSIGTYPE handle_sigwinch(int signal);
void regenerate_screen(void); void regenerate_screen(void);
void allow_sigwinch(bool allow); void allow_sigwinch(bool allow);
void do_toggle(int flag); void do_toggle(int flag);
#endif
void do_toggle_void(void); 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); void enable_signals(void);
#endif #endif
void disable_flow_control(void); void disable_flow_control(void);

View File

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