diff options
Diffstat (limited to 'meta/recipes-extended/tzcode/files/0002-Port-zdump-to-C90-snprintf.patch')
| -rw-r--r-- | meta/recipes-extended/tzcode/files/0002-Port-zdump-to-C90-snprintf.patch | 115 |
1 files changed, 115 insertions, 0 deletions
diff --git a/meta/recipes-extended/tzcode/files/0002-Port-zdump-to-C90-snprintf.patch b/meta/recipes-extended/tzcode/files/0002-Port-zdump-to-C90-snprintf.patch new file mode 100644 index 0000000000..87afe47694 --- /dev/null +++ b/meta/recipes-extended/tzcode/files/0002-Port-zdump-to-C90-snprintf.patch | |||
| @@ -0,0 +1,115 @@ | |||
| 1 | From e231da4fb2beb17c60b4b1a5c276366d6a6e433f Mon Sep 17 00:00:00 2001 | ||
| 2 | From: Paul Eggert <eggert@cs.ucla.edu> | ||
| 3 | Date: Mon, 23 Oct 2017 17:58:36 -0700 | ||
| 4 | Subject: [PATCH] Port zdump to C90 + snprintf | ||
| 5 | MIME-Version: 1.0 | ||
| 6 | Content-Type: text/plain; charset=UTF-8 | ||
| 7 | Content-Transfer-Encoding: 8bit | ||
| 8 | |||
| 9 | Problem reported by Jon Skeet in: | ||
| 10 | https://mm.icann.org/pipermail/tz/2017-October/025362.html | ||
| 11 | * NEWS: Mention this. | ||
| 12 | * zdump.c (my_snprintf): New macro or function. If a macro, it is | ||
| 13 | just snprintf. If a function, it is the same as the old snprintf | ||
| 14 | static function, with an ATTRIBUTE_FORMAT to pacify modern GCC. | ||
| 15 | All uses of snprintf changed to use my_snprintf. This way, | ||
| 16 | installers don’t need to specify -DHAVE_SNPRINTF if they are using | ||
| 17 | a pre-C99 compiler with a library that has snprintf. | ||
| 18 | |||
| 19 | Upstream-Status: Backport | ||
| 20 | Signed-off-by: Armin Kuster <akuster@mvista.com> | ||
| 21 | |||
| 22 | --- | ||
| 23 | NEWS | 4 ++++ | ||
| 24 | zdump.c | 29 ++++++++++++++++------------- | ||
| 25 | 2 files changed, 20 insertions(+), 13 deletions(-) | ||
| 26 | |||
| 27 | diff --git a/NEWS b/NEWS | ||
| 28 | index 75ab095..dea08b8 100644 | ||
| 29 | --- a/NEWS | ||
| 30 | +++ b/NEWS | ||
| 31 | @@ -7,6 +7,10 @@ Unreleased, experimental changes | ||
| 32 | The Makefile now quotes values like BACKWARD more carefully when | ||
| 33 | passing them to the shell. (Problem reported by Zefram.) | ||
| 34 | |||
| 35 | + Builders no longer need to specify -DHAVE_SNPRINTF on platforms | ||
| 36 | + that have snprintf and use pre-C99 compilers. (Problem reported | ||
| 37 | + by Jon Skeet.) | ||
| 38 | + | ||
| 39 | |||
| 40 | Release 2017c - 2017-10-20 14:49:34 -0700 | ||
| 41 | |||
| 42 | diff --git a/zdump.c b/zdump.c | ||
| 43 | index 8e3bf3e..d4e6084 100644 | ||
| 44 | --- a/zdump.c | ||
| 45 | +++ b/zdump.c | ||
| 46 | @@ -795,12 +795,14 @@ show(timezone_t tz, char *zone, time_t t, bool v) | ||
| 47 | abbrok(abbr(tmp), zone); | ||
| 48 | } | ||
| 49 | |||
| 50 | -#if !HAVE_SNPRINTF | ||
| 51 | +#if HAVE_SNPRINTF | ||
| 52 | +# define my_snprintf snprintf | ||
| 53 | +#else | ||
| 54 | # include <stdarg.h> | ||
| 55 | |||
| 56 | /* A substitute for snprintf that is good enough for zdump. */ | ||
| 57 | -static int | ||
| 58 | -snprintf(char *s, size_t size, char const *format, ...) | ||
| 59 | +static int ATTRIBUTE_FORMAT((printf, 3, 4)) | ||
| 60 | +my_snprintf(char *s, size_t size, char const *format, ...) | ||
| 61 | { | ||
| 62 | int n; | ||
| 63 | va_list args; | ||
| 64 | @@ -839,10 +841,10 @@ format_local_time(char *buf, size_t size, struct tm const *tm) | ||
| 65 | { | ||
| 66 | int ss = tm->tm_sec, mm = tm->tm_min, hh = tm->tm_hour; | ||
| 67 | return (ss | ||
| 68 | - ? snprintf(buf, size, "%02d:%02d:%02d", hh, mm, ss) | ||
| 69 | + ? my_snprintf(buf, size, "%02d:%02d:%02d", hh, mm, ss) | ||
| 70 | : mm | ||
| 71 | - ? snprintf(buf, size, "%02d:%02d", hh, mm) | ||
| 72 | - : snprintf(buf, size, "%02d", hh)); | ||
| 73 | + ? my_snprintf(buf, size, "%02d:%02d", hh, mm) | ||
| 74 | + : my_snprintf(buf, size, "%02d", hh)); | ||
| 75 | } | ||
| 76 | |||
| 77 | /* Store into BUF, of size SIZE, a formatted UTC offset for the | ||
| 78 | @@ -877,10 +879,10 @@ format_utc_offset(char *buf, size_t size, struct tm const *tm, time_t t) | ||
| 79 | mm = off / 60 % 60; | ||
| 80 | hh = off / 60 / 60; | ||
| 81 | return (ss || 100 <= hh | ||
| 82 | - ? snprintf(buf, size, "%c%02ld%02d%02d", sign, hh, mm, ss) | ||
| 83 | + ? my_snprintf(buf, size, "%c%02ld%02d%02d", sign, hh, mm, ss) | ||
| 84 | : mm | ||
| 85 | - ? snprintf(buf, size, "%c%02ld%02d", sign, hh, mm) | ||
| 86 | - : snprintf(buf, size, "%c%02ld", sign, hh)); | ||
| 87 | + ? my_snprintf(buf, size, "%c%02ld%02d", sign, hh, mm) | ||
| 88 | + : my_snprintf(buf, size, "%c%02ld", sign, hh)); | ||
| 89 | } | ||
| 90 | |||
| 91 | /* Store into BUF (of size SIZE) a quoted string representation of P. | ||
| 92 | @@ -983,15 +985,16 @@ istrftime(char *buf, size_t size, char const *time_fmt, | ||
| 93 | for (abp = ab; is_alpha(*abp); abp++) | ||
| 94 | continue; | ||
| 95 | len = (!*abp && *ab | ||
| 96 | - ? snprintf(b, s, "%s", ab) | ||
| 97 | + ? my_snprintf(b, s, "%s", ab) | ||
| 98 | : format_quoted_string(b, s, ab)); | ||
| 99 | if (s <= len) | ||
| 100 | return false; | ||
| 101 | b += len, s -= len; | ||
| 102 | } | ||
| 103 | - formatted_len = (tm->tm_isdst | ||
| 104 | - ? snprintf(b, s, &"\t\t%d"[show_abbr], tm->tm_isdst) | ||
| 105 | - : 0); | ||
| 106 | + formatted_len | ||
| 107 | + = (tm->tm_isdst | ||
| 108 | + ? my_snprintf(b, s, &"\t\t%d"[show_abbr], tm->tm_isdst) | ||
| 109 | + : 0); | ||
| 110 | } | ||
| 111 | break; | ||
| 112 | } | ||
| 113 | -- | ||
| 114 | 2.7.4 | ||
| 115 | |||
