Merge "Upgrade bionic to tzdata2014f." into lmp-dev
diff --git a/libc/tools/zoneinfo/ZoneCompactor.java b/libc/tools/zoneinfo/ZoneCompactor.java
index f47afd1..bf3153e 100644
--- a/libc/tools/zoneinfo/ZoneCompactor.java
+++ b/libc/tools/zoneinfo/ZoneCompactor.java
@@ -1,9 +1,6 @@
 
 import java.io.*;
-import java.nio.ByteOrder;
 import java.util.*;
-import libcore.io.BufferIterator;
-import libcore.util.ZoneInfo;
 
 // usage: java ZoneCompiler <setup file> <data directory> <output directory> <tzdata version>
 //
@@ -27,66 +24,20 @@
 //
 
 public class ZoneCompactor {
-  public static class ByteArrayBufferIteratorBE extends BufferIterator {
-    private final byte[] bytes;
-    private int offset = 0;
-
-    public ByteArrayBufferIteratorBE(byte[] bytes) {
-      this.bytes = bytes;
-      this.offset = 0;
-    }
-
-    public void seek(int offset) {
-      this.offset = offset;
-    }
-
-    public void skip(int byteCount) {
-      this.offset += byteCount;
-    }
-
-    public void readByteArray(byte[] dst, int dstOffset, int byteCount) {
-      System.arraycopy(bytes, offset, dst, dstOffset, byteCount);
-      offset += byteCount;
-    }
-
-    public byte readByte() {
-      return bytes[offset++];
-    }
-
-    public int readInt() {
-      return ((readByte() & 0xff) << 24) | ((readByte() & 0xff) << 16) | ((readByte() & 0xff) << 8) | (readByte() & 0xff);
-    }
-
-    public void readIntArray(int[] dst, int dstOffset, int intCount) {
-      for (int i = 0; i < intCount; ++i) {
-        dst[dstOffset++] = readInt();
-      }
-    }
-
-    public short readShort() {
-      throw new UnsupportedOperationException();
-    }
-  }
-
-  // Maximum number of characters in a zone name, including '\0' terminator
+  // Maximum number of characters in a zone name, including '\0' terminator.
   private static final int MAXNAME = 40;
 
-  // Zone name synonyms
+  // Zone name synonyms.
   private Map<String,String> links = new HashMap<String,String>();
 
-  // File starting bytes by zone name
-  private Map<String,Integer> starts = new HashMap<String,Integer>();
+  // File offsets by zone name.
+  private Map<String,Integer> offsets = new HashMap<String,Integer>();
 
-  // File lengths by zone name
+  // File lengths by zone name.
   private Map<String,Integer> lengths = new HashMap<String,Integer>();
 
-  // Raw GMT offsets by zone name
-  private Map<String,Integer> offsets = new HashMap<String,Integer>();
-  private int start = 0;
-
-  // Concatenate the contents of 'inFile' onto 'out'
-  // and return the contents as a byte array.
-  private static byte[] copyFile(File inFile, OutputStream out) throws Exception {
+  // Concatenate the contents of 'inFile' onto 'out'.
+  private static void copyFile(File inFile, OutputStream out) throws Exception {
     byte[] ret = new byte[0];
 
     InputStream in = new FileInputStream(inFile);
@@ -104,14 +55,14 @@
       ret = nret;
     }
     out.flush();
-    return ret;
   }
 
   public ZoneCompactor(String setupFile, String dataDirectory, String zoneTabFile, String outputDirectory, String version) throws Exception {
-    // Read the setup file, and concatenate all the data.
+    // Read the setup file and concatenate all the data.
     ByteArrayOutputStream allData = new ByteArrayOutputStream();
     BufferedReader reader = new BufferedReader(new FileReader(setupFile));
     String s;
+    int offset = 0;
     while ((s = reader.readLine()) != null) {
       s = s.trim();
       if (s.startsWith("Link")) {
@@ -125,16 +76,11 @@
         if (link == null) {
           File sourceFile = new File(dataDirectory, s);
           long length = sourceFile.length();
-          starts.put(s, start);
+          offsets.put(s, offset);
           lengths.put(s, (int) length);
 
-          start += length;
-          byte[] data = copyFile(sourceFile, allData);
-
-          BufferIterator it = new ByteArrayBufferIteratorBE(data);
-          TimeZone tz = ZoneInfo.makeTimeZone(s, it);
-          int gmtOffset = tz.getRawOffset();
-          offsets.put(s, gmtOffset);
+          offset += length;
+          copyFile(sourceFile, allData);
         }
       }
     }
@@ -146,9 +92,8 @@
       String from = it.next();
       String to = links.get(from);
 
-      starts.put(from, starts.get(to));
-      lengths.put(from, lengths.get(to));
       offsets.put(from, offsets.get(to));
+      lengths.put(from, lengths.get(to));
     }
 
     // Create/truncate the destination file.
@@ -178,7 +123,7 @@
 
     // Write the index.
     ArrayList<String> sortedOlsonIds = new ArrayList<String>();
-    sortedOlsonIds.addAll(starts.keySet());
+    sortedOlsonIds.addAll(offsets.keySet());
     Collections.sort(sortedOlsonIds);
     it = sortedOlsonIds.iterator();
     while (it.hasNext()) {
@@ -188,9 +133,9 @@
       }
 
       f.write(toAscii(new byte[MAXNAME], zoneName));
-      f.writeInt(starts.get(zoneName));
-      f.writeInt(lengths.get(zoneName));
       f.writeInt(offsets.get(zoneName));
+      f.writeInt(lengths.get(zoneName));
+      f.writeInt(0); // Used to be raw GMT offset. No longer used.
     }
 
     int data_offset = (int) f.getFilePointer();
diff --git a/libc/tools/zoneinfo/update-tzdata.py b/libc/tools/zoneinfo/update-tzdata.py
index 6b69a5a..e800e8f 100755
--- a/libc/tools/zoneinfo/update-tzdata.py
+++ b/libc/tools/zoneinfo/update-tzdata.py
@@ -115,7 +115,7 @@
   print 'Configuring ICU tools...'
   subprocess.check_call(['%s/runConfigureICU' % icu_dir, 'Linux'])
   print 'Making ICU tools...'
-  subprocess.check_call(['make', '-j6'])
+  subprocess.check_call(['make', '-j32'])
 
   # Run the ICU tools.
   os.chdir('tools/tzcode')
@@ -169,11 +169,8 @@
   WriteSetupFile()
 
   print 'Calling ZoneCompactor to update bionic to %s...' % new_version
-  libcore_src_dir = '%s/../libcore/luni/src/main/java/' % bionic_dir
   subprocess.check_call(['javac', '-d', '.',
-                         '%s/ZoneCompactor.java' % bionic_libc_tools_zoneinfo_dir,
-                         '%s/libcore/util/ZoneInfo.java' % libcore_src_dir,
-                         '%s/libcore/io/BufferIterator.java' % libcore_src_dir])
+                         '%s/ZoneCompactor.java' % bionic_libc_tools_zoneinfo_dir])
   subprocess.check_call(['java', 'ZoneCompactor',
                          'setup', 'data', 'extracted/zone.tab',
                          bionic_libc_zoneinfo_dir, new_version])
diff --git a/libc/tzcode/localtime.c b/libc/tzcode/localtime.c
index 5e4e962..3bbed90 100644
--- a/libc/tzcode/localtime.c
+++ b/libc/tzcode/localtime.c
@@ -2210,7 +2210,7 @@
     char buf[NAME_LENGTH];
     int32_t start;
     int32_t length;
-    int32_t raw_gmt_offset;
+    int32_t unused; // Was raw GMT offset; always 0 since tzdata2014f (L).
   };
 
   size_t id_count = (ntohl(header.data_offset) - ntohl(header.index_offset)) / sizeof(struct index_entry_t);