Skip to content

Commit ff918d9

Browse files
committed
1 parent 27b2af9 commit ff918d9

File tree

2 files changed

+11
-18
lines changed

2 files changed

+11
-18
lines changed

Diff for: src/postgres/include/pg_config.h

+7-4
Original file line numberDiff line numberDiff line change
@@ -116,6 +116,10 @@
116116
don't. */
117117
#define HAVE_DECL_PWRITEV 1
118118

119+
/* Define to 1 if you have the declaration of `strchrnul', and to 0 if you
120+
don't. */
121+
#undef HAVE_DECL_STRCHRNUL
122+
119123
/* Define to 1 if you have the declaration of `strlcat', and to 0 if you
120124
don't. */
121125
#define HAVE_DECL_STRLCAT 1
@@ -397,9 +401,6 @@
397401
/* Define to 1 if you have the <stdlib.h> header file. */
398402
#define HAVE_STDLIB_H 1
399403

400-
/* Define to 1 if you have the `strchrnul' function. */
401-
/* #undef HAVE_STRCHRNUL */
402-
403404
/* Define to 1 if you have the `strerror_r' function. */
404405
#define HAVE_STRERROR_R 1
405406

@@ -851,7 +852,9 @@
851852
/* Ensure we do not fail on systems that have strchrnul support (FreeBSD, NetBSD and newer glibc) */
852853
#include <stdlib.h>
853854
#if defined(__FreeBSD__) || defined(__NetBSD__) || (defined(__GLIBC__) && ((__GLIBC__ == 2 && __GLIBC_MINOR__ >= 38) || __GLIBC__ > 2))
854-
#define HAVE_STRCHRNUL
855+
#define HAVE_DECL_STRCHRNUL 1
856+
#else
857+
#define HAVE_DECL_STRCHRNUL 0
855858
#endif
856859

857860
/* 32-bit */

Diff for: src/postgres/src_port_snprintf.c

+4-14
Original file line numberDiff line numberDiff line change
@@ -368,7 +368,9 @@ static void trailing_pad(int padlen, PrintfTarget *target);
368368
* Note: glibc declares this as returning "char *", but that would require
369369
* casting away const internally, so we don't follow that detail.
370370
*/
371-
#ifndef HAVE_STRCHRNUL
371+
#if !HAVE_DECL_STRCHRNUL
372+
373+
#define strchrnul pg_strchrnul
372374

373375
static inline const char *
374376
strchrnul(const char *s, int c)
@@ -378,19 +380,7 @@ strchrnul(const char *s, int c)
378380
return s;
379381
}
380382

381-
#else
382-
383-
/*
384-
* glibc's <string.h> declares strchrnul only if _GNU_SOURCE is defined.
385-
* While we typically use that on glibc platforms, configure will set
386-
* HAVE_STRCHRNUL whether it's used or not. Fill in the missing declaration
387-
* so that this file will compile cleanly with or without _GNU_SOURCE.
388-
*/
389-
#ifndef _GNU_SOURCE
390-
extern char *strchrnul(const char *s, int c);
391-
#endif
392-
393-
#endif /* HAVE_STRCHRNUL */
383+
#endif /* !HAVE_DECL_STRCHRNUL */
394384

395385

396386
/*

0 commit comments

Comments
 (0)