projects/aports·blob master · refs

45 lines · 1.1 KiB

1--- a/src/parser/snprintf.c.orig
2+++ b/src/parser/snprintf.c
3@@ -400,18 +400,7 @@
4 * Note: glibc declares this as returning "char *", but that would require
5 * casting away const internally, so we don't follow that detail.
6 */
7-#ifndef HAVE_STRCHRNUL
8
9-static inline const char *
10-strchrnul(const char *s, int c)
11-{
12- while (*s != '\0' && *s != c)
13- s++;
14- return s;
15-}
16-
17-#else
18-
19 /*
20 * glibc's <string.h> declares strchrnul only if _GNU_SOURCE is defined.
21 * While we typically use that on glibc platforms, configure will set
22@@ -422,9 +411,7 @@
23 extern char *strchrnul(const char *s, int c);
24 #endif
25
26-#endif /* HAVE_STRCHRNUL */
27
28-
29 /*
30 * dopr(): the guts of *printf for all cases.
31 */
32@@ -764,10 +751,10 @@
33 break;
34 case 'm':
35 {
36- char errbuf[PG_STRERROR_R_BUFLEN];
37- const char *errm = strerror_r(save_errno,
38+ char errbuf[256];
39+ int ret = strerror_r(save_errno,
40 errbuf, sizeof(errbuf));
41-
42+ const char *errm = (ret == 0) ? errbuf : "Unknown error";
43 dostr(errm, strlen(errm), target);
44 }
45 break;