improve readability of string: fix indentation and remove trailing spaces

Signed-off-by: André Goddard Rosa <andre.goddard@gmail.com>
This commit is contained in:
André Goddard Rosa
2010-01-30 22:28:49 -02:00
parent 8f92500fa9
commit 30a419afc3
13 changed files with 17 additions and 18 deletions

View File

@@ -98,8 +98,8 @@ strncasecmp(const char *s1, const char *s2, size_t n)
if (cm[*us1] != cm[*us2++]) if (cm[*us1] != cm[*us2++])
return (cm[*us1] - cm[*--us2]); return (cm[*us1] - cm[*--us2]);
if (*us1++ == '\0') if (*us1++ == '\0')
break; break;
} while (--n != 0); } while (--n != 0);
} }
return (0); return (0);
} }

View File

@@ -38,6 +38,6 @@ strchr(const char *p, int ch)
return((char *)p); return((char *)p);
if (!*p) if (!*p)
return((char *)NULL); return((char *)NULL);
} }
/* NOTREACHED */ /* NOTREACHED */
} }

View File

@@ -36,5 +36,5 @@
int int
strcoll(const char *s1, const char *s2) strcoll(const char *s1, const char *s2)
{ {
return strcmp (s1, s2); return strcmp(s1, s2);
} }

View File

@@ -46,9 +46,9 @@ strlcat(char *dst, const char *src, size_t siz)
if (n != 1) { if (n != 1) {
*d++ = *s; *d++ = *s;
n--; n--;
} }
s++; s++;
} }
*d = '\0'; *d = '\0';
return(dlen + (s - src)); /* count does not include NUL */ return(dlen + (s - src)); /* count does not include NUL */

View File

@@ -37,7 +37,7 @@ strlcpy(char *dst, const char *src, size_t siz)
if ((*d++ = *s++) == '\0') if ((*d++ = *s++) == '\0')
break; break;
} }
} }
/* Not enough room in dst, add NUL and traverse rest of src */ /* Not enough room in dst, add NUL and traverse rest of src */
if (n == 0) { if (n == 0) {

View File

@@ -52,6 +52,6 @@ strncat(char *dst, const char *src, size_t n)
d++; d++;
} while (--n != 0); } while (--n != 0);
*d = 0; *d = 0;
} }
return (dst); return (dst);
} }

View File

@@ -38,14 +38,13 @@
int int
strncmp(const char *s1, const char *s2, size_t n) strncmp(const char *s1, const char *s2, size_t n)
{ {
if (n == 0) if (n == 0)
return (0); return (0);
do { do {
if (*s1 != *s2++) if (*s1 != *s2++)
return (*(unsigned char *)s1 - *(unsigned char *)--s2); return (*(unsigned char *)s1 - *(unsigned char *)--s2);
if (*s1++ == 0) if (*s1++ == 0)
break; break;
} while (--n != 0); } while (--n != 0);
return (0); return (0);
} }

View File

@@ -54,8 +54,8 @@ strncpy(char *dst, const char *src, size_t n)
/* NUL pad the remaining n-1 bytes */ /* NUL pad the remaining n-1 bytes */
while (--n != 0) while (--n != 0)
*d++ = 0; *d++ = 0;
break; break;
} }
} while (--n != 0); } while (--n != 0);
} }
return (dst); return (dst);

View File

@@ -40,6 +40,6 @@ strrchr(const char *p, int ch)
save = (char *)p; save = (char *)p;
if (!*p) if (!*p)
return(save); return(save);
} }
/* NOTREACHED */ /* NOTREACHED */
} }

View File

@@ -51,6 +51,6 @@ strstr(const char *s, const char *find)
} while (sc != c); } while (sc != c);
} while (strncmp(s, find, len) != 0); } while (strncmp(s, find, len) != 0);
s--; s--;
} }
return ((char *)s); return ((char *)s);
} }