OSDN Git Service

Don't segfault for --help of single.sh build of OLDTOY commands that use another...
authorRob Landley <rob@landley.net>
Sun, 28 Sep 2014 00:58:18 +0000 (19:58 -0500)
committerRob Landley <rob@landley.net>
Sun, 28 Sep 2014 00:58:18 +0000 (19:58 -0500)
lib/help.c
main.c

index 6a0c7b4..9965539 100644 (file)
@@ -25,6 +25,11 @@ void show_help(void)
     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;
   }
 
diff --git a/main.c b/main.c
index 6e7d267..c3577b6 100644 (file)
--- a/main.c
+++ b/main.c
@@ -26,6 +26,8 @@ struct toy_list *toy_find(char *name)
 {
   int top, bottom, middle;
 
+  if (!CFG_TOYBOX) return 0;
+
   // If the name starts with "toybox" accept that as a match.  Otherwise
   // skip the first entry, which is out of order.
 
@@ -69,7 +71,7 @@ static void toy_singleinit(struct toy_list *which, char *argv[])
   if (CFG_TOYBOX_I18N) setlocale(LC_ALL, "C"+!!(which->flags & TOYFLAG_LOCALE));
 
   if (CFG_TOYBOX_HELP_DASHDASH && argv[1] && !strcmp(argv[1], "--help")) {
-    if (toys.which == toy_list && toys.argv[2])
+    if (CFG_TOYBOX && toys.which == toy_list && toys.argv[2])
       if (!(toys.which = toy_find(toys.argv[2]))) return;
     show_help();
     xexit();