changeset 5236:9189ec1bb33a

7144063: [macosx] Swing JMenu mnemonic doesn't work; hint misleading; cross symbol typed Reviewed-by: leonidr, skovatch, swingler
author kizune
date Wed, 21 Mar 2012 17:12:31 +0400
parents 2dbcbe945cc3
children e7cc6c5a858c 100b6c2f75ba e0bf70361777
files src/macosx/native/sun/awt/AWTView.m src/macosx/native/sun/awt/OSVersion.m
diffstat 2 files changed, 21 insertions(+), 23 deletions(-) [+]
line wrap: on
line diff
--- a/src/macosx/native/sun/awt/AWTView.m	Wed Mar 21 15:25:12 2012 +0400
+++ b/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/src/macosx/native/sun/awt/OSVersion.m	Wed Mar 21 15:25:12 2012 +0400
+++ b/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);
 }