diff options
Diffstat (limited to '')
| -rw-r--r-- | src/string/strcat.c | 1 | ||||
| -rw-r--r-- | src/string/strchr.c | 19 | ||||
| -rw-r--r-- | src/string/strcmp.c | 1 | ||||
| -rw-r--r-- | src/string/strcpy.c | 3 | ||||
| -rw-r--r-- | src/string/strdup.c | 1 | ||||
| -rw-r--r-- | src/string/strerror.c | 2 | ||||
| -rw-r--r-- | src/string/strfry.c | 5 | ||||
| -rw-r--r-- | src/string/strlen.c | 1 | ||||
| -rw-r--r-- | src/string/strmove.c | 3 | ||||
| -rw-r--r-- | src/string/strspn.c | 8 | ||||
| -rw-r--r-- | src/string/strstr.c | 1 | ||||
| -rw-r--r-- | src/string/strtok.c | 3 |
12 files changed, 25 insertions, 23 deletions
diff --git a/src/string/strcat.c b/src/string/strcat.c index ed10cc2..2205f39 100644 --- a/src/string/strcat.c +++ b/src/string/strcat.c @@ -16,7 +16,6 @@ * along with this program. If not, see <http://www.gnu.org/licenses/>. */ #include <string.h> -#include <stddef.h> diff --git a/src/string/strchr.c b/src/string/strchr.c index 21345d4..2b49c2e 100644 --- a/src/string/strchr.c +++ b/src/string/strchr.c @@ -16,7 +16,9 @@ * along with this program. If not, see <http://www.gnu.org/licenses/>. */ #include <string.h> -#include <stddef.h> + + +# pragma GCC diagnostic ignored "-Wdiscarded-qualifiers" @@ -31,9 +33,10 @@ */ void* memchr(const void* segment, int c, size_t size) { + char* s = segment; while (size--) - if (*segment++ == c) - return segment - 1; + if (*s++ == c) + return s - 1; return NULL; } @@ -50,9 +53,10 @@ void* memchr(const void* segment, int c, size_t size) */ void* rawmemchr(const void* segment, int c) { + char* s = segment; for (;;) - if (*segment++ == c) - return segment - 1; + if (*s++ == c) + return s - 1; } @@ -71,9 +75,10 @@ void* rawmemchr(const void* segment, int c) */ void* memrchr(const void* segment, int c, size_t size) { + char* s = segment; while (size--) - if (segment[size] == c) - return segment + size; + if (s[size] == c) + return s + size; return NULL; } diff --git a/src/string/strcmp.c b/src/string/strcmp.c index 966bb06..f626f91 100644 --- a/src/string/strcmp.c +++ b/src/string/strcmp.c @@ -17,7 +17,6 @@ */ #include <string.h> #include <strings.h> -#include <stddef.h> #include <inttypes.h> #include <ctype.h> diff --git a/src/string/strcpy.c b/src/string/strcpy.c index dfbdc75..17dd339 100644 --- a/src/string/strcpy.c +++ b/src/string/strcpy.c @@ -16,7 +16,6 @@ * along with this program. If not, see <http://www.gnu.org/licenses/>. */ #include <string.h> -#include <stddef.h> @@ -93,7 +92,7 @@ char* strstrcpy(char* restrict whither, const char* restrict whence, const char* { const char* stop = str == NULL ? NULL : strstr(whence, str); size_t n = stop == NULL ? strlen(whence) : (size_t)(stop - whence); - char* r = stop == NULL ? NULL ? whither + n; + char* r = stop == NULL ? NULL : (whither + n); memcpy(whither, whence, n); whither[n] = 0; return r; diff --git a/src/string/strdup.c b/src/string/strdup.c index c65970e..c23548b 100644 --- a/src/string/strdup.c +++ b/src/string/strdup.c @@ -16,7 +16,6 @@ * along with this program. If not, see <http://www.gnu.org/licenses/>. */ #include <string.h> -#include <stddef.h> diff --git a/src/string/strerror.c b/src/string/strerror.c index 7366f63..87f3261 100644 --- a/src/string/strerror.c +++ b/src/string/strerror.c @@ -16,7 +16,7 @@ * along with this program. If not, see <http://www.gnu.org/licenses/>. */ #include <string.h> -#include <stddef.h> +#include <errno.h> diff --git a/src/string/strfry.c b/src/string/strfry.c index f020202..cf8d643 100644 --- a/src/string/strfry.c +++ b/src/string/strfry.c @@ -34,13 +34,16 @@ char* strfry(char* anagram) { size_t i, j; + int r; char t; if (anagram == NULL) return NULL; for (i = strlen(anagram); --i;) { - j = (int)((double)rand() / (RAND_MAX + 1)); + r = rand(); + j = (int)((double)r / (RAND_MAX + 1)); t = anagram[i], anagram[i] = anagram[j], anagram[j] = t; } + return anagram; } diff --git a/src/string/strlen.c b/src/string/strlen.c index 7023cc0..7a08fa0 100644 --- a/src/string/strlen.c +++ b/src/string/strlen.c @@ -16,7 +16,6 @@ * along with this program. If not, see <http://www.gnu.org/licenses/>. */ #include <string.h> -#include <stddef.h> diff --git a/src/string/strmove.c b/src/string/strmove.c index 86298cf..596822a 100644 --- a/src/string/strmove.c +++ b/src/string/strmove.c @@ -16,7 +16,6 @@ * along with this program. If not, see <http://www.gnu.org/licenses/>. */ #include <string.h> -#include <stddef.h> @@ -97,7 +96,7 @@ char* strstrmove(char* whither, const char* whence, const char* restrict str) { const char* stop = str == NULL ? NULL : strstr(whence, str); size_t n = stop == NULL ? strlen(whence) : (size_t)(stop - whence); - char* r = stop == NULL ? NULL ? whither + n; + char* r = stop == NULL ? NULL : (whither + n); memmove(whither, whence, n); whither[n] = 0; return r; diff --git a/src/string/strspn.c b/src/string/strspn.c index cf82529..3facfd8 100644 --- a/src/string/strspn.c +++ b/src/string/strspn.c @@ -16,7 +16,9 @@ * along with this program. If not, see <http://www.gnu.org/licenses/>. */ #include <string.h> -#include <stddef.h> + + +# pragma GCC diagnostic ignored "-Wdiscarded-qualifiers" @@ -59,7 +61,7 @@ size_t strcspn(const char* string, const char* stopset) char c; const char* s = string; memset(set, 0, 256); - while ((c = *skipset++)) + while ((c = *stopset++)) set[(size_t)c] = 1; while ((c = *s++)) if (!set[(size_t)c]) @@ -86,7 +88,7 @@ char* stpbrk(const char* string, const char* stopset) char c; const char* s = string; memset(set, 0, 256); - while ((c = *skipset++)) + while ((c = *stopset++)) set[(size_t)c] = 1; while ((c = *s++)) if (!set[(size_t)c]) diff --git a/src/string/strstr.c b/src/string/strstr.c index a7e490a..68cc647 100644 --- a/src/string/strstr.c +++ b/src/string/strstr.c @@ -16,7 +16,6 @@ * along with this program. If not, see <http://www.gnu.org/licenses/>. */ #include <string.h> -#include <stddef.h> #include <inttypes.h> diff --git a/src/string/strtok.c b/src/string/strtok.c index 04668fc..1520431 100644 --- a/src/string/strtok.c +++ b/src/string/strtok.c @@ -16,7 +16,6 @@ * along with this program. If not, see <http://www.gnu.org/licenses/>. */ #include <string.h> -#include <stddef.h> @@ -102,7 +101,7 @@ char* strsep(char** restrict string, const char* restrict delimiters) if (r == NULL) return NULL; - next = stpbrk(string, delimiters); + next = stpbrk(r, delimiters); if (next != NULL) *next++ = 0; *string = next; |
