1
0
Fork 0
mirror of git://git.code.sf.net/p/cdesktopenv/code synced 2025-02-15 04:32:24 +00:00

libcsa: fix up some stupidness.

This commit is contained in:
Jon Trulson 2014-03-12 17:00:07 -06:00
parent a9bf30d12b
commit 3c14b8b5ce

View file

@ -29,6 +29,10 @@
*/ */
#include <EUSCompat.h> #include <EUSCompat.h>
#define XOS_USE_NO_LOCKING
#define X_INCLUDE_TIME_H
#include <X11/Xos_r.h>
#include <stdlib.h> #include <stdlib.h>
#include <stdio.h> #include <stdio.h>
#include <unistd.h> #include <unistd.h>
@ -42,12 +46,12 @@ set_timezone(char *tzname)
static char tzenv[BUFSIZ]; static char tzenv[BUFSIZ];
if (tzname==NULL) if (tzname==NULL)
system("unset TZ\n"); (void) putenv("TZ");
else { else {
snprintf(tzenv, sizeof tzenv, "TZ=%s", tzname); snprintf(tzenv, sizeof tzenv, "TZ=%s", tzname);
(void) putenv(tzenv); (void) putenv(tzenv);
tzset();
} }
tzset();
} }
static int static int
@ -166,12 +170,16 @@ _csa_tick_to_iso8601(time_t tick, char *buf_out)
time_t tk=tick; time_t tk=tick;
char tz_orig[BUFSIZ]; char tz_orig[BUFSIZ];
boolean_t orig_tzset = B_FALSE; boolean_t orig_tzset = B_FALSE;
_Xgtimeparams gmtime_buf;
/* tick must be +ve to be valid */ /* tick must be +ve to be valid */
if (tick < 0) { if (tick < 0) {
return(-1); return(-1);
} }
/* JET. This is horrible. */
#if !defined(linux) && !defined(CSRG_BASED)
if (getenv("TZ")) { if (getenv("TZ")) {
strncpy(tz_orig, getenv("TZ"), sizeof(tz_orig)); strncpy(tz_orig, getenv("TZ"), sizeof(tz_orig));
tz_orig[sizeof(tz_orig)-1] = '\0'; tz_orig[sizeof(tz_orig)-1] = '\0';
@ -191,6 +199,11 @@ _csa_tick_to_iso8601(time_t tick, char *buf_out)
else else
set_timezone(NULL); set_timezone(NULL);
#else
/* let's use something a little more reasonable */
time_str = _XGmtime(&tk, gmtime_buf);
#endif /* !linux && !CSGRC_BASED */
/* format string forces fixed width (zero-padded) fields */ /* format string forces fixed width (zero-padded) fields */
sprintf(buf_out, "%04d%02d%02dT%02d%02d%02dZ", sprintf(buf_out, "%04d%02d%02dT%02d%02d%02dZ",
time_str->tm_year + 1900, time_str->tm_year + 1900,