]> git.ipfire.org Git - thirdparty/curl.git/commitdiff
src: Remove C99 constructs to ensure C89 compliance
authorTom <tomaviv57@gmail.com>
Fri, 17 Apr 2020 14:53:40 +0000 (17:53 +0300)
committerDaniel Gustafsson <daniel@yesql.se>
Sun, 19 Apr 2020 19:56:52 +0000 (21:56 +0200)
This fixes the error: 'for' loop initial declaration used outside C99
mode by declaring the loop increment variable in the beginning of the
block instead of inside the for loop.

Fixes #5254
Reviewed-by: Daniel Gustafsson <daniel@yesql.se>
docs/examples/crawler.c
tests/unit/unit1655.c

index 7ddfb81bf13baa662f4a42b6ec752e605bb7b063..59de99d7a8e716dd69ce15a3189389c87d175489 100644 (file)
@@ -6,7 +6,7 @@
  *                             \___|\___/|_| \_\_____|
  *
  * Web crawler based on curl and libxml2.
- * Copyright (C) 2018 - 2019 Jeroen Ooms <jeroenooms@gmail.com>
+ * Copyright (C) 2018 - 2020 Jeroen Ooms <jeroenooms@gmail.com>
  * License: MIT
  *
  * To compile:
@@ -116,7 +116,8 @@ size_t follow_links(CURLM *multi_handle, memory *mem, char *url)
     return 0;
   }
   size_t count = 0;
-  for(int i = 0; i < nodeset->nodeNr; i++) {
+  int i;
+  for(i = 0; i < nodeset->nodeNr; i++) {
     double r = rand();
     int x = r * nodeset->nodeNr / RAND_MAX;
     const xmlNode *node = nodeset->nodeTab[x]->xmlChildrenNode;
index a06b23a7609244d6b3371461f001e0ebc81aa265..1b910ed9f1ac2fd2191c236bb737c9a4cc333000 100644 (file)
@@ -5,7 +5,7 @@
  *                            | (__| |_| |  _ <| |___
  *                             \___|\___/|_| \_\_____|
  *
- * Copyright (C) 2019, Daniel Stenberg, <daniel@haxx.se>, et al.
+ * Copyright (C) 2019 - 2020, Daniel Stenberg, <daniel@haxx.se>, et al.
  *
  * This software is licensed as described in the file COPYING, which
  * you should have received as part of this distribution. The terms
@@ -75,6 +75,7 @@ do {
     "this.is.an.otherwise-valid.hostname."
     "with-a-label-of-greater-length-than-the-sixty-three-characters-"
     "specified.in.the.RFCs.";
+  int i;
 
   struct test {
     const char *name;
@@ -96,7 +97,7 @@ do {
     { max, DOH_OK }                      /* expect buffer overwrite */
   };
 
-  for(int i = 0; i < (int)(sizeof(playlist)/sizeof(*playlist)); i++) {
+  for(i = 0; i < (int)(sizeof(playlist)/sizeof(*playlist)); i++) {
     const char *name = playlist[i].name;
     size_t olen = 100000;
     struct demo victim;