diff options
author | Jakob Kaivo <jkk@ung.org> | 2020-08-16 14:00:51 -0400 |
---|---|---|
committer | Jakob Kaivo <jkk@ung.org> | 2020-08-16 14:00:51 -0400 |
commit | 896e28812c51b9ffdf3efc00c7d7ef699e380a58 (patch) | |
tree | aaa25e093fb4a2ac4c57609e1f745e5ac0734ca8 /src/string | |
parent | 0b0d1fe1d4fbf8560577d81e5af0549683eac8ba (diff) |
formatting
Diffstat (limited to 'src/string')
-rw-r--r-- | src/string/NULL.ref | 1 | ||||
-rw-r--r-- | src/string/memchr.c | 2 | ||||
-rw-r--r-- | src/string/memcmp.c | 2 | ||||
-rw-r--r-- | src/string/memcpy.c | 2 | ||||
-rw-r--r-- | src/string/memmove.c | 2 | ||||
-rw-r--r-- | src/string/memset.c | 2 | ||||
-rw-r--r-- | src/string/size_t.ref | 1 | ||||
-rw-r--r-- | src/string/strcat.c | 1 | ||||
-rw-r--r-- | src/string/strchr.c | 2 | ||||
-rw-r--r-- | src/string/strcmp.c | 2 | ||||
-rw-r--r-- | src/string/strcoll.c | 5 | ||||
-rw-r--r-- | src/string/strcpy.c | 2 | ||||
-rw-r--r-- | src/string/strcspn.c | 4 | ||||
-rw-r--r-- | src/string/strerror.c | 7 | ||||
-rw-r--r-- | src/string/strlen.c | 3 | ||||
-rw-r--r-- | src/string/strncat.c | 4 | ||||
-rw-r--r-- | src/string/strncmp.c | 2 | ||||
-rw-r--r-- | src/string/strncpy.c | 4 | ||||
-rw-r--r-- | src/string/strpbrk.c | 6 | ||||
-rw-r--r-- | src/string/strrchr.c | 2 | ||||
-rw-r--r-- | src/string/strspn.c | 4 | ||||
-rw-r--r-- | src/string/strstr.c | 2 | ||||
-rw-r--r-- | src/string/strtok.c | 2 | ||||
-rw-r--r-- | src/string/strxfrm.c | 5 |
24 files changed, 52 insertions, 17 deletions
diff --git a/src/string/NULL.ref b/src/string/NULL.ref index 5d6e9890..b247705b 100644 --- a/src/string/NULL.ref +++ b/src/string/NULL.ref @@ -1,3 +1,2 @@ -#include <string.h> REFERENCE(stddef/NULL.c) STDC(1) diff --git a/src/string/memchr.c b/src/string/memchr.c index 02fdfcdc..f39ef6bc 100644 --- a/src/string/memchr.c +++ b/src/string/memchr.c @@ -2,6 +2,7 @@ #include "_assert.h" /** search memory **/ + void * memchr(const void *s, int c, size_t n) { char *p = (char*)s; @@ -26,6 +27,7 @@ void * memchr(const void *s, int c, size_t n) searches the first ARGUMENT(n) bytes of memory at ARGUMENT(s) for ARGUMENT(c) (converted to an TYPE(unsigned char)). ***/ + /* STDC(1) */ diff --git a/src/string/memcmp.c b/src/string/memcmp.c index 20cb6df5..d5d94bf0 100644 --- a/src/string/memcmp.c +++ b/src/string/memcmp.c @@ -2,6 +2,7 @@ #include "_assert.h" /** compare memory regions **/ + int memcmp(const void *s1, const void *s2, size_t n) { unsigned char *p = (void*)s1; @@ -29,6 +30,7 @@ int memcmp(const void *s1, const void *s2, size_t n) compares the first ARGUMENT(n) bytes of memory at ARGUMENT(s1) and ARGUMENT(s2). ***/ + /* STDC(1) */ diff --git a/src/string/memcpy.c b/src/string/memcpy.c index 835411f3..69975605 100644 --- a/src/string/memcpy.c +++ b/src/string/memcpy.c @@ -2,6 +2,7 @@ #include "_assert.h" /** copy memory **/ + void * memcpy(void * restrict s1, const void * restrict s2, size_t n) { char *dst = (char*)s1; @@ -26,6 +27,7 @@ void * memcpy(void * restrict s1, const void * restrict s2, size_t n) copies ARGUMENT(n) bytes from the object at ARGUMENT(s2) to the object at ARGUMENT(s1). ***/ + /* STDC(1) */ diff --git a/src/string/memmove.c b/src/string/memmove.c index 5d72c862..c9ae1245 100644 --- a/src/string/memmove.c +++ b/src/string/memmove.c @@ -2,6 +2,7 @@ #include "_assert.h" /** move memory **/ + void * memmove(void *s1, const void *s2, size_t n) { ASSERT_NONNULL(s1); @@ -30,6 +31,7 @@ copies ARGUMENT(n) bytes of memory from the object at ARGUMENT(s2) to the object at ARGUMENT(s1). If ARGUMENT(s1) and ARGUMENT(s2) overlap, the memory is copied so that the ARGUMENT(n) bytes are safely written to ARGUMENT(s1). ***/ + /* STDC(1) */ diff --git a/src/string/memset.c b/src/string/memset.c index 9addc413..6991ba4e 100644 --- a/src/string/memset.c +++ b/src/string/memset.c @@ -2,6 +2,7 @@ #include "_assert.h" /** fill memory **/ + void * memset(void *s, int c, size_t n) { unsigned char *p = (unsigned char *)s; @@ -23,6 +24,7 @@ void * memset(void *s, int c, size_t n) fills the first ARGUMENT(n) bytes of memory at ARGUMENT(s) with the value ARGUMENT(c) (converted to an TYPE(unsigned char)). ***/ + /* STDC(1) */ diff --git a/src/string/size_t.ref b/src/string/size_t.ref index 3c087e0b..fc611c25 100644 --- a/src/string/size_t.ref +++ b/src/string/size_t.ref @@ -1,3 +1,2 @@ -#include <string.h> REFERENCE(stddef/size_t.c) STDC(1) diff --git a/src/string/strcat.c b/src/string/strcat.c index 51737787..77a95095 100644 --- a/src/string/strcat.c +++ b/src/string/strcat.c @@ -24,6 +24,7 @@ appends a copy of the string at ARGUMENT(s2) to the end of the string at ARGUMENT(s1). The first byte of ARGUMENT(s2) will overwrite the terminating null character of ARGUMENT(s1). ***/ + /* STDC(1) */ diff --git a/src/string/strchr.c b/src/string/strchr.c index f8a65bab..9aa16001 100644 --- a/src/string/strchr.c +++ b/src/string/strchr.c @@ -2,6 +2,7 @@ #include "_assert.h" /** string search **/ + char * strchr(const char *s, int c) { ASSERT_NONNULL(s); @@ -17,6 +18,7 @@ char * strchr(const char *s, int c) searches the string ARGUMENT(s) for the first occurrence of ARGUMENT(c) (converted to a TYPE(char)). ***/ + /* STDC(1) */ diff --git a/src/string/strcmp.c b/src/string/strcmp.c index 8925d1be..e447eb31 100644 --- a/src/string/strcmp.c +++ b/src/string/strcmp.c @@ -2,6 +2,7 @@ #include "_assert.h" /** compare strings **/ + int strcmp(const char *s1, const char *s2) { ASSERT_NONNULL(s1); @@ -35,6 +36,7 @@ int strcmp(const char *s1, const char *s2) /*** compares the strings at ARGUMENT(s1) and ARGUMENT(s2). ***/ + /* STDC(1) */ diff --git a/src/string/strcoll.c b/src/string/strcoll.c index a6a44e8d..875d990c 100644 --- a/src/string/strcoll.c +++ b/src/string/strcoll.c @@ -1,8 +1,9 @@ +#include <stdlib.h> #include <string.h> -#include "stdlib.h" #include "_assert.h" /** collate strings **/ + int strcoll(const char *s1, const char *s2) { char *x1 = NULL; @@ -38,7 +39,5 @@ compares the collation values of the strings at ARGUMENT(s1) and ARGUMENT(s2). /* LC_COLLATE -*/ -/* STDC(1) */ diff --git a/src/string/strcpy.c b/src/string/strcpy.c index ea8a9a1f..b6e3ed11 100644 --- a/src/string/strcpy.c +++ b/src/string/strcpy.c @@ -2,6 +2,7 @@ #include "_assert.h" /** copy string **/ + char * strcpy(char * restrict s1, const char * restrict s2) { char *p = s1; @@ -24,6 +25,7 @@ char * strcpy(char * restrict s1, const char * restrict s2) copies the string at ARGUMENT(s2) to ARGUMENT(s1), up to and including the terminating CHAR(\0). ***/ + /* STDC(1) */ diff --git a/src/string/strcspn.c b/src/string/strcspn.c index 49f7d92b..58d3f33b 100644 --- a/src/string/strcspn.c +++ b/src/string/strcspn.c @@ -2,6 +2,7 @@ #include "_assert.h" /** count non-matching characters **/ + size_t strcspn(const char *s1, const char *s2) { size_t i = 0; @@ -22,7 +23,8 @@ size_t strcspn(const char *s1, const char *s2) the number of characters that the beginning of the string ARGUMENT(s1) that are not in the string ARGUMENT(s2). ***/ + /* - RETURN_ALWAYS(the number of non-matching characters); +RETURN_ALWAYS(the number of non-matching characters); STDC(1) */ diff --git a/src/string/strerror.c b/src/string/strerror.c index 055a11f7..a2d43f0c 100644 --- a/src/string/strerror.c +++ b/src/string/strerror.c @@ -1,9 +1,11 @@ +#include <errno.h> +#include <stdio.h> #include <string.h> -#include "errno.h" -#include "stdio.h" + # define __LONGEST_STRERR 64 /* FIXME */ /** convert error number to string **/ + char * strerror(int errnum) { static char errstr[__LONGEST_STRERR+1]; @@ -26,6 +28,7 @@ converts the error number ARGUMENT(errnum) to an error message string. The string returned should not be modified, and may be overwritten by subsequent calls. ***/ + /* STDC(1) */ diff --git a/src/string/strlen.c b/src/string/strlen.c index 53e62e98..5425970b 100644 --- a/src/string/strlen.c +++ b/src/string/strlen.c @@ -19,7 +19,8 @@ size_t strlen(const char *s) counts the number of bytes in the string ARGUMENT(s), not including the terminating null character. ***/ + /* - RETURN_ALWAYS(the length of the string); +RETURN_ALWAYS(the length of the string); STDC(1) */ diff --git a/src/string/strncat.c b/src/string/strncat.c index e2a64ad5..cd3c8efc 100644 --- a/src/string/strncat.c +++ b/src/string/strncat.c @@ -2,6 +2,7 @@ #include "_assert.h" /** concatenate bounded string **/ + char * strncat(char * restrict s1, const char * restrict s2, size_t n) { char *append = NULL; @@ -34,7 +35,8 @@ overwrite the terminating null character of ARGUMENT(s1). No characters after th first CHAR(\0) will be copied. The resulting string will always be null terminated. ***/ + /* - RETURN_ALWAYS(ARGUMENT(s1)); +RETURN_ALWAYS(ARGUMENT(s1)); STDC(1) */ diff --git a/src/string/strncmp.c b/src/string/strncmp.c index 340ac6b8..e5d92e3e 100644 --- a/src/string/strncmp.c +++ b/src/string/strncmp.c @@ -2,6 +2,7 @@ #include "_assert.h" /** compare bound strings **/ + int strncmp(const char *s1, const char *s2, size_t n) { ASSERT_NONNULL(s1); @@ -26,6 +27,7 @@ int strncmp(const char *s1, const char *s2, size_t n) compares up to the first ARGUMENT(n) bytes of the strings at ARGUMENT(s1) and ARGUMENT(s2), or until the first CHAR(\0), whichever comes first. ***/ + /* STDC(1) */ diff --git a/src/string/strncpy.c b/src/string/strncpy.c index 0ecd19fc..b714f0cf 100644 --- a/src/string/strncpy.c +++ b/src/string/strncpy.c @@ -2,6 +2,7 @@ #include "_assert.h" /** copy bounded string **/ + char * strncpy(char * restrict s1, const char * restrict s2, size_t n) { size_t i; @@ -28,7 +29,8 @@ ARGUMENT(s1) until ARGUMENT(n) bytes have been written. If no null characters ar in the first ARGUMENT(n) bytes of ARGUMENT(s2), the resulting string will not be null terminated. ***/ + /* - RETURN_ALWAYS(ARGUMENT(s1)); +RETURN_ALWAYS(ARGUMENT(s1)); STDC(1) */ diff --git a/src/string/strpbrk.c b/src/string/strpbrk.c index 096917ff..9ad6a5ff 100644 --- a/src/string/strpbrk.c +++ b/src/string/strpbrk.c @@ -2,6 +2,7 @@ #include "_assert.h" /** count matching characters **/ + char * strpbrk(const char *s1, const char *s2) { size_t i; @@ -21,8 +22,9 @@ char * strpbrk(const char *s1, const char *s2) /*** locates the first occurence in ARGUMENT(s1) of any character in ARGUMENT(s2). ***/ + /* - RETURN_FAILURE(CONSTANT(NULL)); - RETURN_SUCCESS(a pointer to the located character); +RETURN_FAILURE(CONSTANT(NULL)); +RETURN_SUCCESS(a pointer to the located character); STDC(1) */ diff --git a/src/string/strrchr.c b/src/string/strrchr.c index 799fb3dd..8b033596 100644 --- a/src/string/strrchr.c +++ b/src/string/strrchr.c @@ -2,6 +2,7 @@ #include "_assert.h" /** search string from end **/ + char * strrchr(const char *s, int c) { int i = 0; @@ -25,6 +26,7 @@ char * strrchr(const char *s, int c) finds the last occurence of ARGUMENT(c) (converted to TYPE(char)) in the string ARGUMENT(s). ***/ + /* STDC(1) */ diff --git a/src/string/strspn.c b/src/string/strspn.c index 450b541f..098ea8d0 100644 --- a/src/string/strspn.c +++ b/src/string/strspn.c @@ -2,6 +2,7 @@ #include "_assert.h" /** count matching characters **/ + size_t strspn(const char *s1, const char *s2) { size_t i = 0; @@ -22,7 +23,8 @@ size_t strspn(const char *s1, const char *s2) computes the length of the maximum initial segment of the ARGUMENT(s1) made up of characters from ARGUMENT(s2). ***/ + /* - RETURN_ALWAYS(the number of matching characters); +RETURN_ALWAYS(the number of matching characters); STDC(1) */ diff --git a/src/string/strstr.c b/src/string/strstr.c index bdcabc9e..3dd968da 100644 --- a/src/string/strstr.c +++ b/src/string/strstr.c @@ -2,6 +2,7 @@ #include "_assert.h" /** search for substring **/ + char * strstr(const char *s1, const char *s2) { size_t l1 = 0; @@ -38,6 +39,7 @@ finds the first occurrence of the string ARGUMENT(s2) in the string ARGUMENT(s1). Specifying the empty string for ARGUMENT(s2) matches the first character of ARGUMENT(s1). ***/ + /* STDC(1) */ diff --git a/src/string/strtok.c b/src/string/strtok.c index 141d3982..f6c340ef 100644 --- a/src/string/strtok.c +++ b/src/string/strtok.c @@ -2,6 +2,7 @@ #include "_assert.h" /** split string into tokens **/ + char * strtok(char * restrict s1, const char * restrict s2) { static char *current = 0; @@ -31,6 +32,7 @@ The list of token separators in ARGUMENT(s2) may vary from call to call. When tokens are found, the next token separate character is replaced with a CHAR(\0), terminating the token. ***/ + /* STDC(1) */ diff --git a/src/string/strxfrm.c b/src/string/strxfrm.c index eb4a6d15..c107d662 100644 --- a/src/string/strxfrm.c +++ b/src/string/strxfrm.c @@ -2,6 +2,7 @@ #include "_assert.h" /** transform string **/ + size_t strxfrm(char * restrict s1, const char * restrict s2, size_t n) { /* TODO */ @@ -25,8 +26,6 @@ transformed, no further characters are transformed. /* UNDEFINED(ARGUMENT(n) is not ZERO and ARGUMENT(s1) is CONSTANT(NULL)) -*/ -/* - RETURN_ALWAYS(the length of the transformed string, not including the terminating CHAR(\0)); +RETURN_ALWAYS(the length of the transformed string, not including the terminating CHAR(\0)); STDC(1) */ |