summaryrefslogtreecommitdiff
path: root/src/term.c
diff options
context:
space:
mode:
authorLucas De Marchi <lucas.demarchi@profusion.mobi>2010-08-21 13:52:25 +0000
committerLucas De Marchi <lucas.demarchi@profusion.mobi>2010-08-21 13:52:25 +0000
commit3f375e63e26172b3c81f019055c4dfe606f99e63 (patch)
tree4173ad82b98203336ae4c82db2a183b3bdd2f0aa /src/term.c
parentc81f5795de828ab88232f5a7481437f17b9e6831 (diff)
downloadeterm-3f375e63e26172b3c81f019055c4dfe606f99e63.tar.gz
Convert (hopefully) all comparisons to NULL
Apply badzero.cocci, badnull.coci and badnull2.cocci This should convert all cases where there's a comparison to NULL to simpler forms. This patch applies the following transformations: code before patch ||code after patch =============================================================== return a == NULL; return !a; return a != NULL; return !!a; func(a == NULL); func(!a); func(a != NULL); func(!!a); b = a == NULL; b = !a; b = a != NULL; b = !!a; b = a == NULL ? c : d; b = !a ? c : d; b = a != NULL ? c : d; b = a ? c : d; other cases: a == NULL !a a != NULL a SVN revision: 51487
Diffstat (limited to 'src/term.c')
-rw-r--r--src/term.c80
1 files changed, 40 insertions, 40 deletions
diff --git a/src/term.c b/src/term.c
index 8435da1..3023720 100644
--- a/src/term.c
+++ b/src/term.c
@@ -473,7 +473,7 @@ lookup_key(XEvent * ev)
PrivMode((!numlock_state), PrivMode_aplKP);
}
#ifdef USE_XIM
- if (xim_input_context != NULL) {
+ if (xim_input_context) {
Status status_return;
kbuf[0] = '\0';
@@ -680,7 +680,7 @@ lookup_key(XEvent * ev)
if (keysym >= 0xff00 && keysym <= 0xffff) {
#ifdef KEYSYM_ATTRIBUTE
/* The "keysym" attribute in the config file gets handled here. */
- if (!(shft | ctrl) && KeySym_map[keysym - 0xff00] != NULL) {
+ if (!(shft | ctrl) && KeySym_map[keysym - 0xff00]) {
const unsigned char *tmpbuf;
unsigned int len;
@@ -1080,7 +1080,7 @@ popen_printer(void)
libast_print_warning("Running setuid/setgid. Refusing to use custom printpipe.\n");
RESET_AND_ASSIGN(rs_print_pipe, STRDUP(PRINTPIPE));
}
- if ((stream = (FILE *) popen(rs_print_pipe, "w")) == NULL) {
+ if (!(stream = (FILE *)popen(rs_print_pipe, "w"))) {
libast_print_error("Can't open printer pipe \"%s\" -- %s\n", rs_print_pipe, strerror(errno));
}
return stream;
@@ -1102,7 +1102,7 @@ process_print_pipe(void)
int index;
FILE *fd;
- if ((fd = popen_printer()) != NULL) {
+ if ((fd = popen_printer())) {
for (index = 0; index < 4; /* nil */ ) {
unsigned char ch = cmd_getc();
@@ -2078,10 +2078,10 @@ append_to_title(const char *str)
{
char *name, *buff;
- REQUIRE(str != NULL);
+ REQUIRE(!!str);
XFetchName(Xdisplay, TermWin.parent, &name);
- if (name != NULL) {
+ if (name) {
buff = (char *) MALLOC(strlen(name) + strlen(str) + 1);
strcpy(buff, name);
strcat(buff, str);
@@ -2095,10 +2095,10 @@ append_to_icon_name(const char *str)
{
char *name, *buff;
- REQUIRE(str != NULL);
+ REQUIRE(!!str);
XGetIconName(Xdisplay, TermWin.parent, &name);
- if (name != NULL) {
+ if (name) {
buff = (char *) MALLOC(strlen(name) + strlen(str) + 1);
strcpy(buff, name);
strcat(buff, str);
@@ -2158,19 +2158,19 @@ xterm_seq(int op, const char *str)
set_title(str);
break;
case ESCSEQ_XTERM_PROP: /* 3 */
- if ((nstr = (char *) strsep(&tnstr, ";")) == NULL) {
+ if (!(nstr = (char *)strsep(&tnstr, ";"))) {
break;
}
- if ((valptr = strchr(nstr, '=')) != NULL) {
+ if ((valptr = strchr(nstr, '='))) {
*(valptr++) = 0;
}
set_text_property(TermWin.parent, nstr, valptr);
break;
case ESCSEQ_XTERM_CHANGE_COLOR: /* Changing existing colors 256 */
- while ((nstr = (char *) strsep(&tnstr, ";")) != NULL) {
+ while ((nstr = (char *)strsep(&tnstr, ";"))) {
i = (unsigned int) strtoul(nstr, (char **) NULL, 0);
nstr = (char *) strsep(&tnstr, ";");
- if ((i < 256) && (nstr != NULL)) {
+ if ((i < 256) && (nstr)) {
D_COLORS(("Changing color : [%d] -> %s\n", i, nstr));
set_window_color(i, nstr);
}
@@ -2256,7 +2256,7 @@ xterm_seq(int op, const char *str)
case 1:
changed = 0;
for (; 1;) {
- if ((color = (char *) strsep(&tnstr, ";")) == NULL) {
+ if (!(color = (char *)strsep(&tnstr, ";"))) {
break;
}
which = image_max;
@@ -2264,13 +2264,13 @@ xterm_seq(int op, const char *str)
which = idx; break;}
);
if (which != image_max) {
- if ((color = (char *) strsep(&tnstr, ";")) == NULL) {
+ if (!(color = (char *)strsep(&tnstr, ";"))) {
break;
}
} else {
which = image_bg;
}
- if ((mod = (char *) strsep(&tnstr, ";")) == NULL) {
+ if (!(mod = (char *)strsep(&tnstr, ";"))) {
break;
}
if (!strcasecmp(mod, "clear")) {
@@ -2297,7 +2297,7 @@ xterm_seq(int op, const char *str)
changed = 1;
continue;
}
- if ((valptr = (char *) strsep(&tnstr, ";")) == NULL) {
+ if (!(valptr = (char *)strsep(&tnstr, ";"))) {
break;
}
D_CMD(("Modifying the %s attribute of the %s color modifier of the %s image to be %s\n",
@@ -2314,7 +2314,7 @@ xterm_seq(int op, const char *str)
if (!strcasecmp(color, "image")) {
imlib_t *iml = images[which].current->iml;
- if (iml->mod == NULL) {
+ if (!iml->mod) {
iml->mod = create_colormod();
}
if (!BEG_STRCASECMP(mod, "brightness")) {
@@ -2331,7 +2331,7 @@ xterm_seq(int op, const char *str)
} else if (!strcasecmp(color, "red")) {
imlib_t *iml = images[which].current->iml;
- if (iml->rmod == NULL) {
+ if (!iml->rmod) {
iml->rmod = create_colormod();
}
if (!BEG_STRCASECMP(mod, "brightness")) {
@@ -2348,7 +2348,7 @@ xterm_seq(int op, const char *str)
} else if (!strcasecmp(color, "green")) {
imlib_t *iml = images[which].current->iml;
- if (iml->gmod == NULL) {
+ if (!iml->gmod) {
iml->gmod = create_colormod();
}
if (!BEG_STRCASECMP(mod, "brightness")) {
@@ -2365,7 +2365,7 @@ xterm_seq(int op, const char *str)
} else if (!strcasecmp(color, "blue")) {
imlib_t *iml = images[which].current->iml;
- if (iml->bmod == NULL) {
+ if (!iml->bmod) {
iml->bmod = create_colormod();
}
if (!BEG_STRCASECMP(mod, "bright")) {
@@ -2387,14 +2387,14 @@ xterm_seq(int op, const char *str)
case 2:
changed = 0;
which = image_max;
- if ((nstr = (char *) strsep(&tnstr, ";")) == NULL || (valptr = (char *) strsep(&tnstr, ";")) == NULL) {
+ if (!(nstr = (char *)strsep(&tnstr, ";")) || !(valptr = (char *)strsep(&tnstr, ";"))) {
break;
}
FOREACH_IMAGE(if (!strcasecmp(valptr, (get_image_type(idx) + 6))) {
which = idx; break;}
);
if (which != image_max) {
- if ((valptr = (char *) strsep(&tnstr, ";")) == NULL) {
+ if (!(valptr = (char *)strsep(&tnstr, ";"))) {
break;
}
} else {
@@ -2408,7 +2408,7 @@ xterm_seq(int op, const char *str)
s = (int) strtol(valptr, (char **) NULL, 0);
s = ((100 - s) << 8) / 100;
if (s == 0x100) {
- if (iml->mod != NULL) {
+ if (iml->mod) {
if (iml->mod->brightness != 0x100) {
iml->mod->brightness = 0x100;
changed = 1;
@@ -2418,7 +2418,7 @@ xterm_seq(int op, const char *str)
}
}
} else {
- if (iml->mod == NULL) {
+ if (!iml->mod) {
iml->mod = create_colormod();
}
if (iml->mod->brightness != s) {
@@ -2438,7 +2438,7 @@ xterm_seq(int op, const char *str)
}
r = (t & 0xff0000) >> 16;
if (r == 0xff) {
- if (iml->rmod != NULL) {
+ if (iml->rmod) {
if (iml->rmod->brightness != 0x100) {
iml->rmod->brightness = 0x100;
changed = 1;
@@ -2448,7 +2448,7 @@ xterm_seq(int op, const char *str)
}
}
} else {
- if (iml->rmod == NULL) {
+ if (!iml->rmod) {
iml->rmod = create_colormod();
}
if (iml->rmod->brightness != (int) r) {
@@ -2458,7 +2458,7 @@ xterm_seq(int op, const char *str)
}
g = (t & 0xff00) >> 8;
if (g == 0xff) {
- if (iml->gmod != NULL) {
+ if (iml->gmod) {
if (iml->gmod->brightness != 0x100) {
iml->gmod->brightness = 0x100;
changed = 1;
@@ -2468,7 +2468,7 @@ xterm_seq(int op, const char *str)
}
}
} else {
- if (iml->gmod == NULL) {
+ if (!iml->gmod) {
iml->gmod = create_colormod();
}
if (iml->gmod->brightness != (int) g) {
@@ -2478,7 +2478,7 @@ xterm_seq(int op, const char *str)
}
b = t & 0xff;
if (b == 0xff) {
- if (iml->bmod != NULL) {
+ if (iml->bmod) {
if (iml->bmod->brightness != 0x100) {
iml->bmod->brightness = 0x100;
changed = 1;
@@ -2488,7 +2488,7 @@ xterm_seq(int op, const char *str)
}
}
} else {
- if (iml->bmod == NULL) {
+ if (!iml->bmod) {
iml->bmod = create_colormod();
iml->bmod->contrast = iml->bmod->gamma = 0x100;
}
@@ -2709,54 +2709,54 @@ xterm_seq(int op, const char *str)
#ifdef XTERM_COLOR_CHANGE
case ESCSEQ_XTERM_FGCOLOR: /* 10 */
- if ((nstr = (char *) strsep(&tnstr, ";")) != NULL) {
+ if ((nstr = (char *)strsep(&tnstr, ";"))) {
set_window_color(fgColor, nstr);
}
/* drop */
case ESCSEQ_XTERM_BGCOLOR: /* 11 */
- if ((nstr = (char *) strsep(&tnstr, ";")) != NULL) {
+ if ((nstr = (char *)strsep(&tnstr, ";"))) {
set_window_color(bgColor, nstr);
}
/* drop */
case ESCSEQ_XTERM_CURSOR_COLOR: /* 12 */
- if ((nstr = (char *) strsep(&tnstr, ";")) != NULL) {
+ if ((nstr = (char *)strsep(&tnstr, ";"))) {
# ifndef NO_CURSORCOLOR
set_window_color(cursorColor, nstr);
# endif
}
/* drop */
case ESCSEQ_XTERM_PTR_FGCOLOR: /* 13 */
- if ((nstr = (char *) strsep(&tnstr, ";")) != NULL) {
+ if ((nstr = (char *)strsep(&tnstr, ";"))) {
set_pointer_colors(nstr, NULL);
}
/* drop */
case ESCSEQ_XTERM_PTR_BGCOLOR: /* 14 */
- if ((nstr = (char *) strsep(&tnstr, ";")) != NULL) {
+ if ((nstr = (char *)strsep(&tnstr, ";"))) {
/* UNSUPPORTED */
}
/* drop */
case ESCSEQ_XTERM_TEK_FGCOLOR: /* 15 */
- if ((nstr = (char *) strsep(&tnstr, ";")) != NULL) {
+ if ((nstr = (char *)strsep(&tnstr, ";"))) {
/* UNSUPPORTED */
}
/* drop */
case ESCSEQ_XTERM_TEK_BGCOLOR: /* 16 */
- if ((nstr = (char *) strsep(&tnstr, ";")) != NULL) {
+ if ((nstr = (char *)strsep(&tnstr, ";"))) {
/* UNSUPPORTED */
}
/* drop */
case ESCSEQ_XTERM_HILIGHT_COLOR: /* 17 */
- if ((nstr = (char *) strsep(&tnstr, ";")) != NULL) {
+ if ((nstr = (char *)strsep(&tnstr, ";"))) {
/* UNSUPPORTED */
}
/* drop */
case ESCSEQ_XTERM_BOLD_COLOR: /* 18 */
- if ((nstr = (char *) strsep(&tnstr, ";")) != NULL) {
+ if ((nstr = (char *)strsep(&tnstr, ";"))) {
set_window_color(colorBD, nstr);
}
/* drop */
case ESCSEQ_XTERM_ULINE_COLOR: /* 19 */
- if ((nstr = (char *) strsep(&tnstr, ";")) != NULL) {
+ if ((nstr = (char *)strsep(&tnstr, ";"))) {
set_window_color(colorUL, nstr);
}
#endif