From caec5991567ba9546ca21b904b1a4824776a835c Mon Sep 17 00:00:00 2001
From: Erik Charlebois <erikc@ermac.local>
Date: Wed, 9 Sep 2009 00:24:37 -0700
Subject: [PATCH] Fix Emacs 64-bit on Snow Leopard.

---
 lib-src/ChangeLog  |    4 ++++
 lib-src/movemail.c |    2 +-
 src/ChangeLog      |   50 ++++++++++++++++++++++++++++++++++++++++++++++++++
 src/emacs.c        |    2 +-
 src/font.c         |   11 ++++++-----
 src/menu.c         |    2 +-
 src/nsfns.m        |    6 ++----
 src/nsfont.m       |   44 ++++++++++++++++++++++++++++++++------------
 src/nsgui.h        |   18 +++++++++++++++---
 src/nsimage.m      |    4 ++--
 src/nsmenu.m       |    6 +++---
 src/nsterm.h       |    7 +++++++
 src/nsterm.m       |   31 ++++++++++++++++++++++---------
 src/process.c      |    2 +-
 src/unexmacosx.c   |    4 ++--
 15 files changed, 149 insertions(+), 44 deletions(-)

diff --git a/lib-src/ChangeLog b/lib-src/ChangeLog
index 7970ee5..f2f9144 100644
--- a/lib-src/ChangeLog
+++ b/lib-src/ChangeLog
@@ -1,3 +1,7 @@
+2009-09-09  Erik Charlebois  <erikcharlebois@gmail.com>
+
+	* movemail.c (error): Change fprintf to fputs to fix warning.
+
 2009-09-09  Glenn Morris  <rgm@gnu.org>
 
 	* Makefile.in ($(DESTDIR)${archlibdir}): Set umask to world-readable
diff --git a/lib-src/movemail.c b/lib-src/movemail.c
index 732f8dd..2feaae8 100644
--- a/lib-src/movemail.c
+++ b/lib-src/movemail.c
@@ -622,7 +622,7 @@ error (s1, s2, s3)
   else if (s2)
     fprintf (stderr, s1, s2);
   else
-    fprintf (stderr, s1);
+    fputs (s1, stderr);
   fprintf (stderr, "\n");
 }
 
diff --git a/src/ChangeLog b/src/ChangeLog
index 52ee600..80c487a 100644
--- a/src/ChangeLog
+++ b/src/ChangeLog
@@ -1,3 +1,53 @@
+2009-09-09  Erik Charlebois  <erikcharlebois@gmail.com>
+
+	* emacs.c (main): Remove extra format specifier to fix warning.
+
+	* font.c (font_unparse_xlfd): Print EMACS_INT with %ld.
+	(font_unparse_fcname): Print EMACS_INT with %ld.
+
+	* menu.c (find_and_return_menu_selection): Fix truncation warning.
+
+	* nsfns.m (x-close-connection): Remove PSFlush call. Does not do anything
+	on Cocoa. Does not exist in 64-bit Cocoa.
+	(xw-color-values): Use CGFloat instead of float.
+
+	* nsfont.m (ns_char_width): Use sizeWithAttributes: instead of
+	widthOfString:, which does no exist in 64-bit Cocoa.
+	(ns_findfonts): Print EMACS_INT with %ld.
+	(nsfont_list_family): Print EMACS_INT with %ld.
+	(nsfont_open): Use Core Text for OS X 10.5 and later.
+	(nsfont_close): Release Core Text resource.
+	(ns_uni_to_glyphs): Use NSUInteger when calling Cocoa APIs.
+	(layoutOptions): Use NSUInteger in method signature.
+	(insertGlyphs): Use NSUIntger in method signature.
+	(setIntAttribute): Use NSInteger and NSUInteger in method signature.
+
+	* nsgui.h: Add typedefs for NSUInteger, NSInteger and CGFloat for
+	pre-10.5 OS X and GNUstep.
+
+	* nsimage.m (setXBMColor): Use CGFloat for calls to Cocoa.
+	(getPixelAtX): Use CGFloat for calls to Cocoa.
+
+	* nsmenu.m (addItemWithWidgetValue): Use NSInteger for call to Cocoa.
+	(fillWithWidgetValue): sizeToFit is deprecated (does nothing). Remove
+	call for OS X 10.5 and later.
+	(initWithContentRect): Use NSUInteger in method signature.
+
+	* nsterm.h: Use Core Text on OS X 10.5 and later.
+
+	* nsterm.m (mouseDown): Remove redundant leading 0s in format specifier.
+	(ns_query_color): Use CGFloat for calls to Cocoa.
+	(characterIndexForPoint): Use NUSInteger in method signature.
+	(draggingEntered): Use NSDragOperation in method signature.
+	(scrollerWidth): Use CGFloat in method signature.
+	(setPosition): Use setDoubleValue: and setKnobProportion: on 10.5 and
+	later since setFloatVAlue:knobProportion: is deprecated.
+	(mouseDown): Use %ld to print NSScrollerPart.
+
+	* process.c (list_processes_1): Use %ld to print EMACS_INT.
+
+	* unexmacosx.c (read_load_commands): Use %ld to print vm_address_t.
+
 2009-09-09  Stefan Monnier  <monnier@iro.umontreal.ca>
 
 	* keymap.c (where_is_internal): Filter out shadowed remappings.
diff --git a/src/emacs.c b/src/emacs.c
index 2c14be5..44ed9ce 100644
--- a/src/emacs.c
+++ b/src/emacs.c
@@ -1181,7 +1181,7 @@ main (int argc, char **argv)
             argv[skip_args] = fdStr;
 
             execv (argv[0], argv);
-            fprintf (stderr, "emacs daemon: exec failed: %d\t%d\n", errno);
+            fprintf (stderr, "emacs daemon: exec failed: %d\n", errno);
             exit (1);
           }
 
diff --git a/src/font.c b/src/font.c
index cfc4852..7571a00 100644
--- a/src/font.c
+++ b/src/font.c
@@ -1357,7 +1357,7 @@ font_unparse_xlfd (font, pixel_size, name, nbytes)
     {
       f[XLFD_AVGWIDTH_INDEX] = alloca (11);
       len += sprintf (f[XLFD_AVGWIDTH_INDEX],
-		      "%d", XINT (AREF (font, FONT_AVGWIDTH_INDEX))) + 1;
+		      "%ld", (long) XINT (AREF (font, FONT_AVGWIDTH_INDEX))) + 1;
     }
   else
     f[XLFD_AVGWIDTH_INDEX] = "*", len += 2;
@@ -1673,7 +1673,7 @@ font_unparse_fcname (font, pixel_size, name, nbytes)
     }
 
   if (INTEGERP (AREF (font, FONT_DPI_INDEX)))
-    len += sprintf (work, ":dpi=%d", XINT (AREF (font, FONT_DPI_INDEX)));
+    len += sprintf (work, ":dpi=%ld", (long) XINT (AREF (font, FONT_DPI_INDEX)));
   if (INTEGERP (AREF (font, FONT_SPACING_INDEX)))
     len += strlen (":spacing=100");
   if (INTEGERP (AREF (font, FONT_AVGWIDTH_INDEX)))
@@ -1686,7 +1686,7 @@ font_unparse_fcname (font, pixel_size, name, nbytes)
       if (STRINGP (val))
 	len += SBYTES (val);
       else if (INTEGERP (val))
-	len += sprintf (work, "%d", XINT (val));
+	len += sprintf (work, "%ld", (long) XINT (val));
       else if (SYMBOLP (val))
 	len += (NILP (val) ? 5 : 4); /* for "false" or "true" */
     }
@@ -1713,9 +1713,10 @@ font_unparse_fcname (font, pixel_size, name, nbytes)
       p += sprintf (p, ":%s=%s", style_names[i],
 		    SDATA (SYMBOL_NAME (styles[i])));
   if (INTEGERP (AREF (font, FONT_DPI_INDEX)))
-    p += sprintf (p, ":dpi=%d", XINT (AREF (font, FONT_DPI_INDEX)));
+    p += sprintf (p, ":dpi=%ld", (long) XINT (AREF (font, FONT_DPI_INDEX)));
   if (INTEGERP (AREF (font, FONT_SPACING_INDEX)))
-    p += sprintf (p, ":spacing=%d", XINT (AREF (font, FONT_SPACING_INDEX)));
+    p += sprintf (p, ":spacing=%ld",
+            (long) XINT (AREF (font, FONT_SPACING_INDEX)));
   if (INTEGERP (AREF (font, FONT_AVGWIDTH_INDEX)))
     {
       if (XINT (AREF (font, FONT_AVGWIDTH_INDEX)) == 0)
diff --git a/src/menu.c b/src/menu.c
index 940986f..23a7013 100644
--- a/src/menu.c
+++ b/src/menu.c
@@ -1005,7 +1005,7 @@ find_and_return_menu_selection (FRAME_PTR f, int keymaps, void *client_data)
         {
           entry
             = XVECTOR (menu_items)->contents[i + MENU_ITEMS_ITEM_VALUE];
-          if ((int) (EMACS_INT)client_data ==  (int)(&XVECTOR (menu_items)->contents[i]))
+          if ((EMACS_INT)client_data == (EMACS_INT)(&XVECTOR (menu_items)->contents[i]))
             {
               if (keymaps != 0)
                 {
diff --git a/src/nsfns.m b/src/nsfns.m
index 136ae03..8375109 100644
--- a/src/nsfns.m
+++ b/src/nsfns.m
@@ -1771,9 +1771,7 @@ The argument DISPLAY is currently ignored.  */)
      Lisp_Object display;
 {
   check_ns ();
-#ifdef NS_IMPL_COCOA
-  PSFlush ();
-#endif
+
   /*ns_delete_terminal (dpyinfo->terminal); */
   [NSApp terminate: NSApp];
   return Qnil;
@@ -2237,7 +2235,7 @@ DEFUN ("xw-color-values", Fxw_color_values, Sxw_color_values, 1, 2, 0,
      Lisp_Object color, frame;
 {
   NSColor * col;
-  float red, green, blue, alpha;
+  CGFloat red, green, blue, alpha;
 
   check_ns ();
   CHECK_STRING (color);
diff --git a/src/nsfont.m b/src/nsfont.m
index 46c50aa..c141fa4 100644
--- a/src/nsfont.m
+++ b/src/nsfont.m
@@ -245,7 +245,10 @@ ns_char_width (NSFont *sfont, int c)
 	    return w;
       }
 #endif
-    w = [sfont widthOfString: cstr];
+    NSDictionary *attrsDictionary =
+        [NSDictionary dictionaryWithObject: sfont
+                      forKey: NSFontAttributeName];
+    w = [cstr sizeWithAttributes: attrsDictionary].width;
     return max (w, 2.0);
 }
 
@@ -517,7 +520,8 @@ ns_findfonts (Lisp_Object font_spec, BOOL isMatch)
       return ns_fallback_entity ();
 
     if (NSFONT_TRACE)
-	fprintf (stderr, "    Returning %d entities.\n", XINT (Flength (list)));
+	fprintf (stderr, "    Returning %ld entities.\n",
+            (long) XINT (Flength (list)));
 
     return list;
 }
@@ -623,8 +627,8 @@ nsfont_list_family (Lisp_Object frame)
   /* FIXME: escape the name? */
 
   if (NSFONT_TRACE)
-    fprintf (stderr, "nsfont: list families returning %d entries\n",
-            XINT (Flength (list)));
+    fprintf (stderr, "nsfont: list families returning %ld entries\n",
+            (long) XINT (Flength (list)));
 
   return list;
 }
@@ -843,14 +847,27 @@ nsfont_open (FRAME_PTR f, Lisp_Object font_entity, int pixel_size)
                 ((CFStringRef)@"Monaco", kATSOptionFlagsDefault);
             }
         }
+
+#if MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_5
+      font_info->ctfont =
+          CTFontCreateWithPlatformFont (atsFont, 0.0f, NULL, NULL);
+      font_info->cgfont = CTFontCopyGraphicsFont (font_info->ctfont, NULL);
+#else
       font_info->cgfont = CGFontCreateWithPlatformFont ((void*)&atsFont);
+#endif
     }
 #endif
 
     /* set up metrics portion of font struct */
     font->ascent = [sfont ascender];
     font->descent = -[sfont descender];
-    font->min_width = [sfont widthOfString: @"|"]; /* FIXME */
+ 
+    /* FIXME */
+    NSDictionary *attrsDictionary =
+        [NSDictionary dictionaryWithObject: sfont
+                      forKey: NSFontAttributeName];
+    font->min_width = [@"|" sizeWithAttributes: attrsDictionary].width;
+
     font->space_width = lrint (ns_char_width (sfont, ' '));
     font->average_width = lrint (font_info->width);
     font->max_width = lrint (font_info->max_bounds.width);
@@ -888,6 +905,9 @@ nsfont_close (FRAME_PTR f, struct font *font)
   [font_info->nsfont release];
 #ifdef NS_IMPL_COCOA
   CGFontRelease (font_info->cgfont);
+#if MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_5
+  CFRelease (font_info->ctfont);
+#endif
 #endif
   xfree (font_info->name);
   xfree (font_info);
@@ -1308,7 +1328,7 @@ ns_uni_to_glyphs (struct nsfont_info *font_info, unsigned char block)
     NSGlyphGenerator *glyphGenerator = [NSGlyphGenerator sharedGlyphGenerator];
     /*NSCharacterSet *coveredChars = [nsfont coveredCharacterSet]; */
     unsigned int numGlyphs = [font_info->nsfont numberOfGlyphs];
-    unsigned int gInd =0, cInd =0;
+    NSUInteger gInd =0, cInd =0;
 
     [glyphStorage setString: allChars font: font_info->nsfont];
     [glyphGenerator generateGlyphsForGlyphStorage: glyphStorage
@@ -1439,7 +1459,7 @@ ns_glyph_metrics (struct nsfont_info *font_info, unsigned char block)
 }
 
 /* NSGlyphStorage protocol */
-- (unsigned int)layoutOptions
+- (NSUInteger)layoutOptions
 {
   return 0;
 }
@@ -1449,9 +1469,9 @@ ns_glyph_metrics (struct nsfont_info *font_info, unsigned char block)
   return attrStr;
 }
 
-- (void)insertGlyphs: (const NSGlyph *)glyphs length: (unsigned int)length
-        forStartingGlyphAtIndex: (unsigned int)glyphIndex
-        characterIndex: (unsigned int)charIndex
+- (void)insertGlyphs: (const NSGlyph *)glyphs length: (NSUInteger)length
+        forStartingGlyphAtIndex: (NSUInteger)glyphIndex
+        characterIndex: (NSUInteger)charIndex
 {
   len = glyphIndex+length;
   for (i =glyphIndex; i<len; i++)
@@ -1460,8 +1480,8 @@ ns_glyph_metrics (struct nsfont_info *font_info, unsigned char block)
     maxGlyph = len;
 }
 
-- (void)setIntAttribute: (int)attributeTag value: (int)val
-        forGlyphAtIndex: (unsigned)glyphIndex
+- (void)setIntAttribute: (NSInteger)attributeTag value: (NSInteger)val
+        forGlyphAtIndex: (NSUInteger)glyphIndex
 {
   return;
 }
diff --git a/src/nsgui.h b/src/nsgui.h
index 9bf6be6..5594b7b 100644
--- a/src/nsgui.h
+++ b/src/nsgui.h
@@ -128,13 +128,25 @@ typedef struct {
       unsigned width, height;
 } XRectangle;
 
+#if !defined(__OBJC__) || MAC_OS_X_VERSION_MAX_ALLOWED < MAC_OS_X_VERSION_10_5
+#ifdef _LP64
+typedef unsigned long NSUInteger;
+typedef long NSInteger;
+typedef double CGFloat;
+#else
+typedef unsigned int NSUInteger;
+typedef int NSInteger;
+typedef float CGFloat;
+#endif
+#endif
+
 #ifndef __OBJC__
-typedef struct _NSPoint { float x, y; } NSPoint;
-typedef struct _NSSize  { float width, height; } NSSize;
+typedef struct _NSPoint { CGFloat x, y; } NSPoint;
+typedef struct _NSSize  { CGFloat width, height; } NSSize;
 typedef struct _NSRect  { NSPoint origin; NSSize size; } NSRect;
 #endif
 
-#define NativeRectangle struct _NSRect
+#define NativeRectangle NSRect
 
 #define CONVERT_TO_XRECT(xr, nr)		\
   ((xr).x     = (nr).origin.x,			\
diff --git a/src/nsimage.m b/src/nsimage.m
index 9ef7ad3..87499b0 100644
--- a/src/nsimage.m
+++ b/src/nsimage.m
@@ -329,7 +329,7 @@ static EmacsImage *ImageList = nil;
   NSSize s = [self size];
   int len = (int) s.width * s.height;
   unsigned char *planes[5];
-  float r, g, b, a;
+  CGFloat r, g, b, a;
   NSColor *rgbColor;
 
   if (bmRep == nil || color == nil)
@@ -431,7 +431,7 @@ static EmacsImage *ImageList = nil;
   else if (onTiger)
     {
       NSColor *color = [bmRep colorAtX: x y: y];
-      float r, g, b, a;
+      CGFloat r, g, b, a;
       [color getRed: &r green: &g blue: &b alpha: &a];
       return ((int)(a * 255.0) << 24)
         | ((int)(r * 255.0) << 16) | ((int)(g * 255.0) << 8)
diff --git a/src/nsmenu.m b/src/nsmenu.m
index 0518466..e8549b4 100644
--- a/src/nsmenu.m
+++ b/src/nsmenu.m
@@ -656,7 +656,7 @@ name_is_separator (name)
       else
         [item setState: NSOffState];
 
-      [item setTag: (int)wv->call_data];
+      [item setTag: (NSInteger)wv->call_data];
     }
 
   return item;
@@ -708,7 +708,7 @@ name_is_separator (name)
 #ifdef NS_IMPL_GNUSTEP
   if ([[self window] isVisible])
     [self sizeToFit];
-#else
+#elif MAC_OS_X_VERSION_MAX_ALLOWED < MAC_OS_X_VERSION_10_5
   if ([self supermenu] == nil)
     [self sizeToFit];
 #endif
@@ -1611,7 +1611,7 @@ ns_popup_dialog (Lisp_Object position, Lisp_Object contents, Lisp_Object header)
 #define TEXTHEIGHT	20.0
 #define MINCELLWIDTH	90.0
 
-- initWithContentRect: (NSRect)contentRect styleMask: (unsigned int)aStyle
+- initWithContentRect: (NSRect)contentRect styleMask: (NSUInteger)aStyle
               backing: (NSBackingStoreType)backingType defer: (BOOL)flag
 {
   NSSize spacing = {SPACER, SPACER};
diff --git a/src/nsterm.h b/src/nsterm.h
index 7375e3c..033f757 100644
--- a/src/nsterm.h
+++ b/src/nsterm.h
@@ -420,9 +420,16 @@ struct nsfont_info
 #else /* GNUstep or OS X < 10.3 */
   void *cgfont;
 #endif
+  /* ctFont is used only on OS X 10.5+ */
+#if defined (NS_IMPL_COCOA) && (MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_5)
+  CTFontRef ctfont;
+#else /* GNUstep or OS X < 10.5 */
+  void *ctfont;
+#endif
 #else /* ! OBJC */
   void *nsfont;
   void *cgfont;
+  void *ctfont;
 #endif
   char bold, ital;  /* convenience flags */
   char synthItal;
diff --git a/src/nsterm.m b/src/nsterm.m
index 5a58f1d..233f699 100644
--- a/src/nsterm.m
+++ b/src/nsterm.m
@@ -1481,7 +1481,7 @@ ns_color_to_lisp (NSColor *col)
      Convert a color to a lisp string with the RGB equivalent
    -------------------------------------------------------------------------- */
 {
-  float red, green, blue, alpha, gray;
+  CGFloat red, green, blue, alpha, gray;
   char buf[1024];
   const char *str;
   NSTRACE (ns_color_to_lisp);
@@ -1501,13 +1501,13 @@ ns_color_to_lisp (NSColor *col)
     {
       [[col colorUsingColorSpaceName: NSCalibratedWhiteColorSpace]
             getWhite: &gray alpha: &alpha];
-      snprintf (buf, sizeof (buf), "#%02.2lx%02.2lx%02.2lx",
+      snprintf (buf, sizeof (buf), "#%2.2lx%2.2lx%2.2lx",
 		lrint (gray * 0xff), lrint (gray * 0xff), lrint (gray * 0xff));
       UNBLOCK_INPUT;
       return build_string (buf);
     }
 
-  snprintf (buf, sizeof (buf), "#%02.2lx%02.2lx%02.2lx",
+  snprintf (buf, sizeof (buf), "#%2.2lx%2.2lx%2.2lx",
             lrint (red*0xff), lrint (green*0xff), lrint (blue*0xff));
 
   UNBLOCK_INPUT;
@@ -1523,7 +1523,7 @@ ns_query_color(void *col, XColor *color_def, int setPixel)
          and set color_def pixel to the resulting index.
    -------------------------------------------------------------------------- */
 {
-  float r, g, b, a;
+  CGFloat r, g, b, a;
 
   [((NSColor *)col) getRed: &r green: &g blue: &b alpha: &a];
   color_def->red   = r * 65535;
@@ -4741,7 +4741,7 @@ extern void update_window_cursor (struct window *w, int on);
   return NSMakeRange (NSNotFound, 0);
 }
 
-- (unsigned int)characterIndexForPoint: (NSPoint)thePoint
+- (NSUInteger)characterIndexForPoint: (NSPoint)thePoint
 {
   if (NS_KEYLOG)
     NSLog (@"characterIndexForPoint request");
@@ -5418,7 +5418,7 @@ extern void update_window_cursor (struct window *w, int on);
 /* NSDraggingDestination protocol methods.  Actually this is not really a
    protocol, but a category of Object.  O well...  */
 
--(unsigned int) draggingEntered: (id <NSDraggingInfo>) sender
+-(NSDragOperation) draggingEntered: (id <NSDraggingInfo>) sender
 {
   NSTRACE (draggingEntered);
   return NSDragOperationGeneric;
@@ -5703,7 +5703,7 @@ extern void update_window_cursor (struct window *w, int on);
 #define SCROLL_BAR_FIRST_DELAY 0.5
 #define SCROLL_BAR_CONTINUOUS_DELAY (1.0 / 15)
 
-+ (float) scrollerWidth
++ (CGFloat) scrollerWidth
 {
   /* TODO: if we want to allow variable widths, this is the place to do it,
            however neither GNUstep nor Cocoa support it very well */
@@ -5834,14 +5834,26 @@ extern void update_window_cursor (struct window *w, int on);
   em_whole = whole;
 
   if (portion >= whole)
-    [self setFloatValue: 0.0 knobProportion: 1.0];
+    {
+#if MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_5
+      [self setDoubleValue: 0.0];
+      [self setKnobProportion: 1.0];
+#else
+      [self setFloatValue: 0.0 knobProportion: 1.0];
+#endif
+    }
   else
     {
       float pos, por;
       portion = max ((float)whole*min_portion/pixel_height, portion);
       pos = (float)position / (whole - portion);
       por = (float)portion/whole;
+#if MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_5
+      [self setDoubleValue: pos];
+      [self setKnobProportion: por];
+#else
       [self setFloatValue: pos knobProportion: por];
+#endif
     }
 #ifdef NS_IMPL_GNUSTEP
   [self display];
@@ -5946,7 +5958,8 @@ extern void update_window_cursor (struct window *w, int on);
     case NSScrollerKnobSlot:  /* GNUstep-only */
       last_hit_part = scroll_bar_move_ratio; break;
     default:  /* NSScrollerNoPart? */
-      fprintf (stderr, "EmacsScoller-mouseDown: unexpected part %d\n", part);
+      fprintf (stderr, "EmacsScoller-mouseDown: unexpected part %ld\n",
+             (long) part);
       return;
     }
 
diff --git a/src/process.c b/src/process.c
index e65d495..99f57d3 100644
--- a/src/process.c
+++ b/src/process.c
@@ -1522,7 +1522,7 @@ list_processes_1 (query_only)
 	    insert_string ("?");
 	  if (INTEGERP (speed))
 	    {
-	      sprintf (tembuf, " at %d b/s", XINT (speed));
+	      sprintf (tembuf, " at %ld b/s", (long) XINT (speed));
 	      insert_string (tembuf);
 	    }
 	  insert_string (")\n");
diff --git a/src/unexmacosx.c b/src/unexmacosx.c
index bb71d8f..489489d 100644
--- a/src/unexmacosx.c
+++ b/src/unexmacosx.c
@@ -684,8 +684,8 @@ read_load_commands ()
 	}
     }
 
-  printf ("Highest address of load commands in input file: %#8x\n",
-	  infile_lc_highest_addr);
+  printf ("Highest address of load commands in input file: %#8lx\n",
+	  (long) infile_lc_highest_addr);
 
   printf ("Lowest offset of all sections in __TEXT segment: %#8lx\n",
 	  text_seg_lowest_offset);
-- 
1.6.4.1

