qemu-trivial
[Top][All Lists]
Advanced

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

Re: [Qemu-trivial] [Qemu-devel] [PATCH RFC] util: Fix wrong indentation


From: Thomas Huth
Subject: Re: [Qemu-trivial] [Qemu-devel] [PATCH RFC] util: Fix wrong indentation TAB with space
Date: Mon, 19 Feb 2018 09:17:52 +0100
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.6.0

On 19.02.2018 08:23, Su Hang wrote:
> BiteSizedTasks: Developer conveniences
> 
> I use checkpatch.pl to find these files
> (bitops.c envlist.c osdep.c qemu-sockets.c readline.c uri.c)
> use TAB instead of space for indentation.
> 
> Repalcing all TABs in the beginning of lines with space, and left
> the rest of file untouched.
> 
> Signed-off-by: Su Hang <address@hidden>
> ---

 Hi,

thanks for tackling this! Some comments below...


> diff --git a/util/envlist.c b/util/envlist.c
> index 1eeb7fca87c1..8c0e32f89c39 100644
> --- a/util/envlist.c
> +++ b/util/envlist.c
> @@ -4,13 +4,13 @@
>  #include "qemu/envlist.h"
>  
>  struct envlist_entry {
> -     const char *ev_var;                     /* actual env value */
> -     QLIST_ENTRY(envlist_entry) ev_link;
> +    const char *ev_var;                      /* actual env value */

There are still some TABs here between the code and the comment.

> +    QLIST_ENTRY(envlist_entry) ev_link;
>  };
>  
>  struct envlist {
> -     QLIST_HEAD(, envlist_entry) el_entries; /* actual entries */
> -     size_t el_count;                        /* number of entries */
> +    QLIST_HEAD(, envlist_entry) el_entries;  /* actual entries */
> +    size_t el_count;                 /* number of entries */

dito.

>  };
>  
>  static int envlist_parse(envlist_t *envlist,
> @@ -22,14 +22,14 @@ static int envlist_parse(envlist_t *envlist,
>  envlist_t *
>  envlist_create(void)
>  {
> -     envlist_t *envlist;
> +    envlist_t *envlist;
>  
> -     envlist = g_malloc(sizeof(*envlist));
> +    envlist = g_malloc(sizeof(*envlist));
>  
> -     QLIST_INIT(&envlist->el_entries);
> -     envlist->el_count = 0;
> +    QLIST_INIT(&envlist->el_entries);
> +    envlist->el_count = 0;
>  
> -     return (envlist);
> +    return (envlist);

Not sure whether this should be done in your patch here, or whether we
shoud clean that up later (I'll leave that up to you to decide), but
"return (envlist);" should be replace with "return envlist;" to match
our coding style (and to please our scripts/checkpatch.pl script).

(the same applies for the other "return (...);" statements in your patch)

[...]
> diff --git a/util/qemu-sockets.c b/util/qemu-sockets.c
> index fbbef69f6275..2e8b26256e64 100644
> --- a/util/qemu-sockets.c
> +++ b/util/qemu-sockets.c
> @@ -262,8 +262,8 @@ static int inet_listen_saddr(InetSocketAddress *saddr,
>      /* create socket + bind/listen */
>      for (e = res; e != NULL; e = e->ai_next) {
>          getnameinfo((struct sockaddr*)e->ai_addr,e->ai_addrlen,
> -                     uaddr,INET6_ADDRSTRLEN,uport,32,
> -                     NI_NUMERICHOST | NI_NUMERICSERV);
> +                    uaddr,INET6_ADDRSTRLEN,uport,32,

While you're at it, could you please add a space before
"INET6_ADDRSTRLEN", "uport" and "32" to make checkpatch.pl happy here?

> +                    NI_NUMERICHOST | NI_NUMERICSERV);
>  
>          port_min = inet_getport(e);
>          port_max = saddr->has_to ? saddr->to + port_offset : port_min;
[...]
> diff --git a/util/uri.c b/util/uri.c
> index 21b18281703a..aa1c2da00c17 100644
> --- a/util/uri.c
> +++ b/util/uri.c
> @@ -98,17 +98,17 @@ static void uri_clean(URI *uri);
>   */
>  
>  #define IS_MARK(x) (((x) == '-') || ((x) == '_') || ((x) == '.') ||     \
> -    ((x) == '!') || ((x) == '~') || ((x) == '*') || ((x) == '\'') ||    \
> -    ((x) == '(') || ((x) == ')'))
> +        ((x) == '!') || ((x) == '~') || ((x) == '*') || ((x) == '\'') ||    \
> +        ((x) == '(') || ((x) == ')'))
>  
>  /*
>   * unwise = "{" | "}" | "|" | "\" | "^" | "`"
>   */
>  
>  #define IS_UNWISE(p)                                                    \
> -      (((*(p) == '{')) || ((*(p) == '}')) || ((*(p) == '|')) ||         \
> -       ((*(p) == '\\')) || ((*(p) == '^')) || ((*(p) == '[')) ||        \
> -       ((*(p) == ']')) || ((*(p) == '`')))
> +    (((*(p) == '{')) || ((*(p) == '}')) || ((*(p) == '|')) ||         \
> +     ((*(p) == '\\')) || ((*(p) == '^')) || ((*(p) == '[')) ||        \
> +     ((*(p) == ']')) || ((*(p) == '`')))
>  /*
>   * reserved = ";" | "/" | "?" | ":" | "@" | "&" | "=" | "+" | "$" | "," |
>   *            "[" | "]"
> @@ -150,28 +150,28 @@ static void uri_clean(URI *uri);
>  
>  #define ISA_DIGIT(p) ((*(p) >= '0') && (*(p) <= '9'))
>  #define ISA_ALPHA(p) (((*(p) >= 'a') && (*(p) <= 'z')) ||            \
> -                      ((*(p) >= 'A') && (*(p) <= 'Z')))
> +        ((*(p) >= 'A') && (*(p) <= 'Z')))
>  #define ISA_HEXDIG(p)                                                        
> \

There are still some TABs left in the line above

> -       (ISA_DIGIT(p) || ((*(p) >= 'a') && (*(p) <= 'f')) ||          \
> -        ((*(p) >= 'A') && (*(p) <= 'F')))
> +    (ISA_DIGIT(p) || ((*(p) >= 'a') && (*(p) <= 'f')) ||             \

Here are also some TABs left before the "\"

> +     ((*(p) >= 'A') && (*(p) <= 'F')))
>  
>  /*
>   *    sub-delims    = "!" / "$" / "&" / "'" / "(" / ")"
>   *                     / "*" / "+" / "," / ";" / "="
>   */
>  #define ISA_SUB_DELIM(p)                                             \
> -      (((*(p) == '!')) || ((*(p) == '$')) || ((*(p) == '&')) ||              
> \
> -       ((*(p) == '(')) || ((*(p) == ')')) || ((*(p) == '*')) ||              
> \
> -       ((*(p) == '+')) || ((*(p) == ',')) || ((*(p) == ';')) ||              
> \
> -       ((*(p) == '=')) || ((*(p) == '\'')))
> +    (((*(p) == '!')) || ((*(p) == '$')) || ((*(p) == '&')) ||                
> \
> +     ((*(p) == '(')) || ((*(p) == ')')) || ((*(p) == '*')) ||                
> \
> +     ((*(p) == '+')) || ((*(p) == ',')) || ((*(p) == ';')) ||                
> \

dito

> +     ((*(p) == '=')) || ((*(p) == '\'')))
>  
>  /*
>   *    gen-delims    = ":" / "/" / "?" / "#" / "[" / "]" / "@"
>   */
>  #define ISA_GEN_DELIM(p)                                             \
> -      (((*(p) == ':')) || ((*(p) == '/')) || ((*(p) == '?')) ||         \
> -       ((*(p) == '#')) || ((*(p) == '[')) || ((*(p) == ']')) ||         \
> -       ((*(p) == '@')))
> +    (((*(p) == ':')) || ((*(p) == '/')) || ((*(p) == '?')) ||         \
> +     ((*(p) == '#')) || ((*(p) == '[')) || ((*(p) == ']')) ||         \
> +     ((*(p) == '@')))
>  
>  /*
>   *    reserved      = gen-delims / sub-delims
> @@ -182,21 +182,21 @@ static void uri_clean(URI *uri);
>   *    unreserved    = ALPHA / DIGIT / "-" / "." / "_" / "~"
>   */
>  #define ISA_UNRESERVED(p)                                            \
> -      ((ISA_ALPHA(p)) || (ISA_DIGIT(p)) || ((*(p) == '-')) ||                
> \
> -       ((*(p) == '.')) || ((*(p) == '_')) || ((*(p) == '~')))
> +    ((ISA_ALPHA(p)) || (ISA_DIGIT(p)) || ((*(p) == '-')) ||          \

dito

> +     ((*(p) == '.')) || ((*(p) == '_')) || ((*(p) == '~')))
>  
>  /*
>   *    pct-encoded   = "%" HEXDIG HEXDIG
>   */
>  #define ISA_PCT_ENCODED(p)                                           \

dito

> -     ((*(p) == '%') && (ISA_HEXDIG(p + 1)) && (ISA_HEXDIG(p + 2)))
> +    ((*(p) == '%') && (ISA_HEXDIG(p + 1)) && (ISA_HEXDIG(p + 2)))
>  
>  /*
>   *    pchar         = unreserved / pct-encoded / sub-delims / ":" / "@"
>   */
>  #define ISA_PCHAR(p)                                                 \
> -     (ISA_UNRESERVED(p) || ISA_PCT_ENCODED(p) || ISA_SUB_DELIM(p) || \
> -      ((*(p) == ':')) || ((*(p) == '@')))
> +    (ISA_UNRESERVED(p) || ISA_PCT_ENCODED(p) || ISA_SUB_DELIM(p) ||  \

dito

> +     ((*(p) == ':')) || ((*(p) == '@')))
>  
[...]
> @@ -281,7 +281,7 @@ rfc3986_parse_fragment(URI *uri, const char **str)
>   *
>   * Returns 0 or the error code
>   */
> -static int
> +    static int
>  rfc3986_parse_query(URI *uri, const char **str)
>  {
>      const char *cur;
> @@ -292,11 +292,11 @@ rfc3986_parse_query(URI *uri, const char **str)
>      cur = *str;
>  
>      while ((ISA_PCHAR(cur)) || (*cur == '/') || (*cur == '?') ||
> -           ((uri != NULL) && (uri->cleanup & 1) && (IS_UNWISE(cur))))
> +            ((uri != NULL) && (uri->cleanup & 1) && (IS_UNWISE(cur))))
>          NEXT(cur);
>      if (uri != NULL) {
>          g_free(uri->query);
> -     uri->query = g_strndup (*str, cur - *str);
> +        uri->query = g_strndup (*str, cur - *str);

While you're at it, could you please remove the space after "g_strndup"
to make checkpatch.pl happy here?

>      }
>      *str = cur;
>      return (0);
> @@ -314,7 +314,7 @@ rfc3986_parse_query(URI *uri, const char **str)
>   *
>   * Returns 0 or the error code
>   */
> -static int
> +    static int
>  rfc3986_parse_port(URI *uri, const char **str)

The change here (and to the other return values in that you've made to
uri.c) looks wrong to me. I think it's more common to keep the return
value starting in column 0, so could you please drop these changes from
your patch?

[...]
> @@ -1047,198 +1047,198 @@ uri_to_string(URI *uri) {
>      len = 0;
>  
>      if (uri->scheme != NULL) {
> -     p = uri->scheme;
> -     while (*p != 0) {
> -         if (len >= max) {
> +        p = uri->scheme;
> +        while (*p != 0) {
> +            if (len >= max) {
>                  temp = realloc2n(ret, &max);
> -             ret = temp;
> -         }
> -         ret[len++] = *p++;
> -     }
> -     if (len >= max) {
> +                ret = temp;
> +            }
> +            ret[len++] = *p++;
> +        }
> +        if (len >= max) {
>              temp = realloc2n(ret, &max);
>              ret = temp;
> -     }
> -     ret[len++] = ':';
> +        }
> +        ret[len++] = ':';
>      }
>      if (uri->opaque != NULL) {
> -     p = uri->opaque;
> -     while (*p != 0) {
> -         if (len + 3 >= max) {
> +        p = uri->opaque;
> +        while (*p != 0) {
> +            if (len + 3 >= max) {
>                  temp = realloc2n(ret, &max);
>                  ret = temp;
> -         }
> -         if (IS_RESERVED(*(p)) || IS_UNRESERVED(*(p)))
> -             ret[len++] = *p++;
> -         else {
> -             int val = *(unsigned char *)p++;
> -             int hi = val / 0x10, lo = val % 0x10;
> -             ret[len++] = '%';
> -             ret[len++] = hi + (hi > 9? 'A'-10 : '0');
> -             ret[len++] = lo + (lo > 9? 'A'-10 : '0');
> -         }
> -     }
> +            }
> +            if (IS_RESERVED(*(p)) || IS_UNRESERVED(*(p)))
> +                ret[len++] = *p++;
> +            else {
> +                int val = *(unsigned char *)p++;
> +                int hi = val / 0x10, lo = val % 0x10;
> +                ret[len++] = '%';
> +                ret[len++] = hi + (hi > 9? 'A'-10 : '0');
> +                ret[len++] = lo + (lo > 9? 'A'-10 : '0');

While you're at it, could you please add a space before the "?" and
around the "-" to make checkpatch.pl happy here?

> +            }
> +        }
>      } else {
> -     if (uri->server != NULL) {
> -         if (len + 3 >= max) {
> +        if (uri->server != NULL) {
> +            if (len + 3 >= max) {
>                  temp = realloc2n(ret, &max);
>                  ret = temp;
> -         }
> -         ret[len++] = '/';
> -         ret[len++] = '/';
> -         if (uri->user != NULL) {
> -             p = uri->user;
> -             while (*p != 0) {
> -                 if (len + 3 >= max) {
> +            }
> +            ret[len++] = '/';
> +            ret[len++] = '/';
> +            if (uri->user != NULL) {
> +                p = uri->user;
> +                while (*p != 0) {
> +                    if (len + 3 >= max) {
>                          temp = realloc2n(ret, &max);
>                          ret = temp;
> -                 }
> -                 if ((IS_UNRESERVED(*(p))) ||
> -                     ((*(p) == ';')) || ((*(p) == ':')) ||
> -                     ((*(p) == '&')) || ((*(p) == '=')) ||
> -                     ((*(p) == '+')) || ((*(p) == '$')) ||
> -                     ((*(p) == ',')))
> -                     ret[len++] = *p++;
> -                 else {
> -                     int val = *(unsigned char *)p++;
> -                     int hi = val / 0x10, lo = val % 0x10;
> -                     ret[len++] = '%';
> -                     ret[len++] = hi + (hi > 9? 'A'-10 : '0');
> -                     ret[len++] = lo + (lo > 9? 'A'-10 : '0');
> -                 }
> -             }
> -             if (len + 3 >= max) {
> +                    }
> +                    if ((IS_UNRESERVED(*(p))) ||
> +                            ((*(p) == ';')) || ((*(p) == ':')) ||
> +                            ((*(p) == '&')) || ((*(p) == '=')) ||
> +                            ((*(p) == '+')) || ((*(p) == '$')) ||
> +                            ((*(p) == ',')))
> +                        ret[len++] = *p++;
> +                    else {
> +                        int val = *(unsigned char *)p++;
> +                        int hi = val / 0x10, lo = val % 0x10;
> +                        ret[len++] = '%';
> +                        ret[len++] = hi + (hi > 9? 'A'-10 : '0');
> +                        ret[len++] = lo + (lo > 9? 'A'-10 : '0');

dito

> +                    }
> +                }
> +                if (len + 3 >= max) {
>                      temp = realloc2n(ret, &max);
>                      ret = temp;
> -             }
> -             ret[len++] = '@';
> -         }
> -         p = uri->server;
> -         while (*p != 0) {
> -             if (len >= max) {
> +                }
> +                ret[len++] = '@';
> +            }
> +            p = uri->server;
> +            while (*p != 0) {
> +                if (len >= max) {
>                      temp = realloc2n(ret, &max);
>                      ret = temp;
> -             }
> -             ret[len++] = *p++;
> -         }
> -         if (uri->port > 0) {
> -             if (len + 10 >= max) {
> +                }
> +                ret[len++] = *p++;
> +            }
> +            if (uri->port > 0) {
> +                if (len + 10 >= max) {
>                      temp = realloc2n(ret, &max);
>                      ret = temp;
> -             }
> -             len += snprintf(&ret[len], max - len, ":%d", uri->port);
> -         }
> -     } else if (uri->authority != NULL) {
> -         if (len + 3 >= max) {
> +                }
> +                len += snprintf(&ret[len], max - len, ":%d", uri->port);
> +            }
> +        } else if (uri->authority != NULL) {
> +            if (len + 3 >= max) {
>                  temp = realloc2n(ret, &max);
>                  ret = temp;
> -         }
> -         ret[len++] = '/';
> -         ret[len++] = '/';
> -         p = uri->authority;
> -         while (*p != 0) {
> -             if (len + 3 >= max) {
> +            }
> +            ret[len++] = '/';
> +            ret[len++] = '/';
> +            p = uri->authority;
> +            while (*p != 0) {
> +                if (len + 3 >= max) {
>                      temp = realloc2n(ret, &max);
>                      ret = temp;
> -             }
> -             if ((IS_UNRESERVED(*(p))) ||
> -                    ((*(p) == '$')) || ((*(p) == ',')) || ((*(p) == ';')) ||
> -                    ((*(p) == ':')) || ((*(p) == '@')) || ((*(p) == '&')) ||
> -                    ((*(p) == '=')) || ((*(p) == '+')))
> -                 ret[len++] = *p++;
> -             else {
> -                 int val = *(unsigned char *)p++;
> -                 int hi = val / 0x10, lo = val % 0x10;
> -                 ret[len++] = '%';
> -                 ret[len++] = hi + (hi > 9? 'A'-10 : '0');
> -                 ret[len++] = lo + (lo > 9? 'A'-10 : '0');
> -             }
> -         }
> -     } else if (uri->scheme != NULL) {
> -         if (len + 3 >= max) {
> +                }
> +                if ((IS_UNRESERVED(*(p))) ||
> +                        ((*(p) == '$')) || ((*(p) == ',')) || ((*(p) == 
> ';')) ||
> +                        ((*(p) == ':')) || ((*(p) == '@')) || ((*(p) == 
> '&')) ||
> +                        ((*(p) == '=')) || ((*(p) == '+')))
> +                    ret[len++] = *p++;
> +                else {
> +                    int val = *(unsigned char *)p++;
> +                    int hi = val / 0x10, lo = val % 0x10;
> +                    ret[len++] = '%';
> +                    ret[len++] = hi + (hi > 9? 'A'-10 : '0');
> +                    ret[len++] = lo + (lo > 9? 'A'-10 : '0');

dito

> +                }
> +            }
> +        } else if (uri->scheme != NULL) {
> +            if (len + 3 >= max) {
>                  temp = realloc2n(ret, &max);
>                  ret = temp;
> -         }
> -         ret[len++] = '/';
> -         ret[len++] = '/';
> -     }
> -     if (uri->path != NULL) {
> -         p = uri->path;
> -         /*
> -          * the colon in file:///d: should not be escaped or
> -          * Windows accesses fail later.
> -          */
> -         if ((uri->scheme != NULL) &&
> -             (p[0] == '/') &&
> -             (((p[1] >= 'a') && (p[1] <= 'z')) ||
> -              ((p[1] >= 'A') && (p[1] <= 'Z'))) &&
> -             (p[2] == ':') &&
> -             (!strcmp(uri->scheme, "file"))) {
> -             if (len + 3 >= max) {
> +            }
> +            ret[len++] = '/';
> +            ret[len++] = '/';
> +        }
> +        if (uri->path != NULL) {
> +            p = uri->path;
> +            /*
> +             * the colon in file:///d: should not be escaped or
> +             * Windows accesses fail later.
> +             */
> +            if ((uri->scheme != NULL) &&
> +                    (p[0] == '/') &&
> +                    (((p[1] >= 'a') && (p[1] <= 'z')) ||
> +                     ((p[1] >= 'A') && (p[1] <= 'Z'))) &&
> +                    (p[2] == ':') &&
> +                    (!strcmp(uri->scheme, "file"))) {
> +                if (len + 3 >= max) {
>                      temp = realloc2n(ret, &max);
>                      ret = temp;
> -             }
> -             ret[len++] = *p++;
> -             ret[len++] = *p++;
> -             ret[len++] = *p++;
> -         }
> -         while (*p != 0) {
> -             if (len + 3 >= max) {
> +                }
> +                ret[len++] = *p++;
> +                ret[len++] = *p++;
> +                ret[len++] = *p++;
> +            }
> +            while (*p != 0) {
> +                if (len + 3 >= max) {
>                      temp = realloc2n(ret, &max);
>                      ret = temp;
> -             }
> -             if ((IS_UNRESERVED(*(p))) || ((*(p) == '/')) ||
> -                    ((*(p) == ';')) || ((*(p) == '@')) || ((*(p) == '&')) ||
> -                 ((*(p) == '=')) || ((*(p) == '+')) || ((*(p) == '$')) ||
> -                 ((*(p) == ',')))
> -                 ret[len++] = *p++;
> -             else {
> -                 int val = *(unsigned char *)p++;
> -                 int hi = val / 0x10, lo = val % 0x10;
> -                 ret[len++] = '%';
> -                 ret[len++] = hi + (hi > 9? 'A'-10 : '0');
> -                 ret[len++] = lo + (lo > 9? 'A'-10 : '0')> -         }
> -         }
> -     }
> -     if (uri->query != NULL) {
> -         if (len + 1 >= max) {
> +                }
> +                if ((IS_UNRESERVED(*(p))) || ((*(p) == '/')) ||
> +                        ((*(p) == ';')) || ((*(p) == '@')) || ((*(p) == 
> '&')) ||
> +                        ((*(p) == '=')) || ((*(p) == '+')) || ((*(p) == 
> '$')) ||
> +                        ((*(p) == ',')))
> +                    ret[len++] = *p++;
> +                else {
> +                    int val = *(unsigned char *)p++;
> +                    int hi = val / 0x10, lo = val % 0x10;
> +                    ret[len++] = '%';
> +                    ret[len++] = hi + (hi > 9? 'A'-10 : '0');
> +                    ret[len++] = lo + (lo > 9? 'A'-10 : '0');

dito

[...]
> @@ -1700,23 +1700,23 @@ uri_resolve(const char *uri, const char *base) {
>       */
>      res = uri_new();
>      if ((ref->scheme == NULL) && (ref->path == NULL) &&
> -     ((ref->authority == NULL) && (ref->server == NULL))) {
> +            ((ref->authority == NULL) && (ref->server == NULL))) {
>          res->scheme = g_strdup(bas->scheme);
> -     if (bas->authority != NULL)
> -         res->authority = g_strdup(bas->authority);
> -     else if (bas->server != NULL) {
> +        if (bas->authority != NULL)
> +            res->authority = g_strdup(bas->authority);
> +        else if (bas->server != NULL) {
>              res->server = g_strdup(bas->server);
>              res->user = g_strdup(bas->user);
>              res->port = bas->port;
> -     }
> +        }
>          res->path = g_strdup(bas->path);
>          if (ref->query != NULL) {
> -         res->query = g_strdup (ref->query);
> +            res->query = g_strdup (ref->query);

While you're at it, please remove the space after "g_strdup" to make
checkpatch.pl happy.

[...]
> @@ -1958,78 +1958,78 @@ uri_resolve_relative (const char *uri, const char * 
> base)
>       * two path components may be missing (bug 316224)
>       */
>      if (bas->path == NULL) {
> -     if (ref->path != NULL) {
> -         uptr = ref->path;
> -         if (*uptr == '/')
> -             uptr++;
> -         /* exception characters from uri_to_string */
> -         val = uri_string_escape(uptr, "/;&=+$,");
> -     }
> -     goto done;
> +        if (ref->path != NULL) {
> +            uptr = ref->path;
> +            if (*uptr == '/')
> +                uptr++;
> +            /* exception characters from uri_to_string */
> +            val = uri_string_escape(uptr, "/;&=+$,");
> +        }
> +        goto done;
>      }
>      bptr = bas->path;
>      if (ref->path == NULL) {
> -     for (ix = 0; bptr[ix] != 0; ix++) {
> -         if (bptr[ix] == '/')
> -             nbslash++;
> -     }
> -     uptr = NULL;
> -     len = 1;        /* this is for a string terminator only */
> +        for (ix = 0; bptr[ix] != 0; ix++) {
> +            if (bptr[ix] == '/')
> +                nbslash++;
> +        }
> +        uptr = NULL;
> +        len = 1;     /* this is for a string terminator only */

There is still a TAB left here between the code and comment.

>      } else {
> -    /*
> -     * Next we compare the two strings and find where they first differ
> -     */
> -     if ((ref->path[pos] == '.') && (ref->path[pos+1] == '/'))
> +        /*
> +         * Next we compare the two strings and find where they first differ
> +         */
> +        if ((ref->path[pos] == '.') && (ref->path[pos+1] == '/'))
>              pos += 2;
> -     if ((*bptr == '.') && (bptr[1] == '/'))
> +        if ((*bptr == '.') && (bptr[1] == '/'))
>              bptr += 2;
> -     else if ((*bptr == '/') && (ref->path[pos] != '/'))
> -         bptr++;
> -     while ((bptr[pos] == ref->path[pos]) && (bptr[pos] != 0))
> -         pos++;
> -
> -     if (bptr[pos] == ref->path[pos]) {
> -         val = g_strdup("");
> -         goto done;          /* (I can't imagine why anyone would do this) */
> -     }
> -
> -     /*
> -      * In URI, "back up" to the last '/' encountered.  This will be the
> -      * beginning of the "unique" suffix of URI
> -      */
> -     ix = pos;
> -     if ((ref->path[ix] == '/') && (ix > 0))
> -         ix--;
> -     else if ((ref->path[ix] == 0) && (ix > 1) && (ref->path[ix - 1] == '/'))
> -         ix -= 2;
> -     for (; ix > 0; ix--) {
> -         if (ref->path[ix] == '/')
> -             break;
> -     }
> -     if (ix == 0) {
> -         uptr = ref->path;
> -     } else {
> -         ix++;
> -         uptr = &ref->path[ix];
> -     }
> -
> -     /*
> -      * In base, count the number of '/' from the differing point
> -      */
> -     if (bptr[pos] != ref->path[pos]) {/* check for trivial URI == base */
> -         for (; bptr[ix] != 0; ix++) {
> -             if (bptr[ix] == '/')
> -                 nbslash++;
> -         }
> -     }
> -     len = strlen (uptr) + 1;
> +        else if ((*bptr == '/') && (ref->path[pos] != '/'))
> +            bptr++;
> +        while ((bptr[pos] == ref->path[pos]) && (bptr[pos] != 0))
> +            pos++;
> +
> +        if (bptr[pos] == ref->path[pos]) {
> +            val = g_strdup("");
> +            goto done;               /* (I can't imagine why anyone would do 
> this) */

There is still a TAB left here between the code and comment.

> @@ -2043,29 +2043,29 @@ uri_resolve_relative (const char *uri, const char * 
> base)
>       * Put in as many "../" as needed
>       */
>      for (; nbslash>0; nbslash--) {
> -     *vptr++ = '.';
> -     *vptr++ = '.';
> -     *vptr++ = '/';
> +        *vptr++ = '.';
> +        *vptr++ = '.';
> +        *vptr++ = '/';
>      }
>      /*
>       * Finish up with the end of the URI
>       */
>      if (uptr != NULL) {
>          if ((vptr > val) && (len > 0) &&
> -         (uptr[0] == '/') && (vptr[-1] == '/')) {
> -         memcpy (vptr, uptr + 1, len - 1);
> -         vptr[len - 2] = 0;
> -     } else {
> -         memcpy (vptr, uptr, len);
> -         vptr[len - 1] = 0;
> -     }
> +                (uptr[0] == '/') && (vptr[-1] == '/')) {
> +            memcpy (vptr, uptr + 1, len - 1);

While you're at it, please remove the space after "memcpy".

> +            vptr[len - 2] = 0;
> +        } else {
> +            memcpy (vptr, uptr, len);

dito

> +            vptr[len - 1] = 0;
> +        }
>      } else {
> -     vptr[len - 1] = 0;
> +        vptr[len - 1] = 0;
>      }
>  
>      /* escape the freshly-built path */
>      vptr = val;
> -     /* exception characters from uri_to_string */
> +    /* exception characters from uri_to_string */
>      val = uri_string_escape(vptr, "/;&=+$,");
>      g_free(vptr);
>  
> @@ -2076,9 +2076,9 @@ done:
>      if (remove_path != 0)
>          ref->path = NULL;
>      if (ref != NULL)
> -     uri_free (ref);
> +        uri_free (ref);

While you're at it, please remove the space after "uri_free".

>      if (bas != NULL)
> -     uri_free (bas);
> +        uri_free (bas);

dito.

>  
>      return val;
>  }
> @@ -2087,7 +2087,7 @@ done:
>   * Utility functions to help parse and assemble query strings.
>   */
>  
> -struct QueryParams *
> +    struct QueryParams *
>  query_params_new (int init_alloc)
>  {
>      struct QueryParams *ps;
> @@ -2105,9 +2105,9 @@ query_params_new (int init_alloc)
>  /* Ensure there is space to store at least one more parameter
>   * at the end of the set.
>   */
> -static int
> +    static int
>  query_params_append (struct QueryParams *ps,
> -               const char *name, const char *value)
> +        const char *name, const char *value)
>  {
>      if (ps->n >= ps->alloc) {
>          ps->p = g_renew(QueryParam, ps->p, ps->alloc * 2);
> @@ -2122,7 +2122,7 @@ query_params_append (struct QueryParams *ps,
>      return 0;
>  }
>  
> -void
> +    void
>  query_params_free (struct QueryParams *ps)
>  {
>      int i;
> @@ -2135,7 +2135,7 @@ query_params_free (struct QueryParams *ps)
>      g_free (ps);
>  }
>  
> -struct QueryParams *
> +    struct QueryParams *
>  query_params_parse (const char *query)
>  {
>      struct QueryParams *ps;
> @@ -2193,7 +2193,7 @@ query_params_parse (const char *query)
>          g_free(name);
>          g_free(value);
>  
> -    next:
> +next:
>          query = end;
>          if (*query) query ++; /* skip '&' separator */
>      }
> 

 Thanks,
  Thomas



reply via email to

[Prev in Thread] Current Thread [Next in Thread]