diff options
-rw-r--r-- | st.c | 21 | ||||
-rw-r--r-- | x.c | 27 |
2 files changed, 24 insertions, 24 deletions
@@ -256,10 +256,10 @@ xwrite(int fd, const char *s, size_t len) | |||
256 | void * | 256 | void * |
257 | xmalloc(size_t len) | 257 | xmalloc(size_t len) |
258 | { | 258 | { |
259 | void *p = malloc(len); | 259 | void *p; |
260 | 260 | ||
261 | if (!p) | 261 | if (!(p = malloc(len))) |
262 | die("Out of memory\n"); | 262 | die("malloc: %s\n", strerror(errno)); |
263 | 263 | ||
264 | return p; | 264 | return p; |
265 | } | 265 | } |
@@ -268,7 +268,7 @@ void * | |||
268 | xrealloc(void *p, size_t len) | 268 | xrealloc(void *p, size_t len) |
269 | { | 269 | { |
270 | if ((p = realloc(p, len)) == NULL) | 270 | if ((p = realloc(p, len)) == NULL) |
271 | die("Out of memory\n"); | 271 | die("realloc: %s\n", strerror(errno)); |
272 | 272 | ||
273 | return p; | 273 | return p; |
274 | } | 274 | } |
@@ -277,7 +277,7 @@ char * | |||
277 | xstrdup(char *s) | 277 | xstrdup(char *s) |
278 | { | 278 | { |
279 | if ((s = strdup(s)) == NULL) | 279 | if ((s = strdup(s)) == NULL) |
280 | die("Out of memory\n"); | 280 | die("strdup: %s\n", strerror(errno)); |
281 | 281 | ||
282 | return s; | 282 | return s; |
283 | } | 283 | } |
@@ -687,7 +687,7 @@ execsh(char *cmd, char **args) | |||
687 | errno = 0; | 687 | errno = 0; |
688 | if ((pw = getpwuid(getuid())) == NULL) { | 688 | if ((pw = getpwuid(getuid())) == NULL) { |
689 | if (errno) | 689 | if (errno) |
690 | die("getpwuid:%s\n", strerror(errno)); | 690 | die("getpwuid: %s\n", strerror(errno)); |
691 | else | 691 | else |
692 | die("who are you?\n"); | 692 | die("who are you?\n"); |
693 | } | 693 | } |
@@ -730,7 +730,7 @@ sigchld(int a) | |||
730 | pid_t p; | 730 | pid_t p; |
731 | 731 | ||
732 | if ((p = waitpid(pid, &stat, WNOHANG)) < 0) | 732 | if ((p = waitpid(pid, &stat, WNOHANG)) < 0) |
733 | die("Waiting for pid %hd failed: %s\n", pid, strerror(errno)); | 733 | die("waiting for pid %hd failed: %s\n", pid, strerror(errno)); |
734 | 734 | ||
735 | if (pid != p) | 735 | if (pid != p) |
736 | return; | 736 | return; |
@@ -781,7 +781,8 @@ ttynew(char *line, char *cmd, char *out, char **args) | |||
781 | 781 | ||
782 | if (line) { | 782 | if (line) { |
783 | if ((cmdfd = open(line, O_RDWR)) < 0) | 783 | if ((cmdfd = open(line, O_RDWR)) < 0) |
784 | die("open line failed: %s\n", strerror(errno)); | 784 | die("open line '%s' failed: %s\n", |
785 | line, strerror(errno)); | ||
785 | dup2(cmdfd, 0); | 786 | dup2(cmdfd, 0); |
786 | stty(args); | 787 | stty(args); |
787 | return cmdfd; | 788 | return cmdfd; |
@@ -793,7 +794,7 @@ ttynew(char *line, char *cmd, char *out, char **args) | |||
793 | 794 | ||
794 | switch (pid = fork()) { | 795 | switch (pid = fork()) { |
795 | case -1: | 796 | case -1: |
796 | die("fork failed\n"); | 797 | die("fork failed: %s\n", strerror(errno)); |
797 | break; | 798 | break; |
798 | case 0: | 799 | case 0: |
799 | close(iofd); | 800 | close(iofd); |
@@ -826,7 +827,7 @@ ttyread(void) | |||
826 | 827 | ||
827 | /* append read bytes to unprocessed bytes */ | 828 | /* append read bytes to unprocessed bytes */ |
828 | if ((ret = read(cmdfd, buf+buflen, LEN(buf)-buflen)) < 0) | 829 | if ((ret = read(cmdfd, buf+buflen, LEN(buf)-buflen)) < 0) |
829 | die("Couldn't read from shell: %s\n", strerror(errno)); | 830 | die("couldn't read from shell: %s\n", strerror(errno)); |
830 | buflen += ret; | 831 | buflen += ret; |
831 | 832 | ||
832 | written = twrite(buf, buflen, 0); | 833 | written = twrite(buf, buflen, 0); |
@@ -742,9 +742,9 @@ xloadcols(void) | |||
742 | for (i = 0; i < dc.collen; i++) | 742 | for (i = 0; i < dc.collen; i++) |
743 | if (!xloadcolor(i, NULL, &dc.col[i])) { | 743 | if (!xloadcolor(i, NULL, &dc.col[i])) { |
744 | if (colorname[i]) | 744 | if (colorname[i]) |
745 | die("Could not allocate color '%s'\n", colorname[i]); | 745 | die("could not allocate color '%s'\n", colorname[i]); |
746 | else | 746 | else |
747 | die("Could not allocate color %d\n", i); | 747 | die("could not allocate color %d\n", i); |
748 | } | 748 | } |
749 | loaded = 1; | 749 | loaded = 1; |
750 | } | 750 | } |
@@ -869,7 +869,7 @@ xloadfont(Font *f, FcPattern *pattern) | |||
869 | if ((XftPatternGetInteger(f->match->pattern, "slant", 0, | 869 | if ((XftPatternGetInteger(f->match->pattern, "slant", 0, |
870 | &haveattr) != XftResultMatch) || haveattr < wantattr) { | 870 | &haveattr) != XftResultMatch) || haveattr < wantattr) { |
871 | f->badslant = 1; | 871 | f->badslant = 1; |
872 | fputs("st: font slant does not match\n", stderr); | 872 | fputs("font slant does not match\n", stderr); |
873 | } | 873 | } |
874 | } | 874 | } |
875 | 875 | ||
@@ -878,7 +878,7 @@ xloadfont(Font *f, FcPattern *pattern) | |||
878 | if ((XftPatternGetInteger(f->match->pattern, "weight", 0, | 878 | if ((XftPatternGetInteger(f->match->pattern, "weight", 0, |
879 | &haveattr) != XftResultMatch) || haveattr != wantattr) { | 879 | &haveattr) != XftResultMatch) || haveattr != wantattr) { |
880 | f->badweight = 1; | 880 | f->badweight = 1; |
881 | fputs("st: font weight does not match\n", stderr); | 881 | fputs("font weight does not match\n", stderr); |
882 | } | 882 | } |
883 | } | 883 | } |
884 | 884 | ||
@@ -906,14 +906,13 @@ xloadfonts(char *fontstr, double fontsize) | |||
906 | FcPattern *pattern; | 906 | FcPattern *pattern; |
907 | double fontval; | 907 | double fontval; |
908 | 908 | ||
909 | if (fontstr[0] == '-') { | 909 | if (fontstr[0] == '-') |
910 | pattern = XftXlfdParse(fontstr, False, False); | 910 | pattern = XftXlfdParse(fontstr, False, False); |
911 | } else { | 911 | else |
912 | pattern = FcNameParse((FcChar8 *)fontstr); | 912 | pattern = FcNameParse((FcChar8 *)fontstr); |
913 | } | ||
914 | 913 | ||
915 | if (!pattern) | 914 | if (!pattern) |
916 | die("st: can't open font %s\n", fontstr); | 915 | die("can't open font %s\n", fontstr); |
917 | 916 | ||
918 | if (fontsize > 1) { | 917 | if (fontsize > 1) { |
919 | FcPatternDel(pattern, FC_PIXEL_SIZE); | 918 | FcPatternDel(pattern, FC_PIXEL_SIZE); |
@@ -939,7 +938,7 @@ xloadfonts(char *fontstr, double fontsize) | |||
939 | } | 938 | } |
940 | 939 | ||
941 | if (xloadfont(&dc.font, pattern)) | 940 | if (xloadfont(&dc.font, pattern)) |
942 | die("st: can't open font %s\n", fontstr); | 941 | die("can't open font %s\n", fontstr); |
943 | 942 | ||
944 | if (usedfontsize < 0) { | 943 | if (usedfontsize < 0) { |
945 | FcPatternGetDouble(dc.font.match->pattern, | 944 | FcPatternGetDouble(dc.font.match->pattern, |
@@ -956,17 +955,17 @@ xloadfonts(char *fontstr, double fontsize) | |||
956 | FcPatternDel(pattern, FC_SLANT); | 955 | FcPatternDel(pattern, FC_SLANT); |
957 | FcPatternAddInteger(pattern, FC_SLANT, FC_SLANT_ITALIC); | 956 | FcPatternAddInteger(pattern, FC_SLANT, FC_SLANT_ITALIC); |
958 | if (xloadfont(&dc.ifont, pattern)) | 957 | if (xloadfont(&dc.ifont, pattern)) |
959 | die("st: can't open font %s\n", fontstr); | 958 | die("can't open font %s\n", fontstr); |
960 | 959 | ||
961 | FcPatternDel(pattern, FC_WEIGHT); | 960 | FcPatternDel(pattern, FC_WEIGHT); |
962 | FcPatternAddInteger(pattern, FC_WEIGHT, FC_WEIGHT_BOLD); | 961 | FcPatternAddInteger(pattern, FC_WEIGHT, FC_WEIGHT_BOLD); |
963 | if (xloadfont(&dc.ibfont, pattern)) | 962 | if (xloadfont(&dc.ibfont, pattern)) |
964 | die("st: can't open font %s\n", fontstr); | 963 | die("can't open font %s\n", fontstr); |
965 | 964 | ||
966 | FcPatternDel(pattern, FC_SLANT); | 965 | FcPatternDel(pattern, FC_SLANT); |
967 | FcPatternAddInteger(pattern, FC_SLANT, FC_SLANT_ROMAN); | 966 | FcPatternAddInteger(pattern, FC_SLANT, FC_SLANT_ROMAN); |
968 | if (xloadfont(&dc.bfont, pattern)) | 967 | if (xloadfont(&dc.bfont, pattern)) |
969 | die("st: can't open font %s\n", fontstr); | 968 | die("can't open font %s\n", fontstr); |
970 | 969 | ||
971 | FcPatternDestroy(pattern); | 970 | FcPatternDestroy(pattern); |
972 | } | 971 | } |
@@ -1003,13 +1002,13 @@ xinit(int cols, int rows) | |||
1003 | XColor xmousefg, xmousebg; | 1002 | XColor xmousefg, xmousebg; |
1004 | 1003 | ||
1005 | if (!(xw.dpy = XOpenDisplay(NULL))) | 1004 | if (!(xw.dpy = XOpenDisplay(NULL))) |
1006 | die("Can't open display\n"); | 1005 | die("can't open display\n"); |
1007 | xw.scr = XDefaultScreen(xw.dpy); | 1006 | xw.scr = XDefaultScreen(xw.dpy); |
1008 | xw.vis = XDefaultVisual(xw.dpy, xw.scr); | 1007 | xw.vis = XDefaultVisual(xw.dpy, xw.scr); |
1009 | 1008 | ||
1010 | /* font */ | 1009 | /* font */ |
1011 | if (!FcInit()) | 1010 | if (!FcInit()) |
1012 | die("Could not init fontconfig.\n"); | 1011 | die("could not init fontconfig.\n"); |
1013 | 1012 | ||
1014 | usedfont = (opt_font == NULL)? font : opt_font; | 1013 | usedfont = (opt_font == NULL)? font : opt_font; |
1015 | xloadfonts(usedfont, 0); | 1014 | xloadfonts(usedfont, 0); |