Mercurial > gnulib
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 |
rev | line source |
---|---|
18840 | 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 | 3 |
4 This program is free software: you can redistribute it and/or modify | |
5 it under the terms of the GNU General Public License as published by | |
6 the Free Software Foundation; either version 3 of the License, or | |
7 (at your option) any later version. | |
8 | |
9 This program is distributed in the hope that it will be useful, | |
10 but WITHOUT ANY WARRANTY; without even the implied warranty of | |
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
12 GNU General Public License for more details. | |
13 | |
14 You should have received a copy of the GNU General Public License | |
19190 | 15 along with this program. If not, see <https://www.gnu.org/licenses/>. */ |
18840 | 16 |
17 #include <config.h> | |
18 | |
19 /* Specification. */ | |
20 #include <wchar.h> | |
21 | |
22 #include <stdlib.h> | |
23 #include <string.h> | |
24 #include <time.h> | |
25 | |
26 #undef wcsftime | |
27 | |
28 size_t | |
29 rpl_wcsftime (wchar_t *buf, size_t bufsize, const wchar_t *format, const struct tm *tp) | |
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 | 54 const char *tz = getenv ("TZ"); |
55 if (tz != NULL && strchr (tz, '/') != NULL) | |
56 _putenv ("TZ="); | |
57 #endif | |
58 | |
59 return wcsftime (buf, bufsize, format, tp); | |
60 } |