[openssl-commits] [openssl] master update

Richard Levitte levitte at openssl.org
Sat Jan 6 18:28:03 UTC 2018


The branch master has been updated
       via  da6be198f7ab690b8ace83f35502bca8dd9218e5 (commit)
       via  391e987e9cd837446d3d0bf5505bbc7aa44b627e (commit)
      from  a032ed0a7ba3a276fe7d9880d26c0c5f2ba702c7 (commit)


- Log -----------------------------------------------------------------
commit da6be198f7ab690b8ace83f35502bca8dd9218e5
Author: Richard Levitte <levitte at openssl.org>
Date:   Sun Dec 31 08:44:26 2017 +0100

    Add the possibility to do 'openssl help [command]'
    
    Reviewed-by: Rich Salz <rsalz at openssl.org>
    (Merged from https://github.com/openssl/openssl/pull/5002)

commit 391e987e9cd837446d3d0bf5505bbc7aa44b627e
Author: Richard Levitte <levitte at openssl.org>
Date:   Sun Dec 31 08:44:12 2017 +0100

    apps: make sure prog_init only calculates once
    
    Reviewed-by: Rich Salz <rsalz at openssl.org>
    (Merged from https://github.com/openssl/openssl/pull/5002)

-----------------------------------------------------------------------

Summary of changes:
 apps/openssl.c | 21 +++++++++++++++++++--
 1 file changed, 19 insertions(+), 2 deletions(-)

diff --git a/apps/openssl.c b/apps/openssl.c
index 2cb49cb..4ab6be8 100644
--- a/apps/openssl.c
+++ b/apps/openssl.c
@@ -442,6 +442,8 @@ typedef enum HELP_CHOICE {
 } HELP_CHOICE;
 
 const OPTIONS help_options[] = {
+    {OPT_HELP_STR, 1, '-', "Usage: help [options]\n"},
+    {OPT_HELP_STR, 1, '-', "       help [command]\n"},
     {"help", OPT_hHELP, '-', "Display this summary"},
     {NULL}
 };
@@ -469,6 +471,14 @@ int help_main(int argc, char **argv)
         }
     }
 
+    if (opt_num_rest() == 1) {
+        char *new_argv[3];
+
+        new_argv[0] = opt_rest()[0];
+        new_argv[1] = "--help";
+        new_argv[2] = NULL;
+        return do_cmd(prog_init(), 2, new_argv);
+    }
     if (opt_num_rest() != 0) {
         BIO_printf(bio_err, "Usage: %s\n", prog);
         return 1;
@@ -787,12 +797,19 @@ static void list_disabled(void)
 
 static LHASH_OF(FUNCTION) *prog_init(void)
 {
-    LHASH_OF(FUNCTION) *ret;
+    static LHASH_OF(FUNCTION) *ret = NULL;
+    static int prog_inited = 0;
     FUNCTION *f;
     size_t i;
 
+    if (prog_inited)
+        return ret;
+
+    prog_inited = 1;
+
     /* Sort alphabetically within category. For nicer help displays. */
-    for (i = 0, f = functions; f->name != NULL; ++f, ++i) ;
+    for (i = 0, f = functions; f->name != NULL; ++f, ++i)
+        ;
     qsort(functions, i, sizeof(*functions), SortFnByName);
 
     if ((ret = lh_FUNCTION_new(function_hash, function_cmp)) == NULL)


More information about the openssl-commits mailing list