static void maybe_set_utc(int opt)
{
if (opt & DATE_OPT_UTC)
- xputenv("TZ=UTC0");
+ xputenv((char*)"TZ=UTC0");
}
+int date_main(int argc, char **argv);
int date_main(int argc, char **argv)
{
time_t tm;
if (!isofmt_arg) {
ifmt = 0; /* default is date */
} else {
- const char * const isoformats[] =
- {"date", "hours", "minutes", "seconds"};
+ static const char * const isoformats[] =
+ { "date", "hours", "minutes", "seconds" };
for (ifmt = 0; ifmt < 4; ifmt++)
- if (!strcmp(isofmt_arg, isoformats[ifmt])) {
- break;
- }
- if (ifmt == 4) /* parse error */
- bb_show_usage();
+ if (!strcmp(isofmt_arg, isoformats[ifmt]))
+ goto found;
+ /* parse error */
+ bb_show_usage();
+ found: ;
}
}
date_fmt[i++] = '%';
date_fmt[i++] = 'S';
}
-format_utc:
+ format_utc:
date_fmt[i++] = '%';
date_fmt[i] = (opt & DATE_OPT_UTC) ? 'Z' : 'z';
}
} else if (opt & DATE_OPT_RFC2822) {
/* Undo busybox.c for date -R */
- setlocale(LC_TIME, "C");
+ if (ENABLE_LOCALE_SUPPORT)
+ setlocale(LC_TIME, "C");
strcpy(date_fmt, "%a, %d %b %Y %H:%M:%S ");
i = 22;
goto format_utc;
} else /* default case */
- date_fmt = "%a %b %e %H:%M:%S %Z %Y";
+ date_fmt = (char*)"%a %b %e %H:%M:%S %Z %Y";
}
if (*date_fmt == '\0') {
/* Handle special conversions */
if (strncmp(date_fmt, "%f", 2) == 0) {
- date_fmt = "%Y.%m.%d-%H:%M:%S";
+ date_fmt = (char*)"%Y.%m.%d-%H:%M:%S";
}
/* Generate output string */