lib/C/iec_std_functions.h
changeset 1090 61fee9f5368a
parent 1086 ee66a14e38f7
child 1091 6f4e7a8387ae
equal deleted inserted replaced
1089:25271e1a3426 1090:61fee9f5368a
  1440     /****************/
  1440     /****************/
  1441 
  1441 
  1442 static inline __strlen_t __pfind(STRING* IN1, STRING* IN2){
  1442 static inline __strlen_t __pfind(STRING* IN1, STRING* IN2){
  1443     UINT count1 = 0; /* offset of first matching char in IN1 */
  1443     UINT count1 = 0; /* offset of first matching char in IN1 */
  1444     UINT count2 = 0; /* count of matching char */
  1444     UINT count2 = 0; /* count of matching char */
       
  1445     if(!(IN2->len > 0 && IN1->len >= IN2->len)) return 0;
  1445     while(count1 + count2 < IN1->len && count2 < IN2->len)
  1446     while(count1 + count2 < IN1->len && count2 < IN2->len)
  1446     {
  1447     {
  1447         if(IN1->body[count1 + count2] != IN2->body[count2]){
  1448         if(IN1->body[count1 + count2] != IN2->body[count2]){
  1448             count1 += count2 + 1;
  1449             count1 += count2 + 1;
  1449             count2 = 0;
  1450             count2 = 0;
  1450         }
  1451         }
  1451         else {
  1452         else {
  1452             count2++;
  1453             count2++;
  1453         }
  1454         }
  1454     }
  1455     }
  1455     return count2 == IN2->len -1 ? 0 : count1 + 1;
  1456     return count2 == IN2->len ? count1 + 1 : 0;
  1456 }
  1457 }
  1457 
  1458 
  1458 #define __iec_(TYPENAME) \
  1459 #define __iec_(TYPENAME) \
  1459 static inline TYPENAME FIND__##TYPENAME##__STRING__STRING(EN_ENO_PARAMS STRING str1, STRING str2){\
  1460 static inline TYPENAME FIND__##TYPENAME##__STRING__STRING(EN_ENO_PARAMS STRING str1, STRING str2){\
  1460   TEST_EN(TYPENAME)\
  1461   TEST_EN(TYPENAME)\