ソースを参照

Make mg_read C-90 compliant

Put var declarations at the top of the block to satisfy C-90
compilers.
Keith Kyzivat 10 年 前
コミット
116c01fbd8
1 ファイル変更6 行追加4 行削除
  1. 6 4
      src/civetweb.c

+ 6 - 4
src/civetweb.c

@@ -2648,6 +2648,11 @@ int mg_read(struct mg_connection *conn, void *buf, size_t len)
 {
     if (conn->is_chunked)
     {
+        int i = 0;
+        char buf[64];
+        char *end = 0;
+        long chunkSize = strtol(buf,&end,16);
+
         if (conn->content_len <= 0)
         {
             conn->content_len = 0;
@@ -2657,8 +2662,6 @@ int mg_read(struct mg_connection *conn, void *buf, size_t len)
             return mg_read_inner(conn, buf,len);
         }
 
-        int i = 0;
-        char buf[64];
         while (1)
         {
             int c = mg_getc(conn);
@@ -2681,8 +2684,7 @@ int mg_read(struct mg_connection *conn, void *buf, size_t len)
                 break;
             }
         }
-        char *end = 0;
-        long chunkSize = strtol(buf,&end,16);
+
         if (end != buf+(i-1))
         {
             return -1;