emacs-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Emacs-diffs] /srv/bzr/emacs/trunk r102732: For nextstep: Handle bad utf


From: Jan D.
Subject: [Emacs-diffs] /srv/bzr/emacs/trunk r102732: For nextstep: Handle bad utf-8 in buffer name, always use buffer name for title.
Date: Fri, 31 Dec 2010 14:16:16 +0100
User-agent: Bazaar (2.0.3)

------------------------------------------------------------
revno: 102732
committer: Jan D. <address@hidden>
branch nick: trunk
timestamp: Fri 2010-12-31 14:16:16 +0100
message:
  For nextstep: Handle bad utf-8 in buffer name, always use buffer name for 
title.
  
  * nsfns.m (ns_set_name_as_filename): Always use buffer name for
  title and buffer filename only for RepresentedFilename.
  Handle bad UTF-8 in buffer name.
modified:
  src/ChangeLog
  src/nsfns.m
=== modified file 'src/ChangeLog'
--- a/src/ChangeLog     2010-12-30 11:30:55 +0000
+++ b/src/ChangeLog     2010-12-31 13:16:16 +0000
@@ -1,3 +1,9 @@
+2010-12-31  Jan Djärv  <address@hidden>
+
+       * nsfns.m (ns_set_name_as_filename): Always use buffer name for
+       title and buffer filename only for RepresentedFilename.
+       Handle bad UTF-8 in buffer name (Bug#7517).
+
 2010-12-30  Jan Djärv  <address@hidden>
 
        * coding.h (ENCODE_UTF_8): Remove "Used by ..." comment.

=== modified file 'src/nsfns.m'
--- a/src/nsfns.m       2010-12-30 11:30:55 +0000
+++ b/src/nsfns.m       2010-12-31 13:16:16 +0000
@@ -602,12 +602,13 @@
 ns_set_name_as_filename (struct frame *f)
 {
   NSView *view;
-  Lisp_Object name;
+  Lisp_Object name, filename;
   Lisp_Object buf = XWINDOW (f->selected_window)->buffer;
   const char *title;
   NSAutoreleasePool *pool;
   struct gcpro gcpro1;
-  Lisp_Object encoded_name;
+  Lisp_Object encoded_name, encoded_filename;
+  NSString *str;
   NSTRACE (ns_set_name_as_filename);
 
   if (f->explicit_name || ! NILP (f->title) || ns_in_resize)
@@ -615,16 +616,16 @@
 
   BLOCK_INPUT;
   pool = [[NSAutoreleasePool alloc] init];
-  name = XBUFFER (buf)->filename;
-  if (NILP (name) || FRAME_ICONIFIED_P (f)) name = XBUFFER (buf)->name;
-
-  if (FRAME_ICONIFIED_P (f) && !NILP (f->icon_name))
-    name = f->icon_name;
+  filename = XBUFFER (buf)->filename;
+  name = XBUFFER (buf)->name;
 
   if (NILP (name))
-    name = build_string ([ns_app_name UTF8String]);
-  else
-    CHECK_STRING (name);
+    {
+      if (! NILP (filename))
+        name = Ffile_name_nondirectory (filename);
+      else
+        name = build_string ([ns_app_name UTF8String]);
+    }
 
   GCPRO1 (name);
   encoded_name = ENCODE_UTF_8 (name);
@@ -642,33 +643,39 @@
       return;
     }
 
-  if (! FRAME_ICONIFIED_P (f))
+  str = [NSString stringWithUTF8String: SDATA (encoded_name)];
+  if (str == nil) str = @"Bad coding";
+
+  if (FRAME_ICONIFIED_P (f))
+    [[view window] setMiniwindowTitle: str];
+  else 
     {
+      NSString *fstr;
+
+      if (! NILP (filename))
+        {
+          GCPRO1 (filename);
+          encoded_filename = ENCODE_UTF_8 (filename);
+          UNGCPRO;
+
+          fstr = [NSString stringWithUTF8String: SDATA (encoded_filename)];
+          if (fstr == nil) fstr = @"";
 #ifdef NS_IMPL_COCOA
-      /* work around a bug observed on 10.3 where
-         setTitleWithRepresentedFilename does not clear out previous state
-         if given filename does not exist */
-      NSString *str = [NSString stringWithUTF8String: SDATA (encoded_name)];
-      if (![[NSFileManager defaultManager] fileExistsAtPath: str])
-        {
-          [[view window] setTitleWithRepresentedFilename: @""];
-          [[view window] setTitle: str];
+          /* work around a bug observed on 10.3 and later where
+             setTitleWithRepresentedFilename does not clear out previous state
+             if given filename does not exist */
+          if (! [[NSFileManager defaultManager] fileExistsAtPath: fstr])
+            [[view window] setRepresentedFilename: @""];
+#endif
         }
       else
-        {
-          [[view window] setTitleWithRepresentedFilename: str];
-        }
-#else
-      [[view window] setTitleWithRepresentedFilename:
-                         [NSString stringWithUTF8String: SDATA 
(encoded_name)]];
-#endif
+        fstr = @"";
+
+      [[view window] setRepresentedFilename: fstr];
+      [[view window] setTitle: str];
       f->name = name;
     }
-  else
-    {
-      [[view window] setMiniwindowTitle:
-            [NSString stringWithUTF8String: SDATA (encoded_name)]];
-    }
+
   [pool release];
   UNBLOCK_INPUT;
 }


reply via email to

[Prev in Thread] Current Thread [Next in Thread]