List:Commits« Previous MessageNext Message »
From:Kristofer Pettersson Date:June 25 2009 1:55pm
Subject:bzr commit into mysql-5.1-bugteam branch (kristofer.pettersson:2968)
Bug#45336
View as plain text  
#At file:///Users/thek/Development/51-bug45336/ based on revid:matthias.leich@stripped

 2968 Kristofer Pettersson	2009-06-25
      Bug#45336 --enable-foobar doesn't work for any plugin foobar.
      
      Because of a regression introduced by bug#19027 the option --enable-foobar
      doesn't work anymore for any plugin 'foobar'. The reason is that plugin
      names are tristate options variables with optional parameters and integer
      values are not accepted. Since the 'enable' prefix attempts to assign '1'
      to the option the operation fails.
      
      This patch translates any number n assigned to a plugin variable of type ENUM
      to be the corresponding enumerated item. As a side effect --enable-foobar and
      --disable-foobar will also start working again.
     @ mysys/my_getopt.c
        * setval now accepts integer values for option variables of type ENUM.

    modified:
      mysys/my_getopt.c
=== modified file 'mysys/my_getopt.c'
--- a/mysys/my_getopt.c	2009-05-14 12:03:33 +0000
+++ b/mysys/my_getopt.c	2009-06-25 13:55:26 +0000
@@ -20,6 +20,7 @@
 #include <mysys_err.h>
 #include <my_getopt.h>
 #include <errno.h>
+#include <m_string.h>
 
 typedef void (*init_func_p)(const struct my_option *option, uchar* *variable,
                             longlong value);
@@ -649,8 +650,18 @@ static int setval(const struct my_option
 	return EXIT_OUT_OF_MEMORY;
       break;
     case GET_ENUM:
-      if (((*(int*)result_pos)= find_type(argument, opts->typelib, 2) - 1) < 0)
-        return EXIT_ARGUMENT_INVALID;
+      if (((*(int*)result_pos)=
+             find_type(argument, opts->typelib, 2) - 1) < 0)
+      {
+        /*
+          Accept an integer representation of the enumerated item.
+        */
+        char *endptr;
+        unsigned int arg= (unsigned int) strtol(argument, &endptr, 10);
+        if (*endptr || arg >= opts->typelib->count)
+          return EXIT_ARGUMENT_INVALID;
+        *(int*)result_pos= arg;
+      }
       break;
     case GET_SET:
       *((ulonglong*)result_pos)= find_typeset(argument, opts->typelib, &err);


Attachment: [text/bzr-bundle] bzr/kristofer.pettersson@sun.com-20090625135526-pn1mqv48st28qe3z.bundle
Thread
bzr commit into mysql-5.1-bugteam branch (kristofer.pettersson:2968)Bug#45336Kristofer Pettersson25 Jun