-
Notifications
You must be signed in to change notification settings - Fork 47
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Can't snarf/exchange from sam to any mac program #93
Comments
I had the same problem on Windows (with WSL + VcXsrv), I could not exchange to Win programs.
|
My optimized version of the patch
|
No luck. I get several warnings when i compile:
gcc -std=c99 -D_POSIX_C_SOURCE=200809L -D_DARWIN_C_SOURCE -I../include -I/opt/X11/include -I/opt/X11/include/freetype2 -c -o gwin.o gwin.c
gwin.c:482:33: warning: passing 'unsigned char *' to parameter of type 'const char *' converts between pointers to integer types with
different sign [-Wpointer-sign]
gw->gwin.selection = strdup(p.value);
^~~~~~~
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.14.sdk/usr/include/string.h:117:26: note:
passing argument to parameter '__s1' here
char *strdup(const char *__s1);
^
gwin.c:513:40: warning: passing 'unsigned char *' to parameter of type 'const char *' converts between pointers to integer types with
different sign [-Wpointer-sign]
*ans = (XtPointer) XtNewString(p.value);
^~~~~~~
/opt/X11/include/X11/Intrinsic.h:1895:56: note: expanded from macro 'XtNewString'
((str) != NULL ? (strcpy(XtMalloc((unsigned)strlen(str) + 1), str)) : NULL)
^~~
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.14.sdk/usr/include/secure/_string.h:83:27: note:
expanded from macro 'strcpy'
__builtin___strcpy_chk (dest, __VA_ARGS__, __darwin_obsz (dest))
^~~~
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.14.sdk/usr/include/string.h:82:28: note:
passing argument to parameter '__s' here
size_t strlen(const char *__s);
^
gwin.c:513:40: warning: passing 'unsigned char *' to parameter of type 'const char *' converts between pointers to integer types with
different sign [-Wpointer-sign]
*ans = (XtPointer) XtNewString(p.value);
^~~~~~~
/opt/X11/include/X11/Intrinsic.h:1895:56: note: expanded from macro 'XtNewString'
((str) != NULL ? (strcpy(XtMalloc((unsigned)strlen(str) + 1), str)) : NULL)
^~~
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.14.sdk/usr/include/secure/_string.h:83:61: note:
expanded from macro 'strcpy'
__builtin___strcpy_chk (dest, __VA_ARGS__, __darwin_obsz (dest))
^~~~
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.14.sdk/usr/include/secure/_common.h:39:54: note:
expanded from macro '__darwin_obsz'
#define __darwin_obsz(object) __builtin_object_size (object, _USE_FORTIFY_LEVEL > 1 ? 1 : 0)
^~~~~~
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.14.sdk/usr/include/string.h:82:28: note:
passing argument to parameter '__s' here
size_t strlen(const char *__s);
^
gwin.c:513:40: warning: passing 'unsigned char *' to parameter of type 'const char *' converts between pointers to integer types with
different sign [-Wpointer-sign]
*ans = (XtPointer) XtNewString(p.value);
^~~~~~~
/opt/X11/include/X11/Intrinsic.h:1895:67: note: expanded from macro 'XtNewString'
((str) != NULL ? (strcpy(XtMalloc((unsigned)strlen(str) + 1), str)) : NULL)
^~~
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.14.sdk/usr/include/secure/_string.h:83:33: note:
expanded from macro 'strcpy'
__builtin___strcpy_chk (dest, __VA_ARGS__, __darwin_obsz (dest))
^~~~~~~~~~~
gwin.c:534:97: warning: incompatible pointer types passing 'void (Widget, XtPointer, Atom *, Atom *, XtPointer, uint64_t *, int *)'
(aka 'void (struct _WidgetRec *, void *, unsigned long *, unsigned long *, void *, unsigned long long *, int *)') to parameter
of type 'XtSelectionCallbackProc' (aka 'void (*)(struct _WidgetRec *, void *, unsigned long *, unsigned long *, void *,
unsigned long *, int *)') [-Wincompatible-pointer-types]
XtGetSelectionValue(w, XInternAtom(_dpy, clipatom, 0), XInternAtom(_dpy, "UTF8_STRING", 0), SelCallback, 0,
^~~~~~~~~~~
/opt/X11/include/X11/Intrinsic.h:2013:43: note: passing argument to parameter here
XtSelectionCallbackProc /* callback */,
^
gwin.c:544:13: warning: incompatible pointer types passing 'Boolean (Widget, Atom *, Atom *, Atom *, XtPointer *, uint64_t *, int *)'
(aka 'char (struct _WidgetRec *, unsigned long *, unsigned long *, unsigned long *, void **, unsigned long long *, int *)') to
parameter of type 'XtConvertSelectionProc' (aka 'char (*)(struct _WidgetRec *, unsigned long *, unsigned long *, unsigned long
*, void **, unsigned long *, int *)') [-Wincompatible-pointer-types]
SendSel, NULL, NULL);
^~~~~~~
/opt/X11/include/X11/Intrinsic.h:567:41: note: passing argument to parameter here
XtConvertSelectionProc /* convert */,
^
6 warnings generated.
… On Sep 5, 2019, at 2:08 PM, TobiasKarnat ***@***.***> wrote:
My optimized version of the patch
diff -urN sam/libXg/gwin.c sam/libXg/gwin.c
--- sam/libXg/gwin.c 2019-09-05 19:58:44.982208690 +0200
+++ sam/libXg/gwin.c 2019-09-05 20:00:09.889502801 +0200
@@ -7,6 +7,7 @@
#include <X11/Xatom.h>
#include <X11/XKBlib.h>
#include <X11/keysym.h>
+#include <X11/Xmu/Atoms.h>
#include "GwinP.h"
#include "libgint.h"
@@ -488,12 +489,25 @@
SendSel(Widget w, Atom *sel, Atom *target, Atom *rtype, XtPointer *ans,
uint64_t *anslen, int *ansfmt)
{
- GwinWidget gw = (GwinWidget)w;
- XTextProperty p = {0};
- char *ls[2] = {NULL, NULL};
+ Display* d = XtDisplay(w);
+
+ if (*target == XA_TARGETS(d)){
+ Atom* targets = (Atom*)XtMalloc(sizeof(Atom));
+ *targets = XA_STRING;
+
+ *rtype = XA_ATOM;
+ *ans = (XtPointer)targets;
+ *anslen = 1;
+ *ansfmt = 32;
+ return true;
+ }
if ((*target == XA_STRING) ||
(*target == XInternAtom(_dpy, "UTF8_STRING", 0))){
+ GwinWidget gw = (GwinWidget)w;
+ XTextProperty p = {0};
+ char *ls[2] = {NULL, NULL};
+
ls[0] = gw->gwin.selection? gw->gwin.selection : "";
if (XmbTextListToTextProperty(_dpy, ls, 1, XUTF8StringStyle, &p) != Success)
return false;
diff -urN sam/samterm/Makefile sam/samterm/Makefile
--- sam/samterm/Makefile 2019-09-05 19:58:44.984208721 +0200
+++ sam/samterm/Makefile 2019-09-05 19:58:52.471322835 +0200
@@ -15,7 +15,7 @@
# set this if your X libraries are in different locations
# or if you need extra libraries to load with X11 applications
-XLIBS=-lXt -lX11 -lXft -lXi
+XLIBS=-lXt -lX11 -lXft -lXi -lXmu
CFLAGS+=$(INCS) $(STANDARDS) $(INCLUDES)
—
You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub <#93?email_source=notifications&email_token=ACHQHAJRLJVDPC35K36OYJ3QIFDITA5CNFSM4F3JESG2YY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOD6AF52Y#issuecomment-528506603>, or mute the thread <https://github.com/notifications/unsubscribe-auth/ACHQHAKHO3C2625DGPNWAJDQIFDITANCNFSM4F3JESGQ>.
|
Could you try (uint32_t instead of uint64_t and cast to const char*)?:
|
2 warnings and it crashes when i <exch>
gwin.c:534:97: warning: incompatible pointer types passing 'void (Widget, XtPointer, Atom *, Atom *, XtPointer, uint32_t *, int *)' (aka 'void (struct _WidgetRec *, void *, unsigned long *,
unsigned long *, void *, unsigned int *, int *)') to parameter of type 'XtSelectionCallbackProc' (aka 'void (*)(struct _WidgetRec *, void *, unsigned long *, unsigned long *, void *,
unsigned long *, int *)') [-Wincompatible-pointer-types]
XtGetSelectionValue(w, XInternAtom(_dpy, clipatom, 0), XInternAtom(_dpy, "UTF8_STRING", 0), SelCallback, 0,
^~~~~~~~~~~
/opt/X11/include/X11/Intrinsic.h:2013:43: note: passing argument to parameter here
XtSelectionCallbackProc /* callback */,
^
gwin.c:544:13: warning: incompatible pointer types passing 'Boolean (Widget, Atom *, Atom *, Atom *, XtPointer *, uint32_t *, int *)' (aka 'char (struct _WidgetRec *, unsigned long *,
unsigned long *, unsigned long *, void **, unsigned int *, int *)') to parameter of type 'XtConvertSelectionProc' (aka 'char (*)(struct _WidgetRec *, unsigned long *, unsigned long *,
unsigned long *, void **, unsigned long *, int *)') [-Wincompatible-pointer-types]
SendSel, NULL, NULL);
^~~~~~~
/opt/X11/include/X11/Intrinsic.h:567:41: note: passing argument to parameter here
XtConvertSelectionProc /* convert */,
^
2 warnings generated.
… On Sep 6, 2019, at 12:41 PM, TobiasKarnat ***@***.***> wrote:
Could you try (unint32_t instead of uint64_t and cast to const char*)?:
SelCallback(Widget w, XtPointer cldata, Atom *sel, Atom *seltype,
XtPointer val, uint32_t *len, int *fmt)
gw->gwin.selection = strdup((const char*)p.value);
SendSel(Widget w, Atom *sel, Atom *target, Atom *rtype, XtPointer *ans,
uint32_t *anslen, int *ansfmt)
*ans = (XtPointer) XtNewString((const char*)p.value);
—
You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub <#93?email_source=notifications&email_token=ACHQHAMCTHB74JPP7TRGPJDQIKB2XA5CNFSM4F3JESG2YY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOD6DMQRY#issuecomment-528926791>, or mute the thread <https://github.com/notifications/unsubscribe-auth/ACHQHAMUPEG4VFL7EEQKVB3QIKB2XANCNFSM4F3JESGQ>.
|
Strange, uint64_t is unsigned long long and uint32_t is unsigned int on mac. But we need unsigned long, sorry I don't know the C99 type for mac: SelCallback(Widget w, XtPointer cldata, Atom *sel, Atom *seltype, SendSel(Widget w, Atom *sel, Atom *target, Atom *rtype, XtPointer *ans, |
yeah that fixes the warnings but <exch> still crashes sam. So something bad is happening.
I ran under dtruss and here’s the output when I hit <exch> with button 2:
madvise(0x10C20C000, 0x40000, 0x9) = 0 0
madvise(0x10C24C000, 0x40000, 0x9) = 0 0
madvise(0x10C14C000, 0x40000, 0x9) = 0 0
madvise(0x10C18C000, 0x40000, 0x9) = 0 0
madvise(0x10C1CC000, 0x40000, 0x9) = 0 0
close(0x5) = 0 0
unlink("/Users/mkr/.sam.localhost\0", 0x0, 0x0) = 0 0
not sure if that’s helpful.
… On Sep 6, 2019, at 2:15 PM, TobiasKarnat ***@***.***> wrote:
Strange, uint64_t is unsigned long long and uint32_t is unsigned int on mac.
https://stackoverflow.com/a/11603907 <https://stackoverflow.com/a/11603907>
But we need unsigned long, sorry I don't know the C99 type for mac:
SelCallback(Widget w, XtPointer cldata, Atom *sel, Atom *seltype,
XtPointer val, unsigned long *len, int *fmt)
SendSel(Widget w, Atom *sel, Atom *target, Atom *rtype, XtPointer *ans,
unsigned long *anslen, int *ansfmt)
—
You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub <#93?email_source=notifications&email_token=ACHQHANKR7C3RIPHRKLKPO3QIKM2TA5CNFSM4F3JESG2YY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOD6DUQIQ#issuecomment-528959522>, or mute the thread <https://github.com/notifications/unsubscribe-auth/ACHQHAKJJU2W2BXKPONXM43QIKM2TANCNFSM4F3JESGQ>.
|
Did it crash before adding the cast? Sorry I'm a systems engineer and not a programmer. |
I started from scratch with a fresh copy of the code from GitHub.
warnings during compile but it runs. <exch> still fails with that, but no crashes.
applying your optimized patch still generates warnings and does not fix <exch>.
pretty sure if I make your last couple of changes, <exch> will crash again. I don’t see .xsession-errors.
I don’t want you to waste your time on this. It took Rob and I quite a while to get sam working on the mac.
I don’t think we can fix this without his help (or someone with his knowledge of the code AND a mac).
… On Sep 6, 2019, at 2:46 PM, TobiasKarnat ***@***.***> wrote:
Did it crash before adding the cast? Sorry I'm a systems engineer and not a programmer.
Do you have .xsession-errors also available under mac? Maybe there are more information.
—
You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub <#93?email_source=notifications&email_token=ACHQHANAZ2VOWPOBALXHGYTQIKQPBA5CNFSM4F3JESG2YY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOD6DXFMY#issuecomment-528970419>, or mute the thread <https://github.com/notifications/unsubscribe-auth/ACHQHAP4B7F34FWQSBSUL7LQIKQPBANCNFSM4F3JESGQ>.
|
btw i’m not a c programmer so I’m not the “someone” I referred to below :-)
… On Sep 6, 2019, at 3:09 PM, Michael K. Rosenberg ***@***.***> wrote:
I started from scratch with a fresh copy of the code from GitHub.
warnings during compile but it runs. <exch> still fails with that, but no crashes.
applying your optimized patch still generates warnings and does not fix <exch>.
pretty sure if I make your last couple of changes, <exch> will crash again. I don’t see .xsession-errors.
I don’t want you to waste your time on this. It took Rob and I quite a while to get sam working on the mac.
I don’t think we can fix this without his help (or someone with his knowledge of the code AND a mac).
> On Sep 6, 2019, at 2:46 PM, TobiasKarnat ***@***.*** ***@***.***>> wrote:
>
> Did it crash before adding the cast? Sorry I'm a systems engineer and not a programmer.
> Do you have .xsession-errors also available under mac? Maybe there are more information.
>
> —
> You are receiving this because you authored the thread.
> Reply to this email directly, view it on GitHub <#93?email_source=notifications&email_token=ACHQHANAZ2VOWPOBALXHGYTQIKQPBA5CNFSM4F3JESG2YY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOD6DXFMY#issuecomment-528970419>, or mute the thread <https://github.com/notifications/unsubscribe-auth/ACHQHAP4B7F34FWQSBSUL7LQIKQPBANCNFSM4F3JESGQ>.
>
|
Sorry for the late response, everyone. Personal and work obligations have been...obligating. I'm happy to help, but I don't have a Mac. @mikerosenberg Could you paste the warnings you get with the latest code? @TobiasKarnat Thanks for all your help on this issue. X is finicky about types and sizes, unfortunately. I was too hasty on C99-ifying the code, I think. I'll see if I can adapt the patches above to something that's a bit more X11-type aware. It may be a day or two, though. |
Will do, soonish. I assume you want to see the warnings that come out from the unpatched code, i.e. a fresh pull from git.
If you also (or instead) want the warnings after installing the patch from @TobiasKarnat let me know.
… On Sep 10, 2019, at 12:05 PM, Rob King ***@***.***> wrote:
Sorry for the late response, everyone. Personal and work obligations have been...obligating.
I'm happy to help, but I don't have a Mac.
@mikerosenberg <https://github.com/mikerosenberg> Could you paste the warnings you get with the latest code?
@TobiasKarnat <https://github.com/TobiasKarnat> Thanks for all your help on this issue.
X is finicky about types and sizes, unfortunately. I was too hasty on C99-ifying the code, I think. I'll see if I can adapt the patches above to something that's a bit more X11-type aware. It may be a day or two, though.
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub <#93?email_source=notifications&email_token=ACHQHAMBNGPGERQS7UTCGULQI7AVNA5CNFSM4F3JESG2YY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOD6LUKMY#issuecomment-530007347>, or mute the thread <https://github.com/notifications/unsubscribe-auth/ACHQHALYSKH5JZOPTS7JW3DQI7AVNANCNFSM4F3JESGQ>.
|
I can exchange/paste from any mac program into sam, but not the opposite. I've tried every combination of snarfselection and xquartz pasteboard settings. Using high sierra and latest xquartz. Other x programs (xterm) work fine both ways. So I think it's a bug in sam. Exchange is pulling from the mac clipboard, but won't push to it.
The text was updated successfully, but these errors were encountered: