Procházet zdrojové kódy

Declare all variables at begin of the block, to comply with old C standards.

bel2125 před 7 roky
rodič
revize
08e7ad7c76
2 změnil soubory, kde provedl 12 přidání a 8 odebrání
  1. 10 6
      src/civetweb.c
  2. 2 2
      test/websocket.lua

+ 10 - 6
src/civetweb.c

@@ -13969,9 +13969,11 @@ is_ssl_port_used(const char *ports)
 		 * So, for now, we use this simple algorithm, that may still return
 		 * a false positive in bizarre cases.
 		 */
+		int i;
 		int portslen = (int)strlen(ports);
 		char prevIsNumber = 0;
-		for (int i = 0; i < portslen; i++) {
+
+		for (i = 0; i < portslen; i++) {
 			if (prevIsNumber && (ports[i] == 's' || ports[i] == 'r')) {
 				return 1;
 			}
@@ -18796,6 +18798,13 @@ mg_get_context_info_impl(const struct mg_context *ctx, char *buffer, int buflen)
 	}
 
 	if (ctx) {
+		/* Declare all variables at begin of the block, to comply
+		 * with old C standards. */
+		char start_time_str[64] = {0};
+		char now_str[64] = {0};
+		time_t start_time = ctx->start_time;
+		time_t now = time(NULL);
+
 		/* Connections information */
 		mg_snprintf(NULL,
 		            NULL,
@@ -18860,11 +18869,6 @@ mg_get_context_info_impl(const struct mg_context *ctx, char *buffer, int buflen)
 		}
 
 		/* Execution time information */
-		char start_time_str[64] = {0};
-		char now_str[64] = {0};
-		time_t start_time = ctx->start_time;
-		time_t now = time(NULL);
-
 		gmt_time_string(start_time_str,
 		                sizeof(start_time_str) - 1,
 		                &start_time);

+ 2 - 2
test/websocket.lua

@@ -96,8 +96,8 @@ function senddata()
     mg.write("text", string.format("%u:%02u:%02u", date.hour, date.min, date.sec));
 
     if (hand ~= lasthand) then
-        mg.write(1, string.format("-->h %u", hand*360/(12*60)));
-        mg.write(   string.format("-->m %u", date.min*360/60));
+        mg.write(1, string.format("-->h %f", hand*360/(12*60)));
+        mg.write(   string.format("-->m %f", date.min*360/60));
         lasthand = hand;
     end