X-Git-Url: https://git.danieliu.xyz/?a=blobdiff_plain;f=x.c;h=f0195c900477b665bdada304cc9a48f4e04bf5c4;hb=bd3f7fd84270025696790512cf3c2dafaf5bc77f;hp=06e53d389c149459647be3fd1a203bdded4fc812;hpb=e7ef3c4ce95a21cfcd0988d493f636e1d0115871;p=st.git diff --git a/x.c b/x.c index 06e53d3..f0195c9 100644 --- a/x.c +++ b/x.c @@ -245,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); @@ -618,6 +618,9 @@ selrequest(XEvent *e) void setsel(char *str, Time t) { + if (!str) + return; + free(xsel.primary); xsel.primary = str; @@ -1922,19 +1925,19 @@ main(int argc, char *argv[]) opt_embed = EARGF(usage()); break; case 'v': - die("%s " VERSION " (c) 2010-2016 st engineers\n", argv0); + die("%s " VERSION "\n", argv0); break; default: usage(); } 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);