]> git.ipfire.org Git - thirdparty/libarchive.git/commitdiff
Reformat long calculation, make consistent across copies
authorTim Kientzle <kientzle@acm.org>
Sun, 22 Jun 2014 17:50:17 +0000 (10:50 -0700)
committerTim Kientzle <kientzle@acm.org>
Sun, 22 Jun 2014 17:50:17 +0000 (10:50 -0700)
libarchive/archive_read_support_format_iso9660.c
libarchive/archive_read_support_format_warc.c
libarchive/archive_read_support_format_xar.c

index 86d07fecbb5ead771cde7f1806b84d33f9049286..47268a2ab4a8dd135e236b3b6e3eab444b97a9cd 100644 (file)
@@ -3147,21 +3147,24 @@ static time_t
 time_from_tm(struct tm *t)
 {
 #if HAVE_TIMEGM
-       /* Use platform timegm() if available. */
-       return (timegm(t));
+        /* Use platform timegm() if available. */
+        return (timegm(t));
 #elif HAVE__MKGMTIME64
-       return (_mkgmtime64(t));
+        return (_mkgmtime64(t));
 #else
-       /* Else use direct calculation using POSIX assumptions. */
-       /* First, fix up tm_yday based on the year/month/day. */
-       if (mktime(t) == (time_t)-1)
-               return ((time_t)-1);
-       /* Then we can compute timegm() from first principles. */
-       return (t->tm_sec + t->tm_min * 60 + t->tm_hour * 3600
-           + t->tm_yday * 86400 + (t->tm_year - 70) * 31536000
-           + ((t->tm_year - 69) / 4) * 86400 -
-           ((t->tm_year - 1) / 100) * 86400
-           + ((t->tm_year + 299) / 400) * 86400);
+        /* Else use direct calculation using POSIX assumptions. */
+        /* First, fix up tm_yday based on the year/month/day. */
+        if (mktime(t) == (time_t)-1)
+                return ((time_t)-1);
+        /* Then we can compute timegm() from first principles. */
+        return (t->tm_sec
+            + t->tm_min * 60
+            + t->tm_hour * 3600
+            + t->tm_yday * 86400
+            + (t->tm_year - 70) * 31536000
+            + ((t->tm_year - 69) / 4) * 86400
+            - ((t->tm_year - 1) / 100) * 86400
+            + ((t->tm_year + 299) / 400) * 86400);
 #endif
 }
 
index aa5045a368c99a734a2347a395e8efad9b2435bd..cfedb3b2d5099978dbc31e18ef8ea9f1236a3cf6 100644 (file)
@@ -509,10 +509,13 @@ time_from_tm(struct tm *t)
         if (mktime(t) == (time_t)-1)
                 return ((time_t)-1);
         /* Then we can compute timegm() from first principles. */
-        return (t->tm_sec + t->tm_min * 60 + t->tm_hour * 3600
-            + t->tm_yday * 86400 + (t->tm_year - 70) * 31536000
-            + ((t->tm_year - 69) / 4) * 86400 -
-            ((t->tm_year - 1) / 100) * 86400
+        return (t->tm_sec
+            + t->tm_min * 60
+            + t->tm_hour * 3600
+            + t->tm_yday * 86400
+            + (t->tm_year - 70) * 31536000
+            + ((t->tm_year - 69) / 4) * 86400
+            - ((t->tm_year - 1) / 100) * 86400
             + ((t->tm_year + 299) / 400) * 86400);
 #endif
 }
index b0f5352212a8fc0b6ded91f59a433f9844cf487f..ba1be8d2f5b8ddb31b0c11a0f50c67251d27673a 100644 (file)
@@ -1107,20 +1107,23 @@ static time_t
 time_from_tm(struct tm *t)
 {
 #if HAVE_TIMEGM
-       /* Use platform timegm() if available. */
-       return (timegm(t));
+        /* Use platform timegm() if available. */
+        return (timegm(t));
 #elif HAVE__MKGMTIME64
-       return (_mkgmtime64(t));
+        return (_mkgmtime64(t));
 #else
-       /* Else use direct calculation using POSIX assumptions. */
-       /* First, fix up tm_yday based on the year/month/day. */
-       mktime(t);
-       /* Then we can compute timegm() from first principles. */
-       return (t->tm_sec + t->tm_min * 60 + t->tm_hour * 3600
-           + t->tm_yday * 86400 + (t->tm_year - 70) * 31536000
-           + ((t->tm_year - 69) / 4) * 86400 -
-           ((t->tm_year - 1) / 100) * 86400
-           + ((t->tm_year + 299) / 400) * 86400);
+        /* Else use direct calculation using POSIX assumptions. */
+        /* First, fix up tm_yday based on the year/month/day. */
+        mktime(t);
+        /* Then we can compute timegm() from first principles. */
+        return (t->tm_sec
+            + t->tm_min * 60
+            + t->tm_hour * 3600
+            + t->tm_yday * 86400
+            + (t->tm_year - 70) * 31536000
+            + ((t->tm_year - 69) / 4) * 86400
+            - ((t->tm_year - 1) / 100) * 86400
+            + ((t->tm_year + 299) / 400) * 86400);
 #endif
 }