view lib/help.c @ 1715:a471f338b055 draft

fix format problems in tar.c %o is unsigned, but off_t is signed. * takes an int. an error_msg call was missing an argument. only one of these is an actual error, but i'd like to fix the others too so that we (toybox, but if not, then Android) can turn on format string warnings to prevent future bugs like the stat.c LP32 ones.
author Elliott Hughes <enh@google.com>
date Sun, 01 Mar 2015 16:11:50 -0600
parents 5fac2769a159
children
line wrap: on
line source

// Function to display help text

#include "toys.h"

#if !CFG_TOYBOX_HELP
void show_help(void) {;}
#else
#include "generated/help.h"

#undef NEWTOY
#undef OLDTOY
#define NEWTOY(name,opt,flags) help_##name "\0"
#define OLDTOY(name,oldname,flags) "\xff" #oldname "\0"
static char *help_data =
#include "generated/newtoys.h"
;

void show_help(void)
{
  int i = toys.which-toy_list;
  char *s;

  for (;;) {
    s = help_data;
    while (i--) s += strlen(s) + 1;
    // If it's an alias, restart search for real name
    if (*s != 255) break;
    if (!CFG_TOYBOX) {
      s = xmprintf("See %s --help\n", ++s);

      break;
    }
    i = toy_find(++s)-toy_list;
  }

  fprintf(toys.exithelp ? stderr : stdout, "%s", s);
}
#endif