# HG changeset patch
# User Edouard Tisserant
# Date 1592483540 -7200
# Node ID 6f4e7a8387aeaa1f427599cb936386dde096ba58
# Parent  61fee9f5368ad803436ca7f2cbc663231e03d563
Fixed in standard function library: String comparison was retrurning wrong result whith strings of different sizes but starting the same, or with zero length strings.

diff -r 61fee9f5368a -r 6f4e7a8387ae lib/C/iec_std_functions.h
--- a/lib/C/iec_std_functions.h	Fri May 08 10:20:04 2020 +0200
+++ b/lib/C/iec_std_functions.h	Thu Jun 18 14:32:20 2020 +0200
@@ -890,7 +890,11 @@
 __iec_(TIME)
 #undef __iec_
 
-#define __STR_CMP(str1, str2) memcmp((char*)&str1.body,(char*)&str2.body, str1.len < str2.len ? str1.len : str2.len)
+inline int __str_cmp(uint8_t* str1, __strlen_t len1, uint8_t* str2, __strlen_t len2) { 
+    int cmp = memcmp(str1, str2, len1 < len2 ? len1 : len2);
+    return cmp ? cmp : (len1 > len2 ? 1 : (len1 < len2 ? - 1 : 0));
+}
+#define __STR_CMP(str1, str2) __str_cmp(str1.body, str1.len, str2.body, str2.len)
 
 /* Max for string data types */	
 __extrem_(MAX_STRING, STRING, __STR_CMP(op1,tmp) < 0) /* The explicitly typed standard functions */