libbb/time.c:144:4: error: a label can only be part of a statement and a declaration is not a statement
Applied, thank you On Sat, Sep 18, 2021 at 9:41 AM Ron Yorston <[email protected]> wrote: > > Commit 9fe1548bb (date,touch: allow timezone offsets in dates) > mentioned the similarity between '@' format dates and those with > timezone offsets. It didn't notice that as a result there's > common code which can be shared. > > function old new delta > parse_datestr 730 687 -43 > ------------------------------------------------------------------------------ > (add/remove: 0/0 grow/shrink: 0/1 up/down: 0/-43) Total: -43 bytes > > Signed-off-by: Ron Yorston <[email protected]> > --- > libbb/time.c | 12 +++--------- > 1 file changed, 3 insertions(+), 9 deletions(-) > > diff --git a/libbb/time.c b/libbb/time.c > index 41a69c754..8010c0caa 100644 > --- a/libbb/time.c > +++ b/libbb/time.c > @@ -13,6 +13,7 @@ > int FAST_FUNC parse_datestr(const char *date_str, struct tm *ptm) > { > char end = '\0'; > + time_t t; > #if ENABLE_DESKTOP > /* > * strptime is BIG: ~1k in uclibc, ~10k in glibc > @@ -47,9 +48,6 @@ int FAST_FUNC parse_datestr(const char *date_str, struct tm > *ptm) > if (endp && *endp == '\0') { > #if ENABLE_FEATURE_TIMEZONE > if (strchr(fmt, 'z')) { > - time_t t; > - struct tm *utm; > - > /* we have timezone offset: obtain Unix > time_t */ > ptm->tm_sec -= ptm->tm_gmtoff; > ptm->tm_isdst = 0; > @@ -57,11 +55,7 @@ int FAST_FUNC parse_datestr(const char *date_str, struct > tm *ptm) > if (t == (time_t)-1) > break; > /* convert Unix time_t to struct tm in user's > locale */ > - utm = localtime(&t); > - if (!utm) > - break; > - *ptm = *utm; > - return 0; > + goto localise; > } > #endif > return 1; > @@ -141,12 +135,12 @@ int FAST_FUNC parse_datestr(const char *date_str, > struct tm *ptm) > } else > #endif /* ENABLE_DESKTOP */ > if (date_str[0] == '@') { > - time_t t; > if (sizeof(t) <= sizeof(long)) > t = bb_strtol(date_str + 1, NULL, 10); > else /* time_t is 64 bits but longs are smaller */ > t = bb_strtoll(date_str + 1, NULL, 10); > if (!errno) { > + IF_FEATURE_TIMEZONE(localise:) > struct tm *lt = localtime(&t); > if (lt) { > *ptm = *lt; > -- > 2.31.1 > > _______________________________________________ > busybox mailing list > [email protected] > http://lists.busybox.net/mailman/listinfo/busybox _______________________________________________ busybox mailing list [email protected] http://lists.busybox.net/mailman/listinfo/busybox
