fix broken ext arg parsing
authorAndy Green <andy.green@linaro.org>
Tue, 19 Jan 2016 12:01:33 +0000 (20:01 +0800)
committerAndy Green <andy.green@linaro.org>
Tue, 19 Jan 2016 12:02:34 +0000 (20:02 +0800)
This gets us back to all the Autobahn tests passing

Signed-off-by: Andy Green <andy.green@linaro.org>
lib/client.c
lib/extension.c

index 8b7176f..9424ed3 100644 (file)
@@ -749,8 +749,11 @@ check_extensions:
                        /*
                         * give the extension the server options
                         */
-                       if (a && lws_ext_parse_options(ext, wsi, wsi->act_ext_user[wsi->count_act_ext], opts, a, c - a)) {
-                               lwsl_err("%s: unable to parse remote defaults '%s'", __func__, a);
+                       if (a && lws_ext_parse_options(ext, wsi,
+                                       wsi->act_ext_user[wsi->count_act_ext],
+                                       opts, a, c - a)) {
+                               lwsl_err("%s: unable to parse remote def '%s'",
+                                        __func__, a);
                                goto bail2;
                        }
 
@@ -758,7 +761,8 @@ check_extensions:
                                        LWS_EXT_CB_OPTION_CONFIRM,
                                      wsi->act_ext_user[wsi->count_act_ext],
                                      NULL, 0)) {
-                               lwsl_err("%s: ext %s rejects server options %s", ext->name, a);
+                               lwsl_err("%s: ext %s rejects server options %s",
+                                        ext->name, a);
                                goto bail2;
                        }
 
index 4868299..d21be5e 100644 (file)
@@ -21,7 +21,8 @@ enum lws_ext_option_parser_states {
 
 LWS_VISIBLE int
 lws_ext_parse_options(const struct lws_extension *ext, struct lws *wsi,
-                      void *ext_user, const struct lws_ext_options *opts, const char *in, int len)
+                     void *ext_user, const struct lws_ext_options *opts,
+                     const char *in, int len)
 {
        enum lws_ext_option_parser_states leap = LEAPS_SEEK_NAME;
        unsigned int match_map = 0, n, m, w = 0, count_options = 0,
@@ -31,7 +32,7 @@ lws_ext_parse_options(const struct lws_extension *ext, struct lws *wsi,
        while (opts[count_options].name)
                count_options++;
        while (len) {
-               lwsl_ext("'%c'", *in);
+               lwsl_ext("'%c' %d", *in, leap);
                switch (leap) {
                case LEAPS_SEEK_NAME:
                        if (*in == ' ')
@@ -51,11 +52,10 @@ lws_ext_parse_options(const struct lws_extension *ext, struct lws *wsi,
                        oa.len = 0;
                        m = match_map;
                        n = 0;
-                       w = 0;
                        pending_close_quote = 0;
                        while (m) {
                                if (m & 1) {
-                                       // lwsl_ext("    m=%d, n=%d\n", m, n);
+                                       lwsl_ext("    m=%d, n=%d, w=%d\n", m, n, w);
 
                                        if (*in == opts[n].name[w]) {
                                                if (!opts[n].name[w + 1]) {
@@ -68,8 +68,10 @@ lws_ext_parse_options(const struct lws_extension *ext, struct lws *wsi,
                                                }
                                        } else {
                                                match_map &= ~(1 << n);
-                                               if (!match_map)
+                                               if (!match_map) {
+                                                       lwsl_ext("empty match map\n");
                                                        return -1;
+                                               }
                                        }
                                }
                                m >>= 1;