Subject: bug#5250: 23.1.90; src/xterm.c does not compile –like #3895 from 2009-07-27

From: Peter Dyballa <[email-masked]>
Date: Sun, 20 Dec 2009 21:21:32 +0100

I tried again to compile with GCC 4.2.1 (Apple Inc. build 5577) and  
making use of some (modern, up-to-date) C header and library files  
from MacPorts. With GTK+2 as X toolkit. Now it compiles src/xterm.c!  
In the pre-processed output I see some differences (diff GTK+2- 
GCC4.2.1 GTK+2-GCC4.0.1) by which in the end the strange and faulty  
construct appears, although I have no idea why!
(Many differences with just the use of different variants of the same  
C header file omitted.)

********4.2.1*******                                             
********4.0.1*******
*** 300,320 ****
   #define HAVE_WORKING_FORK 1                                      
#define HAVE_WORKING_FORK 1
   #define HAVE_WORKING_VFORK 1                                     
#define HAVE_WORKING_VFORK 1
   #define HAVE_X11 1                                               
#define HAVE_X11 1
- #define HAVE_X11R6 1
   #define HAVE_XFT 1                                               
#define HAVE_XFT 1
   #define HAVE_XIM 1                                               
#define HAVE_XIM 1
- #define HAVE_XKBGETKEYBOARD 1
   #define HAVE_XPM 1                                               
#define HAVE_XPM 1
! #define HAVE_XRMSETDATABASE 1
! #define HAVE_XSCREENNUMBEROFSCREEN 1
! #define HAVE_XSCREENRESOURCESTRING 1
! #define HAVE_XSETWMPROTOCOLS 1

*** 664,671 ****
   # 1169 "./config.h" 2                                           #  
1169 "./config.h" 2
   # 1 "/usr/include/strings.h" 1 3 4                              # 1  
"/usr/include/strings.h" 1 3 4
- # 62 "/usr/include/strings.h" 3 4
- # 1 "/usr/include/string.h" 1 3 4
- # 63 "/usr/include/strings.h" 2 3 4
   # 1172 "./config.h" 2                                           #  
1172 "./config.h" 2
   # 1 "/usr/include/stdlib.h" 1 3 4                               # 1  
"/usr/include/stdlib.h" 1 3 4
   # 59 "/usr/include/stdlib.h" 3 4                                #  
59 "/usr/include/stdlib.h" 3 4

*** 1531,1535 ****
   #define _MACHTYPES_H_                                            
#define _MACHTYPES_H_
! # 1 "/usr/include/ppc/_types.h" 1 3 4
! # 71 "/usr/include/ppc/types.h" 2 3 4                         ! # 77  
"/usr/include/ppc/types.h" 3 4
   #define _INT8_T                                                  
#define _INT8_T

*** 1607,1613 ****
   # 1175 "./config.h" 2                                           #  
1175 "./config.h" 2
! # 1193 "./config.h"                                           ! #  
1195 "./config.h"
   #define HAVE_X_I18N                                              
#define HAVE_X_I18N
! #define HAVE_X11R6_XIM
                                                                 ! #  
1206 "./config.h"

*** 4045,4052 ****
   # 41 "xterm.c" 2                                                #  
41 "xterm.c" 2
   # 1 "xterm.h" 1                                                 # 1  
"xterm.h" 1
   # 20 "xterm.h"                                                  #  
20 "xterm.h"
! # 1 "/opt/local/include/X11/Xlib.h" 1                         ! # 1  
"/usr/X11/include/X11/Xlib.h" 1
! # 37 "/opt/local/include/X11/Xlib.h"                          ! # 37  
"/usr/X11/include/X11/Xlib.h"
   #define _XLIB_H_                                                 
#define _XLIB_H_
   #define XlibSpecificationRelease 6                               
#define XlibSpecificationRelease 6
   # 1 "/usr/include/sys/types.h" 1 3 4                            # 1  
"/usr/include/sys/types.h" 1 3 4

*** 5243,5255 ****
- typedef struct {
-     int type;
-     unsigned long serial;
-     int send_event;
-     Display *display;
-     int extension;
-     int evtype;
-     unsigned int cookie;
-     void *data;
- } XGenericEventCookie;

-  XGenericEvent xgeneric;
-  XGenericEventCookie xcookie;

*** 7824,7837 ****
- extern int XGetEventData(
-     Display* ,
-     XGenericEventCookie*
- );
- extern void XFreeEventData(
-     Display* ,
-     XGenericEventCookie*
- );
   # 21 "xterm.h" 2                                                #  
21 "xterm.h" 2
! # 1 "/opt/local/include/X11/cursorfont.h" 1                   ! # 1  
"/usr/X11/include/X11/cursorfont.h" 1
! # 31 "/opt/local/include/X11/cursorfont.h"                    ! # 31  
"/usr/X11/include/X11/cursorfont.h"

! # 1 "/opt/local/include/X11/keysym.h" 1                       ! # 1  
"/usr/X11/include/X11/keysym.h" 1

*** 12537,12544 ****
   # 1 "/usr/include/ppc/limits.h" 1 3 4
   # 37 "/usr/include/ppc/limits.h" 3 4
   #define _PPC_LIMITS_H_
- # 1 "/usr/include/ppc/_limits.h" 1 3 4
- # 41 "/usr/include/ppc/limits.h" 2 3 4

*** 47599,47607 ****
! # 93 "xterm.h"                                                ! #  
103 "xterm.h"
! struct xim_inst_t
! {
!   struct x_display_info *dpyinfo;
!   char *resource_name;
! };
   struct x_bitmap_record                                           
struct x_bitmap_record
   {                                                               {
     Pixmap pixmap;                                                   
Pixmap pixmap;

*** 57646,57675 ****
       }                                                               }
     return font_object;                                              
return font_object;
   }                                                               }
! # 8121 "xterm.c"                                              ! #  
8159 "xterm.c"
! static void
! xim_destroy_callback (xim, client_data, call_data)
!      XIM xim;
!      XPointer client_data;
!      XPointer call_data;
! {
!   struct x_display_info *dpyinfo = (struct x_display_info *)  
client_data;
!   Lisp_Object frame, tail;
!   (interrupt_input_blocked++);
!   for ((tail) = Vframe_list; ((((enum Lisp_Type) (((unsigned int)  
((tail))) & ((((int) 1) << 3) - 1))) == Lisp_Cons) && (frame = (0+ 
((((void) 0,(struct Lisp_Cons *) ((int) (((tail)) & ~((((int) 1) << 3)  
- 1))))->car))), 1)); tail = (0+((((void) 0,(struct Lisp_Cons *)  
((int) (((tail)) & ~((((int) 1) << 3) - 1))))->u.cdr))))
!     {
!       struct frame *f = ((void) 0,(struct frame *) ((int) ((frame) &  
~((((int) 1) << 3) - 1))));
!       if (((f)->output_method == output_x_window) && ((f)- 
 >output_data.x->display_info) == dpyinfo)
!  {
!    ((f)->output_data.x->xic) = ((void *)0);
!           xic_free_xfontset (f);
!  }
!     }
!   dpyinfo->xim = ((void *)0);
!   XFree (dpyinfo->xim_styles);
!   do { --interrupt_input_blocked; if (interrupt_input_blocked == 0)  
{ if (interrupt_input_pending) reinvoke_input_signal (); if  
(pending_atimers) do_pending_atimers (); } else if  
(interrupt_input_blocked < 0) abort (); } while (0);
! }
! extern char *XSetIMValues (XIM, ...);
   static void                                                      
static void
   xim_open_dpy (dpyinfo, resource_name)                            
xim_open_dpy (dpyinfo, resource_name)
        struct x_display_info  
*dpyinfo;                                 struct x_display_info  
*dpyinfo;

*** 57685,57736 ****
         dpyinfo->xim = xim;
         if (xim)
    {
-    XIMCallback destroy;
      XGetIMValues (xim, "queryInputStyle", &dpyinfo->xim_styles,  
((void *)0));
-    destroy.callback = xim_destroy_callback;
-    destroy.client_data = (XPointer)dpyinfo;
-    XSetIMValues (xim, "destroyCallback", &destroy, ((void *)0));
    }
       }
     else
       dpyinfo->xim = ((void *)0);
   }
- # 8205 "xterm.c"
- static void
- xim_instantiate_callback (display, client_data, call_data)
-      Display *display;
-      XPointer client_data;
-      XPointer call_data;
- {
-   struct xim_inst_t *xim_inst = (struct xim_inst_t *) client_data;
-   struct x_display_info *dpyinfo = xim_inst->dpyinfo;
-   if (dpyinfo->xim)
-     return;
-   xim_open_dpy (dpyinfo, xim_inst->resource_name);
-   if (dpyinfo->xim && dpyinfo->reference_count > 0)
-     {
-       Lisp_Object tail, frame;
-       (interrupt_input_blocked++);
-       for ((tail) = Vframe_list; ((((enum Lisp_Type) (((unsigned  
int) ((tail))) & ((((int) 1) << 3) - 1))) == Lisp_Cons) && (frame = (0+ 
((((void) 0,(struct Lisp_Cons *) ((int) (((tail)) & ~((((int) 1) << 3)  
- 1))))->car))), 1)); tail = (0+((((void) 0,(struct Lisp_Cons *)  
((int) (((tail)) & ~((((int) 1) << 3) - 1))))->u.cdr))))
-  {
-    struct frame *f = ((void) 0,(struct frame *) ((int) ((frame) &  
~((((int) 1) << 3) - 1))));
-    if (((f)->output_method == output_x_window)
-               && ((f)->output_data.x->display_info) == xim_inst- 
 >dpyinfo)
-      if (((f)->output_data.x->xic) == ((void *)0))
-        {
-   create_frame_xic (f);
-   if (((f)->output_data.x->xic_style) & 0x0100L)
-     xic_set_statusarea (f);
-   if (((f)->output_data.x->xic_style) & 0x0004L)
-     {
-       struct window *w = ((void) 0,(struct window *) ((int) ((f- 
 >selected_window) & ~((((int) 1) << 3) - 1))));
-       xic_set_preeditarea (w, w->cursor.x, w->cursor.y);
-     }
-        }
-  }
-       do { --interrupt_input_blocked; if (interrupt_input_blocked ==  
0) { if (interrupt_input_pending) reinvoke_input_signal (); if  
(pending_atimers) do_pending_atimers (); } else if  
(interrupt_input_blocked < 0) abort (); } while (0);
-     }
- }
   # 8258 "xterm.c"
   static void
   xim_initialize (dpyinfo, resource_name)
--- 57693,57704 ----
***************
*** 57740,57757 ****
     dpyinfo->xim = ((void *)0);                                      
dpyinfo->xim = ((void *)0);
     if (use_xim)                                                     
if (use_xim)
       {                                                               {
                                                                 ! #  
8285 "xterm.c"
                                                                 !       xim_open_dpy 
  (dpyinfo, resource_name);
!       struct xim_inst_t *xim_inst;
!       int len;
!       xim_inst = (struct xim_inst_t *) xmalloc (sizeof (struct  
xim_inst_t));
!       dpyinfo->xim_callback_data = xim_inst;
!       xim_inst->dpyinfo = dpyinfo;
!       len = strlen (resource_name);
!       xim_inst->resource_name = (char *) xmalloc (len + 1);
!       bcopy (resource_name, xim_inst->resource_name, len + 1);
!       XRegisterIMInstantiateCallback (dpyinfo->display, dpyinfo->xrdb,
!           resource_name, "Emacs",
!           xim_instantiate_callback,
!           (XPointer) xim_inst);
       }                                                               }
   }                                                               }
   static void                                                      
static void

***************
*** 57760,57771 ****
    
{                                                                       {
     if  
(use_xim)                                                             
if (use_xim)
        
{                                                                       {
         if (dpyinfo- 
 >display)                                                   if  
(dpyinfo->display)
!  XUnregisterIMInstantiateCallback (dpyinfo->display, dpyinfo->xrdb,
!        ((void *)0), "Emacs",
!        xim_instantiate_callback, ((void *)0));
!       xfree (dpyinfo->xim_callback_data->resource_name);
!       xfree (dpyinfo->xim_callback_data);
         if (dpyinfo->display)
    XCloseIM (dpyinfo- 
 >xim);                                                XCloseIM  
(dpyinfo->xim);

***************
*** 58841,58847 ****
       = XCreateFontCursor (dpyinfo->display, 116);                     
= XCreateFontCursor (dpyinfo->display, 116);
     xrdb = x_load_resources (dpyinfo->display, xrm_option,           
xrdb = x_load_resources (dpyinfo->display, xrm_option,
         resource_name,  
"Emacs");                                        resource_name,  
"Emacs");
!   XrmSetDatabase (dpyinfo->display, xrdb);                    !    
dpyinfo->display->db = xrdb;
     dpyinfo->xrdb = xrdb;                                            
dpyinfo->xrdb = xrdb;

--
Greetings

   Pete

There is no worse tyranny than to force a man to pay for what he does  
not want merely because you think it would be good for him.
				– Robert Heinlein