Skip to content

Commit 8d11ef4

Browse files
committed
[c89stringutils/c89stringutils_string_extras{.h,.c}] Merge commit from 3 months ago then refactor into shared|static lib (again)
1 parent 3953f21 commit 8d11ef4

File tree

2 files changed

+9
-45
lines changed

2 files changed

+9
-45
lines changed

c89stringutils/c89stringutils_string_extras.c

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,13 @@
33
* are now made available on other platforms (Windows, SunOS, &etc.)
44
* */
55

6-
#include <stdlib.h>
7-
86
#include "c89stringutils_string_extras.h"
97

8+
#include <stdarg.h>
9+
#include <stdio.h>
10+
#include <string.h>
11+
#include <stdlib.h>
12+
1013
#if !defined(HAVE_SNPRINTF_H)
1114
#define HAVE_SNPRINTF_H
1215
/*
@@ -53,7 +56,7 @@ inline double wtf_vsnprintf(char *buffer, size_t count, const char *format,
5356

5457
#ifndef HAVE_STRNCASECMP_H
5558

56-
#if defined(C89STRINGUTILS_IMPLEMENTATION)
59+
#if !defined(HAVE_STRNCASECMP_H)
5760
#define HAVE_STRNCASECMP_H
5861

5962
#define strncasecmp _strnicmp
@@ -279,5 +282,5 @@ char *jasprintf(char **unto, const char *fmt, ...) {
279282

280283
return result;
281284
}
282-
#endif /* !defined(HAVE_JASPRINTF) */
285+
#endif /* !defined(HAVE_JASPRINTF) */
283286
#endif /* !HAVE_JASPRINTF */

c89stringutils/c89stringutils_string_extras.h

Lines changed: 2 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -94,50 +94,12 @@ typedef int errno_t;
9494
#include <strings.h>
9595
#endif /* HAVE_STRINGS_H */
9696

97-
#if !defined(HAVE_SNPRINTF_H) && defined(C89STRINGUTILS_IMPLEMENTATION)
98-
#define HAVE_SNPRINTF_H
99-
/*
100-
* `snprintf`, `vsnprintf`, `strnstr` taken from:
101-
* https://chromium.googlesource.com/chromium/blink/+/5cedd2fd208daf119b9ea47c7c1e22d760a586eb/Source/wtf/StringExtras.h
102-
* …then modified to remove C++ specifics and WebKit specific macros
103-
*
104-
* Copyright (C) 2006, 2010 Apple Inc. All rights reserved.
105-
* Copyright (C) 2020 Offscale.io. All rights reserved.
106-
*
107-
* SPDX-License-Identifier: BSD-2-Clause
108-
*/
109-
110-
C89STRINGUTILS_EXPORT inline int snprintf(char *buffer, size_t count,
111-
const char *format, ...);
112-
113-
C89STRINGUTILS_EXPORT inline double
114-
wtf_vsnprintf(char *buffer, size_t count, const char *format, va_list args);
115-
116-
/* Work around a difference in Microsoft's implementation of vsnprintf, where
117-
vsnprintf does not null terminate the buffer. WebKit can rely on the null
118-
termination. Microsoft's implementation is fixed in VS 2015. */
119-
#define vsnprintf(buffer, count, format, args) \
120-
wtf_vsnprintf(buffer, count, format, args)
121-
122-
#endif /* !defined(HAVE_SNPRINTF_H) && defined(C89STRINGUTILS_IMPLEMENTATION) \
123-
*/
124-
12597
#ifndef HAVE_STRNCASECMP_H
12698

127-
extern C89STRINGUTILS_EXPORT int strncasecmp(const char *, const char *,
128-
size_t);
99+
extern C89STRINGUTILS_EXPORT int strncasecmp(const char *, const char *, size_t);
129100

130101
extern C89STRINGUTILS_EXPORT int strcasecmp(const char *, const char *);
131102

132-
#if defined(C89STRINGUTILS_IMPLEMENTATION) && !defined(HAVE_STRNCASECMP_H)
133-
#define HAVE_STRNCASECMP_H
134-
135-
#define strncasecmp _strnicmp
136-
#define strcasecmp _stricmp
137-
138-
#endif /* defined(C89STRINGUTILS_IMPLEMENTATION) && \
139-
!defined(HAVE_STRNCASECMP_H) */
140-
141103
#endif /* !HAVE_STRNCASECMP_H */
142104

143105
#ifndef HAVE_STRNSTR
@@ -159,8 +121,7 @@ extern C89STRINGUTILS_EXPORT size_t strerrorlen_s(errno_t);
159121

160122
#ifndef HAVE_ASPRINTF
161123

162-
extern C89STRINGUTILS_EXPORT int vasprintf(char **str, const char *fmt,
163-
va_list ap);
124+
extern C89STRINGUTILS_EXPORT int vasprintf(char **str, const char *fmt, va_list ap);
164125

165126
extern C89STRINGUTILS_EXPORT int asprintf(char **str, const char *fmt, ...);
166127

0 commit comments

Comments
 (0)