diff options
author | Rob Landley <rob@landley.net> | 2015-02-09 16:34:24 -0600 |
---|---|---|
committer | Rob Landley <rob@landley.net> | 2015-02-09 16:34:24 -0600 |
commit | c277f347bba2417106b32212d9d40aceb4a88fb5 (patch) | |
tree | ba7228ee308b980970b8c3419af5c9690095e3b7 /lib/xwrap.c | |
parent | 452dcd5f7d5374411da86777de9fe94f5a88f709 (diff) | |
download | toybox-c277f347bba2417106b32212d9d40aceb4a88fb5.tar.gz |
Cleanup/refactoring pass on hwclock.
Inline open_wall_clock_rtc() into rtc_open(), factor out xtzset(),
inline set_sysclock_from_hwclock(), set_hwclock_from_sysclock(),
and set_sysclock_timezone().
/etc/adjtime is short enough we don't need to bother with a break.
The final "else" case in main() should always trigger because >0 in optstr
says "at most zero arguments", so the || at the end is always true, so
take the test off.
Diffstat (limited to 'lib/xwrap.c')
-rw-r--r-- | lib/xwrap.c | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/lib/xwrap.c b/lib/xwrap.c index cd3c6845..0a2b38ff 100644 --- a/lib/xwrap.c +++ b/lib/xwrap.c @@ -627,3 +627,14 @@ void xregcomp(regex_t *preg, char *regex, int cflags) error_exit("xregcomp: %s", libbuf); } } + +char *xtzset(char *new) +{ + char *tz = getenv("TZ"); + + if (tz) tz = xstrdup(tz); + if (setenv("TZ", new, 1)) perror_exit("setenv"); + tzset(); + + return tz; +} |