7144063: [macosx] Swing JMenu mnemonic doesn't work; hint misleading; cross symbol typed
authorkizune
Wed, 21 Mar 2012 17:12:31 +0400
changeset 12178 6b681d75ebe5
parent 12177 7b84ed7d0efa
child 12179 8c73ea088862
child 12278 f3519c549711
child 12288 30d13a7dd03f
7144063: [macosx] Swing JMenu mnemonic doesn't work; hint misleading; cross symbol typed Reviewed-by: leonidr, skovatch, swingler
jdk/src/macosx/native/sun/awt/AWTView.m
jdk/src/macosx/native/sun/awt/OSVersion.m
--- a/jdk/src/macosx/native/sun/awt/AWTView.m	Wed Mar 21 15:25:12 2012 +0400
+++ b/jdk/src/macosx/native/sun/awt/AWTView.m	Wed Mar 21 17:12:31 2012 +0400
@@ -812,7 +812,7 @@
     // Unicode value.
     NSUInteger utf8Length = [aString lengthOfBytesUsingEncoding:NSUTF8StringEncoding];
 
-    if ([self hasMarkedText] || !fProcessingKeystroke || (utf8Length > 2)) {
+    if ([self hasMarkedText] || !fProcessingKeystroke || (utf8Length > 1)) {
         JNIEnv *env = [ThreadUtilities getJNIEnv];
 
         static JNF_MEMBER_CACHE(jm_selectPreviousGlyph, jc_CInputMethod, "selectPreviousGlyph", "()V");
--- a/jdk/src/macosx/native/sun/awt/OSVersion.m	Wed Mar 21 15:25:12 2012 +0400
+++ b/jdk/src/macosx/native/sun/awt/OSVersion.m	Wed Mar 21 17:12:31 2012 +0400
@@ -31,33 +31,31 @@
 #import <JavaRuntimeSupport/JavaRuntimeSupport.h>
 
 
-// returns 10.7 for Lion, 10.6 for SnowLeopard etc.
-double getOSXMajorVersion() {
-    char *version = JRSCopyOSVersion();
-
-    if (version == NULL) return 0.0;
-
-    char temp[32];
-    strlcpy(temp, version, sizeof(temp));
-    free(version);
-
-    if (strlen(temp) < 3) {
-        return 0.0;
+// returns 107 for Lion, 106 for SnowLeopard etc.
+int getOSXMajorVersion() {
+    char *ver = JRSCopyOSVersion();
+    if (ver == NULL) { 
+        return 0;
     }
 
-    if (temp[2] != '.')  { // Third char must be a '.'
-        return 0.0;
+    int len = strlen(ver);
+    int v = 0;
+    
+    // Third char must be a '.'    
+    if (len >= 3 && ver[2] == '.') {
+        int i;
+        
+        v = (ver[0] - '0') * 10 + (ver[1] - '0');
+        for (i = 3; i < len && isdigit(ver[i]); ++i) {
+            v = v * 10 + (ver[i] - '0');
+        }
     }
 
-    char *ptr = strchr(temp+3, '.'); // remove the second . if one exists.
-    if (ptr != NULL) {
-        *ptr = 0;
-    }
-
-    return atof(temp);
+    free(ver);
+    
+    return v;
 }
 
-
 BOOL isSnowLeopardOrLower() {
-    return (getOSXMajorVersion() < 10.7);
+    return (getOSXMajorVersion() < 107);
 }