Fix bug in definition of CONCAT standard function in iec_std_lib.h
authorlaurent
Sun, 09 Oct 2011 20:12:05 +0200
changeset 379 7dc97c825bb8
parent 378 7f2e120c7352
child 380 b78e59ed4269
Fix bug in definition of CONCAT standard function in iec_std_lib.h
lib/iec_std_lib.h
--- a/lib/iec_std_lib.h	Wed Sep 28 14:55:26 2011 +0200
+++ b/lib/iec_std_lib.h	Sun Oct 09 20:12:05 2011 +0200
@@ -1876,59 +1876,49 @@
     /*     RIGHT     */
     /*****************/
 
-static inline STRING __right(STRING IN, __strlen_t L){
-    STRING res;
-    res = __INIT_STRING;
-    L = L < IN.len ? L : IN.len;
-    memcpy(&res.body, &IN.body[IN.len - L], L);
-    res.len = L;
-    return res;
-}
-
-
-#define __iec_(TYPENAME) \
-static inline STRING RIGHT__STRING__STRING__##TYPENAME(EN_ENO_PARAMS, STRING str, TYPENAME L){\
+#define __right(TYPENAME) \
+static inline STRING RIGHT__STRING__STRING__##TYPENAME(EN_ENO_PARAMS, STRING IN, TYPENAME L){\
+  STRING res;\
   TEST_EN_COND(STRING, L < 0)\
-  return (STRING)__right(str,L);\
-}
-__ANY_INT(__iec_)
-#undef __iec_
+  res = __INIT_STRING;\
+  L = L < IN.len ? L : IN.len;\
+  memcpy(&res.body, &IN.body[IN.len - L], L);\
+  res.len = L;\
+  return res;\
+}
+__ANY_INT(__right)
 
 
     /***************/
     /*     MID     */
     /***************/
 
-static inline STRING __mid(STRING IN, __strlen_t L, __strlen_t P){
-    STRING res;
-    res = __INIT_STRING;
-    if(P <= IN.len){
-	    P -= 1; /* now can be used as [index]*/
-	    L = L + P <= IN.len ? L : IN.len - P;
-	    memcpy(&res.body, &IN.body[P] , L);
-        res.len = L;
-    }
-    return res;
-}
-
-#define __iec_(TYPENAME) \
-static inline STRING MID__STRING__STRING__##TYPENAME##__##TYPENAME(EN_ENO_PARAMS, STRING str, TYPENAME L, TYPENAME P){\
+#define __mid(TYPENAME) \
+static inline STRING MID__STRING__STRING__##TYPENAME##__##TYPENAME(EN_ENO_PARAMS, STRING IN, TYPENAME L, TYPENAME P){\
+  STRING res;\
   TEST_EN_COND(STRING, L < 0 || P < 0)\
-  return (STRING)__mid(str,L,P);\
-}
-__ANY_INT(__iec_)
-#undef __iec_
+  res = __INIT_STRING;\
+  if(P <= IN.len){\
+	P -= 1; /* now can be used as [index]*/\
+	L = L + P <= IN.len ? L : IN.len - P;\
+	memcpy(&res.body, &IN.body[P] , L);\
+	  res.len = L;\
+  }\
+  return res;\
+}
+__ANY_INT(__mid)
 
 
     /******************/
     /*     CONCAT     */
     /******************/
 
-static inline STRING CONCAT__STRING__STRING(UINT param_count, ...){
+static inline STRING CONCAT(EN_ENO_PARAMS, UINT param_count, ...){
   UINT i;
   STRING res;
   va_list ap;
   __strlen_t charcount;
+  TEST_EN(STRING)
   charcount = 0;
   res = __INIT_STRING;