On 2025-10-21 06:15, Manuela Friedrich wrote:
localtime.c(383): error C2065: 'uid_t': undeclared identifier
Please compile with these flags too:
-DHAVE_GETEUID=0 -DHAVE_GETRESUID=0 -DHAVE_STRUCT_STAT_ST_CTIM=0
tzcode assumes a POSIX-like platform, and if you're on a non-POSIX
platform you need to use flags telling tzcode which POSIX-required
features are missing. tzcode has long had flags like these, such as the
-DHAVE_INTTYPES_H=0 and -DHAVE_UNISTD_H=0 flags you're already using.
The flags I listed above are new since 2025b; this is documented in the
Makefile.
By the way, why compile with -DHAVE_INTTYPES_H=0? The Microsoft website
says MS-Windows has <inttypes.h> [1]. I suggest removing that flag.
Similarly, while compile with -DHAVE_STRTOLL=0? [2]
PS. Getting back to umask, it looks we'll need it after all, to get a
FreeBSD-like zic -u option to work securely. Please check whether the
attached patch compiles for you. I haven't installed it, but plan to
install something like it soon.
[1]: https://learn.microsoft.com/en-us/cpp/c-runtime-library/standard-types
[2]:
https://learn.microsoft.com/en-us/cpp/c-runtime-library/reference/strtoll-strtoll-l-wcstoll-wcstoll-lFrom 036274f8c1a068035c0028020b6e4d738971f6e1 Mon Sep 17 00:00:00 2001
From: Paul Eggert <[email protected]>
Date: Tue, 21 Oct 2025 08:39:40 -0700
Subject: [TEST] Test patch - please try out on MS-Windows
* zic.c (mode_t) [HAVE_DIRECT_H]: Now a typedef, not a macro.
(mkdir) [HAVE_DIRECT_H]: Define unconditionally.
(mkdir) [!HAVE_POSIX_DECLS]: Remove recently-added decl.
(current_umask): New var.
(main): Set it.
---
zic.c | 16 +++++++---------
1 file changed, 7 insertions(+), 9 deletions(-)
diff --git a/zic.c b/zic.c
index 67bcaa43..748dabce 100644
--- a/zic.c
+++ b/zic.c
@@ -48,12 +48,8 @@ enum { FORMAT_LEN_GROWTH_BOUND = 5 };
#ifdef HAVE_DIRECT_H
# include <direct.h>
# include <io.h>
-# ifndef mode_t
-# define mode_t int
-# endif
-# ifndef mkdir
-# define mkdir(name, mode) _mkdir(name)
-# endif
+typedef int mode_t;
+# define mkdir(name, mode) _mkdir(name)
#endif
#ifndef HAVE_GETRANDOM
@@ -182,9 +178,6 @@ struct zone {
extern int getopt(int argc, char * const argv[],
const char * options);
extern int link(const char * target, const char * linkname);
-# ifndef mkdir
-extern int mkdir(char const *, mode_t);
-# endif
extern char * optarg;
extern int optind;
#endif
@@ -1017,6 +1010,8 @@ want_bloat(void)
# define ZIC_BLOAT_DEFAULT "slim"
#endif
+mode_t current_umask;
+
int
main(int argc, char **argv)
{
@@ -1024,6 +1019,9 @@ main(int argc, char **argv)
register ptrdiff_t i, j;
bool timerange_given = false;
+ current_umask = umask(0);
+ umask(current_umask);
+
#if HAVE_GETTEXT
setlocale(LC_ALL, "");
# ifdef TZ_DOMAINDIR
--
2.51.0