73 Commits

Author SHA1 Message Date
Andrey Gorbachev
510a05429f Fix expected file format under Windows.
Make sure we handle "\r\n" correctly under Windows and Unix.
2024-09-30 13:59:57 -04:00
Vasyl Gello
447f5a30b9 Fix unused functions on Android
... spotted with `-Wall`

Signed-off-by: Vasyl Gello <vasek.gello@gmail.com>
2024-09-30 11:00:51 -04:00
Eugene Golushkov
7657ad7855 Fixed Android build - reasonable defaults for HAS_REMOTE_API and INSTALL to avoid including unavailable curl.h and wordexp.h 2024-09-29 20:30:45 -04:00
Eugene Golushkov
bbe2f51bc0 Fixed WINRT build - we need convert_utf8_to_utf16 in WINRT mode too 2024-09-29 20:30:45 -04:00
Vasyl Gello
3e43210885 Implement USE_OS_TZDB for Android
Signed-off-by: Vasyl Gello <vasek.gello@gmail.com>
2024-09-29 16:21:36 -04:00
Andrea Pappacoda
ac0c58d5da Stop using PATH_MAX
PATH_MAX isn't guaranteed to be defined in Posix environments; it is
only on systems that have a path length limit, and even in environments
where it is defined its usage can lead to issues.

To avoid using PATH_MAX, I've made two main changes:

- Where realpath() was used, I've changed the code to use its
  [POSIX.1-2008]'s new behaviour, where passing a null pointer as the
  resolved_name buffer results in realpath() to automatically allocate
  a buffer large enough to handle the given path, that is returned to
  the caller. This has been supported for a long time as a GNU libc
  extension before being standardized.
- Where readlink() was used, the size of the buffer was already
  determined when calling lstat(); the returned struct stat contains a
  st_size field, containing the number of bytes needed to store the
  symbolic link contents. This meant that to avoid using the tricky
  define I only needed to use a dynamically allocated buffer instead of
  a static one, of size stat.st_size (+1 when a null terminator is
  needed).

To make sure that memory is always freed, I've wrapped the new dynamic
allocations in an std::unique_ptr. The pointer returned by realpath()
must be freed with free(), so a unique_ptr with a custom deleter that
calls free() on destruction was used.

To read more about why PATH_MAX leads to buggy code I'd suggest reading
something like this: <https://eklitzke.org/path-max-is-tricky>.

[POSIX.1-2008]: https://pubs.opengroup.org/onlinepubs/9699919799/functions/realpath.html
2024-09-28 16:56:16 -04:00
Michael Maroszek
dc9d161607 detect current zone on OpenWRT systems 2024-09-28 16:31:51 -04:00
Edward Nolan
6219dd7e4d Support tz databases from release 2023d and newer by adding new zonenow.tab file to ignore list
date's internal init_tzdb function iterates through the files provided
by the tz database, and init_tzdb contains a list of files that should
not be interpreted as being in TZif format.

The 2023d release of the tz database added a new file that is not in
TZif format, zonenow.tab. However, this file had not been added to the
ignore list.

This caused date to intepret the zonenow.tab file as a TZif file,
which caused assertions to fire in debug mode if the user attempted to
load its associated time_zone, causing load_header() to be invoked
on the file, which would find that it did not contain a 'TZif' magic
number.

This commit addresses the issue by adding the file to the ignore list.

The announcement on the tz database mailing list which describes the
addition of zonenow.tab can be found at this link:

https://mm.icann.org/pipermail/tz-announce/2023-December/000080.html
2024-09-28 15:56:36 -04:00
Howard Hinnant
51ce7e1310 A couple more fixes for parsing compliance
* Fixes: #839
2024-09-13 20:31:29 -04:00
Howard Hinnant
155c6b9e76 Bring text parsing into compliance with the tzdata spec
* Fixes #836
2024-09-12 15:53:39 +01:00
Nicolas Dusart
f986299fbb support Android for current_zone() 2024-05-13 20:16:17 -04:00
Howard Hinnant
706b1286e8 One more fix for issue #826 2024-05-10 16:44:22 -04:00
Martin Zink
8a93211679 #826 Build fix for ambiguity with >= libc++ 17 2024-05-10 16:26:43 -04:00
Howard Hinnant
6b1c1b8b3a Clean up restore_recursion_depth code. 2024-05-10 16:21:36 -04:00
Howard Hinnant
8f8336f42b Add support for links to links 2024-04-19 14:58:58 -04:00
Tim Tavlintsev
50acf3ffd8 Fix compilation when MISSING_LEAP_SECONDS is set to true 2023-03-04 15:42:06 -05:00
Howard Hinnant
22ceabf205 Fix tzdb parsing to handle new offset comments in 2022b 2022-08-12 10:30:35 -04:00
DavisVaughan
9d9161c978 Sync set_install() signatures 2022-02-16 20:23:27 -05:00
DavisVaughan
529a09267f Allow set_install() on Windows to use a file path containing Unicode
Anywhere we utilize that install file path, we carefully convert it to UTF-16 and utilize wide character helpers for file manipulation
2021-11-02 18:51:18 -04:00
Howard Hinnant
d9049ee697 Fix current_zone for SLES
* Fixes #708
* Patch submitted by JaroslawMelzer
2021-10-15 09:03:33 -04:00
tylawin
2709deddd3 fix -Wshadow warnings 2021-09-12 01:29:13 -06:00
Aaron Franke
417402ad35
Remove trailing whitespace and add gitattributes (#672) 2021-05-24 08:22:43 -04:00
Howard Hinnant
b49a7575eb Zero initialize local_info in get_info
* Even when the result is unique, the second sys_info
  should be zero initialized.
2021-05-18 16:15:31 -04:00
Howard Hinnant
b899774303 Run curl_global_cleanup only once per application 2021-03-11 19:58:34 -05:00
satishbhat-umd
811be52e1c
Add global cleanup to curl object destructor (#652)
Co-authored-by: Satish Bhat <sbhat@belvederetrading.com>
2021-03-01 17:00:11 -05:00
LarsGullik
432bab81f9
Skip "version" file and USE_OS_TZDB to return "unknown" if no version found (#616)
In commit commit 0b72599bd43f72d8935e507e25e4f0063f9bb34e there
was a change to read "version" in addition to "+VERSION", so that
file shold also be ignored when scanning/reading zonefiles.

Also before the above mentioed commit get_version() would return
"unknown" if not on __APPLE__ and the version file was not found.
Put back that behaviour, for all USE_OS_TZDB users.

This last change changes the behaviour for __APPLE__ from throwing
an exception to returning "unknown".

Co-authored-by: Lars Gullik Bjønnes <lbjonnes@cisco.com>
2020-10-27 10:08:30 -04:00
Evgen Bodunov
115dd428cf
Proposed fix for issue #161
Header include should follow the same preprocessor rules as function definition.
2020-10-08 11:47:09 +03:00
Howard Hinnant
0b72599bd4 For USE_OS_TZDB, look for version number in the files
version and +VERSION
2020-09-11 16:00:18 -04:00
Howard Hinnant
ba99134b8a For USE_OS_TZDB, look for leap seconds in the files
leapseconds and leap-seconds.list
2020-09-11 15:53:07 -04:00
Andre Nguyen
d7a0bf1fa7 replace noexcept with NOEXCEPT macro 2020-08-21 17:09:51 -04:00
Howard Hinnant
658a3b9495 Fix crasher for early local times and USE_OS_TZDB=1 2020-08-17 21:34:20 -04:00
Joshua Jackson
d784766640 iOS Simulator support 2020-05-24 21:31:18 -04:00
Howard Hinnant
9a0ee25428 Do a runtime test for realpath vs readlink
* Ubuntu needs to use readlink under current_zone
  and most everyone else needs realpath.  Attempting
  to make everyone happy with this commit.
2020-01-25 10:05:26 -05:00
Ten10
940f4a5ceb Support Curl Error Buffer
Allow user to get error message when download fails
2019-11-29 19:38:40 -05:00
Howard Hinnant
3e376be2e9 Rename link to time_zone_link
* At the request of LEWG
2019-11-08 19:36:09 +00:00
Howard Hinnant
224c71a899 Rename leap to leap_second and leaps to leap_seconds
* At the request of LEWG
2019-11-08 19:24:03 +00:00
Mike Ellery
48f1455cd2 CMake refactor for easier subdirectory inclusion 2019-10-18 14:59:37 -04:00
Howard Hinnant
3f0f9b3cbe Search for '/' after "zoneinfo" in current_zone() 2019-10-14 15:54:32 -04:00
Howard Hinnant
4481c75192 Improve current_zone().
Fixes #454
2019-09-23 22:09:13 -04:00
James Beach
46ccd69c9c Resolve GCC 9.1.0 unused-function warning 2019-07-21 23:18:54 -04:00
Matt Kline
7ef1a55143 tz.cpp: Cast conversions to/from size_t
These cause warnings with -Wsign-conversion.
2019-07-21 20:46:01 -04:00
muriukip
ed0368fc75 The URL for windowsZones.xml changed to (#447)
https://raw.githubusercontent.com/unicode-org/cldr/master/common/supplemental/windowsZones.xml
2019-05-15 12:08:24 -04:00
Elvis Oric
429d9ba739 Add User-Agent curl option in download_to_string function. [#438] 2019-04-19 09:07:03 -04:00
Daniela Engert
10ab6ae9e5 Fix warnings from Clang (#421)
Clang 9 (in Visual Studio) complains about a mixed signed-unsigned comparison and an unused function.
Replace the naked `int` constant -1 by `std::size_t(-1)` with the same codegen as before (no curlies to avoid narrowing).
Guard the definition of `get_download_folder()` by the same condition as its call-site.

Signed-off-by: Daniela Engert <dani@ngrt.de>
2019-03-19 20:25:59 -04:00
Howard Hinnant
9cb0013aef Update time_of_day to be more consistent ...
the needs of formatting.
2019-02-02 14:06:12 -05:00
Howard Hinnant
f1326968af Make compatible with const-only string.data() spec 2019-01-31 19:23:17 -05:00
Daniela Engert
61c3d35634 Fix problem with wchar_t* to std::string conversion. (#419)
VS2019 correctly points out that a conversion from a wide NTCS to std::string requires narrowing. This may result in an undesired string value. Implement the string conversion properly.

Signed-off-by: Daniela Engert <dani@ngrt.de>
2019-01-27 17:08:01 -05:00
apretori-tic
2cb4c34009 Ignore tzdata.zi and leapseconds tzdb files on Linux when loading time zones (#411) 2018-12-18 12:15:00 -05:00
Howard Hinnant
0e85704e47 Don't write to ~/Downloads if not installing there 2018-12-14 20:12:55 -05:00
Howard Hinnant
be2ec2310b Emphasize Sunday over sun in the implementation
*  Keep the three letter lower case spellings for backwards
   compatibility purposes.
2018-06-03 13:55:00 -04:00