aboutsummaryrefslogtreecommitdiff
path: root/fastjar
diff options
context:
space:
mode:
authorTom Tromey <tromey@redhat.com>2002-11-11 22:20:56 +0000
committerTom Tromey <tromey@gcc.gnu.org>2002-11-11 22:20:56 +0000
commit90e76e864a228ac5cb306aa33f5716913fab061a (patch)
tree7ede7b92af25472f234c9fbc72532e09c8aadda5 /fastjar
parent303b90b00106ed64c731827336490830ebf6ca4a (diff)
downloadgcc-90e76e864a228ac5cb306aa33f5716913fab061a.zip
gcc-90e76e864a228ac5cb306aa33f5716913fab061a.tar.gz
gcc-90e76e864a228ac5cb306aa33f5716913fab061a.tar.bz2
dostime.c (dos2unixtime): Mask for seconds is 0x1f.
* dostime.c (dos2unixtime): Mask for seconds is 0x1f. Correctly compute month. (unix2dostime): Handle years before 1980. Correctly compute month and day of month. From-SVN: r59027
Diffstat (limited to 'fastjar')
-rw-r--r--fastjar/ChangeLog7
-rw-r--r--fastjar/dostime.c13
2 files changed, 15 insertions, 5 deletions
diff --git a/fastjar/ChangeLog b/fastjar/ChangeLog
index 4567ee3..5adc87d 100644
--- a/fastjar/ChangeLog
+++ b/fastjar/ChangeLog
@@ -1,3 +1,10 @@
+2002-11-11 Tom Tromey <tromey@redhat.com>
+
+ * dostime.c (dos2unixtime): Mask for seconds is 0x1f. Correctly
+ compute month.
+ (unix2dostime): Handle years before 1980. Correctly compute month
+ and day of month.
+
2002-11-10 Jakub Jelinek <jakub@redhat.com>
* jartool.c (add_to_jar): Only compare file to jarfile if jarfile is
diff --git a/fastjar/dostime.c b/fastjar/dostime.c
index b3c76e5..5117a82 100644
--- a/fastjar/dostime.c
+++ b/fastjar/dostime.c
@@ -49,11 +49,11 @@ dos2unixtime (unsigned long dostime)
ltime = *localtime (&now);
ltime.tm_year = (dostime >> 25) + 80;
- ltime.tm_mon = 1 + ((dostime >> 21) & 0x0f);
+ ltime.tm_mon = ((dostime >> 21) & 0x0f) - 1;
ltime.tm_mday = (dostime >> 16) & 0x1f;
ltime.tm_hour = (dostime >> 11) & 0x0f;
ltime.tm_min = (dostime >> 5) & 0x3f;
- ltime.tm_sec = (dostime & 0x0f) << 1;
+ ltime.tm_sec = (dostime & 0x1f) << 1;
ltime.tm_wday = -1;
ltime.tm_yday = -1;
@@ -66,10 +66,13 @@ unsigned long
unix2dostime (time_t *time)
{
struct tm *ltime = localtime (time);
+ int year = ltime->tm_year - 80;
+ if (year < 0)
+ year = 0;
- return ((ltime->tm_year - 80) << 25
- | ltime->tm_mon << 21
- | (ltime->tm_mday - 1) << 16
+ return (year << 25
+ | (ltime->tm_mon + 1) << 21
+ | ltime->tm_mday << 16
| ltime->tm_hour << 11
| ltime->tm_min << 5
| ltime->tm_sec >> 1);