From 4f9ccd87297d2df6caf453ed1dba0fe07fdfe4e9 Mon Sep 17 00:00:00 2001 From: Luke Howard Date: Mon, 27 Sep 2010 02:48:17 +0200 Subject: [PATCH] cleanup --- lib/client.c | 32 +++++++++++++------------------- 1 file changed, 13 insertions(+), 19 deletions(-) diff --git a/lib/client.c b/lib/client.c index 2f627c1..1ba3874 100644 --- a/lib/client.c +++ b/lib/client.c @@ -419,36 +419,30 @@ _sasl_client_order_mechs(const sasl_utils_t *utils, if (list == NULL) return SASL_NOMEM; - if (has_cb_data) { + do { for (start = p = mechs, i = 0; *p != '\0'; p++) { if (isspace(*p) || p[1] == '\0') { - size_t len = p - start + 1; + size_t len = p - start; - if (_mech_plus_p(start, len)) { + if (p[1] == '\0') + len++; + + if (_mech_plus_p(start, len) == has_cb_data) { memcpy(listp, start, len); listp[len] = '\0'; listp += len + 1; (*count)++; - *server_can_cb = 1; + if (*server_can_cb == 0 && has_cb_data) + *server_can_cb = 1; } start = p + 1; } } - } - - for (start = p = mechs, i = 0; *p != '\0'; p++) { - if (isspace(*p) || p[1] == '\0') { - size_t len = p - start + 1; - - if (!_mech_plus_p(start, len)) { - memcpy(listp, start, len); - listp[len] = '\0'; - listp += len + 1; - (*count)++; - } - start = p + 1; - } - } + if (has_cb_data) + has_cb_data = 0; + else + break; + } while (1); *listp = '\0'; *ordered_mechs = list; -- 2.1.4