@@ -500,49 +500,54 @@ rt_int32_t rt_strcmp(const char *cs, const char *ct)
500500RTM_EXPORT (rt_strcmp );
501501
502502/**
503- * The strnlen() function returns the number of characters in the
504- * string pointed to by s, excluding the terminating null byte ('\0'),
505- * but at most maxlen. In doing this, strnlen() looks only at the
506- * first maxlen characters in the string pointed to by s and never
507- * beyond s+maxlen.
508- *
509- * @param s is the string.
503+ * This function will return the length of a string, which terminate will
504+ * null character.
510505 *
511- * @param maxlen is the max size.
506+ * @param s is the string
512507 *
513508 * @return The length of string.
514509 */
515- rt_size_t rt_strnlen (const char * s , rt_ubase_t maxlen )
510+ rt_size_t rt_strlen (const char * s )
516511{
517512 const char * sc ;
518513
519- for (sc = s ; * sc != '\0' && ( rt_ubase_t )( sc - s ) < maxlen ; ++ sc ) /* nothing */
514+ for (sc = s ; * sc != '\0' ; ++ sc ) /* nothing */
520515 ;
521516
522517 return sc - s ;
523518}
524- RTM_EXPORT (rt_strnlen );
519+ RTM_EXPORT (rt_strlen );
525520
521+ #endif /* RT_KSERVICE_USING_STDLIB */
522+
523+ #if !defined(RT_KSERVICE_USING_STDLIB ) || defined(__ARMCC_VERSION )
526524/**
527- * This function will return the length of a string, which terminate will
528- * null character.
525+ * The strnlen() function returns the number of characters in the
526+ * string pointed to by s, excluding the terminating null byte ('\0'),
527+ * but at most maxlen. In doing this, strnlen() looks only at the
528+ * first maxlen characters in the string pointed to by s and never
529+ * beyond s+maxlen.
529530 *
530- * @param s is the string
531+ * @param s is the string.
532+ *
533+ * @param maxlen is the max size.
531534 *
532535 * @return The length of string.
533536 */
534- rt_size_t rt_strlen (const char * s )
537+ rt_size_t rt_strnlen (const char * s , rt_ubase_t maxlen )
535538{
536539 const char * sc ;
537540
538- for (sc = s ; * sc != '\0' ; ++ sc ) /* nothing */
541+ for (sc = s ; * sc != '\0' && ( rt_ubase_t )( sc - s ) < maxlen ; ++ sc ) /* nothing */
539542 ;
540543
541544 return sc - s ;
542545}
543- RTM_EXPORT (rt_strlen );
544-
545- #endif /* RT_KSERVICE_USING_STDLIB */
546+ RTM_EXPORT (rt_strnlen );
547+ #ifdef __ARMCC_VERSION
548+ size_t strnlen (const char * s , size_t maxlen ) __attribute__((alias ("rt_strnlen" )));
549+ #endif /* __ARMCC_VERSION */
550+ #endif /* !defined(RT_KSERVICE_USING_STDLIB) || defined(__ARMCC_VERSION) */
546551
547552#ifdef RT_USING_HEAP
548553/**
@@ -567,7 +572,7 @@ char *rt_strdup(const char *s)
567572RTM_EXPORT (rt_strdup );
568573#ifdef __ARMCC_VERSION
569574char * strdup (const char * s ) __attribute__((alias ("rt_strdup" )));
570- #endif
575+ #endif /* __ARMCC_VERSION */
571576#endif /* RT_USING_HEAP */
572577
573578/**
0 commit comments