From bc7c14e0408665addd01b978b1950963b1ed799f Mon Sep 17 00:00:00 2001 From: Theodore Ts'o Date: Sat, 3 May 2003 16:40:09 -0400 Subject: [PATCH] tune2fs.c (parse_time): Add portability code to work around lack of strptime(). --- misc/ChangeLog | 3 +++ misc/tune2fs.c | 11 +++++++++++ 2 files changed, 14 insertions(+) diff --git a/misc/ChangeLog b/misc/ChangeLog index e32fa8b..83fc2c6 100644 --- a/misc/ChangeLog +++ b/misc/ChangeLog @@ -1,5 +1,8 @@ 2003-05-03 Theodore Ts'o + * tune2fs.c (parse_time): Add portability code to work around lack + of strptime(). + * Makefile.in: Add $(LIBINTL) to the link line so we can support using the internal gettext library. diff --git a/misc/tune2fs.c b/misc/tune2fs.c index 818c8a1..229b6e7 100644 --- a/misc/tune2fs.c +++ b/misc/tune2fs.c @@ -443,7 +443,18 @@ static time_t parse_time(char *str) return (time(0)); } memset(&ts, 0, sizeof(ts)); +#ifdef HAVE_STRPTIME strptime(optarg, "%Y%m%d%H%M%S", &ts); +#else + sscanf(optarg, "%4d%2d%2d%2d%2d%2d", &ts.tm_year, &ts.tm_mon, + &ts.tm_mday, &ts.tm_hour, &ts.tm_min, &ts.tm_sec); + ts.tm_year -= 1900; + ts.tm_mon -= 1; + if (ts.tm_year < 0 || ts.tm_mon < 0 || ts.tm_mon > 11 || + ts.tm_mday < 0 || ts.tm_mday > 31 || ts.tm_hour > 23 || + ts.tm_min > 59 || ts.tm_sec > 61) + ts.tm_mday = 0; +#endif if (ts.tm_mday == 0) { com_err(program_name, 0, _("Couldn't parse date/time specifier: %s"), -- 1.8.3.1