[evolution-data-server] Simplify camel_imapx_stream_nstring().



commit ef3d0954f535024f27c27672bc53d53fe8d48a8b
Author: Matthew Barnes <mbarnes redhat com>
Date:   Sun Jul 14 08:29:11 2013 -0400

    Simplify camel_imapx_stream_nstring().

 camel/camel-imapx-stream.c |   77 ++++++++++++++++++++++++--------------------
 1 files changed, 42 insertions(+), 35 deletions(-)
---
diff --git a/camel/camel-imapx-stream.c b/camel/camel-imapx-stream.c
index 3e191ed..3d04f41 100644
--- a/camel/camel-imapx-stream.c
+++ b/camel/camel-imapx-stream.c
@@ -477,50 +477,57 @@ camel_imapx_stream_nstring (CamelIMAPXStream *is,
                             GCancellable *cancellable,
                             GError **error)
 {
+       camel_imapx_token_t tok;
        guchar *p, *start;
        guint len, inlen;
        gint ret;
-       GError *local_error = NULL;
 
        g_return_val_if_fail (CAMEL_IS_IMAPX_STREAM (is), IMAPX_TOK_ERROR);
        g_return_val_if_fail (data != NULL, IMAPX_TOK_ERROR);
 
-       switch (camel_imapx_stream_token (is, data, &len, cancellable, &local_error)) {
-       case IMAPX_TOK_STRING:
-               return 0;
-       case IMAPX_TOK_LITERAL:
-               if (len >= is->priv->bufsize)
-                       camel_imapx_stream_grow (is, len, NULL, NULL);
-               p = is->priv->tokenbuf;
-               camel_imapx_stream_set_literal (is, len);
-               do {
-                       ret = camel_imapx_stream_getl (is, &start, &inlen, cancellable, error);
-                       if (ret < 0)
-                               return ret;
-                       memcpy (p, start, inlen);
-                       p += inlen;
-               } while (ret > 0);
-               *p = 0;
-               *data = is->priv->tokenbuf;
-               return 0;
-       case IMAPX_TOK_TOKEN:
-               p = *data;
-               if (toupper (p[0]) == 'N' && toupper (p[1]) == 'I' && toupper (p[2]) == 'L' && p[3] == 0) {
-                       *data = NULL;
+       tok = camel_imapx_stream_token (is, data, &len, cancellable, error);
+
+       switch (tok) {
+               case IMAPX_TOK_ERROR:
+                       return IMAPX_TOK_ERROR;
+
+               case IMAPX_TOK_STRING:
                        return 0;
-               }
-       default:
-               if (local_error == NULL)
-                       g_set_error (error, CAMEL_IMAPX_ERROR, 1, "expecting nstring");
-               else
-                       g_propagate_error (error, local_error);
-               return IMAPX_TOK_ERROR;
-       case IMAPX_TOK_ERROR:
-               /* we'll never get this unless there are no exception  handlers anyway */
-               if (local_error != NULL)
-                       g_propagate_error (error, local_error);
-               return IMAPX_TOK_ERROR;
 
+               case IMAPX_TOK_LITERAL:
+                       if (len >= is->priv->bufsize)
+                               camel_imapx_stream_grow (is, len, NULL, NULL);
+                       p = is->priv->tokenbuf;
+                       camel_imapx_stream_set_literal (is, len);
+                       do {
+                               ret = camel_imapx_stream_getl (
+                                       is, &start, &inlen, cancellable, error);
+                               if (ret < 0)
+                                       return IMAPX_TOK_ERROR;
+                               memcpy (p, start, inlen);
+                               p += inlen;
+                       } while (ret > 0);
+                       *p = 0;
+                       *data = is->priv->tokenbuf;
+                       return 0;
+
+               case IMAPX_TOK_TOKEN:
+                       p = *data;
+                       if (toupper (p[0]) == 'N' &&
+                           toupper (p[1]) == 'I' &&
+                           toupper (p[2]) == 'L' &&
+                           p[3] == 0) {
+                               *data = NULL;
+                               return 0;
+                       }
+                       /* fall through */
+
+               default:
+                       g_set_error (
+                               error, CAMEL_IMAPX_ERROR, 1,
+                               "expecting nstring");
+                       io (is->tagprefix, "expecting nstring!\n");
+                       return IMAPX_TOK_ERROR;
        }
 }
 


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]