libs/libc/string: fix various style issues in code
Signed-off-by: Petro Karashchenko <petro.karashchenko@gmail.com>
This commit is contained in:
parent
2a38c38b03
commit
187def2611
|
@ -37,8 +37,8 @@
|
|||
no_builtin("memcmp")
|
||||
int memcmp(FAR const void *s1, FAR const void *s2, size_t n)
|
||||
{
|
||||
unsigned char *p1 = (unsigned char *)s1;
|
||||
unsigned char *p2 = (unsigned char *)s2;
|
||||
FAR unsigned char *p1 = (FAR unsigned char *)s1;
|
||||
FAR unsigned char *p2 = (FAR unsigned char *)s2;
|
||||
|
||||
while (n-- > 0)
|
||||
{
|
||||
|
|
|
@ -43,7 +43,11 @@ FAR void *memcpy(FAR void *dest, FAR const void *src, size_t n)
|
|||
{
|
||||
FAR unsigned char *pout = (FAR unsigned char *)dest;
|
||||
FAR unsigned char *pin = (FAR unsigned char *)src;
|
||||
while (n-- > 0) *pout++ = *pin++;
|
||||
while (n-- > 0)
|
||||
{
|
||||
*pout++ = *pin++;
|
||||
}
|
||||
|
||||
return dest;
|
||||
}
|
||||
#endif
|
||||
|
|
|
@ -42,6 +42,7 @@
|
|||
*
|
||||
****************************************************************************/
|
||||
|
||||
#undef memmem /* See mm/README.txt */
|
||||
FAR void *memmem(FAR const void *haystack, size_t haystacklen,
|
||||
FAR const void *needle, size_t needlelen)
|
||||
{
|
||||
|
|
|
@ -30,10 +30,6 @@
|
|||
* Public Functions
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Name: mempcpy
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Name: mempcpy
|
||||
*
|
||||
|
@ -55,6 +51,7 @@
|
|||
*
|
||||
****************************************************************************/
|
||||
|
||||
#undef mempcpy /* See mm/README.txt */
|
||||
FAR void *mempcpy(FAR void *dest, FAR const void *src, size_t n)
|
||||
{
|
||||
return (FAR char *)memcpy(dest, src, n) + n;
|
||||
|
|
|
@ -44,6 +44,7 @@
|
|||
*
|
||||
****************************************************************************/
|
||||
|
||||
#undef memrchr /* See mm/README.txt */
|
||||
FAR void *memrchr(FAR const void *s, int c, size_t n)
|
||||
{
|
||||
FAR const unsigned char *p = (FAR const unsigned char *)s + n;
|
||||
|
|
|
@ -44,9 +44,9 @@
|
|||
*
|
||||
****************************************************************************/
|
||||
|
||||
void lib_skipspace(const char **pptr)
|
||||
void lib_skipspace(FAR const char **pptr)
|
||||
{
|
||||
const char *ptr = *pptr;
|
||||
FAR const char *ptr = *pptr;
|
||||
while (isspace(*ptr)) ptr++;
|
||||
*pptr = ptr;
|
||||
}
|
||||
|
|
|
@ -44,6 +44,7 @@
|
|||
****************************************************************************/
|
||||
|
||||
#ifndef CONFIG_ARCH_STPCPY
|
||||
#undef stpcpy /* See mm/README.txt */
|
||||
FAR char *stpcpy(FAR char *dest, FAR const char *src)
|
||||
{
|
||||
while ((*dest++ = *src++) != '\0');
|
||||
|
|
|
@ -54,6 +54,7 @@
|
|||
****************************************************************************/
|
||||
|
||||
#ifndef CONFIG_LIBC_ARCH_STPNCPY
|
||||
#undef stpncpy /* See mm/README.txt */
|
||||
FAR char *stpncpy(FAR char *dest, FAR const char *src, size_t n)
|
||||
{
|
||||
FAR char *end = dest + n; /* End of dest buffer + 1 byte */
|
||||
|
|
|
@ -32,11 +32,12 @@
|
|||
* Private Functions
|
||||
****************************************************************************/
|
||||
|
||||
#undef strcasechr /* See mm/README.txt */
|
||||
static FAR char *strcasechr(FAR const char *s, int uc)
|
||||
{
|
||||
register char ch;
|
||||
|
||||
for (; *s; s++)
|
||||
for (; *s != '\0'; s++)
|
||||
{
|
||||
ch = *s;
|
||||
if (toupper(ch) == uc)
|
||||
|
|
|
@ -57,7 +57,7 @@ FAR char *strchr(FAR const char *s, int c)
|
|||
return (FAR char *)s;
|
||||
}
|
||||
|
||||
if (*s == 0)
|
||||
if (*s == '\0')
|
||||
{
|
||||
break;
|
||||
}
|
||||
|
|
|
@ -47,11 +47,12 @@
|
|||
****************************************************************************/
|
||||
|
||||
#if !defined(CONFIG_LIBC_ARCH_STRCHRNUL) && defined(LIBC_BUILD_STRING)
|
||||
#undef strchrnul /* See mm/README.txt */
|
||||
FAR char *strchrnul(FAR const char *s, int c)
|
||||
{
|
||||
if (s)
|
||||
{
|
||||
while (*s && *s != c)
|
||||
while (*s != '\0' && *s != c)
|
||||
{
|
||||
s++;
|
||||
}
|
||||
|
|
|
@ -48,7 +48,7 @@
|
|||
#undef strcpy /* See mm/README.txt */
|
||||
FAR char *strcpy(FAR char *dest, FAR const char *src)
|
||||
{
|
||||
char *tmp = dest;
|
||||
FAR char *tmp = dest;
|
||||
while ((*dest++ = *src++) != '\0');
|
||||
return tmp;
|
||||
}
|
||||
|
|
|
@ -47,6 +47,7 @@
|
|||
****************************************************************************/
|
||||
|
||||
#if !defined(CONFIG_LIBC_ARCH_STRLCAT) && defined(LIBC_BUILD_STRING)
|
||||
#undef strlcat /* See mm/README.txt */
|
||||
size_t strlcat(FAR char *dst, FAR const char *src, size_t dsize)
|
||||
{
|
||||
FAR const char *odst = dst;
|
||||
|
|
|
@ -46,6 +46,7 @@
|
|||
****************************************************************************/
|
||||
|
||||
#if !defined(CONFIG_LIBC_ARCH_STRLCPY) && defined(LIBC_BUILD_STRING)
|
||||
#undef strlcpy /* See mm/README.txt */
|
||||
size_t strlcpy(FAR char *dst, FAR const char *src, size_t dsize)
|
||||
{
|
||||
FAR const char *osrc = src;
|
||||
|
@ -69,9 +70,9 @@ size_t strlcpy(FAR char *dst, FAR const char *src, size_t dsize)
|
|||
*dst = '\0';
|
||||
}
|
||||
|
||||
while (*src++);
|
||||
while (*src++ != '\0');
|
||||
}
|
||||
|
||||
return (src - osrc - 1);
|
||||
return src - osrc - 1;
|
||||
}
|
||||
#endif
|
||||
|
|
|
@ -34,9 +34,9 @@
|
|||
|
||||
#if !defined(CONFIG_LIBC_ARCH_STRLEN) && defined(LIBC_BUILD_STRING)
|
||||
#undef strlen /* See mm/README.txt */
|
||||
size_t strlen(const char *s)
|
||||
size_t strlen(FAR const char *s)
|
||||
{
|
||||
const char *sc;
|
||||
FAR const char *sc;
|
||||
for (sc = s; *sc != '\0'; ++sc);
|
||||
return sc - s;
|
||||
}
|
||||
|
|
|
@ -38,7 +38,7 @@ FAR char *strncat(FAR char *dest, FAR const char *src, size_t n)
|
|||
{
|
||||
FAR char *ret = dest;
|
||||
|
||||
dest += strlen(dest);
|
||||
dest += strlen(dest);
|
||||
for (; n > 0 && *src != '\0' ; n--)
|
||||
{
|
||||
*dest++ = *src++;
|
||||
|
|
|
@ -33,9 +33,10 @@
|
|||
****************************************************************************/
|
||||
|
||||
#if !defined(CONFIG_LIBC_ARCH_STRNLEN) && defined(LIBC_BUILD_STRING)
|
||||
size_t strnlen(const char *s, size_t maxlen)
|
||||
#undef strnlen /* See mm/README.txt */
|
||||
size_t strnlen(FAR const char *s, size_t maxlen)
|
||||
{
|
||||
const char *sc;
|
||||
FAR const char *sc;
|
||||
for (sc = s; maxlen != 0 && *sc != '\0'; maxlen--, ++sc);
|
||||
return sc - s;
|
||||
}
|
||||
|
|
|
@ -46,6 +46,7 @@
|
|||
*
|
||||
****************************************************************************/
|
||||
|
||||
#undef strsep /* See mm/README.txt */
|
||||
FAR char *strsep(FAR char **strp, FAR const char *delim)
|
||||
{
|
||||
FAR char *sbegin = *strp;
|
||||
|
|
|
@ -51,6 +51,7 @@
|
|||
* string haystack. Returns NULL if needle was not found.
|
||||
*/
|
||||
|
||||
#undef strstr /* See mm/README.txt */
|
||||
FAR char *strstr(FAR const char *haystack, FAR const char *needle)
|
||||
{
|
||||
FAR const unsigned char *needle_cmp_end;
|
||||
|
|
|
@ -28,7 +28,7 @@
|
|||
* Private Data
|
||||
****************************************************************************/
|
||||
|
||||
static char *g_saveptr = NULL;
|
||||
static FAR char *g_saveptr = NULL;
|
||||
|
||||
/****************************************************************************
|
||||
* Public Functions
|
||||
|
@ -67,7 +67,7 @@ static char *g_saveptr = NULL;
|
|||
****************************************************************************/
|
||||
|
||||
#undef strtok /* See mm/README.txt */
|
||||
char *strtok(char *str, const char *delim)
|
||||
FAR char *strtok(FAR char *str, FAR const char *delim)
|
||||
{
|
||||
return strtok_r(str, delim, &g_saveptr);
|
||||
}
|
||||
|
|
|
@ -75,6 +75,7 @@
|
|||
*
|
||||
****************************************************************************/
|
||||
|
||||
#undef strtok_r /* See mm/README.txt */
|
||||
FAR char *strtok_r(FAR char *str, FAR const char *delim, FAR char **saveptr)
|
||||
{
|
||||
FAR char *pbegin;
|
||||
|
|
|
@ -69,7 +69,7 @@ size_t strxfrm(FAR char *s1, FAR const char *s2, size_t n)
|
|||
return res;
|
||||
}
|
||||
}
|
||||
while (*s2)
|
||||
while (*s2 != '\0')
|
||||
{
|
||||
++s2;
|
||||
++res;
|
||||
|
|
Loading…
Reference in New Issue