Merge "Only add spaces automatically when appropriate." into jb-mr1.1-dev
diff --git a/java/res/xml/method.xml b/java/res/xml/method.xml
index 3d360a8..0387071 100644
--- a/java/res/xml/method.xml
+++ b/java/res/xml/method.xml
@@ -36,6 +36,7 @@
     en_GB: English Great Britain/qwerty
     eo: Esperanto/spanish
     es: Spanish/spanish
+    es_US: Spanish United States/spanish
     et: Estonian/nordic
     fa: Persian/arabic
     fi: Finnish/nordic
@@ -184,6 +185,13 @@
     />
     <subtype android:icon="@drawable/ic_subtype_keyboard"
             android:label="@string/subtype_generic"
+            android:subtypeId="-2066550842"
+            android:imeSubtypeLocale="es_US"
+            android:imeSubtypeMode="keyboard"
+            android:imeSubtypeExtraValue="KeyboardLayoutSet=spanish,AsciiCapable"
+    />
+    <subtype android:icon="@drawable/ic_subtype_keyboard"
+            android:label="@string/subtype_generic"
             android:subtypeId="-332580523"
             android:imeSubtypeLocale="et"
             android:imeSubtypeMode="keyboard"
diff --git a/java/src/com/android/inputmethod/latin/AdditionalSubtypeSettings.java b/java/src/com/android/inputmethod/latin/AdditionalSubtypeSettings.java
index d126077..9394518 100644
--- a/java/src/com/android/inputmethod/latin/AdditionalSubtypeSettings.java
+++ b/java/src/com/android/inputmethod/latin/AdditionalSubtypeSettings.java
@@ -85,6 +85,9 @@
     }
 
     static final class SubtypeLocaleAdapter extends ArrayAdapter<SubtypeLocaleItem> {
+        private static final String TAG = SubtypeLocaleAdapter.class.getSimpleName();
+        private static final boolean DEBUG_SUBTYPE_ID = false;
+
         public SubtypeLocaleAdapter(final Context context) {
             super(context, android.R.layout.simple_spinner_item);
             setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
@@ -94,6 +97,11 @@
             final int count = imi.getSubtypeCount();
             for (int i = 0; i < count; i++) {
                 final InputMethodSubtype subtype = imi.getSubtypeAt(i);
+                if (DEBUG_SUBTYPE_ID) {
+                    android.util.Log.d(TAG, String.format("%-6s 0x%08x %11d %s",
+                            subtype.getLocale(), subtype.hashCode(), subtype.hashCode(),
+                            SubtypeLocale.getSubtypeDisplayName(subtype, context.getResources())));
+                }
                 if (subtype.containsExtraValueKey(ASCII_CAPABLE)) {
                     items.add(createItem(context, subtype.getLocale()));
                 }
diff --git a/native/jni/src/defines.h b/native/jni/src/defines.h
index ea0f0ef..e06ee42 100644
--- a/native/jni/src/defines.h
+++ b/native/jni/src/defines.h
@@ -250,6 +250,12 @@
 #ifndef S_INT_MAX
 #define S_INT_MAX 2147483647 // ((1 << 31) - 1)
 #endif
+#ifndef S_INT_MIN
+// The literal constant -2147483648 does not work in C prior C90, because
+// the compiler tries to fit the positive number into an int and then negate it.
+// GCC warns about this.
+#define S_INT_MIN (-2147483647 - 1) // -(1 << 31)
+#endif
 
 // Define this to use mmap() for dictionary loading.  Undefine to use malloc() instead of mmap().
 // We measured and compared performance of both, and found mmap() is fairly good in terms of