bump version to 0.8.1
[st.git] / x.c
diff --git a/x.c b/x.c
index 537322b..c343ba2 100644 (file)
--- a/x.c
+++ b/x.c
@@ -1,5 +1,6 @@
 /* See LICENSE for license details. */
 #include <errno.h>
+#include <math.h>
 #include <limits.h>
 #include <locale.h>
 #include <signal.h>
@@ -244,8 +245,8 @@ clipcopy(const Arg *dummy)
 {
        Atom clipboard;
 
-       if (xsel.clipboard != NULL)
-               free(xsel.clipboard);
+       free(xsel.clipboard);
+       xsel.clipboard = NULL;
 
        if (xsel.primary != NULL) {
                xsel.clipboard = xstrdup(xsel.primary);
@@ -617,6 +618,9 @@ selrequest(XEvent *e)
 void
 setsel(char *str, Time t)
 {
+       if (!str)
+               return;
+
        free(xsel.primary);
        xsel.primary = str;
 
@@ -901,7 +905,6 @@ xloadfonts(char *fontstr, double fontsize)
 {
        FcPattern *pattern;
        double fontval;
-       float ceilf(float);
 
        if (fontstr[0] == '-') {
                pattern = XftXlfdParse(fontstr, False, False);
@@ -1492,7 +1495,7 @@ void
 xsettitle(char *p)
 {
        XTextProperty prop;
-       DEFAULT(p, "st");
+       DEFAULT(p, opt_title);
 
        Xutf8TextListToTextProperty(xw.dpy, &p, 1, XUTF8StringStyle,
                        &prop);
@@ -1929,12 +1932,12 @@ main(int argc, char *argv[])
        } ARGEND;
 
 run:
-       if (argc > 0) {
-               /* eat all remaining arguments */
+       if (argc > 0) /* eat all remaining arguments */
                opt_cmd = argv;
-               if (!opt_title && !opt_line)
-                       opt_title = basename(xstrdup(argv[0]));
-       }
+
+       if (!opt_title)
+               opt_title = (opt_line || !opt_cmd) ? "st" : opt_cmd[0];
+
        setlocale(LC_CTYPE, "");
        XSetLocaleModifiers("");
        cols = MAX(cols, 1);