Improve Scanner performance.

We really don't want to compute a new regular expression and compile
it into a new Pattern every time we call nextInt (and friends). Adding
a single-element cache (flushed if the Scanner's locale changes) makes
this 100x faster. There still exists a pathological case where you
switch back and forth between bases.

Also improve the documentation to make it clearer that you really don't
want to use this awful class anyway.

Also bring back a few more of the tests we lost in the gingerbread timeframe.

Bug: https://code.google.com/p/android/issues/detail?id=57050
Change-Id: Id6095682fb44abae2887dda29dd3d32ac777c68f
Remove HistoricalCharsetNames.

Bug: 3032697
Change-Id: Idbf92cded4a7c55b97ee558b0fa844237d262206
Simplify Character.UnicodeBlock.

Bug: 3484927
Change-Id: I6d2417e04fd65ee95160a54b08d7cd5210973354
Fix Selector to allow read and write at the same time.

Bug: https://code.google.com/p/android/issues/detail?id=57456
Change-Id: I29e6688aafce886803bbbd12793df3ab952459c8
Fix BIO_OutputStream::write to return the correct length.

This was leaving bad OpenSSL error states lying around for later
innocent calls to trip over.

Also clean up some of the other error reporting/handling.

Bug: 9822466
Bug: 10344304
Change-Id: I9e6d6fd9a6c5e466336217b47f45c211aff5555d
Fix all backwards (-1 == x) tests.

Change-Id: Idbee45f00da4e107fcdcf0b4c66f3a485c9e1972
Fix java.util.Scanner bugs.

Also improve the documentation for java.util.regex.Matcher and unify the Scanner tests.

Bug: 10310707
Bug: https://code.google.com/p/android/issues/detail?id=40555
Change-Id: I97bd8243845aaa31c084c8424eceb41bbcd8ebbd

Conflicts:
	luni/src/test/java/libcore/java/util/OldScannerTest.java
Fix Fix all backwards (-1 == x) tests.

Change-Id: I37ea9729cca6324af44a7dd7358fe030c1fe2b21
Fix PriorityQueue.removeAt(.), call siftUp(.) if needed.

Bug: 10424240
Change-Id: I6bbe0bb4da008bc9b7c0b006985fa7d5631b094f
Reduce the upper bound on TimeZoneNames memory usage.

The cache had mistakenly been sized based on the number of time zones,
despite the fact that the keys are locales. We now have a lot of locales,
but the cache was still large enough to hold all of them, which wasn't
really the intent. I pulled the number 5 out of my ass.

I've also removed the "one big intern table" and now just do per-locale
deduplication. That avoids another potentially very large leak in an
ill-behaved program.

Also handle OOME in the native code better.

Change-Id: I9a07ad210469f064acde80f7d10ffb4b3a8f6443
Fix a bug in DateFormat, clean up some SimpleDateFormat tests.

We failed a couple of tests because of an assumption about the default
time zone:

  junit.framework.AssertionFailedError: Wrong format: " d" expected:  12 result:  11
  at java.text.SimpleDateFormatTest.test(SimpleDateFormatTest.java:55)
  at org.apache.harmony.tests.java.text.SimpleDateFormatTest.test_formatLjava_util_DateLjava_lang_StringBufferLjava_text_FieldPosition(SimpleDateFormatTest.java:347)

  junit.framework.AssertionFailedError: Wrong result: h input:  12 expected: Thu Jan 01 00:00:00 UTC 1970 result: Thu Jan 01 08:00:00 UTC 1970
  at java.text.SimpleDateFormatTest.parse(SimpleDateFormatTest.java:86)
  at org.apache.harmony.tests.java.text.SimpleDateFormatTest.test_parseLjava_lang_StringLjava_text_ParsePosition(SimpleDateFormatTest.java:546)

Cleaning up the tests and merging OldSimpleDateFormatTest into
SimpleDateFormatTest accidentally made one of our tests more
strict, at which point it failed because we weren't updating the
FieldPosition for 'z' or 'Z' when formatting or parsing. So this
patch fixes that by mapping the DateFormat.Field to the appropriate
int for Calendar.

Change-Id: If4b2f2c02d8ccd50d96d77df3b60e1c1d65ae666

Conflicts:
	harmony-tests/src/test/java/org/apache/harmony/tests/java/text/SimpleDateFormatTest.java
	luni/src/test/java/libcore/java/text/OldSimpleDateFormatTest.java
Use sk_FOO_pop_free instead of sk_FOO_free

The proper way to free a stack of owned "FOO" items is to use
sk_FOO_pop_free since that will iterate through all the FOO instances
in the stack and free them. Calling sk_FOO_free just frees the stack and
not the items.

(cherry picked from commit 64299318644c0c6b86992d414e68d0af236b52c5)

Bug: 10610037
Bug: http://code.google.com/p/android/issues/detail?id=59536
Change-Id: I8af603b10219acb476666e77cc776b6936a19f8d
If libcore wants ASCII casing, it needs to ask for it like everyone else.

http://elliotth.blogspot.com/2012/01/beware-convenience-methods.html

Bug: https://code.google.com/p/android/issues/detail?id=58359
Change-Id: I597b2ac940f17b5b2bc176e390dc4b63fe0a4e72

Conflicts:
	harmony-tests/src/test/java/org/apache/harmony/nio_char/tests/java/nio/charset/CharsetTest.java
Synchronize isClosed.

See https://github.com/square/okhttp/issues/151

Change-Id: I363343e94194668236ab92926883a094a81816d0
Automatically flush the cache when an edit is completed.

This will remove the need for applications to manually flush
the cache.

Change-Id: I6658634f2e6a333c486a5eb5144e7989d3c50be8
Fixed possible file handle leak

Change-Id: I05d57c626c34911d4992e87fed106e4bfe22e807