Skip to content

Commit efa52aa

Browse files
committed
[c89stringutils/c89stringutils_string_extras.h] Guard jasprintf the same way as other functions ;[c89stringutils_tests/test_c89stringutils/test_string_extras.h] Whitespace from clang-format;
1 parent ceb4a10 commit efa52aa

File tree

2 files changed

+6
-2
lines changed

2 files changed

+6
-2
lines changed

c89stringutils/c89stringutils_string_extras.h

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -353,13 +353,15 @@ extern int asprintf(char **str, const char *fmt, ...) {
353353

354354
#endif /* !HAVE_ASPRINTF */
355355

356+
#ifndef HAVE_JASPRINTF
357+
356358
/* `jasprintf`, a version of `asprintf` that concatenates on successive calls:
357359
* char *s; jasprintf(&s, "foo%s", "bar");
358360
* jasprintf(&s, "can%s", "haz"); free(s);
359361
* */
360362
char *jasprintf(char **unto, const char *fmt, ...);
361363

362-
#ifndef HAVE_JASPRINTF
364+
#if defined(C89STRINGUTILS_IMPLEMENTATION) && !defined(HAVE_JASPRINTF)
363365
#define HAVE_JASPRINTF
364366
char *jasprintf(char **unto, const char *fmt, ...) {
365367
va_list args;
@@ -385,6 +387,8 @@ char *jasprintf(char **unto, const char *fmt, ...) {
385387

386388
return result;
387389
}
390+
#endif /* defined(C89STRINGUTILS_IMPLEMENTATION) && !defined(HAVE_JASPRINTF) \
391+
*/
388392
#endif /* !HAVE_JASPRINTF */
389393

390394
#endif /* !C89STRINGUTILS_STRING_EXTRAS_H */

c89stringutils_tests/test_c89stringutils/test_string_extras.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ TEST x_strnstr_should_fail(void) {
1717
}
1818

1919
TEST x_jasprintf_should_succeed(void) {
20-
char *s=NULL;
20+
char *s = NULL;
2121
jasprintf(&s, "foo%s", "bar");
2222
jasprintf(&s, "can%s", "haz");
2323
ASSERT_EQ(strcmp(s, "foobarcanhaz"), 0);

0 commit comments

Comments
 (0)