Fix to get application name correctly. Was dropping argument
authorAlexandra Ellwood <lxs@mit.edu>
Thu, 2 Oct 2008 19:12:59 +0000 (19:12 +0000)
committerAlexandra Ellwood <lxs@mit.edu>
Thu, 2 Oct 2008 19:12:59 +0000 (19:12 +0000)
from launchservices and not removing extension from path in
fallback code.

ticket: 6055

git-svn-id: svn://anonsvn.mit.edu/krb5/trunk@20814 dc483132-0cff-0310-8789-dd5450dbe970

src/kim/lib/mac/kim_os_library.c

index ecac38ca30798c81a018fe29b303a26d712cf1d2..b0781bbf219db05cb9cdde8fc5f79be1f0959e78 100644 (file)
@@ -237,14 +237,16 @@ kim_error kim_os_library_get_caller_name (kim_string *out_application_name)
         
         if (bundle_url) {
             err = LSCopyDisplayNameForURL (bundle_url, &cfname);
+            check_error (err);
         }
         
         if (bundle_url) { CFRelease (bundle_url); }
     }
     
-    if (!err && !name) {
+    if (!err && !cfname) {
         kim_string path = NULL;
         CFURLRef cfpath = NULL;
+        CFURLRef cfpathnoext = NULL;
         
         err = kim_os_library_get_application_path (&path);
         
@@ -253,12 +255,21 @@ kim_error kim_os_library_get_caller_name (kim_string *out_application_name)
                                                               (const UInt8 *) path,
                                                               strlen (path),
                                                               0);
+            
             if (cfpath) {
+                cfpathnoext = CFURLCreateCopyDeletingPathExtension (kCFAllocatorDefault,
+                                                                    cfpath);
+            }
+            
+            if (cfpathnoext) {
+                cfname = CFURLCopyLastPathComponent (cfpathnoext);
+            } else {
                 cfname = CFURLCopyLastPathComponent (cfpath);
             }
         }
         
-        if (cfpath) { CFRelease (cfpath); }
+        if (cfpathnoext) { CFRelease (cfpathnoext); }
+        if (cfpath     ) { CFRelease (cfpath); }
     }
     
     if (!err && cfname) {