From 467778fc5677d3c7f2ff1a221a04be8047c5214e Mon Sep 17 00:00:00 2001 From: def Date: Mon, 10 Aug 2020 18:11:51 +0200 Subject: [PATCH] Satisfy old C standard MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit system.c:2325:2: error: ‘for’ loop initial declarations are only allowed in C99 or C11 mode for(int cursor = 0, pos = 0; pos <= truncation_len && cursor < dst_size && size != cursor; cursor = str_utf8_forward(src, cursor), pos++) --- src/base/system.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/base/system.c b/src/base/system.c index fbf31eadc..5a9e88813 100644 --- a/src/base/system.c +++ b/src/base/system.c @@ -2322,8 +2322,14 @@ void str_copy(char *dst, const char *src, int dst_size) void str_utf8_truncate(char *dst, int dst_size, const char *src, int truncation_len) { int size = -1; - for(int cursor = 0, pos = 0; pos <= truncation_len && cursor < dst_size && size != cursor; cursor = str_utf8_forward(src, cursor), pos++) + int cursor = 0; + int pos = 0; + while(pos <= truncation_len && cursor < dst_size && size != cursor) + { size = cursor; + cursor = str_utf8_forward(src, cursor); + pos++; + } str_copy(dst, src, size+1); }