Skip to content

Commit dba9576

Browse files
committed
Increase coverage and CI fixes
1 parent 9faa0c2 commit dba9576

3 files changed

Lines changed: 30 additions & 19 deletions

File tree

c89stringutils/c89stringutils_string_extras.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@
2020
#include <errno.h>
2121
#include <ctype.h>
2222
#include <limits.h> /* for INT_MAX */
23-
/* clang-format on */
2423
#ifndef RSIZE_MAX
2524
#define RSIZE_MAX ((size_t) - 1 >> 1)
2625
#endif
@@ -255,6 +254,7 @@ C89STRINGUTILS_EXPORT void c89stringutils_log_debug(const char *fmt, ...) {
255254
disable : 4244 4702) /* conversion from int to char, unreachable code */
256255
#endif
257256
#include "stb_sprintf.h"
257+
/* clang-format on */
258258
#if defined(_MSC_VER) && _MSC_VER >= 1300
259259
#pragma warning(pop)
260260
#endif

c89stringutils/c89stringutils_string_extras.h

Lines changed: 22 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -496,16 +496,16 @@ c89stringutils_vsnprintf(char *s, size_t n, const char *format, va_list arg)
496496
*/
497497
#if defined(C89STRINGUTILS_HAVE__STRNICMP)
498498
#define c89stringutils_strncasecmp(s1, s2, n) \
499-
(((s1) == NULL && (s2) == NULL) ? 0 \
500-
: ((s1) == NULL) ? -1 \
501-
: ((s2) == NULL) ? 1 \
502-
: _strnicmp((s1), (s2), (n)))
499+
((((const void *)(s1)) == NULL && ((const void *)(s2)) == NULL) ? 0 \
500+
: (((const void *)(s1)) == NULL) ? -1 \
501+
: (((const void *)(s2)) == NULL) ? 1 \
502+
: _strnicmp((s1), (s2), (n)))
503503
#elif defined(C89STRINGUTILS_HAVE_STRNCASECMP)
504504
#define c89stringutils_strncasecmp(s1, s2, n) \
505-
(((s1) == NULL && (s2) == NULL) ? 0 \
506-
: ((s1) == NULL) ? -1 \
507-
: ((s2) == NULL) ? 1 \
508-
: strncasecmp((s1), (s2), (n)))
505+
((((const void *)(s1)) == NULL && ((const void *)(s2)) == NULL) ? 0 \
506+
: (((const void *)(s1)) == NULL) ? -1 \
507+
: (((const void *)(s2)) == NULL) ? 1 \
508+
: strncasecmp((s1), (s2), (n)))
509509
#else
510510
extern C89STRINGUTILS_EXPORT int
511511
c89stringutils_strncasecmp(const char *s1, const char *s2, size_t n);
@@ -520,16 +520,16 @@ c89stringutils_strncasecmp(const char *s1, const char *s2, size_t n);
520520
*/
521521
#if defined(C89STRINGUTILS_HAVE__STRICMP)
522522
#define c89stringutils_strcasecmp(s1, s2) \
523-
(((s1) == NULL && (s2) == NULL) ? 0 \
524-
: ((s1) == NULL) ? -1 \
525-
: ((s2) == NULL) ? 1 \
526-
: _stricmp((s1), (s2)))
523+
((((const void *)(s1)) == NULL && ((const void *)(s2)) == NULL) ? 0 \
524+
: (((const void *)(s1)) == NULL) ? -1 \
525+
: (((const void *)(s2)) == NULL) ? 1 \
526+
: _stricmp((s1), (s2)))
527527
#elif defined(C89STRINGUTILS_HAVE_STRCASECMP)
528528
#define c89stringutils_strcasecmp(s1, s2) \
529-
(((s1) == NULL && (s2) == NULL) ? 0 \
530-
: ((s1) == NULL) ? -1 \
531-
: ((s2) == NULL) ? 1 \
532-
: strcasecmp((s1), (s2)))
529+
((((const void *)(s1)) == NULL && ((const void *)(s2)) == NULL) ? 0 \
530+
: (((const void *)(s1)) == NULL) ? -1 \
531+
: (((const void *)(s2)) == NULL) ? 1 \
532+
: strcasecmp((s1), (s2)))
533533
#else
534534
extern C89STRINGUTILS_EXPORT int c89stringutils_strcasecmp(const char *s1,
535535
const char *s2);
@@ -546,7 +546,9 @@ extern C89STRINGUTILS_EXPORT int c89stringutils_strcasecmp(const char *s1,
546546
*/
547547
#if defined(C89STRINGUTILS_HAVE_STRNSTR)
548548
#define c89stringutils_strnstr(b, t, l) \
549-
(((b) == NULL || (t) == NULL) ? NULL : strnstr((b), (t), (l)))
549+
((((const void *)(b)) == NULL || ((const void *)(t)) == NULL) \
550+
? NULL \
551+
: strnstr((b), (t), (l)))
550552
#else
551553
extern C89STRINGUTILS_EXPORT char *c89stringutils_strnstr(const char *buffer,
552554
const char *target,
@@ -562,7 +564,9 @@ extern C89STRINGUTILS_EXPORT char *c89stringutils_strnstr(const char *buffer,
562564
*/
563565
#if defined(C89STRINGUTILS_HAVE_STRCASESTR)
564566
#define c89stringutils_strcasestr(h, n) \
565-
(((h) == NULL || (n) == NULL) ? NULL : strcasestr((h), (n)))
567+
((((const void *)(h)) == NULL || ((const void *)(n)) == NULL) \
568+
? NULL \
569+
: strcasestr((h), (n)))
566570
#else
567571
extern C89STRINGUTILS_EXPORT char *c89stringutils_strcasestr(const char *h,
568572
const char *n);

c89stringutils/stb_sprintf.h

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
#ifdef __cplusplus
2+
extern "C" {
3+
#endif /* __cplusplus */
14
/* clang-format off */
25
#if defined(__GNUC__) || defined(__clang__)
36
#pragma GCC diagnostic push
@@ -1920,3 +1923,7 @@ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
19201923
#pragma GCC diagnostic pop
19211924
#endif
19221925
/* clang-format on */
1926+
1927+
#ifdef __cplusplus
1928+
}
1929+
#endif /* __cplusplus */

0 commit comments

Comments
 (0)