1From 81b491e60affd67f4ec2feccbee1cdf98dc57b81 Mon Sep 17 00:00:00 2001
2From: Emil Mikulic <emikulic@gmail.com>
3Date: Sun, 21 Mar 2021 15:03:14 +1100
4Subject: [PATCH] Declare vars outside of for() loop for -std=c90.
5
6Fixes #2.
7
8[Retrieved from:
9https://github.com/emikulic/darkhttpd/commit/81b491e60affd67f4ec2feccbee1cdf98dc57b81]
10Signed-off-by: Fabrice Fontaine <fontaine.fabrice@gmail.com>
11---
12 darkhttpd.c | 7 ++++---
13 1 file changed, 4 insertions(+), 3 deletions(-)
14
15diff --git a/darkhttpd.c b/darkhttpd.c
16index 219a8a3..268628a 100644
17--- a/darkhttpd.c
18+++ b/darkhttpd.c
19@@ -966,8 +966,9 @@ static char *base64_encode(char *str) {
20     char *encoded_data = malloc(output_length+1);
21     if (encoded_data == NULL) return NULL;
22
23-    for (int i = 0, j = 0; i < input_length;) {
24-
25+    int i;
26+    int j;
27+    for (i = 0, j = 0; i < input_length;) {
28         uint32_t octet_a = i < input_length ? (unsigned char)str[i++] : 0;
29         uint32_t octet_b = i < input_length ? (unsigned char)str[i++] : 0;
30         uint32_t octet_c = i < input_length ? (unsigned char)str[i++] : 0;
31@@ -981,7 +982,7 @@ static char *base64_encode(char *str) {
32     }
33
34     const int mod_table[] = {0, 2, 1};
35-    for (int i = 0; i < mod_table[input_length % 3]; i++)
36+    for (i = 0; i < mod_table[input_length % 3]; i++)
37         encoded_data[output_length - 1 - i] = '=';
38     encoded_data[output_length] = '\0';
39
40