Add Solaris support (#3515)
I love jq :) So while updating the version we ship in Solaris I have tried to modify stuff to make everything work out of the box. Just ``` autoreconf -fiv ./configure gmake gmake check ``` I also went ahead and created Solaris test action should you be interested in having it too. The changes are not extensive and I have tried to comment them nicely in each commit. Hopefully that's enough. Thanks for jq!
This commit is contained in:
1 parent
27f417f481
commit
9f778b4cb5
3 files changed
+36
-5
No files matched your search
+10
-2
@@ -1783,21 +1783,29 @@ static jv f_strftime(jq_state *jq, jv a, jv b) {
|
||||
int fmt_not_empty = *fmt != '\0';
|
||||
size_t max_size = strlen(fmt) + 100;
|
||||
char *buf = jv_mem_alloc(max_size);
|
||||
#ifdef __APPLE__
|
||||
#if defined(__APPLE__) || defined(__sun)
|
||||
/* Apple Libc (as of version 1669.40.2) contains a bug which causes it to
|
||||
* ignore the `tm.tm_gmtoff` in favor of the global timezone. To print the
|
||||
* proper timezone offset we temporarily switch the TZ to UTC. */
|
||||
char *tz = (tz = getenv("TZ")) != NULL ? strdup(tz) : NULL;
|
||||
setenv("TZ", "UTC", 1);
|
||||
#endif
|
||||
#if defined(__sun)
|
||||
/* Solaris moreover needs call to tzset to take the changed environment into
|
||||
* account ... */
|
||||
tzset();
|
||||
#endif
|
||||
size_t n = strftime(buf, max_size, fmt, &tm);
|
||||
#ifdef __APPLE__
|
||||
#if defined(__APPLE__) || defined(__sun)
|
||||
if (tz) {
|
||||
setenv("TZ", tz, 1);
|
||||
free(tz);
|
||||
} else {
|
||||
unsetenv("TZ");
|
||||
}
|
||||
#endif
|
||||
#if defined(__sun)
|
||||
tzset();
|
||||
#endif
|
||||
jv_free(b);
|
||||
/* POSIX doesn't provide errno values for strftime() failures; weird */
|
||||
|
||||
Reference in new issue
Block a user