From owner-p4-projects@FreeBSD.ORG Sun Aug 10 11:11:43 2008 Return-Path: Delivered-To: p4-projects@freebsd.org Received: by hub.freebsd.org (Postfix, from userid 32767) id 868491065690; Sun, 10 Aug 2008 11:11:43 +0000 (UTC) Delivered-To: perforce@FreeBSD.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 4A89E1065674 for ; Sun, 10 Aug 2008 11:11:43 +0000 (UTC) (envelope-from strauss@FreeBSD.org) Received: from repoman.freebsd.org (repoman.freebsd.org [IPv6:2001:4f8:fff6::29]) by mx1.freebsd.org (Postfix) with ESMTP id 3EFDB8FC1A for ; Sun, 10 Aug 2008 11:11:43 +0000 (UTC) (envelope-from strauss@FreeBSD.org) Received: from repoman.freebsd.org (localhost [127.0.0.1]) by repoman.freebsd.org (8.14.2/8.14.2) with ESMTP id m7ABBgDE081941 for ; Sun, 10 Aug 2008 11:11:42 GMT (envelope-from strauss@FreeBSD.org) Received: (from perforce@localhost) by repoman.freebsd.org (8.14.2/8.14.1/Submit) id m7ABBaQf081935 for perforce@freebsd.org; Sun, 10 Aug 2008 11:11:36 GMT (envelope-from strauss@FreeBSD.org) Date: Sun, 10 Aug 2008 11:11:36 GMT Message-Id: <200808101111.m7ABBaQf081935@repoman.freebsd.org> X-Authentication-Warning: repoman.freebsd.org: perforce set sender to strauss@FreeBSD.org using -f From: Anselm Strauss To: Perforce Change Reviews Cc: Subject: PERFORCE change 147070 for review X-BeenThere: p4-projects@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: p4 projects tree changes List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 10 Aug 2008 11:11:44 -0000 http://perforce.freebsd.org/chv.cgi?CH=147070 Change 147070 by strauss@strauss_marvelman on 2008/08/10 11:10:45 Unix to DOS time conversion test. Affected files ... .. //depot/projects/soc2008/strauss_libarchive/libarchive/archive_write_set_format_zip.c#27 edit .. //depot/projects/soc2008/strauss_libarchive/libarchive/test/test_write_format_zip_no_compression.c#7 edit Differences ... ==== //depot/projects/soc2008/strauss_libarchive/libarchive/archive_write_set_format_zip.c#27 (text+ko) ==== @@ -381,7 +381,9 @@ struct tm *time; unsigned int dos_time; - time = gmtime(&unix_time); + /* This will not preserve time when creating/extracting the archive + * on two systems with different time zones. */ + time = localtime(&unix_time); dos_time = 0; dos_time += ((time->tm_year - 80) & 0x7f) << 9; @@ -390,10 +392,7 @@ dos_time <<= 16; dos_time += (time->tm_hour & 0x1f) << 11; dos_time += (time->tm_min & 0x3f) << 5; - dos_time += (time->tm_sec & 0x3e) >> 1; /* Only counting every 2 seconds -> [0..30], right? */ - - /* free(time); */ - /* TODO: Getting error when freeing the struct, why? */ + dos_time += (time->tm_sec & 0x3e) >> 1; /* Only counting every 2 seconds. */ return dos_time; } ==== //depot/projects/soc2008/strauss_libarchive/libarchive/test/test_write_format_zip_no_compression.c#7 (text+ko) ==== @@ -18,6 +18,8 @@ const char *p, *q, *buffend; size_t used; int crc; + const time_t t = time(NULL); + struct tm *tm = localtime(&t); /* Create new ZIP archive in memory without padding. */ assert((a = archive_write_new()) != NULL); @@ -39,6 +41,7 @@ archive_entry_set_dev(entry, 12); archive_entry_set_ino(entry, 89); archive_entry_set_nlink(entry, 1); + archive_entry_set_mtime(entry, t, 0); assertEqualIntA(a, 0, archive_write_header(a, entry)); assertEqualIntA(a, sizeof(data1), archive_write_data(a, data1, sizeof(data1))); assertEqualIntA(a, sizeof(data2), archive_write_data(a, data2, sizeof(data2))); @@ -81,8 +84,8 @@ /* assertEqualInt(i2(p + 6), XXXX); */ /* Version needed to extract */ /* assertEqualInt(i2(p + 8), XXXX); */ /* Flags */ /* assertEqualInt(i2(p + 10), XXXX); */ /* Compression method */ - /* assertEqualInt(i2(p + 12), XXXX); */ /* File time */ - /* assertEqualInt(i2(p + 14), XXXX); */ /* File date */ + assertEqualInt(i2(p + 12), (tm->tm_hour * 2048) + (tm->tm_min * 32) + (tm->tm_sec / 2)); /* File time */ + assertEqualInt(i2(p + 14), ((tm->tm_year - 80) * 512) + ((tm->tm_mon + 1) * 32) + tm->tm_mday); /* File date */ crc = crc32(0, &data1, sizeof(data1)); crc = crc32(crc, &data2, sizeof(data2)); assertEqualInt(i4(p + 16), crc); /* CRC-32 */