Fix ordering on samrc processing. - sam - An updated version of the sam text editor.
 (HTM) git clone git://vernunftzentrum.de/sam.git
 (DIR) Log
 (DIR) Files
 (DIR) Refs
 (DIR) LICENSE
       ---
 (DIR) commit f256522620ca007b623e5029d0cb6db4215c0ce0
 (DIR) parent 86273326e9dec50a3c9ced2c9bfe5d81d2e89a84
 (HTM) Author: Rob King <jking@deadpixi.com>
       Date:   Fri, 16 Dec 2016 09:50:50 -0600
       
       Fix ordering on samrc processing.
       
       Diffstat:
         libXg/gwin.c                        |       6 +++---
         libXg/xtbinit.c                     |       3 ---
         samterm/main.c                      |       3 ++-
         samterm/samrc.c                     |      23 ++++++++++++-----------
       
       4 files changed, 17 insertions(+), 18 deletions(-)
       ---
 (DIR) diff --git a/libXg/gwin.c b/libXg/gwin.c
       @@ -11,7 +11,7 @@
        #include "GwinP.h"
        #include "libgint.h"
        
       -Atom clipselection = XA_PRIMARY;
       +const char *clipatom = "PRIMARY";
        
        /* Forward declarations */
        static void Realize(Widget, XtValueMask *, XSetWindowAttributes *);
       @@ -584,7 +584,7 @@ SelectSwap(Widget w, String s)
                XtFree(gw->gwin.selection);
                gw->gwin.selection = NULL;
            }
       -    XtGetSelectionValue(w, clipselection, XInternAtom(_dpy, "UTF8_STRING", 0), SelCallback, 0,
       +    XtGetSelectionValue(w, XInternAtom(_dpy, clipatom, 0), XInternAtom(_dpy, "UTF8_STRING", 0), SelCallback, 0,
                    XtLastTimestampProcessed(XtDisplay(w)));
        
            while(gw->gwin.selection == NULL)
       @@ -593,7 +593,7 @@ SelectSwap(Widget w, String s)
            gw->gwin.selection = XtMalloc(strlen(s)+1);
            strcpy(gw->gwin.selection, s);
        
       -    XtOwnSelection(w, clipselection, XtLastTimestampProcessed(XtDisplay(w)),
       +    XtOwnSelection(w, XInternAtom(_dpy, clipatom, 0), XtLastTimestampProcessed(XtDisplay(w)),
                    SendSel, NULL, NULL);
        
            return ans;
 (DIR) diff --git a/libXg/xtbinit.c b/libXg/xtbinit.c
       @@ -59,7 +59,6 @@ int     _ld2d[6] = { 1, 2, 4, 8, 16, 24 };
        uint64_t   _ld2dmask[6] = { 0x1, 0x3, 0xF, 0xFF, 0xFFFF, 0x00FFFFFF };
        Colormap    _libg_cmap;
        int     _cmap_installed;
       -Atom XA_CLIPBOARD;
        
        /* xbinit implementation globals */
        static XtAppContext app;
       @@ -195,8 +194,6 @@ xtbinit(Errfunc f, char *class, int *pargc, char **argv, char **fallbacks)
        
            _bgpixel = _bgpixels[0];
        
       -    XA_CLIPBOARD = XInternAtom(_dpy, "CLIPBOARD", 0);
       -
            n = 0;
            XtSetArg(args[n], XtNcomposeMod, &compose); n++;
            XtGetValues(widg, args, n);
 (DIR) diff --git a/samterm/main.c b/samterm/main.c
       @@ -65,12 +65,13 @@ main(int argc, char *argv[])
                }
            }
        
       -    getscreen(argc, argv);
            rc = fopen(rcpath, "r");
            if (rc){
                loadrcfile(rc);
                fclose(rc);
            }
       +
       +    getscreen(argc, argv);
            initio();
            scratch = alloc(100*RUNESIZE);
            nscralloc = 100;
 (DIR) diff --git a/samterm/samrc.c b/samterm/samrc.c
       @@ -2,7 +2,6 @@
        #include <stdlib.h>
        #include <string.h>
        #include <strings.h>
       -#include <X11/Xatom.h>
        #include <X11/Xlib.h>
        #include <X11/keysym.h>
        
       @@ -14,7 +13,6 @@
        
        extern int expandtabs;
        extern int tabwidth;
       -extern Atom XA_CLIPBOARD;
        
        typedef struct Namemapping Namemapping;
        struct Namemapping{
       @@ -237,15 +235,18 @@ nametokeysym(const char *n)
        static int
        dirsnarfselection(const char *s1, const char *s2, const char *s3, const char *s4, const char *s5)
        {
       -    extern Atom clipselection;
       -    Namemapping selmapping[] ={
       -        {"primary",   XA_PRIMARY},
       -        {"secondary", XA_SECONDARY},
       -        {"clipboard", XA_CLIPBOARD},
       -        {NULL, 0}
       -    };
       -    clipselection = lookupmapping(s1, selmapping);
       -    return clipselection >= 0? 0 : -1;
       +    extern const char *clipatom;
       +
       +    if (strcasecmp(s1, "primary") == 0)
       +        clipatom = "PRIMARY";
       +    else if (strcasecmp(s1, "secondary") == 0)
       +        clipatom = "SECONDARY";
       +    else if (strcasecmp(s1, "clipboard") == 0)
       +        clipatom = "CLIPBOARD";
       +    else
       +        return -1;
       +
       +    return 0;
        }
        
        static int