Sisyphus repositório
Última atualização: 1 outubro 2023 | SRPMs: 18631 | Visitas: 37479151
en ru br
ALT Linux repositórios
S:0.95.2-alt4
5.0: 0.95-alt2
4.1: 0.95-alt2

Group :: Sistema/Bibliotecas
RPM: lesstif

 Main   Changelog   Spec   Patches   Sources   Download   Gear   Bugs e FR  Repocop 

Patch: lesstif-0.95.0-XxxxProperty-64bit.patch
Download


diff -up lesstif-0.95.0/lib/Xm-2.1/CutPaste.c.XxxxProperty-64bit lesstif-0.95.0/lib/Xm-2.1/CutPaste.c
--- lesstif-0.95.0/lib/Xm-2.1/CutPaste.c.XxxxProperty-64bit	2004-08-28 21:22:43.000000000 +0200
+++ lesstif-0.95.0/lib/Xm-2.1/CutPaste.c	2007-09-16 18:42:27.000000000 +0200
@@ -62,7 +62,7 @@ static void _XmClipboardDeleteMarked(Dis
 				     XmClipboard * clip);
 static void _XmClipboardDeleteFormat(Display *display, int id);
 static int _XmClipboardRegisterFormat(Display *display, char *format_name,
-				      int format_len);
+				      long format_len);
 static void _XmClipboardDeleteFormats(Display *display, Window window, int id);
 static void _XmClipboardDeleteItem(Display *display, Window window,
 				   XmClipboard * clip, unsigned item);
@@ -241,7 +241,7 @@ _XmClipboardDeleteItemLabel(Display *dis
 
 
 static int
-_XmClipboardRegisterFormat(Display *display, char *format_name, int format_len)
+_XmClipboardRegisterFormat(Display *display, char *format_name, long format_len)
 {
     Atom fmt;
     int flen;
@@ -606,7 +606,17 @@ _XmClipboardGetWindowProperty(Display *d
 
 	ret_buf = (unsigned *)XtRealloc((char *)ret_buf,
 					alloc_size + alloc_incr + 1);
-	memcpy(&ret_buf[offset], prop, alloc_incr);
+        /* Fixup X*Property long == 32 bits confusion if needed */
+        if (actual_format == 32 && sizeof(long) != 4)
+        {
+            int i;
+            unsigned long *in = (unsigned long *)prop;
+            
+            for (i = 0; i < nitems; i++)
+                ret_buf[offset + i] = in[i];
+        }
+        else
+	    memcpy(&ret_buf[offset], prop, alloc_incr);
 	alloc_size += alloc_incr;
 
 	switch (actual_format)
@@ -1001,8 +1011,9 @@ _XmClipboardReplaceItem(Display *display
 {
     Window root;
     Atom item;
-    int nunits, tstart, tlen;
+    int i, nunits, tstart, tlen;
     long transferlen;
+    long *convert_buf = NULL;
 
     root = DefaultRootWindow(display);
     item = _XmClipboardGetAtomFromId(display, id);
@@ -1014,6 +1025,14 @@ _XmClipboardReplaceItem(Display *display
     case 32:
 	len >>= 2;
 	nunits = transferlen;
+	/* XChangeProperty expects a buffer of longs when receiving 32 bits
+	   data, MEUHH */
+	if (sizeof(long) != 4)
+	{
+	    convert_buf = XtMalloc(len * sizeof(long));
+	    for (i = 0; i < len; i++)
+                convert_buf[i] = data[i];
+	}
 	break;
 
     case 16:
@@ -1040,7 +1059,9 @@ _XmClipboardReplaceItem(Display *display
 	}
 
 	XChangeProperty(display, root, item, item, format, mode,
-			(unsigned char *)&data[tstart], tlen);
+			convert_buf? (unsigned char *)&convert_buf[tstart] :
+                                     (unsigned char *)&data[tstart],
+                        tlen);
 
 	len -= tlen;
 	mode = PropModeAppend;
@@ -1160,7 +1181,7 @@ _XmClipboardGetLenFromFormat(Display *di
     }
     else
     {
-	*format = *((int *)(prop));
+	*format = *((long *)(prop));
 	ret = True;
     }
 
diff -up lesstif-0.95.0/clients/Motif-2.1/mwm/props.c.XxxxProperty-64bit lesstif-0.95.0/clients/Motif-2.1/mwm/props.c
--- lesstif-0.95.0/clients/Motif-2.1/mwm/props.c.XxxxProperty-64bit	2004-08-28 21:25:46.000000000 +0200
+++ lesstif-0.95.0/clients/Motif-2.1/mwm/props.c	2007-09-16 18:41:04.000000000 +0200
@@ -92,15 +92,28 @@ PROP_Initialize(void)
 void
 PROP_SetBehavior(ScreenInfo *scr, Boolean custom)
 {
-    PropMotifWmInfo info;
+    long info[PROP_MWM_INFO_ELEMENTS];
 
-    /* set the MWM_INFO property on the Root */
+    /* set the MWM_INFO property on the Root, notice that we
+       use an array of longs here and not the PropMotifWmInfo struct,
+       this is because this struct looks like this in lesstif:
+       
+       typedef struct {
+           CARD32 flags;
+           CARD32 wmWindow;
+       } PropMotifWmInfo;
+       
+       But when setting 32 bit properties XChangeProperty expects an array of
+       longs, which it will convert to 32 bit values if need. Thus passing an
+       actual PropMotifWmInfo struct will mess things up on archs where longs
+       are 64 bit. */
+    
     if (custom)
-	info.flags = MWM_INFO_STARTUP_CUSTOM;
+	info[0] = MWM_INFO_STARTUP_CUSTOM;   /* set flags "member" */
     else
-	info.flags = MWM_INFO_STARTUP_STANDARD;
+	info[0] = MWM_INFO_STARTUP_STANDARD; /* set flags "member" */
 
-    info.wmWindow = scr->root_win;
+    info[1] = scr->root_win; /* set wmWindow "member" */
 
     XChangeProperty(dpy, scr->root_win, XA_MWM_INFO, XA_MWM_INFO,
 		    32, PropModeReplace,
@@ -129,7 +142,18 @@ PROP_GetBehavior(ScreenInfo *scr)
     int actual_format, ret;
     Atom actual_type;
     unsigned long nitems, bytesafter;
-    PropMotifWmInfo *info;
+    /* We use a long pointer here and not a PropMotifWmInfo pointer,
+       this is because this type looks like this in lesstif:
+       
+       typedef struct {
+           CARD32 flags;
+           CARD32 wmWindow;
+       } PropMotifWmInfo;
+       
+       But when getting 32 bit properties XGetWindowProperty returns an array
+       of longs. Thus interpreting the returned data as PropMotifWmInfo will
+       mess things up on archs where longs are 64 bit. */
+    unsigned long *info;
 
     if (XGetWindowProperty(dpy, scr->root_win, XA_MWM_INFO, 0L,
 			   PROP_MOTIF_WM_INFO_ELEMENTS, False,
@@ -138,7 +162,7 @@ PROP_GetBehavior(ScreenInfo *scr)
 			   (unsigned char **)&info) == Success)
     {
 	if (nitems > 0 && info)
-	    ret = info->flags;
+	    ret = info[0]; /* Return flags "member" */
 	else
 	    ret = 0;
 	XFree((char *)info);
@@ -284,7 +308,21 @@ PROP_GetMwmHints(MwmWindow *win)
     {
 
 	if (nitems >= PROP_MOTIF_WM_HINTS_ELEMENTS)
+	{
+	    /* Fixup X*Property long == 32 bits confusion if needed */
+	    if (sizeof(long) != 4)
+	    {
+	        long *prop_hints = (long *)win->mwm_hints;
+	        win->mwm_hints = XtMalloc(sizeof(MwmHints));
+	        win->mwm_hints->flags       = prop_hints[0];
+	        win->mwm_hints->functions   = prop_hints[1];
+	        win->mwm_hints->decorations = prop_hints[2];
+	        win->mwm_hints->input_mode  = prop_hints[3];
+	        win->mwm_hints->status      = prop_hints[4];
+	        XFree(prop_hints);
+	    }
 	    return;
+        }
 
 	XFree((char *)win->mwm_hints);
     }
 
projeto & código: Vladimir Lettiev aka crux © 2004-2005, Andrew Avramenko aka liks © 2007-2008
mantenedor atual: Michael Shigorin
mantenedor da tradução: Fernando Martini aka fmartini © 2009