annotate lib/wcsftime.c @ 40231:9b3c79fdfe0b

strtod: fix clash with strtold Problem reported for RHEL 5 by Jesse Caldwell (Bug#34817). * lib/strtod.c (compute_minus_zero, minus_zero): Simplify by remving the macro / external variable, and having just a function. User changed. This avoids the need for an external variable that might clash.
author Paul Eggert <eggert@cs.ucla.edu>
date Mon, 11 Mar 2019 16:40:29 -0700
parents b06060465f09
children 5a52ef2d4772
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
18840
d50c006b784f wcsftime: New module.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
1 /* Work around platform bugs in wcsftime.
40057
b06060465f09 maint: Run 'make update-copyright'
Paul Eggert <eggert@cs.ucla.edu>
parents: 19595
diff changeset
2 Copyright (C) 2017-2019 Free Software Foundation, Inc.
18840
d50c006b784f wcsftime: New module.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
3
d50c006b784f wcsftime: New module.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
4 This program is free software: you can redistribute it and/or modify
d50c006b784f wcsftime: New module.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
5 it under the terms of the GNU General Public License as published by
d50c006b784f wcsftime: New module.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
6 the Free Software Foundation; either version 3 of the License, or
d50c006b784f wcsftime: New module.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
7 (at your option) any later version.
d50c006b784f wcsftime: New module.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
8
d50c006b784f wcsftime: New module.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
9 This program is distributed in the hope that it will be useful,
d50c006b784f wcsftime: New module.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
d50c006b784f wcsftime: New module.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
d50c006b784f wcsftime: New module.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
12 GNU General Public License for more details.
d50c006b784f wcsftime: New module.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
13
d50c006b784f wcsftime: New module.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
14 You should have received a copy of the GNU General Public License
19190
9759915b2aca all: prefer https: URLs
Paul Eggert <eggert@cs.ucla.edu>
parents: 18875
diff changeset
15 along with this program. If not, see <https://www.gnu.org/licenses/>. */
18840
d50c006b784f wcsftime: New module.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
16
d50c006b784f wcsftime: New module.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
17 #include <config.h>
d50c006b784f wcsftime: New module.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
18
d50c006b784f wcsftime: New module.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
19 /* Specification. */
d50c006b784f wcsftime: New module.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
20 #include <wchar.h>
d50c006b784f wcsftime: New module.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
21
d50c006b784f wcsftime: New module.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
22 #include <stdlib.h>
d50c006b784f wcsftime: New module.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
23 #include <string.h>
d50c006b784f wcsftime: New module.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
24 #include <time.h>
d50c006b784f wcsftime: New module.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
25
d50c006b784f wcsftime: New module.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
26 #undef wcsftime
d50c006b784f wcsftime: New module.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
27
d50c006b784f wcsftime: New module.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
28 size_t
d50c006b784f wcsftime: New module.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
29 rpl_wcsftime (wchar_t *buf, size_t bufsize, const wchar_t *format, const struct tm *tp)
d50c006b784f wcsftime: New module.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
30 {
19595
beb2ad957aca Simplify code. Drop support for Borland C++ on Windows.
Bruno Haible <bruno@clisp.org>
parents: 19484
diff changeset
31 #if defined _WIN32 && ! defined __CYGWIN__
18875
affde4311db7 tzset: Expand comment about TZ problem on native Windows.
Bruno Haible <bruno@clisp.org>
parents: 18840
diff changeset
32 /* Rectify the value of the environment variable TZ.
affde4311db7 tzset: Expand comment about TZ problem on native Windows.
Bruno Haible <bruno@clisp.org>
parents: 18840
diff changeset
33 There are four possible kinds of such values:
affde4311db7 tzset: Expand comment about TZ problem on native Windows.
Bruno Haible <bruno@clisp.org>
parents: 18840
diff changeset
34 - Traditional US time zone names, e.g. "PST8PDT". Syntax: see
affde4311db7 tzset: Expand comment about TZ problem on native Windows.
Bruno Haible <bruno@clisp.org>
parents: 18840
diff changeset
35 <https://msdn.microsoft.com/en-us/library/90s5c885.aspx>
affde4311db7 tzset: Expand comment about TZ problem on native Windows.
Bruno Haible <bruno@clisp.org>
parents: 18840
diff changeset
36 - Time zone names based on geography, that contain one or more
affde4311db7 tzset: Expand comment about TZ problem on native Windows.
Bruno Haible <bruno@clisp.org>
parents: 18840
diff changeset
37 slashes, e.g. "Europe/Moscow".
affde4311db7 tzset: Expand comment about TZ problem on native Windows.
Bruno Haible <bruno@clisp.org>
parents: 18840
diff changeset
38 - Time zone names based on geography, without slashes, e.g.
affde4311db7 tzset: Expand comment about TZ problem on native Windows.
Bruno Haible <bruno@clisp.org>
parents: 18840
diff changeset
39 "Singapore".
affde4311db7 tzset: Expand comment about TZ problem on native Windows.
Bruno Haible <bruno@clisp.org>
parents: 18840
diff changeset
40 - Time zone names that contain explicit DST rules. Syntax: see
affde4311db7 tzset: Expand comment about TZ problem on native Windows.
Bruno Haible <bruno@clisp.org>
parents: 18840
diff changeset
41 <http://pubs.opengroup.org/onlinepubs/9699919799/basedefs/V1_chap08.html#tag_08_03>
affde4311db7 tzset: Expand comment about TZ problem on native Windows.
Bruno Haible <bruno@clisp.org>
parents: 18840
diff changeset
42 The Microsoft CRT understands only the first kind. It produces incorrect
affde4311db7 tzset: Expand comment about TZ problem on native Windows.
Bruno Haible <bruno@clisp.org>
parents: 18840
diff changeset
43 results if the value of TZ is of the other kinds.
affde4311db7 tzset: Expand comment about TZ problem on native Windows.
Bruno Haible <bruno@clisp.org>
parents: 18840
diff changeset
44 But in a Cygwin environment, /etc/profile.d/tzset.sh sets TZ to a value
affde4311db7 tzset: Expand comment about TZ problem on native Windows.
Bruno Haible <bruno@clisp.org>
parents: 18840
diff changeset
45 of the second kind for most geographies, or of the first kind in a few
affde4311db7 tzset: Expand comment about TZ problem on native Windows.
Bruno Haible <bruno@clisp.org>
parents: 18840
diff changeset
46 other geographies. If it is of the second kind, neutralize it. For the
affde4311db7 tzset: Expand comment about TZ problem on native Windows.
Bruno Haible <bruno@clisp.org>
parents: 18840
diff changeset
47 Microsoft CRT, an absent or empty TZ means the time zone that the user
affde4311db7 tzset: Expand comment about TZ problem on native Windows.
Bruno Haible <bruno@clisp.org>
parents: 18840
diff changeset
48 has set in the Windows Control Panel.
affde4311db7 tzset: Expand comment about TZ problem on native Windows.
Bruno Haible <bruno@clisp.org>
parents: 18840
diff changeset
49 If the value of TZ is of the third or fourth kind -- Cygwin programs
affde4311db7 tzset: Expand comment about TZ problem on native Windows.
Bruno Haible <bruno@clisp.org>
parents: 18840
diff changeset
50 understand these syntaxes as well --, it does not matter whether we
affde4311db7 tzset: Expand comment about TZ problem on native Windows.
Bruno Haible <bruno@clisp.org>
parents: 18840
diff changeset
51 neutralize it or not, since these values occur only when a Cygwin user
affde4311db7 tzset: Expand comment about TZ problem on native Windows.
Bruno Haible <bruno@clisp.org>
parents: 18840
diff changeset
52 has set TZ explicitly; this case is 1. rare and 2. under the user's
affde4311db7 tzset: Expand comment about TZ problem on native Windows.
Bruno Haible <bruno@clisp.org>
parents: 18840
diff changeset
53 responsibility. */
18840
d50c006b784f wcsftime: New module.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
54 const char *tz = getenv ("TZ");
d50c006b784f wcsftime: New module.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
55 if (tz != NULL && strchr (tz, '/') != NULL)
d50c006b784f wcsftime: New module.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
56 _putenv ("TZ=");
d50c006b784f wcsftime: New module.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
57 #endif
d50c006b784f wcsftime: New module.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
58
d50c006b784f wcsftime: New module.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
59 return wcsftime (buf, bufsize, format, tp);
d50c006b784f wcsftime: New module.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
60 }