diff --git a/.cirrus.yml b/.cirrus.yml index c3799ca..79c600f 100644 --- a/.cirrus.yml +++ b/.cirrus.yml @@ -1,5 +1,5 @@ freebsd_instance: - image_family: freebsd-13-0 + image_family: freebsd-14 task: install_script: pkg install -y cmake diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index d33f9ec..84e398a 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -45,7 +45,7 @@ jobs: EOF - name: Compile Test Amalgamation - run: gcc -Wall -Wextra -Werror -o test_amalg test_amalg.c + run: gcc -std=c89 -Wpedantic -Wall -Wextra -Werror -o test_amalg test_amalg.c - name: Run Test Amalgamation run: ./test_amalg diff --git a/c89stringutils/c89stringutils_string_extras.c b/c89stringutils/c89stringutils_string_extras.c index b24edda..1a5209e 100644 --- a/c89stringutils/c89stringutils_string_extras.c +++ b/c89stringutils/c89stringutils_string_extras.c @@ -103,8 +103,11 @@ char *strnstr(const char *buffer, const char *target, size_t bufferLength) { character of the first occurrence of little is returned. [this doc (c) FreeBSD <3 clause BSD license> from their manpage] */ - const size_t targetLength = strlen(target); + size_t targetLength; const char *start; + + /* Fix assignment of targetLength. C89 requires variables to be defined at beginning of a scope */ + targetLength = strlen(target); if (targetLength == 0) return (char *)buffer; for (start = buffer; *start && start + targetLength <= buffer + bufferLength; @@ -125,7 +128,8 @@ char *strnstr(const char *buffer, const char *target, size_t bufferLength) { /* `strcasestr` from MUSL */ char *strcasestr(const char *h, const char *n) { - const size_t l = strlen(n); + size_t l; + l = strlen(n); for (; *h; h++) if (!strncasecmp(h, n, l)) return (char *)h; @@ -192,7 +196,7 @@ size_t strerrorlen_s(errno_t errnum) { #ifdef HAVE___VA_COPY #define VA_COPY(dest, src) __va_copy(dest, src) #else -#define VA_COPY(dest, src) (dest) = (src) +#define VA_COPY(dest, src) memcpy(&(dest), &(src), sizeof(va_list)) #endif #endif #endif /* ! VA_COPY */ diff --git a/c89stringutils/c89stringutils_string_extras.h b/c89stringutils/c89stringutils_string_extras.h index d4b4e15..389dfc0 100644 --- a/c89stringutils/c89stringutils_string_extras.h +++ b/c89stringutils/c89stringutils_string_extras.h @@ -19,7 +19,8 @@ extern "C" { #if defined(_MSC_VER) #define NUM_FORMAT "%I64d" #else -#define NUM_FORMAT "%lld" +/* Fix:- Change from C99 long long to long */ +#define NUM_FORMAT "%ld" #endif #if defined(__FreeBSD__) || defined(__NetBSD__) || defined(__OpenBSD__) || \