tune2fs.c (parse_time): Add portability code to work around lack

of strptime().
bitmap-optimize
Theodore Ts'o 2003-05-03 16:40:09 -04:00
parent 68dbdc2f1d
commit bc7c14e040
2 changed files with 14 additions and 0 deletions

View File

@ -1,5 +1,8 @@
2003-05-03 Theodore Ts'o <tytso@mit.edu>
* 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.

View File

@ -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"),