Skip to content

Commit 642f486

Browse files
committed
[libacquire/acquire_string_extras.h] Bring in latest changed from c89stringutils; [README.md] =; [tests/test_libacquire/config_for_tests.h.in] Closing comment
1 parent ca32871 commit 642f486

File tree

3 files changed

+26
-22
lines changed

3 files changed

+26
-22
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
libacquire
2-
=======
2+
==========
33
[![License](https://img.shields.io/badge/license-Apache--2.0%20OR%20MIT-blue.svg)](https://opensource.org/licenses/Apache-2.0)
44
[![CI for Linux, Windows, macOS](https://github.com/offscale/libacquire/workflows/CI%20for%20Linux,%20Windows,%20macOS/badge.svg)](https://github.com/offscale/libacquire/actions)
55
[![CI for FreeBSD](https://api.cirrus-ci.com/github/offscale/libacquire.svg)](https://cirrus-ci.com/github/offscale/libacquire)

libacquire/acquire_string_extras.h

Lines changed: 24 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,21 @@
66
#ifndef LIBACQUIRE_ACQUIRE_STRING_EXTRAS_H
77
#define LIBACQUIRE_ACQUIRE_STRING_EXTRAS_H
88

9+
#include <string.h>
10+
11+
#if defined(__FreeBSD__) || defined(__NetBSD__) || defined(__OpenBSD__) || \
12+
defined(__bsdi__) || defined(__DragonFly__) || defined(BSD)
13+
# define ANY_BSD
14+
#endif
15+
916
#if defined(WIN32) || defined(_WIN32) || defined(__WIN32__) || defined(__NT__)
1017

1118
# if defined(_MSC_VER) && !defined(__INTEL_COMPILER)
1219

20+
/* snprintf is implemented in VS 2015 */
1321
# if _MSC_VER >= 1900
1422

15-
/* snprintf is implemented in VS 2015 */
23+
1624
# define HAVE_SNPRINTF_H
1725

1826
# endif /* _MSC_VER >= 1900 */
@@ -27,23 +35,19 @@
2735

2836
# include <sys/param.h>
2937

30-
# if _BSD_SOURCE || _XOPEN_SOURCE >= 500 || _ISOC99_SOURCE || _POSIX_C_SOURCE >= 200112L || \
31-
defined(__FreeBSD__) || defined(__NetBSD__) || defined(__OpenBSD__) || defined(__bsdi__) || \
32-
defined(__DragonFly__) || defined(BSD)
38+
# if _BSD_SOURCE || _XOPEN_SOURCE >= 500 || _ISOC99_SOURCE || _POSIX_C_SOURCE >= 200112L || defined(ANY_BSD)
3339
# define HAVE_SNPRINTF_H
3440
# define HAVE_STRCASESTR_H
35-
# endif /* _BSD_SOURCE || _XOPEN_SOURCE >= 500 || _ISOC99_SOURCE || _POSIX_C_SOURCE >= 200112L */
41+
# endif /* _BSD_SOURCE || _XOPEN_SOURCE >= 500 || _ISOC99_SOURCE || _POSIX_C_SOURCE >= 200112L || defined(ANY_BSD) */
3642

3743
# if defined(__APPLE__) && defined(__MACH__)
3844
# define HAVE_SNPRINTF_H
3945
# define HAVE_STRNCASECMP_H
4046
# endif /* defined(__APPLE__) && defined(__MACH__) */
4147

42-
# if (defined(_POSIX_VERSION) && (_POSIX_VERSION >= 200112L) || defined(BSD) && (BSD >= 199306)) && \
43-
(!defined(__linux__) && !defined(linux) && !defined(__linux))
44-
# define HAVE_STRNSTR_H
45-
# endif /* (defined(_POSIX_VERSION) && (_POSIX_VERSION >= 200112L) || defined(BSD) && (BSD >= 199306)) && \
46-
(!defined(__linux__) && !defined(linux) && !defined(__linux)) */
48+
# if defined(BSD) && (BSD >= 199306) && !defined(__linux__) && !defined(linux) && !defined(__linux)
49+
# define HAVE_STRNSTR
50+
# endif /* defined(BSD) && (BSD >= 199306) && !defined(__linux__) && !defined(linux) && !defined(__linux) */
4751

4852
#endif /* defined(WIN32) || defined(_WIN32) || defined(__WIN32__) || defined(__NT__) */
4953

@@ -66,6 +70,10 @@
6670
# define HAVE_STRNCASECMP_H
6771
#endif
6872

73+
#if defined(ANY_BSD) || defined(__APPLE__) && defined(__MACH__) || defined(_GNU_SOURCE) || defined(_BSD_SOURCE)
74+
# define HAVE_ASPRINTF
75+
#endif /* defined(ANY_BSD) || defined(__APPLE__) && defined(__MACH__) || defined(_GNU_SOURCE) || defined(_BSD_SOURCE) */
76+
6977
#include <stdarg.h>
7078
#include <stdio.h>
7179
#include <string.h>
@@ -77,7 +85,7 @@
7785
#if !defined(HAVE_SNPRINTF_H) && defined(LIBACQUIRE_IMPLEMENTATION)
7886

7987
/*
80-
* `snprintf`, `strncasecmp`, `vsnprintf`, `strnstr` taken from:
88+
* `snprintf`, `vsnprintf`, `strnstr` taken from:
8189
* https://chromium.googlesource.com/chromium/blink/+/5cedd2fd208daf119b9ea47c7c1e22d760a586eb/Source/wtf/StringExtras.h
8290
* …then modified to remove C++ specifics and WebKit specific macros
8391
*
@@ -126,19 +134,15 @@ extern int strcasecmp(const char *, const char *);
126134

127135
#ifdef LIBACQUIRE_IMPLEMENTATION
128136

129-
int strncasecmp(const char *s1, const char *s2, size_t len) {
130-
return _strnicmp(s1, s2, len);
131-
}
137+
#define strncasecmp _strnicmp
132138

133-
int strcasecmp(const char *s1, const char *s2) {
134-
return _stricmp(s1, s2);
135-
}
139+
#define strcasecmp _stricmp
136140

137141
#endif /* LIBACQUIRE_IMPLEMENTATION */
138142

139143
#endif /* !HAVE_STRNCASECMP_H */
140144

141-
#ifndef HAVE_STRNSTR_H
145+
#ifndef HAVE_STRNSTR
142146

143147
extern char *strnstr(const char *, const char *, size_t);
144148

@@ -172,7 +176,7 @@ char *strnstr(const char *buffer, const char *target, size_t bufferLength) {
172176
}
173177
#endif /* LIBACQUIRE_IMPLEMENTATION */
174178

175-
#endif /* ! HAVE_STRNSTR_H */
179+
#endif /* ! HAVE_STRNSTR */
176180

177181
#ifndef HAVE_STRCASESTR_H
178182
extern char *strcasestr(const char *, const char *);
@@ -242,6 +246,6 @@ size_t strerrorlen_s(errno_t errnum)
242246
}
243247
}
244248

245-
#endif /* HAVE_STRERRORLEN_S */
249+
#endif /* !HAVE_STRERRORLEN_S */
246250

247251
#endif /* ! LIBACQUIRE_ACQUIRE_STRING_EXTRAS_H */

libacquire/tests/test_libacquire/config_for_tests.h.in

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,4 +27,4 @@
2727

2828
#define _@TARGET_ARCH@_
2929

30-
#endif
30+
#endif /* ! LIBACQUIRE_CONFIG_FOR_TESTS_H */

0 commit comments

Comments
 (0)