diff options
author | Amadeusz Sławiński <amade@asmblr.net> | 2018-04-05 10:49:55 +0200 |
---|---|---|
committer | Amadeusz Sławiński <amade@asmblr.net> | 2018-04-06 00:18:33 +0200 |
commit | 81a2699fdd5eb0b2c2d8c5e22db6c2fb8241cf20 (patch) | |
tree | 1fd5046b2c68120ea069b9f6a05fed9ef69861c1 | |
parent | 9b5a5ed22808c51359f3e8959edb133c521a850a (diff) | |
download | screen-81a2699fdd5eb0b2c2d8c5e22db6c2fb8241cf20.tar.gz |
use NULL instead of 0 where applicable
found with sparse
warning: Using plain integer as NULL pointer
-rw-r--r-- | src/acls.c | 2 | ||||
-rw-r--r-- | src/ansi.c | 36 | ||||
-rw-r--r-- | src/attacher.c | 2 | ||||
-rw-r--r-- | src/backtick.c | 10 | ||||
-rw-r--r-- | src/canvas.c | 90 | ||||
-rw-r--r-- | src/canvas.h | 2 | ||||
-rw-r--r-- | src/display.c | 92 | ||||
-rw-r--r-- | src/encoding.c | 86 | ||||
-rw-r--r-- | src/fileio.c | 20 | ||||
-rw-r--r-- | src/help.c | 8 | ||||
-rw-r--r-- | src/input.c | 6 | ||||
-rw-r--r-- | src/layer.c | 52 | ||||
-rw-r--r-- | src/layer.h | 2 | ||||
-rw-r--r-- | src/layout.c | 24 | ||||
-rw-r--r-- | src/list_display.c | 6 | ||||
-rw-r--r-- | src/list_license.c | 2 | ||||
-rw-r--r-- | src/list_window.c | 4 | ||||
-rw-r--r-- | src/mark.c | 18 | ||||
-rw-r--r-- | src/misc.c | 2 | ||||
-rw-r--r-- | src/process.c | 322 | ||||
-rw-r--r-- | src/resize.c | 42 | ||||
-rw-r--r-- | src/sched.c | 6 | ||||
-rw-r--r-- | src/screen.c | 58 | ||||
-rw-r--r-- | src/screen.h | 2 | ||||
-rw-r--r-- | src/search.c | 4 | ||||
-rw-r--r-- | src/socket.c | 68 | ||||
-rw-r--r-- | src/termcap.c | 140 | ||||
-rw-r--r-- | src/tty.c | 2 | ||||
-rw-r--r-- | src/utmp.c | 12 | ||||
-rw-r--r-- | src/viewport.c | 4 | ||||
-rw-r--r-- | src/window.c | 62 | ||||
-rw-r--r-- | src/winmsg.c | 4 |
32 files changed, 595 insertions, 595 deletions
@@ -338,7 +338,7 @@ int UserFreeCopyBuffer(struct acluser *u) } free((char *)u->u_plop.buf); u->u_plop.len = 0; - u->u_plop.buf = 0; + u->u_plop.buf = NULL; return 0; } @@ -54,7 +54,7 @@ bool use_altscreen = false; /* enable alternate screen support? */ bool use_hardstatus = true; /* display status line in hs */ bool visual_bell = 0; -char *printcmd = 0; +char *printcmd = NULL; uint32_t *blank; /* line filled with spaces */ uint32_t *null; /* line filled with '\0' */ @@ -290,7 +290,7 @@ void WriteString(Window *win, char *buf, size_t len) close(win->w_pdisplay->d_printfd); win->w_pdisplay->d_printfd = -1; } - win->w_pdisplay = 0; + win->w_pdisplay = NULL; break; default: PrintChar(win, '\033'); @@ -666,7 +666,7 @@ static void WLogString(Window *win, char *buf, size_t len) if (logfwrite(win->w_log, buf, len) < 1) { WMsg(win, errno, "Error writing logfile"); logfclose(win->w_log); - win->w_log = 0; + win->w_log = NULL; } if (!log_flush) logfflush(win->w_log); @@ -1234,7 +1234,7 @@ static int StringEnd(Window *win) *win->w_stringp = '\0'; switch (win->w_StringType) { case OSC: /* special xterm compatibility hack */ - if (win->w_string[0] == ';' || (p = strchr(win->w_string, ';')) == 0) + if (win->w_string[0] == ';' || (p = strchr(win->w_string, ';')) == NULL) break; typ = atoi(win->w_string); p++; @@ -1249,17 +1249,17 @@ static int StringEnd(Window *win) for (display = displays; display; display = display->d_next) if (D_forecv->c_layer->l_bottom == &win->w_layer) break; /* found it */ - if (display == 0 && win->w_layer.l_cvlist) + if (display == NULL && win->w_layer.l_cvlist) display = win->w_layer.l_cvlist->c_display; - if (display == 0) + if (display == NULL) display = displays; EffectiveAclUser = windowuser; fore = win; flayer = fore->w_savelayer ? fore->w_savelayer : &fore->w_layer; DoCommand(args, argl); - EffectiveAclUser = 0; - fore = 0; - flayer = 0; + EffectiveAclUser = NULL; + fore = NULL; + flayer = NULL; } break; } @@ -1297,7 +1297,7 @@ static int StringEnd(Window *win) if (strcmp(win->w_hstatus, win->w_string) == 0) break; /* not changed */ free(win->w_hstatus); - win->w_hstatus = 0; + win->w_hstatus = NULL; } if (win->w_string != win->w_stringp) win->w_hstatus = SaveStr(win->w_string); @@ -1332,7 +1332,7 @@ static int StringEnd(Window *win) static void PrintStart(Window *win) { - win->w_pdisplay = 0; + win->w_pdisplay = NULL; /* find us a nice display to print on, fore prefered */ display = win->w_lastdisp; @@ -1909,14 +1909,14 @@ static void MFixLine(Window *win, int y, struct mchar *mc) { struct mline *ml = &win->w_mlines[y]; if (mc->attr && ml->attr == null) { - if ((ml->attr = calloc(win->w_width + 1, 4)) == 0) { + if ((ml->attr = calloc(win->w_width + 1, 4)) == NULL) { ml->attr = null; mc->attr = win->w_rend.attr = 0; WMsg(win, 0, "Warning: no space for attr - turned off"); } } if (mc->font && ml->font == null) { - if ((ml->font = calloc(win->w_width + 1, 4)) == 0) { + if ((ml->font = calloc(win->w_width + 1, 4)) == NULL) { ml->font = null; win->w_FontL = win->w_charsets[win->w_ss ? win->w_ss : win->w_Charset] = 0; win->w_FontR = win->w_charsets[win->w_ss ? win->w_ss : win->w_CharsetR] = 0; @@ -1925,14 +1925,14 @@ static void MFixLine(Window *win, int y, struct mchar *mc) } } if (mc->colorbg && ml->colorbg == null) { - if ((ml->colorbg = calloc(win->w_width + 1, 4)) == 0) { + if ((ml->colorbg = calloc(win->w_width + 1, 4)) == NULL) { ml->colorbg = null; mc->colorbg = win->w_rend.colorbg = 0; WMsg(win, 0, "Warning: no space for color background - turned off"); } } if (mc->colorfg && ml->colorfg == null) { - if ((ml->colorfg = calloc(win->w_width + 1, 4)) == 0) { + if ((ml->colorfg = calloc(win->w_width + 1, 4)) == NULL) { ml->colorfg = null; mc->colorfg = win->w_rend.colorfg = 0; WMsg(win, 0, "Warning: no space for color foreground - turned off"); @@ -2334,7 +2334,7 @@ static void WChangeSize(Window *win, int w, int h) int wok = 0; Canvas *cv; - if (win->w_layer.l_cvlist == 0) { + if (win->w_layer.l_cvlist == NULL) { /* window not displayed -> works always */ ChangeWindowSize(win, w, h, win->w_histheight); return; @@ -2348,14 +2348,14 @@ static void WChangeSize(Window *win, int w, int h) if (D_CZ0 && (w == Z0width || w == Z1width)) wok = 1; } - if (cv == 0 && wok == 0) /* can't change any display */ + if (cv == NULL && wok == 0) /* can't change any display */ return; if (!D_CWS) h = win->w_height; ChangeWindowSize(win, w, h, win->w_histheight); for (display = displays; display; display = display->d_next) { if (win == D_fore) { - if (D_cvlist && D_cvlist->c_next == 0) + if (D_cvlist && D_cvlist->c_next == NULL) ResizeDisplay(w, h); else ResizeDisplay(w, D_height); diff --git a/src/attacher.c b/src/attacher.c index c6a54b8..421f78a 100644 --- a/src/attacher.c +++ b/src/attacher.c @@ -433,7 +433,7 @@ void SendCmdMessage(char *sty, char *match, char **av, int query) char *p; int n; - if (sty == 0) { + if (sty == NULL) { i = FindSocket(&s, (int *)0, (int *)0, match); if (i == 0) Panic(0, "No screen session found."); diff --git a/src/backtick.c b/src/backtick.c index 79a3a22..4f35ce6 100644 --- a/src/backtick.c +++ b/src/backtick.c @@ -80,7 +80,7 @@ static void backtick_fn(Event *ev, void *data) memmove(bt->result, bt->buf + k, i - j - k); bt->result[i - j - k - 1] = 0; backtick_filter(bt); - WindowChanged(0, WINESC_BACKTICK); + WindowChanged(NULL, WINESC_BACKTICK); } if (j == l && i == MAXSTR) { j = MAXSTR / 2; @@ -99,7 +99,7 @@ void setbacktick(int num, int lifespan, int tick, char **cmdv) struct backtick **btp, *bt; char **v; - for (btp = &backticks; (bt = *btp) != 0; btp = &bt->next) + for (btp = &backticks; (bt = *btp) != NULL; btp = &bt->next) if (bt->num == num) break; if (!bt && !cmdv) @@ -126,7 +126,7 @@ void setbacktick(int num, int lifespan, int tick, char **cmdv) return; } memset(bt, 0, sizeof(struct backtick)); - bt->next = 0; + bt->next = NULL; *btp = bt; } bt->num = num; @@ -134,13 +134,13 @@ void setbacktick(int num, int lifespan, int tick, char **cmdv) bt->lifespan = lifespan; bt->bestbefore = 0; bt->result[0] = 0; - bt->buf = 0; + bt->buf = NULL; bt->bufi = 0; bt->cmdv = cmdv; bt->ev.fd = -1; if (bt->tick == 0 && bt->lifespan == 0) { bt->buf = malloc(MAXSTR); - if (bt->buf == 0) { + if (bt->buf == NULL) { Msg(0, "%s", strnomem); setbacktick(num, 0, 0, (char **)0); return; diff --git a/src/canvas.c b/src/canvas.c index a05913d..981bc5d 100644 --- a/src/canvas.c +++ b/src/canvas.c @@ -43,8 +43,8 @@ static void CanvasInitBlank(Canvas *cv) cv->c_blank.l_height = cv->c_ye - cv->c_ys + 1; cv->c_blank.l_x = cv->c_blank.l_y = 0; cv->c_blank.l_layfn = &BlankLf; - cv->c_blank.l_data = 0; - cv->c_blank.l_next = 0; + cv->c_blank.l_data = NULL; + cv->c_blank.l_next = NULL; cv->c_blank.l_bottom = &cv->c_blank; cv->c_blank.l_blocking = 0; cv->c_layer = &cv->c_blank; @@ -100,7 +100,7 @@ void FreeCanvas(Canvas *cv) if (display) { if (D_forecv == cv) - D_forecv = 0; + D_forecv = NULL; /* remove from canvas chain as SetCanvasWindow might call * some layer function */ for (cvp = &D_cvlist; *cvp; cvp = &(*cvp)->c_next) @@ -109,16 +109,16 @@ void FreeCanvas(Canvas *cv) break; } } - p = cv->c_layer ? Layer2Window(cv->c_layer) : 0; - SetCanvasWindow(cv, 0); + p = cv->c_layer ? Layer2Window(cv->c_layer) : NULL; + SetCanvasWindow(cv, NULL); if (p) WindowChanged(p, 'u'); if (flayer == cv->c_layer) - flayer = 0; + flayer = NULL; for (vp = cv->c_vplist; vp; vp = nvp) { - vp->v_canvas = 0; + vp->v_canvas = NULL; nvp = vp->v_next; - vp->v_next = 0; + vp->v_next = NULL; free(vp); } evdeq(&cv->c_captev); @@ -161,7 +161,7 @@ int CountCanvasPerp(Canvas *cv) Canvas *FindCanvas(int x, int y) { - Canvas *cv, *mcv = 0; + Canvas *cv, *mcv = NULL; int m, mm = 0; for (cv = D_cvlist; cv; cv = cv->c_next) { @@ -210,7 +210,7 @@ Canvas *FindCanvas(int x, int y) void SetCanvasWindow(Canvas *cv, Window *window) { - Window *p = 0, **pp; + Window *p = NULL, **pp; Layer *l; Canvas *cvp, **cvpp; @@ -226,7 +226,7 @@ void SetCanvasWindow(Canvas *cv, Window *window) p = Layer2Window(l); l = cv->c_layer; - cv->c_layer = 0; + cv->c_layer = NULL; if (p && cv == D_forecv) { ReleaseAutoWritelock(display, p); @@ -235,23 +235,23 @@ void SetCanvasWindow(Canvas *cv, Window *window) evenq(&p->w_silenceev); } D_other = fore; - D_fore = 0; + D_fore = NULL; } - if (l->l_cvlist == 0 && (p == 0 || l != p->w_savelayer)) + if (l->l_cvlist == NULL && (p == NULL || l != p->w_savelayer)) KillLayerChain(l); } /* find right layer to display on canvas */ if (window && window->w_type != W_TYPE_GROUP) { l = &window->w_layer; - if (window->w_savelayer && (window->w_blocked || window->w_savelayer->l_cvlist == 0)) + if (window->w_savelayer && (window->w_blocked || window->w_savelayer->l_cvlist == NULL)) l = window->w_savelayer; } else { l = &cv->c_blank; if (window) l->l_data = (char *)window; else - l->l_data = 0; + l->l_data = NULL; } /* add our canvas to the layer's canvaslist */ @@ -262,7 +262,7 @@ void SetCanvasWindow(Canvas *cv, Window *window) cv->c_yoff = cv->c_ys; RethinkViewportOffsets(cv); - if (flayer == 0) + if (flayer == NULL) flayer = l; if (window && window->w_type == W_TYPE_GROUP) { @@ -321,7 +321,7 @@ int MakeDefaultCanvas(void) { Canvas *cv; - if ((cv = calloc(1, sizeof(Canvas))) == 0) + if ((cv = calloc(1, sizeof(Canvas))) == NULL) return -1; cv->c_xs = 0; cv->c_xe = D_width - 1; @@ -329,12 +329,12 @@ int MakeDefaultCanvas(void) cv->c_ye = D_height - 1 - (D_has_hstatus == HSTATUS_LASTLINE) - captionalways * !captiontop; cv->c_xoff = 0; cv->c_yoff = 0; - cv->c_next = 0; + cv->c_next = NULL; cv->c_display = display; - cv->c_vplist = 0; - cv->c_slnext = 0; - cv->c_slprev = 0; - cv->c_slperp = 0; + cv->c_vplist = NULL; + cv->c_slnext = NULL; + cv->c_slprev = NULL; + cv->c_slperp = NULL; cv->c_slweight = 1; cv->c_slback = &D_canvas; D_canvas.c_slperp = cv; @@ -348,7 +348,7 @@ int MakeDefaultCanvas(void) cv->c_captev.handler = cv_winid_fn; CanvasInitBlank(cv); - cv->c_lnext = 0; + cv->c_lnext = NULL; D_cvlist = cv; RethinkDisplayViewports(); @@ -373,7 +373,7 @@ void RecreateCanvasChain(void) { Canvas **cvp; cvp = CreateCanvasChainRec(D_canvas.c_slperp, &D_cvlist); - *cvp = 0; + *cvp = NULL; } void EqualizeCanvas(Canvas *cv, bool gflag) @@ -403,7 +403,7 @@ void ResizeCanvas(Canvas *cv) xe = cv->c_xe; ye = cv->c_ye; cv = cv->c_slperp; - if (cv == 0) + if (cv == NULL) return; if (cv->c_slorient == SLICE_UNKN) { cv->c_xs = xs; @@ -417,7 +417,7 @@ void ResizeCanvas(Canvas *cv) return; } - fcv = 0; + fcv = NULL; if (focusminwidth || focusminheight) { cv2 = D_forecv; while (cv2->c_slback) { @@ -488,7 +488,7 @@ void ResizeCanvas(Canvas *cv) } } } - SetCanvasWindow(cv, 0); + SetCanvasWindow(cv, NULL); FreeCanvas(cv); continue; } @@ -547,9 +547,9 @@ static Canvas *AddPerp(Canvas *cv) { Canvas *pcv; - if ((pcv = calloc(1, sizeof(Canvas))) == 0) - return 0; - pcv->c_next = 0; + if ((pcv = calloc(1, sizeof(Canvas))) == NULL) + return NULL; + pcv->c_next = NULL; pcv->c_display = cv->c_display; pcv->c_slnext = cv->c_slnext; pcv->c_slprev = cv->c_slprev; @@ -571,9 +571,9 @@ static Canvas *AddPerp(Canvas *cv) pcv->c_slweight = cv->c_slweight; CanvasInitBlank(pcv); cv->c_slweight = 1; - cv->c_slnext = 0; - cv->c_slprev = 0; - cv->c_slperp = 0; + cv->c_slnext = NULL; + cv->c_slprev = NULL; + cv->c_slperp = NULL; cv->c_slback = pcv; cv->c_slorient = SLICE_UNKN; return pcv; @@ -613,7 +613,7 @@ int AddCanvas(int orient) if (h < 0) return -1; /* can't fit in */ - if ((cv = calloc(1, sizeof(Canvas))) == 0) + if ((cv = calloc(1, sizeof(Canvas))) == NULL) return -1; D_forecv->c_slback->c_ys = ys; /* in case we modified it above */ @@ -634,15 +634,15 @@ int AddCanvas(int orient) cv->c_xoff = 0; cv->c_yoff = 0; cv->c_display = display; - cv->c_vplist = 0; + cv->c_vplist = NULL; cv->c_captev.type = EV_TIMEOUT; cv->c_captev.data = (char *)cv; cv->c_captev.handler = cv_winid_fn; CanvasInitBlank(cv); - cv->c_lnext = 0; + cv->c_lnext = NULL; - cv->c_next = 0; + cv->c_next = NULL; cv = cv->c_slback; EqualizeCanvas(cv->c_slperp, 0); @@ -710,7 +710,7 @@ void RemCanvas(void) void OneCanvas(void) { - Canvas *cv = D_forecv, *ocv = 0; + Canvas *cv = D_forecv, *ocv = NULL; if (cv->c_slprev) { ocv = cv->c_slprev; @@ -730,8 +730,8 @@ void OneCanvas(void) cv = D_forecv; D_canvas.c_slperp = cv; cv->c_slback = &D_canvas; - cv->c_slnext = 0; - cv->c_slprev = 0; + cv->c_slnext = NULL; + cv->c_slprev = NULL; if (!captionalways) { if (captiontop) D_canvas.c_ys--; /* caption line no longer needed */ @@ -757,14 +757,14 @@ void DupLayoutCv(Canvas *cvf, Canvas *cvt, bool save) cvt->c_captev.type = EV_TIMEOUT; cvt->c_captev.data = (char *)cvt; cvt->c_captev.handler = cv_winid_fn; - cvt->c_blank.l_cvlist = 0; + cvt->c_blank.l_cvlist = NULL; cvt->c_blank.l_layfn = &BlankLf; cvt->c_blank.l_bottom = &cvt->c_blank; } cvt->c_layer = cvf->c_layer; } else { - Window *p = cvf->c_layer ? Layer2Window(cvf->c_layer) : 0; - cvt->c_layer = p ? &p->w_layer : 0; + Window *p = cvf->c_layer ? Layer2Window(cvf->c_layer) : NULL; + cvt->c_layer = p ? &p->w_layer : NULL; } if (cvf->c_slperp) { cvt->c_slperp = calloc(1, sizeof(Canvas)); @@ -791,8 +791,8 @@ void PutWindowCv(Canvas *cv) PutWindowCv(cv->c_slperp); continue; } - p = cv->c_layer ? (Window *)cv->c_layer->l_data : 0; - cv->c_layer = 0; + p = cv->c_layer ? (Window *)cv->c_layer->l_data : NULL; + cv->c_layer = NULL; SetCanvasWindow(cv, p); } } diff --git a/src/canvas.h b/src/canvas.h index 861e12a..b912f81 100644 --- a/src/canvas.h +++ b/src/canvas.h @@ -95,7 +95,7 @@ void PutWindowCv (Canvas *); Canvas *cvlnext = cv->c_lnext; \ flayer = l; \ l->l_cvlist = cv; \ - cv->c_lnext = 0; \ + cv->c_lnext = NULL; \ cmd; \ flayer = oldflayer; \ l->l_cvlist = cvlist; \ diff --git a/src/display.c b/src/display.c index 6f02c93..3a62b51 100644 --- a/src/display.c +++ b/src/display.c @@ -145,12 +145,12 @@ void DefRestore(void) const struct LayFuncs BlankLf = { DefProcess, - 0, + NULL, DefRedisplayLine, DefClearLine, BlankResize, DefRestore, - 0 + NULL }; static int BlankResize(int wi, int he) @@ -171,10 +171,10 @@ Display *MakeDisplay(char *uname, char *utty, char *term, int fd, pid_t pid, str struct acluser **u; if (!*(u = FindUserPtr(uname)) && UserAdd(uname, u)) - return 0; /* could not find or add user */ + return NULL; /* could not find or add user */ - if ((display = calloc(1, sizeof(Display))) == 0) - return 0; + if ((display = calloc(1, sizeof(Display))) == NULL) + return NULL; display->d_next = displays; displays = display; D_flow = 1; @@ -248,10 +248,10 @@ void FreeDisplay(void) freetty(); if (D_tentry) free(D_tentry); - D_tentry = 0; + D_tentry = NULL; if (D_processinputdata) free(D_processinputdata); - D_processinputdata = 0; + D_processinputdata = NULL; D_tcinited = 0; evdeq(&D_hstatusev); evdeq(&D_statusev); @@ -261,12 +261,12 @@ void FreeDisplay(void) evdeq(&D_mapev); if (D_kmaps) { free(D_kmaps); - D_kmaps = 0; + D_kmaps = NULL; D_aseqs = 0; D_nseqs = 0; - D_seqp = 0; + D_seqp = NULL; D_seql = 0; - D_seqh = 0; + D_seqh = NULL; } evdeq(&D_idleev); evdeq(&D_blankerev); @@ -282,26 +282,26 @@ void FreeDisplay(void) while (D_canvas.c_slperp) FreeCanvas(D_canvas.c_slperp); - D_cvlist = 0; + D_cvlist = NULL; for (Window *p = windows; p; p = p->w_next) { if (p->w_pdisplay == display) - p->w_pdisplay = 0; + p->w_pdisplay = NULL; if (p->w_lastdisp == display) - p->w_lastdisp = 0; + p->w_lastdisp = NULL; if (p->w_readev.condneg == (int *)&D_status || p->w_readev.condneg == &D_obuflenmax) - p->w_readev.condpos = p->w_readev.condneg = 0; + p->w_readev.condpos = p->w_readev.condneg = NULL; } for (Window *p = windows; p; p = p->w_next) if (p->w_zdisplay == display) - zmodem_abort(p, 0); + zmodem_abort(p, NULL); if (D_mousetrack) { D_mousetrack = 0; MouseMode(0); ExtMouseMode(0); } free((char *)display); - display = 0; + display = NULL; } /* @@ -899,7 +899,7 @@ void ClearArea(int x1, int y1, int xs, int xe, int x2, int y2, int bce, int usel continue; } if (uselayfn) { - vp = 0; + vp = NULL; for (cv = D_cvlist; cv; cv = cv->c_next) { if (y < cv->c_ys || y > cv->c_ye || xxe < cv->c_xs || x1 > cv->c_xe) continue; @@ -918,7 +918,7 @@ void ClearArea(int x1, int y1, int xs, int xe, int x2, int y2, int bce, int usel cvlist = flayer->l_cvlist; cvlnext = cv->c_lnext; flayer->l_cvlist = cv; - cv->c_lnext = 0; + cv->c_lnext = NULL; LayClearLine(y - vp->v_yoff, x1 - vp->v_xoff, xxe - vp->v_xoff, bce); flayer->l_cvlist = cvlist; cv->c_lnext = cvlnext; @@ -1517,7 +1517,7 @@ void MakeStatus(char *msg) GotoPos(STATCOL(D_width, D_status_len), STATLINE()); RefreshLine(STATLINE(), STATCOL(D_width, D_status_len), STATCOL(D_width, D_status_len) + D_status_len - 1, 0); GotoPos(D_status_lastx, D_status_lasty); - flayer = D_forecv ? D_forecv->c_layer : 0; + flayer = D_forecv ? D_forecv->c_layer : NULL; if (flayer) LaySetCursor(); display = olddisplay; @@ -1556,7 +1556,7 @@ void RemoveStatus(void) } } else RefreshHStatus(); - flayer = D_forecv ? D_forecv->c_layer : 0; + flayer = D_forecv ? D_forecv->c_layer : NULL; if (flayer) LaySetCursor(); display = olddisplay; @@ -1630,14 +1630,14 @@ void ShowHStatus(char *str) return; if (D_HS && D_has_hstatus == HSTATUS_HS) { - if (!D_hstatus && (str == 0 || *str == 0)) + if (!D_hstatus && (str == NULL || *str == 0)) return; SetRendition(&mchar_null); InsertMode(false); if (D_hstatus) AddCStr(D_DS); D_hstatus = false; - if (str == 0 || *str == 0) + if (str == NULL || *str == 0) return; AddCStr2(D_TS, 0); max = D_WS > 0 ? D_WS : (D_width - !D_CLP); @@ -1764,8 +1764,8 @@ void RefreshLine(int y, int from, int to, int isblank) } while (from <= to) { - lcv = 0; - lvp = 0; + lcv = NULL; + lvp = NULL; for (cv = display->d_cvlist; cv; cv = cv->c_next) { if (y == (captiontop ? cv->c_ys - 1 : cv->c_ye + 1) && from >= cv->c_xs && from <= cv->c_xe) { int extrabytes = strlen(captionstring) - strlen_onscreen(captionstring, NULL); @@ -1800,7 +1800,7 @@ void RefreshLine(int y, int from, int to, int isblank) for (vp = cv->c_vplist; vp; vp = vp->v_next) { /* find leftmost overlapping vp */ if (y >= vp->v_ys && y <= vp->v_ye && from <= vp->v_xe && to >= vp->v_xs - && (lvp == 0 || lvp->v_xs > vp->v_xs)) { + && (lvp == NULL || lvp->v_xs > vp->v_xs)) { lcv = cv; lvp = vp; } @@ -1808,7 +1808,7 @@ void RefreshLine(int y, int from, int to, int isblank) } if (cv) continue; /* we advanced from */ - if (lvp == 0) + if (lvp == NULL) break; if (from < lvp->v_xs) { if (!isblank) @@ -1836,7 +1836,7 @@ void RefreshLine(int y, int from, int to, int isblank) if (from >= lvp->v_xe + 1) continue; } - if (lcv->c_layer == 0 || yy >= lcv->c_layer->l_height || from - lvp->v_xoff >= lcv->c_layer->l_width) { + if (lcv->c_layer == NULL || yy >= lcv->c_layer->l_height || from - lvp->v_xoff >= lcv->c_layer->l_width) { if (!isblank) DisplayLine(&mline_null, &mline_blank, y, from, lvp->v_xe); from = lvp->v_xe + 1; @@ -1850,7 +1850,7 @@ void RefreshLine(int y, int from, int to, int isblank) cvlist = flayer->l_cvlist; cvlnext = lcv->c_lnext; flayer->l_cvlist = lcv; - lcv->c_lnext = 0; + lcv->c_lnext = NULL; LayRedisplayLine(yy, from - lvp->v_xoff, xx - lvp->v_xoff, isblank); flayer->l_cvlist = cvlist; lcv->c_lnext = cvlnext; @@ -1907,7 +1907,7 @@ void ClearLine(struct mline *oml, int y, int from, int to, int bce) AddCStr(D_CE); return; } - if (oml == 0) + if (oml == NULL) oml = &mline_null; if (!bce) { DisplayLine(oml, &mline_blank, y, from, to); @@ -2054,7 +2054,7 @@ void WrapChar(struct mchar *c, int x, int y, int xs, int ys, int xe, int ye, boo else if (y < D_height - 1) y++; if (ins) - InsChar(c, xs, xe, y, 0); + InsChar(c, xs, xe, y, NULL); else PutChar(c, xs, y); return; @@ -2081,7 +2081,7 @@ void WrapChar(struct mchar *c, int x, int y, int xs, int ys, int xe, int ye, boo if (ins != D_insert) InsertMode(ins); if (ins && !D_insert) { - InsChar(c, 0, xe, y, 0); + InsChar(c, 0, xe, y, NULL); return; } D_y = y; @@ -2115,7 +2115,7 @@ int ResizeDisplay(int wi, int he) void ChangeScrollRegion(int newtop, int newbot) { - if (display == 0) + if (display == NULL) return; if (newtop == newbot) return; /* xterm etc can't do it */ @@ -2123,7 +2123,7 @@ void ChangeScrollRegion(int newtop, int newbot) newtop = 0; if (newbot == -1) newbot = D_height - 1; - if (D_CS == 0) { + if (D_CS == NULL) { D_top = 0; D_bot = D_height - 1; return; @@ -2168,7 +2168,7 @@ void SetXtermOSC(int i, char *s, char *t) void ClearAllXtermOSC(void) { for (int i = 4; i >= 0; i--) - SetXtermOSC(i, 0, "\a"); + SetXtermOSC(i, NULL, "\a"); if (D_xtermosc[0]) AddStr("\033[23;" WT_FLAG "t"); /* unstack titles (xterm patch #251) */ } @@ -2268,11 +2268,11 @@ void freetty(void) if (D_userfd >= 0) close(D_userfd); D_userfd = -1; - D_obufp = 0; + D_obufp = NULL; D_obuffree = 0; if (D_obuf) free(D_obuf); - D_obuf = 0; + D_obuf = NULL; D_obuflen = 0; D_obuflenmax = -D_obufmax; D_blocked = 0; @@ -2511,7 +2511,7 @@ static void disp_readev_fn(Event *event, void *data) } display = (Display *)data; - if (D_fore == 0) + if (D_fore == NULL) size = IOSIZE; else { if (W_UWP(D_fore)) @@ -2549,7 +2549,7 @@ static void disp_readev_fn(Event *event, void *data) return; } if (D_blocked > 1) { /* 2, 3 */ - flayer = 0; + flayer = NULL; for (Window *p = windows; p; p = p->w_next) if (p->w_zdisplay == display) { char *bufp = (char *)buf; @@ -2558,7 +2558,7 @@ static void disp_readev_fn(Event *event, void *data) LayProcess(&bufp, (size_t*)&size); return; } - zmodem_abort(0, display); + zmodem_abort(NULL, display); } if (idletimo > 0) ResetIdle(); @@ -2779,7 +2779,7 @@ static void disp_processinput(Display * display, unsigned char *buf, size_t size j += EncodeChar(buf2 + j, c, enc, &font); j += EncodeChar(buf2 + j, -1, enc, &font); } else - j += EncodeChar(buf2 + j, c, enc, 0); + j += EncodeChar(buf2 + j, c, enc, NULL); if (j > (int)ARRAY_SIZE(buf2) - 10) /* just in case... */ break; } @@ -2819,7 +2819,7 @@ static void disp_blocked_fn(Event *event, void *data) /* re-enable all windows */ for (Window *p = windows; p; p = p->w_next) if (p->w_readev.condneg == &D_obuflenmax) { - p->w_readev.condpos = p->w_readev.condneg = 0; + p->w_readev.condpos = p->w_readev.condneg = NULL; } } } @@ -2838,13 +2838,13 @@ static void disp_map_fn(Event *event, void *data) p = (char *)D_seqp - l; D_seqp = D_kmaps + 3; D_seql = 0; - if ((q = D_seqh) != 0) { - D_seqh = 0; + if ((q = D_seqh) != NULL) { + D_seqh = NULL; i = q[0] << 8 | q[1]; i &= ~KMAP_NOTIMEOUT; if (StuffKey(i)) ProcessInput2((char *)q + 3, q[2]); - if (display == 0) + if (display == NULL) return; l -= q[2]; p += q[2]; @@ -2975,7 +2975,7 @@ void RunBlanker(char **cmdv) close(slave); return; case 0: - displays = 0; + displays = NULL; if (setgid(real_gid) || setuid(real_uid)) Panic(errno, "setuid/setgid"); brktty(D_userfd); @@ -2999,7 +2999,7 @@ void RunBlanker(char **cmdv) glwz.ws_col = D_width; glwz.ws_row = D_height; (void)ioctl(0, TIOCSWINSZ, (char *)&glwz); - display = 0; + display = NULL; execvpe(*cmdv, cmdv, NewEnv + 3); Panic(errno, "%s", *cmdv); default: diff --git a/src/encoding.c b/src/encoding.c index d9afe1a..4fab4e7 100644 --- a/src/encoding.c +++ b/src/encoding.c @@ -54,28 +54,28 @@ struct encoding { /* CP1251 font: 96 ? */ struct encoding encodings[] = { - {"C", 0, 0, 0, 0, 0}, + {"C", NULL, 0, 0, 0, NULL}, {"eucJP", "B\002I\00401", 0, 1, 0, "\002\004I"}, {"SJIS", "BIBB01", 0, 1, 1, "\002I"}, {"eucKR", "B\003BB01", 0, 1, 0, "\003"}, {"eucCN", "B\001BB01", 0, 1, 0, "\001"}, {"Big5", "B\030BB01", 0, 1, 0, "\030"}, - {"KOI8-R", 0, 0x80 | '!', 0, 1, 0}, - {"CP1251", 0, 0x80 | '?', 0, 1, 0}, - {"UTF-8", 0, -1, 0, 0, 0}, - {"ISO8859-2", 0, 0x80 | 'B', 0, 0, 0}, - {"ISO8859-3", 0, 0x80 | 'C', 0, 0, 0}, - {"ISO8859-4", 0, 0x80 | 'D', 0, 0, 0}, - {"ISO8859-5", 0, 0x80 | 'L', 0, 0, 0}, - {"ISO8859-6", 0, 0x80 | 'G', 0, 0, 0}, - {"ISO8859-7", 0, 0x80 | 'F', 0, 0, 0}, - {"ISO8859-8", 0, 0x80 | 'H', 0, 0, 0}, - {"ISO8859-9", 0, 0x80 | 'M', 0, 0, 0}, - {"ISO8859-10", 0, 0x80 | 'V', 0, 0, 0}, - {"ISO8859-15", 0, 0x80 | 'b', 0, 0, 0}, - {"jis", 0, 0, 0, 0, "\002\004I"}, + {"KOI8-R", NULL, 0x80 | '!', 0, 1, NULL}, + {"CP1251", NULL, 0x80 | '?', 0, 1, NULL}, + {"UTF-8", NULL, -1, 0, 0, NULL}, + {"ISO8859-2", NULL, 0x80 | 'B', 0, 0, NULL}, + {"ISO8859-3", NULL, 0x80 | 'C', 0, 0, NULL}, + {"ISO8859-4", NULL, 0x80 | 'D', 0, 0, NULL}, + {"ISO8859-5", NULL, 0x80 | 'L', 0, 0, NULL}, + {"ISO8859-6", NULL, 0x80 | 'G', 0, 0, NULL}, + {"ISO8859-7", NULL, 0x80 | 'F', 0, 0, NULL}, + {"ISO8859-8", NULL, 0x80 | 'H', 0, 0, NULL}, + {"ISO8859-9", NULL, 0x80 | 'M', 0, 0, NULL}, + {"ISO8859-10", NULL, 0x80 | 'V', 0, 0, NULL}, + {"ISO8859-15", NULL, 0x80 | 'b', 0, 0, NULL}, + {"jis", NULL, 0, 0, 0, "\002\004I"}, {"GBK", "B\031BB01", 0x80 | 'b', 1, 1, "\031"}, - {"KOI8-U", 0, 0x80 | '#', 0, 1, 0} + {"KOI8-U", NULL, 0x80 | '#', 0, 1, NULL} }; static unsigned short builtin_tabs[][2] = { @@ -315,8 +315,8 @@ static int recode_char(int c, int to_utf, int font) break; } p = recodetabs[f].tab; - if (p == 0 && recodetabs[f].flags == 0) { - LoadFontTranslation(f, 0); + if (p == NULL && recodetabs[f].flags == 0) { + LoadFontTranslation(f, NULL); p = recodetabs[f].tab; } if (p) @@ -347,8 +347,8 @@ static int recode_char(int c, int to_utf, int font) return c; if (font >= 32) { p = recodetabs[font].tab; - if (p == 0 && recodetabs[font].flags == 0) { - LoadFontTranslation(font, 0); + if (p == NULL && recodetabs[font].flags == 0) { + LoadFontTranslation(font, NULL); p = recodetabs[font].tab; } if (p) @@ -372,8 +372,8 @@ static int recode_char_dw(int c, int *c2p, int to_utf, int font) c = (c & 255) << 8 | (*c2p & 255); *c2p = 0xffff; p = recodetabs[f].tab; - if (p == 0 && recodetabs[f].flags == 0) { - LoadFontTranslation(f, 0); + if (p == NULL && recodetabs[f].flags == 0) { + LoadFontTranslation(f, NULL); p = recodetabs[f].tab; } if (p) @@ -400,8 +400,8 @@ static int recode_char_dw(int c, int *c2p, int to_utf, int font) } if (font < 32) { p = recodetabs[font].tab; - if (p == 0 && recodetabs[font].flags == 0) { - LoadFontTranslation(font, 0); + if (p == NULL && recodetabs[font].flags == 0) { + LoadFontTranslation(font, NULL); p = recodetabs[font].tab; } if (p) @@ -421,7 +421,7 @@ static int recode_char_to_encoding(int c, int encoding) if (encoding == UTF8) return recode_char(c, 1, -1); - if ((fp = encodings[encoding].fontlist) != 0) + if ((fp = encodings[encoding].fontlist) != NULL) while (*fp) if ((x = recode_char(c, 0, (unsigned char)*fp++)) != -1) return x; @@ -438,7 +438,7 @@ static int recode_char_dw_to_encoding(int c, int *c2p, int encoding) if (encoding == UTF8) return recode_char_dw(c, c2p, 1, -1); - if ((fp = encodings[encoding].fontlist) != 0) + if ((fp = encodings[encoding].fontlist) != NULL) while (*fp) if ((x = recode_char_dw(c, c2p, 0, (unsigned char)*fp++)) != -1) return x; @@ -485,15 +485,15 @@ struct mline *recode_mline(struct mline *ml, int w, int from, int to) return ml; if (w > maxlen) { for (i = 0; i < 2; i++) { - if (rml[i].image == 0) + if (rml[i].image == NULL) rml[i].image = malloc(w * 4); else rml[i].image = realloc(rml[i].image, w * 4); - if (rml[i].font == 0) + if (rml[i].font == NULL) rml[i].font = malloc(w * 4); else rml[i].font = realloc(rml[i].font, w * 4); - if (rml[i].image == 0 || rml[i].font == 0) { + if (rml[i].image == NULL || rml[i].font == NULL) { maxlen = 0; return ml; /* sorry */ } @@ -565,7 +565,7 @@ size_t ToUtf8_comb(char *p, uint32_t c) if (c >= 0xd800 && c < 0xe000 && combchars && combchars[c - 0xd800]) { l = ToUtf8_comb(p, combchars[c - 0xd800]->c1); - return l + ToUtf8(p ? p + l : 0, combchars[c - 0xd800]->c2); + return l + ToUtf8(p ? p + l : NULL, combchars[c - 0xd800]->c2); } return ToUtf8(p, c); } @@ -686,7 +686,7 @@ void WinSwitchEncoding(Window *p, int encoding) if (c < 256) continue; if (ml->font == null) { - if ((ml->font = calloc(p->w_width + 1, 4)) == 0) { + if ((ml->font = calloc(p->w_width + 1, 4)) == NULL) { ml->font = null; break; } @@ -1209,7 +1209,7 @@ int FindEncoding(char *name) { int encoding; - if (name == 0 || *name == 0) + if (name == NULL || *name == 0) return 0; if (encmatch(name, "euc")) name = "eucJP"; @@ -1226,7 +1226,7 @@ int FindEncoding(char *name) char *EncodingName(int encoding) { if (encoding >= (int)(ARRAY_SIZE(encodings))) - return 0; + return NULL; return encodings[encoding].name; } @@ -1561,9 +1561,9 @@ int RecodeBuf(unsigned char *fbuf, int flen, int fenc, int tenc, unsigned char * i--; if (c < 0) continue; - j += EncodeChar(tbuf ? (char *)tbuf + j : 0, c, tenc, &font); + j += EncodeChar(tbuf ? (char *)tbuf + j : NULL, c, tenc, &font); } - j += EncodeChar(tbuf ? (char *)tbuf + j : 0, -1, tenc, &font); + j += EncodeChar(tbuf ? (char *)tbuf + j : NULL, -1, tenc, &font); return j; } @@ -1599,15 +1599,15 @@ int LoadFontTranslation(int font, char *file) unsigned short (*p)[2], (*tab)[2]; myfile = file; - if (myfile == 0) { - if (font == 0 || screenencodings == 0) + if (myfile == NULL) { + if (font == 0 || screenencodings == NULL) return -1; if (strlen(screenencodings) > ARRAY_SIZE(buf) - 10) return -1; sprintf(buf, "%s/%02x", screenencodings, font & 0xff); myfile = buf; } - if ((f = secfopen(myfile, "r")) == 0) + if ((f = secfopen(myfile, "r")) == NULL) return -1; i = ok = 0; for (;;) { @@ -1629,7 +1629,7 @@ int LoadFontTranslation(int font, char *file) getc(f); while ((x = getc(f)) && x != EOF) getc(f); /* skip font name (padded to 2 bytes) */ - if ((p = malloc(sizeof(*p) * (i + 1) * 4)) == 0) + if ((p = malloc(sizeof(*p) * (i + 1) * 4)) == NULL) break; tab = p; while (i > 0) { @@ -1665,7 +1665,7 @@ int LoadFontTranslation(int font, char *file) i = 1; } fclose(f); - if (font != -1 && file == 0 && recodetabs[font].flags == 0) + if (font != -1 && file == NULL && recodetabs[font].flags == 0) recodetabs[font].flags = RECODETAB_TRIED; return ok ? 0 : -1; } @@ -1675,11 +1675,11 @@ void LoadFontTranslationsForEncoding(int encoding) char *c; int f; - if ((c = encodings[encoding].fontlist) != 0) + if ((c = encodings[encoding].fontlist) != NULL) while ((f = (unsigned char)*c++) != 0) if (recodetabs[f].flags == 0) - LoadFontTranslation(f, 0); + LoadFontTranslation(f, NULL); f = encodings[encoding].deffont; if (f > 0 && recodetabs[f].flags == 0) - LoadFontTranslation(f, 0); + LoadFontTranslation(f, NULL); } diff --git a/src/fileio.c b/src/fileio.c index 5e3a3b4..041fb9f 100644 --- a/src/fileio.c +++ b/src/fileio.c @@ -210,7 +210,7 @@ int StartRc(char *rcfilename, int nopanic) continue; } for (p = args[1]; p && *p; p = cp) { - if ((cp = strchr(p, '|')) != 0) + if ((cp = strchr(p, '|')) != NULL) *cp++ = '\0'; len = strlen(p); if (p[len - 1] == '*') { @@ -297,7 +297,7 @@ void RcLine(char *ubuf, int ubufl) fore = D_fore; flayer = D_forecv->c_layer; } else - flayer = fore ? fore->w_savelayer : 0; + flayer = fore ? fore->w_savelayer : NULL; if (Parse(ubuf, ubufl, args, argl) <= 0) return; if (!display) { @@ -305,7 +305,7 @@ void RcLine(char *ubuf, int ubufl) EffectiveAclUser = users; } DoCommand(args, argl); - EffectiveAclUser = 0; + EffectiveAclUser = NULL; } @@ -344,7 +344,7 @@ void WriteFile(struct acluser *user, char *fn, int dump) switch (dump) { case DUMP_TERMCAP: - if (fn == 0) { + if (fn == NULL) { i = SocketName - SocketPath; if (i > (int)ARRAY_SIZE(fnbuf) - 9) i = 0; @@ -355,8 +355,8 @@ void WriteFile(struct acluser *user, char *fn, int dump) break; case DUMP_HARDCOPY: case DUMP_SCROLLBACK: - if (fn == 0) { - if (fore == 0) + if (fn == NULL) { + if (fore == NULL) return; if (hardcopydir && *hardcopydir && strlen(hardcopydir) < ARRAY_SIZE(fnbuf) - 21) sprintf(fnbuf, "%s/hardcopy.%d", hardcopydir, fore->w_number); @@ -368,7 +368,7 @@ void WriteFile(struct acluser *user, char *fn, int dump) mode = "a"; break; case DUMP_EXCHANGE: - if (fn == 0) { + if (fn == NULL) { strncpy(fnbuf, BufferFile, ARRAY_SIZE(fnbuf) - 1); fnbuf[ARRAY_SIZE(fnbuf) - 1] = 0; fn = fnbuf; @@ -400,7 +400,7 @@ void WriteFile(struct acluser *user, char *fn, int dump) } } else fd = open(fn, O_WRONLY | O_CREAT | O_EXCL, 0666); - f = fd >= 0 ? fdopen(fd, mode) : 0; + f = fd >= 0 ? fdopen(fd, mode) : NULL; } else f = fopen(fn, mode); if (f == NULL) { @@ -555,7 +555,7 @@ int printpipe(Window *p, char *cmd) return -1; case 0: display = p->w_pdisplay; - displays = 0; + displays = NULL; close(0); if (dup(pi[0]) < 0) Panic(errno, "printpipe dup"); @@ -587,7 +587,7 @@ int readpipe(char **cmdv) Msg(errno, "fork"); return -1; case 0: - displays = 0; + displays = NULL; close(1); if (dup(pi[1]) != 1) { close(pi[1]); @@ -78,7 +78,7 @@ static const struct LayFuncs HelpLf = { DefClearLine, DefResize, DefRestore, - 0 + NULL }; void display_help(char *class, struct action *ktabp) @@ -384,7 +384,7 @@ static const struct LayFuncs BindkeyLf = { DefClearLine, DefResize, DefRestore, - 0 + NULL }; void display_bindkey(char *title, struct action *tab) @@ -547,12 +547,12 @@ static int ZmodemResize(int, int); static const struct LayFuncs ZmodemLf = { DefProcess, - 0, + NULL, ZmodemRedisplayLine, DefClearLine, ZmodemResize, DefRestore, - 0 + NULL }; static int ZmodemResize(int wi, int he) diff --git a/src/input.c b/src/input.c index b8f42fb..cede6e9 100644 --- a/src/input.c +++ b/src/input.c @@ -74,7 +74,7 @@ static const struct LayFuncs InpLf = { DefClearLine, DefResize, DefRestore, - 0 + NULL }; /* @@ -188,7 +188,7 @@ static void InpProcess(char **ppbuf, size_t *plen) #define RESET_SEARCH do { if (inpdata->search) Free(inpdata->search); } while (0) LGotoPos(flayer, inpdata->inpstringlen + (inpdata->inpmode & INP_NOECHO ? 0 : inpdata->inp.pos), INPUTLINE); - if (ppbuf == 0) { + if (ppbuf == NULL) { InpAbort(); return; } @@ -364,7 +364,7 @@ static void InpProcess(char **ppbuf, size_t *plen) inphist.prev = store; } - flayer->l_data = 0; /* so inpdata does not get freed */ + flayer->l_data = NULL; /* so inpdata does not get freed */ InpAbort(); /* redisplays... */ *ppbuf = pbuf; *plen = len; diff --git a/src/layer.c b/src/layer.c index 2b35421..c004c94 100644 --- a/src/layer.c +++ b/src/layer.c @@ -49,8 +49,8 @@ static struct mline *mlineoffset(const struct mline *ml, const int offset) { static struct mline mml; - if (ml == 0) - return 0; + if (ml == NULL) + return NULL; mml.image = ml->image + offset; mml.attr = ml->attr + offset; mml.font = ml->font + offset; @@ -124,7 +124,7 @@ void LScrollH(Layer *l, int n, int y, int xs, int xe, int bce, struct mline *ol) display = cv->c_display; if (D_blocked) continue; - ScrollH(y2, xs2, xe2, n, bce, ol ? mlineoffset(ol, -vp->v_xoff) : 0); + ScrollH(y2, xs2, xe2, n, bce, ol ? mlineoffset(ol, -vp->v_xoff) : NULL); if (xe2 - xs2 == xe - xs) continue; if (n > 0) { @@ -538,7 +538,7 @@ void LWrapChar(Layer *l, struct mchar *c, int y, int top, int bot, bool ins) && vp->v_xoff <= vp->v_xe) break; } - if (vp == 0) + if (vp == NULL) continue; /* nothing to do, character not visible */ /* find the viewport of the character at the end of the line */ for (evp = cv->c_vplist; evp; evp = evp->v_next) @@ -546,14 +546,14 @@ void LWrapChar(Layer *l, struct mchar *c, int y, int top, int bot, bool ins) && evp->v_xoff + l->l_width - 1 >= evp->v_xs && evp->v_xoff + l->l_width - 1 <= evp->v_xe) break; /* gotcha! */ - if (evp == 0 || (ins && vp->v_xoff + l->l_width - 1 > vp->v_ye)) { + if (evp == NULL || (ins && vp->v_xoff + l->l_width - 1 > vp->v_ye)) { /* no wrapping possible */ cvlist = l->l_cvlist; cvlnext = cv->c_lnext; l->l_cvlist = cv; - cv->c_lnext = 0; + cv->c_lnext = NULL; if (ins) - LInsChar(l, c, 0, yy, 0); + LInsChar(l, c, 0, yy, NULL); else LPutChar(l, c, 0, yy); l->l_cvlist = cvlist; @@ -590,11 +590,11 @@ void LWrapChar(Layer *l, struct mchar *c, int y, int top, int bot, bool ins) cvlist = l->l_cvlist; cvlnext = cv->c_lnext; l->l_cvlist = cv; - cv->c_lnext = 0; + cv->c_lnext = NULL; LScrollV(l, 1, top, bot, bce); if (!vp) { if (ins) - LInsChar(l, c, 0, bot, 0); + LInsChar(l, c, 0, bot, NULL); else LPutChar(l, c, 0, bot); } @@ -750,7 +750,7 @@ void LMsg(int err, const char *fmt, ...) for (cv = D_cvlist; cv; cv = cv->c_next) if (cv->c_layer == flayer) break; - if (cv == 0) + if (cv == NULL) continue; MakeStatus(buf); } @@ -773,11 +773,11 @@ void KillLayerChain(Layer *lay) if (l->l_layfn == &WinLf || l->l_layfn == &BlankLf) break; if (oldflayer == l) - oldflayer = 0; + oldflayer = NULL; for (cv = l->l_cvlist; cv; cv = ncv) { ncv = cv->c_lnext; - cv->c_layer = 0; - cv->c_lnext = 0; + cv->c_layer = NULL; + cv->c_lnext = NULL; } } flayer = lay; @@ -793,17 +793,17 @@ int InitOverlayPage(int datasize, const struct LayFuncs *lf, int block) Canvas *cv, *cvp, **cvpp; Window *win; - cv = 0; + cv = NULL; if (display && D_forecv->c_layer == flayer) cv = D_forecv; /* work only on this cv! */ - if ((newlay = calloc(1, sizeof(Layer))) == 0) { + if ((newlay = calloc(1, sizeof(Layer))) == NULL) { Msg(0, "No memory for layer struct"); return -1; } - data = 0; + data = NULL; if (datasize) { - if ((data = calloc(1, datasize)) == 0) { + if ((data = calloc(1, datasize)) == NULL) { free((char *)newlay); Msg(0, "No memory for layer data"); return -1; @@ -812,13 +812,13 @@ int InitOverlayPage(int datasize, const struct LayFuncs *lf, int block) win = Layer2Window(flayer); - if (win && (win->w_savelayer == flayer || (block && flayer->l_next == 0))) { - if (win->w_savelayer && win->w_savelayer != flayer && win->w_savelayer->l_cvlist == 0) + if (win && (win->w_savelayer == flayer || (block && flayer->l_next == NULL))) { + if (win->w_savelayer && win->w_savelayer != flayer && win->w_savelayer->l_cvlist == NULL) KillLayerChain(win->w_savelayer); win->w_savelayer = newlay; } - if (cv && flayer->l_next == 0 && !block) { + if (cv && flayer->l_next == NULL && !block) { Display *olddisplay = display; display = cv->c_display; RemoveStatus(); @@ -830,7 +830,7 @@ int InitOverlayPage(int datasize, const struct LayFuncs *lf, int block) break; *cvpp = cv->c_lnext; newlay->l_cvlist = cv; - cv->c_lnext = 0; + cv->c_lnext = NULL; cv->c_layer = newlay; } else { LAY_DISPLAYS(flayer, RemoveStatus()); @@ -843,7 +843,7 @@ int InitOverlayPage(int datasize, const struct LayFuncs *lf, int block) newlay->l_cvlist = flayer->l_cvlist; for (cvp = newlay->l_cvlist; cvp; cvp = cvp->c_lnext) cvp->c_layer = newlay; - flayer->l_cvlist = 0; + flayer->l_cvlist = NULL; } newlay->l_width = flayer->l_width; newlay->l_height = flayer->l_height; @@ -889,7 +889,7 @@ void ExitOverlayPage(void) if (p && p->w_savelayer == oldlay) p->w_savelayer = flayer; if (p && oldlay == p->w_paster.pa_pastelayer) - p->w_paster.pa_pastelayer = 0; + p->w_paster.pa_pastelayer = NULL; for (lay = layouts; lay; lay = lay->lay_next) for (cv = lay->lay_cvlist; cv; cv = cv->c_next) @@ -897,20 +897,20 @@ void ExitOverlayPage(void) cv->c_layer = flayer; /* add all canvases back into next layer's canvas list */ - for (ocv = 0, cv = oldlay->l_cvlist; cv; cv = cv->c_lnext) { + for (ocv = NULL, cv = oldlay->l_cvlist; cv; cv = cv->c_lnext) { cv->c_layer = flayer; ocv = cv; } if (ocv) { cv = flayer->l_cvlist; - ocv->c_lnext = 0; + ocv->c_lnext = NULL; flayer->l_cvlist = oldlay->l_cvlist; /* redisplay only the warped cvs */ if (doredisplay) LRefreshAll(flayer, 0); ocv->c_lnext = cv; } - oldlay->l_cvlist = 0; + oldlay->l_cvlist = NULL; LayerCleanupMemory(oldlay); free((char *)oldlay); LayRestore(); diff --git a/src/layer.h b/src/layer.h index 8e7d7db..1489960 100644 --- a/src/layer.h +++ b/src/layer.h @@ -127,7 +127,7 @@ struct Layer { for (cv = D_cvlist; cv; cv = cv->c_next) \ if (cv->c_layer == l) \ break; \ - if (cv == 0) \ + if (cv == NULL) \ continue; \ fn; \ } \ diff --git a/src/layout.c b/src/layout.c index 305e042..b748767 100644 --- a/src/layout.c +++ b/src/layout.c @@ -52,10 +52,10 @@ void FreeLayoutCv(Canvas *cv) if (cv->c_slperp) { FreeLayoutCv(cv->c_slperp); free(cv->c_slperp); - cv->c_slperp = 0; + cv->c_slperp = NULL; } cnext = cv->c_slnext; - cv->c_slnext = 0; + cv->c_slnext = NULL; if (cv != c) free(cv); } @@ -75,7 +75,7 @@ Layout *CreateLayout(char *title, int startat) i = 0; if (i == startat) { Msg(0, "No more layouts\n"); - return 0; + return NULL; } } lay = calloc(1, sizeof(Layout)); @@ -83,7 +83,7 @@ Layout *CreateLayout(char *title, int startat) lay->lay_autosave = 1; lay->lay_number = i; laytab[i] = lay; - lay->lay_next = 0; + lay->lay_next = NULL; pl = &layouts; while (*pl) @@ -149,13 +149,13 @@ void LoadLayout(Layout *lay) while (D_canvas.c_slperp) FreeCanvas(D_canvas.c_slperp); MakeDefaultCanvas(); - SetCanvasWindow(D_forecv, 0); - D_layout = 0; + SetCanvasWindow(D_forecv, NULL); + D_layout = NULL; return; } while (D_canvas.c_slperp) FreeCanvas(D_canvas.c_slperp); - D_cvlist = 0; + D_cvlist = NULL; D_forecv = lay->lay_forecv; if (!D_forecv) MakeDefaultCanvas(); @@ -181,7 +181,7 @@ void NewLayout(char *title, int startat) return; if (display) { - LoadLayout(0); + LoadLayout(NULL); fcv = D_forecv; DupLayoutCv(&D_canvas, &lay->lay_canvas, true); lay->lay_forecv = D_forecv; @@ -203,7 +203,7 @@ static char *AddLayoutsInfo(char *buf, int len, int where) for (pp = laytab; pp < laytab + MAXLAY; pp++) { if (pp - laytab == where && ss == buf) ss = s; - if ((p = *pp) == 0) + if ((p = *pp) == NULL) continue; t = p->lay_title; l = strlen(t); @@ -288,11 +288,11 @@ void UpdateLayoutCanvas(Canvas *cv, Window *wi) if (cv->c_layer && Layer2Window(cv->c_layer) == wi) { /* A simplistic version of SetCanvasWindow(cv, 0) */ Layer *l = cv->c_layer; - cv->c_layer = 0; - if (l->l_cvlist == 0 && (wi == 0 || l != wi->w_savelayer)) + cv->c_layer = NULL; + if (l->l_cvlist == NULL && (wi == NULL || l != wi->w_savelayer)) KillLayerChain(l); l = &cv->c_blank; - l->l_data = 0; + l->l_data = NULL; if (l->l_cvlist != cv) { cv->c_lnext = l->l_cvlist; l->l_cvlist = cv; diff --git a/src/list_display.c b/src/list_display.c index 4f0829f..86edf1b 100644 --- a/src/list_display.c +++ b/src/list_display.c @@ -69,8 +69,8 @@ static int gl_Display_header(ListData *ldata) { (void)ldata; /* unused */ - leftline("term-type size user interface window Perms", 0, 0); - leftline("---------- ------- ---------- ----------------- ---------- -----", 1, 0); + leftline("term-type size user interface window Perms", 0, NULL); + leftline("---------- ------- ---------- ----------------- ---------- -----", 1, NULL); return 2; } @@ -118,7 +118,7 @@ static int gl_Display_row(ListData *ldata, ListRow *lrow) (AclCheckPermWin(d->d_user, ACL_READ, w) ? '-' : 'x') ); } - leftline(tbuf, lrow->y, lrow == ldata->selected ? &mchar_so : d == display ? &m_current : 0); + leftline(tbuf, lrow->y, lrow == ldata->selected ? &mchar_so : d == display ? &m_current : NULL); return 1; } diff --git a/src/list_license.c b/src/list_license.c index 546262b..276f3a3 100644 --- a/src/list_license.c +++ b/src/list_license.c @@ -112,7 +112,7 @@ static int gl_License_row(ListData *ldata, ListRow *lrow) } strncpy(line, start, linelen); - leftline(line, lrow->y, 0); + leftline(line, lrow->y, NULL); free(line); return 1; diff --git a/src/list_window.c b/src/list_window.c index 45fa31b..7bfe7e9 100644 --- a/src/list_window.c +++ b/src/list_window.c @@ -107,7 +107,7 @@ static void window_kill_confirm(char *buf, size_t len, void *data) fore = w; act.nr = RC_KILL; act.args = noargs; - act.argl = 0; + act.argl = NULL; act.quiet = 0; DoAction(&act); } @@ -620,7 +620,7 @@ void WListLinkChanged(void) wdata = ldata->data; if (!(wdata->order & WLIST_MRU)) continue; - CV_CALL(cv, WListUpdate(0, ldata)); + CV_CALL(cv, WListUpdate(NULL, ldata)); } display = olddisplay; } @@ -77,7 +77,7 @@ const struct LayFuncs MarkLf = { DefClearLine, DefResize, DefRestore, - 0 + NULL }; unsigned char mark_key_tab[256]; /* this array must be initialised first! */ @@ -258,12 +258,12 @@ static int rem(int x1, int y1, int x2, int y2, int redisplay, char *pt, int yend ry = y1 - markdata->hist_offset; i = y1; - if (redisplay != 2 && pt == 0 && ry < 0) { + if (redisplay != 2 && pt == NULL && ry < 0) { i -= ry; ry = 0; } for (; i <= y2; i++, ry++) { - if (redisplay != 2 && pt == 0 && ry > yend) + if (redisplay != 2 && pt == NULL && ry > yend) break; ml = WIN(i); from = (i == y1) ? x1 : 0; @@ -278,7 +278,7 @@ static int rem(int x1, int y1, int x2, int y2, int redisplay, char *pt, int yend to = markdata->right_mar; if (redisplay == 1 && from <= to && ry >= 0 && ry <= yend) MarkRedisplayLine(ry, from, to, 0); - if (redisplay != 2 && pt == 0) /* don't count/copy */ + if (redisplay != 2 && pt == NULL) /* don't count/copy */ continue; j = from; if (dw_right(ml, j, fore->w_encoding)) @@ -463,7 +463,7 @@ static void MarkProcess(char **inbufp, size_t *inlenp) markdata = (struct markdata *)flayer->l_data; fore = markdata->md_window; md_user = markdata->md_user; - if (inbufp == 0) { + if (inbufp == NULL) { MarkAbort(); return; } @@ -885,7 +885,7 @@ static void MarkProcess(char **inbufp, size_t *inlenp) in_mark = 0; LMsg(0, "Not enough memory... Sorry."); md_user->u_plop.len = 0; - md_user->u_plop.buf = 0; + md_user->u_plop.buf = NULL; break; } if (append_mode) { @@ -1261,9 +1261,9 @@ void FreePaster(struct paster *pa) { if (pa->pa_pastebuf) free(pa->pa_pastebuf); - pa->pa_pastebuf = 0; - pa->pa_pasteptr = 0; + pa->pa_pastebuf = NULL; + pa->pa_pasteptr = NULL; pa->pa_pastelen = 0; - pa->pa_pastelayer = 0; + pa->pa_pastelayer = NULL; evdeq(&pa->pa_slowev); } @@ -204,7 +204,7 @@ int AddXChars(char *buf, int len, char *str) { char *p; - if (str == 0) { + if (str == NULL) { *buf = 0; return 0; } diff --git a/src/process.c b/src/process.c index 72d84b6..b2a2492 100644 --- a/src/process.c +++ b/src/process.c @@ -386,50 +386,50 @@ void InitKeytab(void) for (i = 0; i < ARRAY_SIZE(ktab); i++) { ktab[i].nr = RC_ILLEGAL; ktab[i].args = noargs; - ktab[i].argl = 0; + ktab[i].argl = NULL; } for (i = 0; i < KMAP_KEYS + KMAP_AKEYS; i++) { umtab[i].nr = RC_ILLEGAL; umtab[i].args = noargs; - umtab[i].argl = 0; + umtab[i].argl = NULL; dmtab[i].nr = RC_ILLEGAL; dmtab[i].args = noargs; - dmtab[i].argl = 0; + dmtab[i].argl = NULL; mmtab[i].nr = RC_ILLEGAL; mmtab[i].args = noargs; - mmtab[i].argl = 0; + mmtab[i].argl = NULL; } - argarr[1] = 0; + argarr[1] = NULL; for (i = 0; i < NKMAPDEF; i++) { if (i + KMAPDEFSTART < T_CAPS) continue; if (i + KMAPDEFSTART >= T_CAPS + KMAP_KEYS) continue; - if (kmapdef[i] == 0) + if (kmapdef[i] == NULL) continue; argarr[0] = kmapdef[i]; - SaveAction(dmtab + i + (KMAPDEFSTART - T_CAPS), RC_STUFF, argarr, 0); + SaveAction(dmtab + i + (KMAPDEFSTART - T_CAPS), RC_STUFF, argarr, NULL); } for (i = 0; i < NKMAPADEF; i++) { if (i + KMAPADEFSTART < T_CURSOR) continue; if (i + KMAPADEFSTART >= T_CURSOR + KMAP_AKEYS) continue; - if (kmapadef[i] == 0) + if (kmapadef[i] == NULL) continue; argarr[0] = kmapadef[i]; - SaveAction(dmtab + i + (KMAPADEFSTART - T_CURSOR + KMAP_KEYS), RC_STUFF, argarr, 0); + SaveAction(dmtab + i + (KMAPADEFSTART - T_CURSOR + KMAP_KEYS), RC_STUFF, argarr, NULL); } for (i = 0; i < NKMAPMDEF; i++) { if (i + KMAPMDEFSTART < T_CAPS) continue; if (i + KMAPMDEFSTART >= T_CAPS + KMAP_KEYS) continue; - if (kmapmdef[i] == 0) + if (kmapmdef[i] == NULL) continue; argarr[0] = kmapmdef[i]; - argarr[1] = 0; - SaveAction(mmtab + i + (KMAPMDEFSTART - T_CAPS), RC_STUFF, argarr, 0); + argarr[1] = NULL; + SaveAction(mmtab + i + (KMAPMDEFSTART - T_CAPS), RC_STUFF, argarr, NULL); } ktab['h'].nr = RC_HARDCOPY; @@ -442,8 +442,8 @@ void InitKeytab(void) char *args[2]; args[0] = "--confirm"; args[1] = NULL; - SaveAction(ktab + 'k', RC_KILL, args, 0); - SaveAction(ktab + Ctrl('k'), RC_KILL, args, 0); + SaveAction(ktab + 'k', RC_KILL, args, NULL); + SaveAction(ktab + Ctrl('k'), RC_KILL, args, NULL); } ktab['l'].nr = ktab[Ctrl('l')].nr = RC_REDISPLAY; ktab['w'].nr = ktab[Ctrl('w')].nr = RC_WINDOWS; @@ -464,14 +464,14 @@ void InitKeytab(void) char *args[2]; args[0] = "--confirm"; args[1] = NULL; - SaveAction(ktab + Ctrl('\\'), RC_QUIT, args, 0); + SaveAction(ktab + Ctrl('\\'), RC_QUIT, args, NULL); } ktab['d'].nr = ktab[Ctrl('d')].nr = RC_DETACH; { char *args[2]; args[0] = "--confirm"; args[1] = NULL; - SaveAction(ktab + 'D', RC_POW_DETACH, args, 0); + SaveAction(ktab + 'D', RC_POW_DETACH, args, NULL); } ktab['r'].nr = ktab[Ctrl('r')].nr = RC_WRAP; ktab['f'].nr = ktab[Ctrl('f')].nr = RC_FLOW; @@ -485,21 +485,21 @@ void InitKeytab(void) char *args[2]; args[0] = "-"; args[1] = NULL; - SaveAction(ktab + '-', RC_SELECT, args, 0); + SaveAction(ktab + '-', RC_SELECT, args, NULL); } for (i = 0; i < ((maxwin && maxwin < 10) ? maxwin : 10); i++) { char *args[2], arg1[10]; args[0] = arg1; - args[1] = 0; + args[1] = NULL; sprintf(arg1, "%d", i); - SaveAction(ktab + '0' + i, RC_SELECT, args, 0); + SaveAction(ktab + '0' + i, RC_SELECT, args, NULL); } ktab['\''].nr = RC_SELECT; /* calling a window by name */ { char *args[2]; args[0] = "-b"; - args[1] = 0; - SaveAction(ktab + '"', RC_WINDOWLIST, args, 0); + args[1] = NULL; + SaveAction(ktab + '"', RC_WINDOWLIST, args, NULL); } ktab[Ctrl('G')].nr = RC_VBELL; ktab[':'].nr = RC_COLON; @@ -507,9 +507,9 @@ void InitKeytab(void) { char *args[2]; args[0] = "."; - args[1] = 0; - SaveAction(ktab + ']', RC_PASTE, args, 0); - SaveAction(ktab + Ctrl(']'), RC_PASTE, args, 0); + args[1] = NULL; + SaveAction(ktab + ']', RC_PASTE, args, NULL); + SaveAction(ktab + Ctrl(']'), RC_PASTE, args, NULL); } ktab['{'].nr = RC_HISTORY; ktab['}'].nr = RC_HISTORY; @@ -528,14 +528,14 @@ void InitKeytab(void) { char *args[2]; args[0] = "prev"; - args[1] = 0; - SaveAction(ktab + T_BACKTAB - T_CAPS + 256, RC_FOCUS, args, 0); + args[1] = NULL; + SaveAction(ktab + T_BACKTAB - T_CAPS + 256, RC_FOCUS, args, NULL); } { char *args[2]; args[0] = "-v"; - args[1] = 0; - SaveAction(ktab + '|', RC_SPLIT, args, 0); + args[1] = NULL; + SaveAction(ktab + '|', RC_SPLIT, args, NULL); } /* These come last; they may want overwrite others: */ if (DefaultEsc >= 0) { @@ -549,7 +549,7 @@ void InitKeytab(void) idleaction.nr = RC_BLANKER; idleaction.args = noargs; - idleaction.argl = 0; + idleaction.argl = NULL; } static struct action *FindKtab(char *class, int create) @@ -557,31 +557,31 @@ static struct action *FindKtab(char *class, int create) struct kclass *kp, **kpp; int i; - if (class == 0) + if (class == NULL) return ktab; - for (kpp = &kclasses; (kp = *kpp) != 0; kpp = &kp->next) + for (kpp = &kclasses; (kp = *kpp) != NULL; kpp = &kp->next) if (!strcmp(kp->name, class)) break; - if (kp == 0) { + if (kp == NULL) { if (!create) - return 0; + return NULL; if (strlen(class) > 80) { Msg(0, "Command class name too long."); - return 0; + return NULL; } kp = malloc(sizeof(struct kclass)); - if (kp == 0) { + if (kp == NULL) { Msg(0, "%s", strnomem); - return 0; + return NULL; } kp->name = SaveStr(class); for (i = 0; i < (int)(ARRAY_SIZE(kp->ktab)); i++) { kp->ktab[i].nr = RC_ILLEGAL; kp->ktab[i].args = noargs; - kp->ktab[i].argl = 0; + kp->ktab[i].argl = NULL; kp->ktab[i].quiet = 0; } - kp->next = 0; + kp->next = NULL; *kpp = kp; } return kp->ktab; @@ -600,7 +600,7 @@ static void ClearAction(struct action *act) free(*p); free((char *)act->args); act->args = noargs; - act->argl = 0; + act->argl = NULL; } /* @@ -621,7 +621,7 @@ void ProcessInput(char *ibuf, size_t ilen) int i, l; char *p; - if (display == 0 || ilen == 0) + if (display == NULL || ilen == 0) return; if (D_seql) evdeq(&D_mapev); @@ -647,20 +647,20 @@ void ProcessInput(char *ibuf, size_t ilen) D_seqp = D_kmaps + 3; if (l == 0) break; - if ((q = D_seqh) != 0) { - D_seqh = 0; + if ((q = D_seqh) != NULL) { + D_seqh = NULL; i = q[0] << 8 | q[1]; i &= ~KMAP_NOTIMEOUT; if (StuffKey(i)) ProcessInput2((char *)q + 3, q[2]); - if (display == 0) + if (display == NULL) return; l -= q[2]; p += q[2]; } else D_dontmap = 1; ProcessInput(p, l); - if (display == 0) + if (display == NULL) return; evdeq(&D_mapev); continue; @@ -670,9 +670,9 @@ void ProcessInput(char *ibuf, size_t ilen) slen -= ilen + 1; if (slen) ProcessInput2(ibuf, slen); - if (display == 0) + if (display == NULL) return; - D_seqh = 0; + D_seqh = NULL; } ibuf = (char *)s; slen = ilen; @@ -692,10 +692,10 @@ void ProcessInput(char *ibuf, size_t ilen) p = (char *)D_seqp - l; D_seql = 0; D_seqp = D_kmaps + 3; - D_seqh = 0; + D_seqh = NULL; if (StuffKey(i)) ProcessInput2(p, l); - if (display == 0) + if (display == NULL) return; } break; @@ -740,7 +740,7 @@ void ProcessInput2(char *ibuf, size_t ilen) } slen -= ilen; if (slen) - DoProcess(fore, &ibuf, &slen, 0); + DoProcess(fore, &ibuf, &slen, NULL); if (ilen == 1) { D_ESCseen = ktab; WindowChanged(fore, WINESC_ESC_SEEN); @@ -751,7 +751,7 @@ void ProcessInput2(char *ibuf, size_t ilen) return; ktabp = D_ESCseen ? D_ESCseen : ktab; if (D_ESCseen) { - D_ESCseen = 0; + D_ESCseen = NULL; WindowChanged(fore, WINESC_ESC_SEEN); } ch = (unsigned char)*s; @@ -998,7 +998,7 @@ static void DoCommandObuflimit(struct action *act) int msgok = display && !*rc_name; char **args = act->args; - if (*args == 0) + if (*args == NULL) OutputMsg(0, "Limit is %d, current buffer size is %d", D_obufmax, D_obuflen); else if (ParseNum(act, &D_obufmax) == 0 && msgok) OutputMsg(0, "Limit set to %d", D_obufmax); @@ -1276,7 +1276,7 @@ static void DoCommandAt(struct action *act) } for (display = displays; display; display = nd) { nd = display->d_next; - if (D_forecv == 0) + if (D_forecv == NULL) continue; flayer = D_forecv->c_layer; fore = D_fore; @@ -1287,7 +1287,7 @@ static void DoCommandAt(struct action *act) OutputMsg(0, "command from %s: %s %s", s, args[1], args[2] ? args[2] : ""); display = NULL; - flayer = 0; + flayer = NULL; fore = NULL; } return; @@ -1298,7 +1298,7 @@ static void DoCommandAt(struct action *act) for (display = displays; display; display = nd) { nd = display->d_next; - if (D_forecv == 0) + if (D_forecv == NULL) continue; fore = D_fore; flayer = D_forecv->c_layer; @@ -1313,7 +1313,7 @@ static void DoCommandAt(struct action *act) s, args[1], args[2] ? args[2] : ""); display = NULL; fore = NULL; - flayer = 0; + flayer = NULL; } return; } @@ -1535,8 +1535,8 @@ static void DoCommandStuff(struct action *act) } if (StuffKey(i - T_CAPS) == 0) return; - s = display ? D_tcs[i].str : 0; - if (s == 0) + s = display ? D_tcs[i].str : NULL; + if (s == NULL) return; len = strlen(s); } @@ -1589,7 +1589,7 @@ static void DoCommandCommand(struct action *act) struct action *ktabp = ktab; if (argc == 2 && !strcmp(*args, "-c")) { - if ((ktabp = FindKtab(args[1], 0)) == 0) { + if ((ktabp = FindKtab(args[1], 0)) == NULL) { OutputMsg(0, "Unknown command class '%s'", args[1]); return; } @@ -1602,7 +1602,7 @@ static void DoCommandCommand(struct action *act) return; } if (D_ESCseen) { - D_ESCseen = 0; + D_ESCseen = NULL; WindowChanged(fore, WINESC_ESC_SEEN); } if (MoreWindows()) @@ -1786,7 +1786,7 @@ static void DoCommandWidth(struct action *act) Activate(D_fore ? D_fore->w_norefresh : 0); /* autofit */ ResizeLayer(D_forecv->c_layer, D_forecv->c_xe - D_forecv->c_xs + 1, - D_forecv->c_ye - D_forecv->c_ys + 1, 0); + D_forecv->c_ye - D_forecv->c_ys + 1, NULL); return; } if (h == D_height) @@ -1880,7 +1880,7 @@ static void DoCommandHeight(struct action *act) Activate(D_fore ? D_fore->w_norefresh : 0); /* autofit */ ResizeLayer(D_forecv->c_layer, D_forecv->c_xe - D_forecv->c_xs + 1, - D_forecv->c_ye - D_forecv->c_ys + 1, 0); + D_forecv->c_ye - D_forecv->c_ys + 1, NULL); return; } if (h == D_height) @@ -1924,7 +1924,7 @@ static void DoCommandTitle(struct action *act) queryflag = -1; return; } - if (*args == 0) + if (*args == NULL) InputAKA(); else ChangeAKA(fore, *args, strlen(*args)); @@ -2142,7 +2142,7 @@ static void DoCommandHelp(struct action *act) if (argc == 2 && !strcmp(*args, "-c")) { struct action *ktabp; - if ((ktabp = FindKtab(args[1], 0)) == 0) { + if ((ktabp = FindKtab(args[1], 0)) == NULL) { OutputMsg(0, "Unknown command class '%s'", args[1]); return; } @@ -2173,7 +2173,7 @@ static void DoCommandCopy(struct action *act) static void DoCommandHistory(struct action *act) { - static char *pasteargs[] = { ".", 0 }; + static char *pasteargs[] = { ".", NULL }; static int pasteargl[] = { 1 }; struct acluser *user = display ? D_user : users; char **args; @@ -2202,7 +2202,7 @@ static void DoCommandHistory(struct action *act) Input("Paste from register:", 1, INP_RAW, ins_reg_fn, NULL, 0); return; } - if (args[1] == 0 && !fore) /* no window? */ + if (args[1] == NULL && !fore) /* no window? */ return; /* * with two arguments we paste into a destination register @@ -2248,7 +2248,7 @@ static void DoCommandHistory(struct action *act) * if there is only one source and the destination is a window, then * pass a pointer rather than duplicating the buffer. */ - if (s[1] == 0 && args[1] == 0) + if (s[1] == 0 && args[1] == NULL) if (enc == (*s == '.' ? user->u_plop.enc : plop_tab[(int)(unsigned char)*s].enc)) { MakePaster(&fore->w_paster, *s == '.' ? user->u_plop.buf : plop_tab[(int)(unsigned char)*s].buf, @@ -2258,7 +2258,7 @@ static void DoCommandHistory(struct action *act) /* * if no shortcut, we construct a buffer */ - if ((dbuf = malloc(l)) == 0) { + if ((dbuf = malloc(l)) == NULL) { OutputMsg(0, "%s", strnomem); return; } @@ -2280,7 +2280,7 @@ static void DoCommandHistory(struct action *act) /* * when called with one argument we paste our buffer into the window */ - if (args[1] == 0) { + if (args[1] == NULL) { MakePaster(&fore->w_paster, dbuf, l, 1); } else { /* @@ -2322,7 +2322,7 @@ static void DoCommandPaste(struct action *act) Input("Paste from register:", 1, INP_RAW, ins_reg_fn, NULL, 0); return; } - if (args[1] == 0 && !fore) /* no window? */ + if (args[1] == NULL && !fore) /* no window? */ return; /* * with two arguments we paste into a destination register @@ -2368,7 +2368,7 @@ static void DoCommandPaste(struct action *act) * if there is only one source and the destination is a window, then * pass a pointer rather than duplicating the buffer. */ - if (s[1] == 0 && args[1] == 0) + if (s[1] == 0 && args[1] == NULL) if (enc == (*s == '.' ? user->u_plop.enc : plop_tab[(int)(unsigned char)*s].enc)) { MakePaster(&fore->w_paster, *s == '.' ? user->u_plop.buf : plop_tab[(int)(unsigned char)*s].buf, @@ -2378,7 +2378,7 @@ static void DoCommandPaste(struct action *act) /* * if no shortcut, we construct a buffer */ - if ((dbuf = malloc(l)) == 0) { + if ((dbuf = malloc(l)) == NULL) { OutputMsg(0, "%s", strnomem); return; } @@ -2400,7 +2400,7 @@ static void DoCommandPaste(struct action *act) /* * when called with one argument we paste our buffer into the window */ - if (args[1] == 0) { + if (args[1] == NULL) { MakePaster(&fore->w_paster, dbuf, l, 1); } else { /* @@ -2671,7 +2671,7 @@ static void DoCommandTerm(struct action *act) strncpy(screenterm, s, MAXTERMLEN); screenterm[MAXTERMLEN] = '\0'; free(s); - MakeTermcap((display == 0)); + MakeTermcap((display == NULL)); } static void DoCommandEcho(struct action *act) @@ -2711,7 +2711,7 @@ static void DoCommandBell(struct action *act) { char **args = act->args; - if (*args == 0) { + if (*args == NULL) { char buf[256]; AddXChars(buf, ARRAY_SIZE(buf), BellString); OutputMsg(0, "bell_msg is '%s'", buf); @@ -2725,7 +2725,7 @@ static void DoCommandBufferfile(struct action *act) char **args = act->args; int msgok = display && !*rc_name; - if (*args == 0) + if (*args == NULL) BufferFile = SaveStr(DEFAULT_BUFFERFILE); else if (ParseSaveStr(act, &BufferFile)) return; @@ -2742,7 +2742,7 @@ static void DoCommandPow_detach_msg(struct action *act) { char **args = act->args; - if (*args == 0) { + if (*args == NULL) { char buf[256]; AddXChars(buf, ARRAY_SIZE(buf), PowDetachString); OutputMsg(0, "pow_detach_msg is '%s'", buf); @@ -3023,7 +3023,7 @@ static void DoCommandCaption(struct action *act) static void DoCommandConsole(struct action *act) { - bool b = (console_window != 0); + bool b = (console_window != NULL); if (ParseSwitch(act, &b)) return; @@ -3036,7 +3036,7 @@ static void DoCommandConsole(struct action *act) HostName, console_window->w_number, console_window->w_title); else OutputMsg(0, "%s: grabbing console %s", rc_name, HostName); - console_window = b ? fore : 0; + console_window = b ? fore : NULL; } static void DoCommandAllpartial(struct action *act) @@ -3137,7 +3137,7 @@ static void DoCommandNumber(struct action *act) { char **args = act->args; - if (*args == 0) + if (*args == NULL) OutputMsg(0, queryflag >= 0 ? "%d (%s)" : "This is window %d (%s).", fore->w_number, fore->w_title); else { @@ -3277,7 +3277,7 @@ static void DoCommandSessionname(struct action *act) { char **args = act->args; - if (*args == 0) + if (*args == NULL) OutputMsg(0, "This session is named '%s'\n", SocketName); else { char buf[MAXPATHLEN]; @@ -3338,7 +3338,7 @@ static void DoCommandSlowpaste(struct action *act) char **args = act->args; int msgok = display && !*rc_name; - if (*args == 0) + if (*args == NULL) OutputMsg(0, fore->w_slowpaste ? "Slowpaste in window %d is %d milliseconds." : "Slowpaste in window %d is unset.", fore->w_number, fore->w_slowpaste); @@ -3387,7 +3387,7 @@ static void DoCommandVbell_msg(struct action *act) { char **args = act->args; - if (*args == 0) { + if (*args == NULL) { char buf[256]; AddXChars(buf, ARRAY_SIZE(buf), VisualBellString); OutputMsg(0, "vbell_msg is '%s'", buf); @@ -3435,7 +3435,7 @@ static void DoCommandBind(struct action *act) for (;;) { if (argc > 2 && !strcmp(*args, "-c")) { ktabp = FindKtab(args[1], 1); - if (ktabp == 0) + if (ktabp == NULL) break; args += 2; argl += 2; @@ -3512,7 +3512,7 @@ static void DoCommandBindkey(struct action *act) OutputMsg(0, "%s: bindkey: -d does not work with -m", rc_name); return; } - if (*args == 0) { + if (*args == NULL) { if (mf) display_bindkey("Edit mode", mmtab); else if (df) @@ -3531,7 +3531,7 @@ static void DoCommandBindkey(struct action *act) return; } for (i = 0, kme = kmap_exts; i < kmap_extn; i++, kme++) - if (kme->str == 0) { + if (kme->str == NULL) { if (args[1]) break; } else @@ -3548,10 +3548,10 @@ static void DoCommandBindkey(struct action *act) kme = kmap_exts + i; memset((char *)kme, 0, 8 * sizeof(struct kmap_ext)); for (; i < kmap_extn; i++, kme++) { - kme->str = 0; + kme->str = NULL; kme->dm.nr = kme->mm.nr = kme->um.nr = RC_ILLEGAL; kme->dm.args = kme->mm.args = kme->um.args = noargs; - kme->dm.argl = kme->mm.argl = kme->um.argl = 0; + kme->dm.argl = kme->mm.argl = kme->um.argl = NULL; } i -= 8; kme -= 8; @@ -3600,7 +3600,7 @@ static void DoCommandBindkey(struct action *act) if (kf == 0 && !args[1]) { if (!used && kme->str) { free(kme->str); - kme->str = 0; + kme->str = NULL; kme->fl = 0; } } @@ -3622,7 +3622,7 @@ static void DoCommandMaptimeout(struct action *act) } maptimeout = n; } - if (*args == 0 || msgok) + if (*args == NULL || msgok) OutputMsg(0, "maptimeout is %dms", maptimeout); } @@ -3721,7 +3721,7 @@ static void DoCommandAclumask(struct action *act) char *s = NULL; while ((s = *args++)) { - char *err = 0; + char *err = NULL; if (AclUmask(display ? D_user : users, s, &err)) OutputMsg(0, "umask: %s\n", err); @@ -3735,7 +3735,7 @@ static void DoCommandMultiuser(struct action *act) if (ParseOnOff(act, &b)) return; - multi = b ? "" : 0; + multi = b ? "" : NULL; chsock(); if (msgok) OutputMsg(0, "Multiuser mode %s", multi ? "enabled" : "disabled"); @@ -3842,7 +3842,7 @@ static void DoCommandEncoding(struct action *act) } for (int i = 0; i < 2; i++) { int n; - if (args[i] == 0) + if (args[i] == NULL) break; if (!strcmp(args[i], ".")) continue; @@ -3891,9 +3891,9 @@ static void DoCommandUtf8(struct action *act) for (int i = 0; i < 2; i++) { int n; - if (i && args[i] == 0) + if (i && args[i] == NULL) break; - if (args[i] == 0) + if (args[i] == NULL) n = fore->w_encoding != UTF8; else if (strcmp(args[i], "off") == 0) n = 0; @@ -3909,7 +3909,7 @@ static void DoCommandUtf8(struct action *act) OutputMsg(0, "Will %suse UTF-8 encoding", n ? "" : "not "); } else if (display) D_encoding = n ? UTF8 : 0; - if (args[i] == 0) + if (args[i] == NULL) break; } } @@ -3922,11 +3922,11 @@ static void DoCommandPrintcmd(struct action *act) if (*args) { if (printcmd) free(printcmd); - printcmd = 0; + printcmd = NULL; if (**args) printcmd = SaveStr(*args); } - if (*args == 0 || msgok) { + if (*args == NULL || msgok) { if (printcmd) OutputMsg(0, "using '%s' as print command", printcmd); else @@ -3984,7 +3984,7 @@ static void DoCommandDefhstatus(struct action *act) { char **args = act->args; - if (*args == 0) { + if (*args == NULL) { char buf[256] = { 0 }; if (nwin_default.hstatus) AddXChars(buf, ARRAY_SIZE(buf), nwin_default.hstatus); @@ -3994,7 +3994,7 @@ static void DoCommandDefhstatus(struct action *act) (void)ParseSaveStr(act, &nwin_default.hstatus); if (*nwin_default.hstatus == 0) { free(nwin_default.hstatus); - nwin_default.hstatus = 0; + nwin_default.hstatus = NULL; } } @@ -4003,7 +4003,7 @@ static void DoCommandHstatus(struct action *act) (void)ParseSaveStr(act, &fore->w_hstatus); if (*fore->w_hstatus == 0) { free(fore->w_hstatus); - fore->w_hstatus = 0; + fore->w_hstatus = NULL; } WindowChanged(fore, WINESC_HSTATUS); } @@ -4013,7 +4013,7 @@ static void DoCommandDefcharset(struct action *act) char **args = act->args; size_t len; - if (*args == 0) { + if (*args == NULL) { char buf[256] = { 0 }; if (nwin_default.charset) AddXChars(buf, ARRAY_SIZE(buf), nwin_default.charset); @@ -4040,7 +4040,7 @@ static void DoCommandCharset(struct action *act) char **args = act->args; size_t len; - if (*args == 0) { + if (*args == NULL) { char buf[256] = { 0 }; if (nwin_default.charset) AddXChars(buf, ARRAY_SIZE(buf), nwin_default.charset); @@ -4185,7 +4185,7 @@ static void DoCommandFit(struct action *act) D_forecv->c_yoff = D_forecv->c_ys; RethinkViewportOffsets(D_forecv); ResizeLayer(D_forecv->c_layer, D_forecv->c_xe - D_forecv->c_xs + 1, D_forecv->c_ye - D_forecv->c_ys + 1, - 0); + NULL); flayer = D_forecv->c_layer; LaySetCursor(); } @@ -4193,7 +4193,7 @@ static void DoCommandFit(struct action *act) static void DoCommandFocus(struct action *act) { char **args = act->args; - Canvas *cv = 0; + Canvas *cv = NULL; if (!*args || !strcmp(*args, "next")) cv = D_forecv->c_next ? D_forecv->c_next : D_cvlist; @@ -4301,7 +4301,7 @@ static void DoCommandBacktick(struct action *act) return; setbacktick(n, lifespan, tick, SaveArgs(args + 3)); } - WindowChanged(0, WINESC_BACKTICK); + WindowChanged(NULL, WINESC_BACKTICK); } static void DoCommandBlanker(struct action *act) @@ -4338,7 +4338,7 @@ static void DoCommandBlankerprg(struct action *act) for (pp = blankerprg; *pp; pp++) free(*pp); free(blankerprg); - blankerprg = 0; + blankerprg = NULL; } if (args[0][0]) blankerprg = SaveArgs(args); @@ -4415,11 +4415,11 @@ static void DoCommandGroup(struct action *act) int msgok = display && !*rc_name; if (*args) { - fore->w_group = 0; + fore->w_group = NULL; if (args[0][0]) { fore->w_group = WindowByName(*args); if (fore->w_group == fore || (fore->w_group && fore->w_group->w_type != W_TYPE_GROUP)) - fore->w_group = 0; + fore->w_group = NULL; } WindowChanged((Window *)0, WINESC_WIN_NAMES); WindowChanged((Window *)0, WINESC_WIN_NAMES_NOCUR); @@ -4597,7 +4597,7 @@ static void DoCommandLayout(struct action *act) if (!strcmp(args[1], ":last")) layout_attach = &layout_last_marker; else if (!args[1][0]) - layout_attach = 0; + layout_attach = NULL; else { Layout *lay; lay = FindLayout(args[1]); @@ -4671,17 +4671,17 @@ void DoAction(struct action *act) queryflag = -1; return; } - if ((n & NEED_DISPLAY) && display == 0) { + if ((n & NEED_DISPLAY) && display == NULL) { OutputMsg(0, "%s: %s: display required", rc_name, comms[nr].name); queryflag = -1; return; } - if ((n & NEED_FORE) && fore == 0) { + if ((n & NEED_FORE) && fore == NULL) { OutputMsg(0, "%s: %s: window required", rc_name, comms[nr].name); queryflag = -1; return; } - if ((n & NEED_LAYER) && flayer == 0) { + if ((n & NEED_LAYER) && flayer == NULL) { OutputMsg(0, "%s: %s: display or window required", rc_name, comms[nr].name); queryflag = -1; return; @@ -5301,12 +5301,12 @@ static void SaveAction(struct action *act, int nr, char **args, int *argl) if (argc == 0) { act->nr = nr; act->args = noargs; - act->argl = 0; + act->argl = NULL; return; } - if ((pp = malloc((unsigned)(argc + 1) * sizeof(char *))) == 0) + if ((pp = malloc((unsigned)(argc + 1) * sizeof(char *))) == NULL) Panic(0, "%s", strnomem); - if ((lp = malloc((unsigned)(argc) * sizeof(int))) == 0) + if ((lp = malloc((unsigned)(argc) * sizeof(int))) == NULL) Panic(0, "%s", strnomem); act->nr = nr; act->args = pp; @@ -5315,7 +5315,7 @@ static void SaveAction(struct action *act, int nr, char **args, int *argl) *lp = argl ? *argl++ : (int)strlen(*args); *pp++ = SaveStrn(*args++, *lp++); } - *pp = 0; + *pp = NULL; } static char **SaveArgs(char **args) @@ -5325,11 +5325,11 @@ static char **SaveArgs(char **args) while (args[argc]) argc++; - if ((pp = ap = malloc((unsigned)(argc + 1) * sizeof(char *))) == 0) + if ((pp = ap = malloc((unsigned)(argc + 1) * sizeof(char *))) == NULL) Panic(0, "%s", strnomem); while (argc--) *pp++ = SaveStr(*args++); - *pp = 0; + *pp = NULL; return ap; } @@ -5364,7 +5364,7 @@ int Parse(char *buf, int bufl, char **args, int *argl) } if (*p == '\0' || *p == '#' || *p == '\n') { *p = '\0'; - args[argc] = 0; + args[argc] = NULL; return argc; } if (++argc >= MAXARGS) { @@ -5454,7 +5454,7 @@ int Parse(char *buf, int bufl, char **args, int *argl) else if (!strcmp(ps, "PID")) sprintf(xbuf, "%d", getpid()); else if (!strcmp(ps, "PWD")) { - if (getcwd(path, ARRAY_SIZE(path) - 1) == 0) + if (getcwd(path, ARRAY_SIZE(path) - 1) == NULL) v = "?"; else v = path; @@ -5536,7 +5536,7 @@ void SetEscape(struct acluser *u, int e, int me) static int ParseSwitch(struct action *act, bool *var) { - if (*act->args == 0) { + if (*act->args == NULL) { *var ^= true; return 0; } @@ -5548,7 +5548,7 @@ static int ParseOnOff(struct action *act, bool *var) int num = -1; char **args = act->args; - if (*args && args[1] == 0) { + if (*args && args[1] == NULL) { if (strcmp(args[0], "on") == 0) num = true; else if (strcmp(args[0], "off") == 0) @@ -5565,7 +5565,7 @@ static int ParseOnOff(struct action *act, bool *var) static int ParseSaveStr(struct action *act, char **var) { char **args = act->args; - if (*args == 0 || args[1]) { + if (*args == NULL || args[1]) { Msg(0, "%s: %s: one argument required.", rc_name, comms[act->nr].name); return -1; } @@ -5581,7 +5581,7 @@ static int ParseNum(struct action *act, int *var) char *p, **args = act->args; p = *args; - if (p == 0 || *p == 0 || args[1]) { + if (p == NULL || *p == 0 || args[1]) { Msg(0, "%s: %s: invalid argument. Give one argument.", rc_name, comms[act->nr].name); return -1; } @@ -5606,7 +5606,7 @@ static int ParseNum1000(struct action *act, int *var) int dig = 0; p = *args; - if (p == 0 || *p == 0 || args[1]) { + if (p == NULL || *p == 0 || args[1]) { Msg(0, "%s: %s: invalid argument. Give one argument.", rc_name, comms[act->nr].name); return -1; } @@ -5648,7 +5648,7 @@ static Window *WindowByName(char *s) for (window = windows; window; window = window->w_next) if (!strncmp(window->w_title, s, strlen(s))) return window; - return 0; + return NULL; } static int WindowByNumber(char *string) @@ -5687,7 +5687,7 @@ static int ParseWinNum(struct action *act, int *var) char **args = act->args; int i = 0; - if (*args == 0 || args[1]) { + if (*args == NULL || args[1]) { Msg(0, "%s: %s: one argument required.", rc_name, comms[act->nr].name); return -1; } @@ -5737,7 +5737,7 @@ static bool IsNum(char *s) int IsNumColon(char *s, char *p, int psize) { char *q; - if ((q = strrchr(s, ':')) != 0) { + if ((q = strrchr(s, ':')) != NULL) { strncpy(p, q + 1, psize - 1); p[psize - 1] = '\0'; *q = '\0'; @@ -5754,11 +5754,11 @@ void SwitchWindow(int n) ShowWindows(-1); return; } - if ((window = wtab[n]) == 0) { + if ((window = wtab[n]) == NULL) { ShowWindows(n); return; } - if (display == 0) { + if (display == NULL) { fore = window; return; } @@ -5782,7 +5782,7 @@ void SetForeWindow(Window *window) { Window *oldfore; - if (display == 0) { + if (display == NULL) { fore = window; return; } @@ -5804,7 +5804,7 @@ void SetForeWindow(Window *window) */ void Activate(int norefresh) { - if (display == 0) + if (display == NULL) return; if (D_status) { Msg(0, "%s", ""); /* wait till mintime (keep gcc quiet) */ @@ -5830,7 +5830,7 @@ static uint16_t NextWindow(void) { Window **pp; int n = fore ? fore->w_number : maxwin; - Window *group = fore ? fore->w_group : 0; + Window *group = fore ? fore->w_group : NULL; for (pp = fore ? wtab + n + 1 : wtab; pp != wtab + n; pp++) { if (pp == wtab + maxwin) @@ -5849,7 +5849,7 @@ static uint16_t PreviousWindow(void) { Window **pp; int n = fore ? fore->w_number : 0; - Window *group = fore ? fore->w_group : 0; + Window *group = fore ? fore->w_group : NULL; for (pp = wtab + n - 1; pp != wtab + n; pp--) { if (pp == wtab - 1) @@ -5867,9 +5867,9 @@ static uint16_t PreviousWindow(void) static int MoreWindows(void) { char *m = "No other window."; - if (windows && (fore == 0 || windows->w_next)) + if (windows && (fore == NULL || windows->w_next)) return 1; - if (fore == 0) { + if (fore == NULL) { Msg(0, "No window available"); return 0; } @@ -5892,9 +5892,9 @@ void KillWindow(Window *window) break; *pp = p->w_next; window->w_inlen = 0; - wtab[window->w_number] = 0; + wtab[window->w_number] = NULL; - if (windows == 0) { + if (windows == NULL) { FreeWindow(window); Finit(0); } @@ -5908,13 +5908,13 @@ void KillWindow(Window *window) if (Layer2Window(cv->c_layer) != window) continue; /* switch to other window */ - SetCanvasWindow(cv, FindNiceWindow(D_other, 0)); + SetCanvasWindow(cv, FindNiceWindow(D_other, NULL)); gotone = 1; } if (gotone) { if (window->w_zdisplay == display) { D_blocked = 0; - D_readev.condpos = D_readev.condneg = 0; + D_readev.condpos = D_readev.condneg = NULL; } Activate(-1); } @@ -5934,15 +5934,15 @@ static void LogToggle(bool on) { char buf[1024]; - if ((fore->w_log != 0) == on) { + if ((fore->w_log != NULL) == on) { if (display && !*rc_name) Msg(0, "You are %s logging.", on ? "already" : "not"); return; } - if (fore->w_log != 0) { + if (fore->w_log != NULL) { Msg(0, "Logfile \"%s\" closed.", fore->w_log->name); logfclose(fore->w_log); - fore->w_log = 0; + fore->w_log = NULL; WindowChanged(fore, WINESC_WFLAGS); return; } @@ -5976,7 +5976,7 @@ char *AddWindows(WinMsgBufContext *wmbc, int len, int flags, int where) int rend = -1; if (pp - wtab == where && ss == buf) ss = s; - if ((p = *pp) == 0) + if ((p = *pp) == NULL) continue; if ((flags & 1) && display && p == D_fore) continue; @@ -6027,7 +6027,7 @@ char *AddWindows(WinMsgBufContext *wmbc, int len, int flags, int where) char *AddWindowFlags(char *buf, int len, Window *p) { char *s = buf; - if (p == 0 || len < 12) { + if (p == NULL || len < 12) { *s = 0; return s; } @@ -6046,7 +6046,7 @@ char *AddWindowFlags(char *buf, int len, Window *p) if (p->w_slot != (slot_t) 0 && p->w_slot != (slot_t) - 1) *s++ = '$'; #endif - if (p->w_log != 0) { + if (p->w_log != NULL) { strcpy(s, "(L)"); s += 3; } @@ -6151,7 +6151,7 @@ static void ShowInfo(void) Window *wp = fore; int i; - if (wp == 0) { + if (wp == NULL) { Msg(0, "(%d,%d)/(%d,%d) no window", D_x + 1, D_y + 1, D_width, D_height); return; } @@ -6184,7 +6184,7 @@ static void ShowInfo(void) sprintf(p += strlen(p), " nored"); p += strlen(p); - if (wp->w_encoding && (display == 0 || D_encoding != wp->w_encoding || EncodingDefFont(wp->w_encoding) <= 0)) { + if (wp->w_encoding && (display == NULL || D_encoding != wp->w_encoding || EncodingDefFont(wp->w_encoding) <= 0)) { *p++ = ' '; strcpy(p, EncodingName(wp->w_encoding)); p += strlen(p); @@ -6239,7 +6239,7 @@ static void ShowDInfo(void) { char buf[128], *p; int l; - if (display == 0) + if (display == NULL) return; p = buf; l = 512; @@ -6618,7 +6618,7 @@ static void copy_reg_fn(char *buf, size_t len, void *data) } if (pp->buf) free(pp->buf); - pp->buf = 0; + pp->buf = NULL; pp->len = 0; if (D_user->u_plop.len) { if ((pp->buf = malloc(D_user->u_plop.len)) == NULL) { @@ -6680,7 +6680,7 @@ static void confirm_fn(char *buf, size_t len, void *data) } act.nr = *(int *)data; act.args = noargs; - act.argl = 0; + act.argl = NULL; act.quiet = 0; DoAction(&act); } @@ -6815,7 +6815,7 @@ int StuffKey(int i) if (i < KMAP_KEYS && D_ESCseen) { struct action *act = &D_ESCseen[i + 256]; if (act->nr != RC_ILLEGAL) { - D_ESCseen = 0; + D_ESCseen = NULL; WindowChanged(fore, WINESC_ESC_SEEN); DoAction(act); return 0; @@ -6829,7 +6829,7 @@ int StuffKey(int i) i += T_OCAPS - T_CURSOR; flayer = D_forecv->c_layer; fore = D_fore; - act = 0; + act = NULL; if (flayer && flayer->l_mode == 1) act = i < KMAP_KEYS + KMAP_AKEYS ? &mmtab[i] : &kmap_exts[i - (KMAP_KEYS + KMAP_AKEYS)].mm; if ((!act || act->nr == RC_ILLEGAL) && !D_mapdefault) @@ -6842,14 +6842,14 @@ int StuffKey(int i) if (D_tcs[keyno + T_CAPS].str && strlen(D_tcs[keyno + T_CAPS].str) == 1) return -1; if (D_ESCseen) { - D_ESCseen = 0; + D_ESCseen = NULL; WindowChanged(fore, WINESC_ESC_SEEN); } return 0; } D_mapdefault = 0; - if (act == 0 || act->nr == RC_ILLEGAL) + if (act == NULL || act->nr == RC_ILLEGAL) return -1; DoAction(act); return 0; @@ -6876,10 +6876,10 @@ Window *FindNiceWindow(Window *win, char *presel) if (!display) return win; if (win && AclCheckPermWin(D_user, ACL_READ, win)) - win = 0; + win = NULL; if (!win || (IsOnDisplay(win) && !presel)) { /* try to get another window */ - win = 0; + win = NULL; for (win = windows; win; win = win->w_next) if (!win->w_layer.l_cvlist && !AclCheckPermWin(D_user, ACL_WRITE, win)) break; @@ -6907,7 +6907,7 @@ Window *FindNiceWindow(Window *win, char *presel) break; } if (win && AclCheckPermWin(D_user, ACL_READ, win)) - win = 0; + win = NULL; return win; } @@ -7150,7 +7150,7 @@ void SetForeCanvas(Display *d, Canvas *cv) } fore = D_fore = Layer2Window(D_forecv->c_layer); if (D_other == fore) - D_other = 0; + D_other = NULL; flayer = D_forecv->c_layer; if (D_xtermosc[2] || D_xtermosc[3]) { Activate(-1); @@ -7160,7 +7160,7 @@ void SetForeCanvas(Display *d, Canvas *cv) flayer = D_forecv->c_layer; CV_CALL(D_forecv, LayRestore(); LaySetCursor()); - WindowChanged(0, WINESC_FOCUS); + WindowChanged(NULL, WINESC_FOCUS); } display = odisplay; @@ -7173,7 +7173,7 @@ void RefreshXtermOSC(void) p = Layer2Window(D_forecv->c_layer); for (i = 4; i >= 0; i--) - SetXtermOSC(i, p ? p->w_xtermosc[i] : 0, "\a"); + SetXtermOSC(i, p ? p->w_xtermosc[i] : NULL, "\a"); } /* diff --git a/src/resize.c b/src/resize.c index 1402e4c..de85d0a 100644 --- a/src/resize.c +++ b/src/resize.c @@ -75,7 +75,7 @@ void CheckScreenSize(int change_flag) { int wi, he; - if (display == 0) { + if (display == NULL) { return; } @@ -116,7 +116,7 @@ void ChangeScreenSize(int wi, int he, int change_fore) RecreateCanvasChain(); RethinkDisplayViewports(); } - if (D_forecv == 0) + if (D_forecv == NULL) D_forecv = D_cvlist; if (D_forecv) D_fore = Layer2Window(D_forecv->c_layer); @@ -137,12 +137,12 @@ void ChangeScreenSize(int wi, int he, int change_fore) } if (change_fore) ResizeLayersToCanvases(); - if (change_fore == 2 && D_CWS == NULL && displays->d_next == 0) { + if (change_fore == 2 && D_CWS == NULL && displays->d_next == NULL) { /* adapt all windows - to be removed ? */ for (p = windows; p; p = p->w_next) { wwi = wi; - if (p->w_savelayer && p->w_savelayer->l_cvlist == 0) - ResizeLayer(p->w_savelayer, wwi, he, 0); + if (p->w_savelayer && p->w_savelayer->l_cvlist == NULL) + ResizeLayer(p->w_savelayer, wwi, he, NULL); } } } @@ -156,7 +156,7 @@ void ResizeLayersToCanvases(void) D_kaablamm = 0; for (cv = D_cvlist; cv; cv = cv->c_next) { l = cv->c_layer; - if (l == 0) + if (l == NULL) continue; if (l->l_width == cv->c_xe - cv->c_xs + 1 && l->l_height == cv->c_ye - cv->c_ys + 1) { continue; @@ -328,7 +328,7 @@ static int AllocMline(struct mline *ml, int w) ml->font = null; ml->colorbg = null; ml->colorfg = null; - if (ml->image == 0) + if (ml->image == NULL) return -1; return 0; } @@ -339,25 +339,25 @@ static int BcopyMline(struct mline *mlf, int xf, struct mline *mlt, int xt, int memmove(mlt->image + xt, mlf->image + xf, l * 4); if (mlf->attr != null && mlt->attr == null) { - if ((mlt->attr = calloc(w, 4)) == 0) + if ((mlt->attr = calloc(w, 4)) == NULL) mlt->attr = null, r = -1; } if (mlt->attr != null) memmove(mlt->attr + xt, mlf->attr + xf, l * 4); if (mlf->font != null && mlt->font == null) { - if ((mlt->font = calloc(w, 4)) == 0) + if ((mlt->font = calloc(w, 4)) == NULL) mlt->font = null, r = -1; } if (mlt->font != null) memmove(mlt->font + xt, mlf->font + xf, l * 4); if (mlf->colorbg != null && mlt->colorbg == null) { - if ((mlt->colorbg = calloc(w, 4)) == 0) + if ((mlt->colorbg = calloc(w, 4)) == NULL) mlt->colorbg = null, r = -1; } if (mlt->colorbg != null) memmove(mlt->colorbg + xt, mlf->colorbg + xf, l * 4); if (mlf->colorfg != null && mlt->colorfg == null) { - if ((mlt->colorfg = calloc(w, 4)) == 0) + if ((mlt->colorfg = calloc(w, 4)) == NULL) mlt->colorfg = null, r = -1; } if (mlt->colorfg != null) @@ -436,7 +436,7 @@ void *xrealloc(void *mem, size_t len) { char *nmem; - if (mem == 0) + if (mem == NULL) return malloc(len); if ((nmem = realloc(mem, len))) return nmem; @@ -458,7 +458,7 @@ static void MakeBlankLine(uint32_t *p, int n) int ChangeWindowSize(Window *p, int wi, int he, int hi) { - struct mline *mlf = 0, *mlt = 0, *ml, *nmlines, *nhlines; + struct mline *mlf = NULL, *mlt = NULL, *ml, *nmlines, *nhlines; int fy, ty, l, lx, lf, lt, yy, oty, addone; int ncx, ncy, naka, t; int y, shift; @@ -488,14 +488,14 @@ int ChangeWindowSize(Window *p, int wi, int he, int hi) fy = p->w_histheight + p->w_height - 1; ty = hi + he - 1; - nmlines = nhlines = 0; + nmlines = nhlines = NULL; ncx = 0; ncy = 0; naka = 0; if (wi) { if (wi != p->w_width || he != p->w_height) { - if ((nmlines = calloc(he, sizeof(struct mline))) == 0) { + if ((nmlines = calloc(he, sizeof(struct mline))) == NULL) { KillWindow(p); Msg(0, "%s", strnomem); return -1; @@ -510,7 +510,7 @@ int ChangeWindowSize(Window *p, int wi, int he, int hi) } } if (hi) { - if ((nhlines = calloc(hi, sizeof(struct mline))) == 0) { + if ((nhlines = calloc(hi, sizeof(struct mline))) == NULL) { Msg(0, "No memory for history buffer - turned off"); hi = 0; ty = he - 1; @@ -591,7 +591,7 @@ int ChangeWindowSize(Window *p, int wi, int he, int hi) oty = ty; while (l > 0 && fy >= 0 && ty >= 0) { lx = lt > lf ? lf : lt; - if (mlt->image == 0) { + if (mlt->image == NULL) { if (AllocMline(mlt, wi + 1)) goto nomem; MakeBlankLine(mlt->image + lt, wi - lt); @@ -669,7 +669,7 @@ int ChangeWindowSize(Window *p, int wi, int he, int hi) if (wi) { t = p->w_tabs ? p->w_width : 0; p->w_tabs = xrealloc(p->w_tabs, (wi + 1) * 4); - if (p->w_tabs == 0) { + if (p->w_tabs == NULL) { nomem: if (nmlines) { for (ty = he + hi - 1; ty >= 0; ty--) { @@ -695,7 +695,7 @@ int ChangeWindowSize(Window *p, int wi, int he, int hi) } else { if (p->w_tabs) free(p->w_tabs); - p->w_tabs = 0; + p->w_tabs = NULL; } } @@ -762,7 +762,7 @@ void FreeAltScreen(Window *p) FreeMline(p->w_alt.mlines + i); free(p->w_alt.mlines); } - p->w_alt.mlines = 0; + p->w_alt.mlines = NULL; p->w_alt.width = 0; p->w_alt.height = 0; if (p->w_alt.hlines) { @@ -770,7 +770,7 @@ void FreeAltScreen(Window *p) FreeMline(p->w_alt.hlines + i); free(p->w_alt.hlines); } - p->w_alt.hlines = 0; + p->w_alt.hlines = NULL; p->w_alt.histidx = 0; p->w_alt.histheight = 0; } diff --git a/src/sched.c b/src/sched.c index 2ca7ded..6f59a0e 100644 --- a/src/sched.c +++ b/src/sched.c @@ -86,8 +86,8 @@ static Event *calctimo(void) Event *ev, *min; long mins; - if ((min = tevs) == 0) - return 0; + if ((min = tevs) == NULL) + return NULL; mins = min->timeout.tv_sec; for (ev = tevs->next; ev; ev = ev->next) { if (mins < ev->timeout.tv_sec) @@ -104,7 +104,7 @@ void sched(void) { Event *ev; fd_set r, w, *set; - Event *timeoutev = 0; + Event *timeoutev = NULL; struct timeval timeout; int nsel; diff --git a/src/screen.c b/src/screen.c index c500cb1..548572f 100644 --- a/src/screen.c +++ b/src/screen.c @@ -202,7 +202,7 @@ static struct passwd *getpwbyname(char *name, struct passwd *ppp) } if (n < 13) - ppp->pw_passwd = 0; + ppp->pw_passwd = NULL; if (ppp->pw_passwd && strlen(ppp->pw_passwd) == 13 + 11) ppp->pw_passwd[13] = 0; /* beware of linux's long passwords */ @@ -287,7 +287,7 @@ int main(int argc, char **argv) struct NewWindow nwin; bool detached = false; /* start up detached */ char *sockp; - char *sty = 0; + char *sty = NULL; /* * First, close all unused descriptors @@ -308,7 +308,7 @@ int main(int argc, char **argv) wliststr = SaveStr("%4n %t%=%f"); BufferFile = SaveStr(DEFAULT_BUFFERFILE); ShellProg = NULL; - PowDetachString = 0; + PowDetachString = NULL; default_startup = (argc > 1) ? false : true; adaptflag = false; VBellWait = VBELLWAIT * 1000; @@ -642,7 +642,7 @@ int main(int argc, char **argv) if (!mflag && !SocketMatch) { sty = getenv("STY"); if (sty && *sty == 0) - sty = 0; + sty = NULL; } own_uid = multi_uid = real_uid; @@ -669,15 +669,15 @@ int main(int argc, char **argv) Panic(0, "Must run suid root for multiuser support."); } if (SocketMatch && *SocketMatch == 0) - SocketMatch = 0; + SocketMatch = NULL; if ((LoginName = getlogin()) != NULL) { if ((ppp = getpwnam(LoginName)) != (struct passwd *)0) if (ppp->pw_uid != real_uid) ppp = (struct passwd *)0; } - if (ppp == 0) { - if ((ppp = getpwuid(real_uid)) == 0) { + if (ppp == NULL) { + if ((ppp = getpwuid(real_uid)) == NULL) { Panic(0, "getpwuid() can't identify your account!"); exit(1); } @@ -704,7 +704,7 @@ int main(int argc, char **argv) eff_gid = real_gid; \ } while (0) - if (home == 0 || *home == '\0') + if (home == NULL || *home == '\0') home = ppp->pw_dir; if (strlen(LoginName) > MAXLOGINLEN) Panic(0, "LoginName too long - sorry."); @@ -741,7 +741,7 @@ int main(int argc, char **argv) close(n); } - if ((attach_term = getenv("TERM")) == 0 || *attach_term == 0) + if ((attach_term = getenv("TERM")) == NULL || *attach_term == 0) Panic(0, "Please set a terminal type."); if (strlen(attach_term) > MAXTERMLEN) Panic(0, "$TERM too long - sorry."); @@ -766,7 +766,7 @@ int main(int argc, char **argv) #endif } else { #ifndef SOCKET_DIR - if (SocketDir == 0) { + if (SocketDir == NULL) { sprintf(SocketPath, "%s/.screen", home); SocketDir = SocketPath; } @@ -965,7 +965,7 @@ int main(int argc, char **argv) if (UserAdd(LoginName, (struct acluser **)0) < 0) Panic(0, "Could not create user info"); if (!detached) { - if (MakeDisplay(LoginName, attach_tty, attach_term, n, getppid(), &attach_Mode) == 0) + if (MakeDisplay(LoginName, attach_tty, attach_term, n, getppid(), &attach_Mode) == NULL) Panic(0, "Could not alloc display"); PanicPid = 0; D_encoding = nwin_options.encoding > 0 ? nwin_options.encoding : 0; @@ -1099,7 +1099,7 @@ void SigHup(int sigsig) { (void)sigsig; /* unused */ /* Hangup all displays */ - while ((display = displays) != 0) + while ((display = displays)) Hangup(); } @@ -1260,7 +1260,7 @@ void eexit(int e) void Hangup(void) { - if (display == 0) + if (display == NULL) return; if (D_userfd >= 0) { close(D_userfd); @@ -1292,7 +1292,7 @@ void Detach(int mode) Canvas *cv; Window *p; - if (display == 0) + if (display == NULL) return; #define AddStrSocket(msg) do { \ @@ -1351,7 +1351,7 @@ void Detach(int mode) break; } #ifdef ENABLE_UTMP - if (displays->d_next == 0) { + if (displays->d_next == NULL) { for (p = windows; p; p = p->w_next) { if (p->w_slot != (slot_t) - 1 && !(p->w_lflag & 2)) { RemoveUtmp(p); @@ -1366,7 +1366,7 @@ void Detach(int mode) if (mode != D_HANGUP) RestoreLoginSlot(); #endif - if (displays->d_next == 0 && console_window) { + if (displays->d_next == NULL && console_window) { if (TtyGrabConsole(console_window->w_ptyfd, false, "detach")) { KillWindow(console_window); display = displays; /* restore display */ @@ -1381,14 +1381,14 @@ void Detach(int mode) layout_last = D_layout; for (cv = D_cvlist; cv; cv = cv->c_next) { p = Layer2Window(cv->c_layer); - SetCanvasWindow(cv, 0); + SetCanvasWindow(cv, NULL); if (p) WindowChanged(p, 'u'); } pid = D_userpid; FreeDisplay(); - if (displays == 0) + if (displays == NULL) /* Flag detached-ness */ (void)chsock(); /* @@ -1434,7 +1434,7 @@ void MakeNewEnv(void) ) *np++ = *op; } - *np = 0; + *np = NULL; } #define PROCESS_MESSAGE(B) do { \ @@ -1469,7 +1469,7 @@ void Msg(int err, const char *fmt, ...) */ char *tty = D_usertty; Display *olddisplay = display; - display = 0; /* only send once */ + display = NULL; /* only send once */ SendErrorMsg(tty, buf); display = olddisplay; } else @@ -1487,16 +1487,16 @@ void Panic(int err, const char *fmt, ...) char buf[MAXPATHLEN * 2]; PROCESS_MESSAGE(buf); - if (displays == 0 && display == 0) { + if (displays == NULL && display == NULL) { printf("%s\r\n", buf); if (PanicPid) Kill(PanicPid, SIG_BYE); - } else if (displays == 0) { + } else if (displays == NULL) { /* no displays but a display - must have forked. * send message to backend! */ char *tty = D_usertty; - display = 0; + display = NULL; SendErrorMsg(tty, buf); sleep(2); _exit(1); @@ -1655,7 +1655,7 @@ static void serv_select_fn(Event *event, void *data) for (cv = D_cvlist; cv; cv = cv->c_next) if (cv->c_layer->l_bottom == &p->w_layer) break; - if (cv == 0) { + if (cv == NULL) { p->w_bell = BELL_DONE; Msg(0, "%s", MakeWinMsg(BellString, p, '%')); } else if (visual && !D_VB && (!D_status || !D_status_bell)) { @@ -1745,7 +1745,7 @@ static void serv_select_fn(Event *event, void *data) if (n > cv->c_layer->l_width) n = cv->c_layer->l_width; CV_CALL(cv, LayRedisplayLine(-1, -1, -1, 1); for (i = 0; i < flayer->l_height; i++) { - LScrollH(flayer, -n, i, 0, flayer->l_width - 1, 0, 0); + LScrollH(flayer, -n, i, 0, flayer->l_width - 1, 0, NULL); LayRedisplayLine(i, 0, n - 1, 1);} if (cv == cv->c_display->d_forecv) LaySetCursor();) ; @@ -1760,7 +1760,7 @@ static void serv_select_fn(Event *event, void *data) if (n > cv->c_layer->l_width) n = cv->c_layer->l_width; CV_CALL(cv, LayRedisplayLine(-1, -1, -1, 1); for (i = 0; i < flayer->l_height; i++) { - LScrollH(flayer, n, i, 0, flayer->l_width - 1, 0, 0); + LScrollH(flayer, n, i, 0, flayer->l_width - 1, 0, NULL); LayRedisplayLine(i, flayer->l_width - n, flayer->l_width - 1, 1);} if (cv == cv->c_display->d_forecv) LaySetCursor();) ; @@ -1769,7 +1769,7 @@ static void serv_select_fn(Event *event, void *data) } for (display = displays; display; display = display->d_next) { - if (D_status == STATUS_ON_WIN || D_cvlist == 0 || D_cvlist->c_next == 0) + if (D_status == STATUS_ON_WIN || D_cvlist == NULL || D_cvlist->c_next == NULL) continue; CV_CALL(D_forecv, LayRestore(); LaySetCursor()); @@ -1818,14 +1818,14 @@ static void logflush_fn(Event *event, void *data) static char *ParseChar(char *p, char *cp) { if (*p == 0) - return 0; + return NULL; if (*p == '^' && p[1]) { if (*++p == '?') *cp = '\177'; else if (*p >= '@') *cp = Ctrl(*p); else - return 0; + return NULL; ++p; } else if (*p == '\\' && *++p <= '7' && *p >= '0') { *cp = 0; diff --git a/src/screen.h b/src/screen.h index d4203f2..0401c5d 100644 --- a/src/screen.h +++ b/src/screen.h @@ -37,7 +37,7 @@ #include "os.h" /* here comes my own Free: jw. */ -#define Free(a) {if ((a) == 0) abort(); else free((void *)(a)); (a)=0;} +#define Free(a) {if ((a) == NULL) abort(); else free((void *)(a)); (a)=NULL;} #define Ctrl(c) ((c)&037) diff --git a/src/search.c b/src/search.c index ca2bfc2..5f40ca2 100644 --- a/src/search.c +++ b/src/search.c @@ -55,9 +55,9 @@ void Search(int dir) if (dir == 0) { markdata = (struct markdata *)flayer->l_data; if (markdata->isdir > 0) - searchend(0, 0, 0); + searchend(NULL, 0, NULL); else if (markdata->isdir < 0) - backsearchend(0, 0, 0); + backsearchend(NULL, 0, NULL); else LMsg(0, "No previous pattern"); } else diff --git a/src/socket.c b/src/socket.c index 9c9b8b8..ee91d19 100644 --- a/src/socket.c +++ b/src/socket.c @@ -144,10 +144,10 @@ int FindSocket(int *fdp, int *nfoundp, int *notherp, char *match) xseteuid(real_uid); xsetegid(real_gid); - if ((dirp = opendir(SocketPath)) == 0) + if ((dirp = opendir(SocketPath)) == NULL) Panic(errno, "Cannot opendir %s", SocketPath); - slist = 0; + slist = NULL; slisttail = &slist; while ((dp = readdir(dirp))) { int cmatch = 0; @@ -198,9 +198,9 @@ int FindSocket(int *fdp, int *nfoundp, int *notherp, char *match) } else { } } - if ((sent = malloc(sizeof(struct sent))) == 0) + if ((sent = malloc(sizeof(struct sent))) == NULL) continue; - sent->next = 0; + sent->next = NULL; sent->name = SaveStr(name); sent->mode = mode; *slisttail = sent; @@ -463,7 +463,7 @@ void SendCreateMsg(char *sty, struct NewWindow *nwin) m.m.create.flowflag = nwin->flowflag; m.m.create.lflag = nwin->lflag; m.m.create.hheight = nwin->histheight; - if (getcwd(m.m.create.dir, ARRAY_SIZE(m.m.create.dir)) == 0) { + if (getcwd(m.m.create.dir, ARRAY_SIZE(m.m.create.dir)) == NULL) { Msg(errno, "getcwd"); return; } @@ -529,7 +529,7 @@ static void ExecCreate(Message *mp) *pp++ = p; p += strlen(p) + 1; } - *pp = 0; + *pp = NULL; if (*p) nwin.aka = p; if (*args) @@ -621,7 +621,7 @@ static int CreateTempDisplay(Message *m, int recvfd, Window *win) */ strncpy(m->m_tty, myttyname, ARRAY_SIZE(m->m_tty) - 1); m->m_tty[ARRAY_SIZE(m->m_tty) - 1] = 0; - } else if (myttyname == 0 || strcmp(myttyname, m->m_tty)) { + } else if (myttyname == NULL || strcmp(myttyname, m->m_tty)) { Msg(errno, "Attach: passed fd does not match tty: %s - %s!", m->m_tty, myttyname ? myttyname : "NULL"); @@ -649,7 +649,7 @@ static int CreateTempDisplay(Message *m, int recvfd, Window *win) } if (strcmp(user, LoginName)) - if (*FindUserPtr(user) == 0) { + if (*FindUserPtr(user) == NULL) { int unused_result = write(i, "Access to session denied.\n", 26); (void)unused_result; /* unused */ close(i); @@ -661,7 +661,7 @@ static int CreateTempDisplay(Message *m, int recvfd, Window *win) /* create new display */ GetTTY(i, &Mode); - if (MakeDisplay(user, m->m_tty, attach ? m->m.attach.envterm : "", i, pid, &Mode) == 0) { + if (MakeDisplay(user, m->m_tty, attach ? m->m.attach.envterm : "", i, pid, &Mode) == NULL) { int unused_result = write(i, "Could not make display.\n", 24); (void)unused_result; /* unused */ close(i); @@ -792,7 +792,7 @@ void ReceiveMsg(void) for (win = windows; win; win = win->w_next) if (!strcmp(m.m_tty, win->w_tty)) { /* XXX: hmmm, rework this? */ - display = win->w_layer.l_cvlist ? win->w_layer.l_cvlist->c_display : 0; + display = win->w_layer.l_cvlist ? win->w_layer.l_cvlist->c_display : NULL; break; } } @@ -839,7 +839,7 @@ void ReceiveMsg(void) break; case MSG_DETACH: case MSG_POW_DETACH: - if (CreateTempDisplay(&m, recvfd, 0)) + if (CreateTempDisplay(&m, recvfd, NULL)) break; AskPassword(&m); break; @@ -952,7 +952,7 @@ static void FinishAttach(Message *m) free(extra_outcap); if (extra_incap) free(extra_incap); - extra_incap = extra_outcap = 0; + extra_incap = extra_outcap = NULL; StartRc(SYSTEM_SCREENRC, 1); StartRc(RcFileName, 1); if (InitTermcap(m->m.attach.columns, m->m.attach.lines)) { @@ -962,7 +962,7 @@ static void FinishAttach(Message *m) } MakeDefaultCanvas(); InitTerm(m->m.attach.adaptflag); /* write init string on fd */ - if (displays->d_next == 0) + if (displays->d_next == NULL) (void)chsock(); xsignal(SIGHUP, SigHup); if (m->m.attach.esc != -1 && m->m.attach.meta_esc != -1) { @@ -976,7 +976,7 @@ static void FinishAttach(Message *m) * don't log zomies back in! */ RemoveLoginSlot(); - if (displays->d_next == 0) + if (displays->d_next == NULL) for (Window *win = windows; win; win = win->w_next) if (win->w_ptyfd >= 0 && win->w_slot != (slot_t) - 1) SetUtmp(win); @@ -989,7 +989,7 @@ static void FinishAttach(Message *m) lay = layout_last; if (lay) { LoadLayout(lay); - SetCanvasWindow(D_forecv, 0); + SetCanvasWindow(D_forecv, NULL); } } /* @@ -998,7 +998,7 @@ static void FinishAttach(Message *m) if (D_user->u_detachwin >= 0) fore = wtab[D_user->u_detachwin]; else - fore = 0; + fore = NULL; /* Wayne wants us to restore the other window too. */ if (D_user->u_detachotherwin >= 0) @@ -1007,13 +1007,13 @@ static void FinishAttach(Message *m) noshowwin = 0; if (*m->m.attach.preselect) { if (!strcmp(m->m.attach.preselect, "=")) - fore = 0; + fore = NULL; else if (!strcmp(m->m.attach.preselect, "-")) { - fore = 0; + fore = NULL; noshowwin = 1; } else if (!strcmp(m->m.attach.preselect, "+")) { struct action newscreen; - char *na = 0; + char *na = NULL; newscreen.nr = RC_SCREEN; newscreen.args = &na; newscreen.quiet = 0; @@ -1021,7 +1021,7 @@ static void FinishAttach(Message *m) } else fore = FindNiceWindow(fore, m->m.attach.preselect); } else - fore = FindNiceWindow(fore, 0); + fore = FindNiceWindow(fore, NULL); if (fore) SetForeWindow(fore); else if (!noshowwin) { @@ -1037,7 +1037,7 @@ static void FinishAttach(Message *m) ResetIdle(); if (!D_fore && !noshowwin) ShowWindows(-1); - if (displays->d_next == 0 && console_window) { + if (displays->d_next == NULL && console_window) { if (TtyGrabConsole(console_window->w_ptyfd, true, "reattach") == 0) Msg(0, "console %s is on window %d", HostName, console_window->w_number); } @@ -1060,7 +1060,7 @@ static void FinishDetach(Message *m) } if (det) { *d = det->d_next; - det->d_next = 0; + det->d_next = NULL; } for (display = displays; display; display = next) { @@ -1136,7 +1136,7 @@ static bool CheckPassword(const char *password) { struct pam_response *reply; - pam_handle_t *pamh = 0; + pam_handle_t *pamh = NULL; struct pam_conv pamc; int pam_ret; char *tty_name; @@ -1225,7 +1225,7 @@ static void PasswordProcessInput(char *ibuf, size_t ilen) /* uh oh, user failed */ memset(pwdata->buf, 0, sizeof(pwdata->buf)); AddStr("\r\nPassword incorrect.\r\n"); - D_processinputdata = 0; /* otherwise freed by FreeDis */ + D_processinputdata = NULL; /* otherwise freed by FreeDis */ FreeDisplay(); Msg(0, "Illegal reattach attempt from terminal %s.", pwdata->m.m_tty); free(pwdata); @@ -1237,7 +1237,7 @@ static void PasswordProcessInput(char *ibuf, size_t ilen) memset(pwdata->buf, 0, sizeof(pwdata->buf)); AddStr("\r\n"); - D_processinputdata = 0; + D_processinputdata = NULL; D_processinput = ProcessInput; if (pwdata->m.type == MSG_DETACH || pwdata->m.type == MSG_POW_DETACH) FinishDetach(&pwdata->m); @@ -1322,7 +1322,7 @@ static void DoCommandMsg(Message *mp) return; } user = *FindUserPtr(mp->m.attach.auser); - if (user == 0) { + if (user == NULL) { Msg(0, "Unknown user %s tried to send a command!", mp->m.attach.auser); queryflag = -1; return; @@ -1340,7 +1340,7 @@ static void DoCommandMsg(Message *mp) for (fore = windows; fore; fore = fore->w_next) if (!strcmp(mp->m_tty, fore->w_tty)) { if (!display) - display = fore->w_layer.l_cvlist ? fore->w_layer.l_cvlist->c_display : 0; + display = fore->w_layer.l_cvlist ? fore->w_layer.l_cvlist->c_display : NULL; /* If the window is not visibile in any display, then do not use the originating window as * the foreground window for the command. This way, if there is an existing display, then @@ -1362,13 +1362,13 @@ static void DoCommandMsg(Message *mp) return; } } - fore = i >= 0 ? wtab[i] : 0; + fore = i >= 0 ? wtab[i] : NULL; } else if (!fore) { if (display && D_user == user) fore = Layer2Window(display->d_forecv->c_layer); if (!fore) { - fore = user->u_detachwin >= 0 ? wtab[user->u_detachwin] : 0; - fore = FindNiceWindow(fore, 0); + fore = user->u_detachwin >= 0 ? wtab[user->u_detachwin] : NULL; + fore = FindNiceWindow(fore, NULL); } } if (!fore) @@ -1377,13 +1377,13 @@ static void DoCommandMsg(Message *mp) if (*args) { char *oldrcname = rc_name; rc_name = "-X"; - flayer = fore ? &fore->w_layer : 0; - if (fore && fore->w_savelayer && (fore->w_blocked || fore->w_savelayer->l_cvlist == 0)) + flayer = fore ? &fore->w_layer : NULL; + if (fore && fore->w_savelayer && (fore->w_blocked || fore->w_savelayer->l_cvlist == NULL)) flayer = fore->w_savelayer; DoCommand(args, argl); rc_name = oldrcname; } - EffectiveAclUser = 0; + EffectiveAclUser = NULL; } int SendAttachMsg(int s, Message *m, int fd) @@ -1396,7 +1396,7 @@ int SendAttachMsg(int s, Message *m, int fd) iov.iov_base = (char *)m; iov.iov_len = sizeof(Message); memset(&msg, 0, sizeof(struct msghdr)); - msg.msg_name = 0; + msg.msg_name = NULL; msg.msg_namelen = 0; msg.msg_iov = &iov; msg.msg_iovlen = 1; diff --git a/src/termcap.c b/src/termcap.c index 5553db0..6757587 100644 --- a/src/termcap.c +++ b/src/termcap.c @@ -71,15 +71,15 @@ char *gettermcapstring(char *s) { int i; - if (display == 0 || s == 0) - return 0; + if (display == NULL || s == NULL) + return NULL; for (i = 0; i < T_N; i++) { if (term[i].type != T_STR) continue; if (strcmp(term[i].tcname, s) == 0) return D_tcs[i].str; } - return 0; + return NULL; } /* @@ -100,7 +100,7 @@ int InitTermcap(int width, int height) return -1; } - if ((D_tentry = malloc(TERMCAP_BUFSIZE + (extra_incap ? strlen(extra_incap) + 1 : 0))) == 0) { + if ((D_tentry = malloc(TERMCAP_BUFSIZE + (extra_incap ? strlen(extra_incap) + 1 : 0))) == NULL) { Msg(0, "%s", strnomem); return -1; } @@ -121,7 +121,7 @@ int InitTermcap(int width, int height) D_tcs[i].str = e_tgetstr(term[i].tcname, &tp); /* no empty strings, please */ if (D_tcs[i].str && *D_tcs[i].str == 0) - D_tcs[i].str = 0; + D_tcs[i].str = NULL; break; default: Panic(0, "Illegal tc type in entry #%d", i); @@ -170,7 +170,7 @@ int InitTermcap(int width, int height) if (D_OP && strstr(D_OP, "\033[39;49m")) D_CAX = 1; if (D_OP && (strstr(D_OP, "\033[m") || strstr(D_OP, "\033[0m"))) - D_OP = 0; + D_OP = NULL; /* ISO2022 */ if ((D_EA && strstr(D_EA, "\033(B")) || (D_AS && strstr(D_AS, "\033(0"))) D_CG0 = 1; @@ -203,36 +203,36 @@ int InitTermcap(int width, int height) */ if (D_UG > 0) - D_US = D_UE = 0; + D_US = D_UE = NULL; if (D_SG > 0) - D_SO = D_SE = 0; + D_SO = D_SE = NULL; /* Unfortunately there is no 'mg' capability. * For now we think that mg > 0 if sg and ug > 0. */ if (D_UG > 0 && D_SG > 0) - D_MH = D_MD = D_MR = D_MB = D_ME = 0; + D_MH = D_MD = D_MR = D_MB = D_ME = NULL; xue = ATYP_U; xse = ATYP_S; xme = ATYP_M; - if (D_SO && D_SE == 0) { + if (D_SO && D_SE == NULL) { Msg(0, "Warning: 'so' but no 'se' capability."); if (D_ME) xse = xme; else - D_SO = 0; + D_SO = NULL; } - if (D_US && D_UE == 0) { + if (D_US && D_UE == NULL) { Msg(0, "Warning: 'us' but no 'ue' capability."); if (D_ME) xue = xme; else - D_US = 0; + D_US = NULL; } - if ((D_MH || D_MD || D_MR || D_MB) && D_ME == 0) { + if ((D_MH || D_MD || D_MR || D_MB) && D_ME == NULL) { Msg(0, "Warning: 'm?' but no 'me' capability."); - D_MH = D_MD = D_MR = D_MB = 0; + D_MH = D_MD = D_MR = D_MB = NULL; } /* * Does ME also reverse the effect of SO and/or US? This is not @@ -252,7 +252,7 @@ int InitTermcap(int width, int height) } /* Set up missing entries (attributes are priority ordered) */ - s = 0; + s = NULL; t = 0; for (i = 0; i < NATTR; i++) if ((s = D_attrtab[i])) { @@ -260,7 +260,7 @@ int InitTermcap(int width, int height) break; } for (i = 0; i < NATTR; i++) { - if (D_attrtab[i] == 0) { + if (D_attrtab[i] == NULL) { D_attrtab[i] = s; D_attrtyp[i] = t; } else { @@ -278,35 +278,35 @@ int InitTermcap(int width, int height) if (!D_SF) D_SF = D_NL; if (D_IN) - D_IC = D_IM = 0; - if (D_EI == 0) - D_IM = 0; + D_IC = D_IM = NULL; + if (D_EI == NULL) + D_IM = NULL; /* some strange termcap entries have IC == IM */ if (D_IC && D_IM && strcmp(D_IC, D_IM) == 0) - D_IC = 0; - if (D_KE == 0) - D_KS = 0; - if (D_CVN == 0) - D_CVR = 0; - if (D_VE == 0) - D_VI = D_VS = 0; - if (D_CCE == 0) - D_CCS = 0; + D_IC = NULL; + if (D_KE == NULL) + D_KS = NULL; + if (D_CVN == NULL) + D_CVR = NULL; + if (D_VE == NULL) + D_VI = D_VS = NULL; + if (D_CCE == NULL) + D_CCS = NULL; if (D_CG0) { - if (D_CS0 == 0) + if (D_CS0 == NULL) D_CS0 = "\033(%p1%c"; - if (D_CE0 == 0) + if (D_CE0 == NULL) D_CE0 = "\033(B"; - D_AC = 0; - D_EA = 0; + D_AC = NULL; + D_EA = NULL; } else if (D_AC || (D_AS && D_AE)) { /* some kind of graphics */ D_CS0 = (D_AS && D_AE) ? D_AS : ""; D_CE0 = (D_AS && D_AE) ? D_AE : ""; D_CC0 = D_AC; } else { D_CS0 = D_CE0 = ""; - D_CC0 = 0; + D_CC0 = NULL; D_AC = ""; /* enable default string */ } @@ -321,20 +321,20 @@ int InitTermcap(int width, int height) if (D_CC0) for (i = (strlen(D_CC0) - 2) & ~1; i >= 0; i -= 2) D_c0_tab[(int)(unsigned char)D_CC0[i]] = D_CC0[i + 1]; - if (D_PF == 0) - D_PO = 0; + if (D_PF == NULL) + D_PO = NULL; if (D_CXC) if (CreateTransTable(D_CXC)) return -1; /* Termcap fields Z0 & Z1 contain width-changing sequences. */ - if (D_CZ1 == 0) - D_CZ0 = 0; + if (D_CZ1 == NULL) + D_CZ0 = NULL; CheckScreenSize(0); - if (D_TS == 0 || D_FS == 0 || D_DS == 0) + if (D_TS == NULL || D_FS == NULL || D_DS == NULL) D_HS = 0; if (D_HS) { if (D_WS < 0) @@ -373,13 +373,13 @@ int InitTermcap(int width, int height) /* Some xterm entries set F0 and F10 to the same string. Nuke F0. */ if (D_tcs[T_CAPS].str && D_tcs[T_CAPS + 10].str && !strcmp(D_tcs[T_CAPS].str, D_tcs[T_CAPS + 10].str)) - D_tcs[T_CAPS].str = 0; + D_tcs[T_CAPS].str = NULL; /* Some xterm entries set kD to ^?. Nuke it. */ if (D_tcs[T_NAVIGATE_DELETE].str && !strcmp(D_tcs[T_NAVIGATE_DELETE].str, "\0177")) - D_tcs[T_NAVIGATE_DELETE].str = 0; + D_tcs[T_NAVIGATE_DELETE].str = NULL; /* wyse52 entries have kcub1 == kb == ^H. Nuke... */ if (D_tcs[T_CURSOR + 3].str && !strcmp(D_tcs[T_CURSOR + 3].str, "\008")) - D_tcs[T_CURSOR + 3].str = 0; + D_tcs[T_CURSOR + 3].str = NULL; D_nseqs = 0; for (i = 0; i < T_OCAPS - T_CAPS; i++) @@ -388,7 +388,7 @@ int InitTermcap(int width, int height) remap(i + (KMAP_KEYS + KMAP_AKEYS), 1); D_seqp = D_kmaps + 3; D_seql = 0; - D_seqh = 0; + D_seqh = NULL; D_tcinited = 1; MakeTermcap(0); @@ -400,13 +400,13 @@ int InitTermcap(int width, int height) int remap(int n, int map) { - char *s = 0; + char *s = NULL; int fl = 0, domap = 0; struct action *a1, *a2, *tab; int l = 0; - struct kmap_ext *kme = 0; + struct kmap_ext *kme = NULL; - a1 = 0; + a1 = NULL; if (n >= KMAP_KEYS + KMAP_AKEYS) { kme = kmap_exts + (n - (KMAP_KEYS + KMAP_AKEYS)); s = kme->str; @@ -416,7 +416,7 @@ int remap(int n, int map) } tab = umtab; for (;;) { - a2 = 0; + a2 = NULL; if (n < KMAP_KEYS + KMAP_AKEYS) { a1 = &tab[n]; if (n >= KMAP_KEYS) @@ -426,23 +426,23 @@ int remap(int n, int map) if (n >= T_CURSOR - T_CAPS) a2 = &tab[n + (T_OCAPS - T_CURSOR)]; } - if (s == 0 || l == 0) + if (s == NULL || l == 0) return 0; if (a1 && a1->nr == RC_ILLEGAL) - a1 = 0; + a1 = NULL; if (a2 && a2->nr == RC_ILLEGAL) - a2 = 0; + a2 = NULL; if (a1 && a1->nr == RC_STUFF && a1->args[0] && strcmp(a1->args[0], s) == 0) - a1 = 0; + a1 = NULL; if (a2 && a2->nr == RC_STUFF && a2->args[0] && strcmp(a2->args[0], s) == 0) - a2 = 0; + a2 = NULL; domap |= (a1 || a2); if (tab == umtab) { tab = dmtab; - a1 = kme ? &kme->dm : 0; + a1 = kme ? &kme->dm : NULL; } else if (tab == dmtab) { tab = mmtab; - a1 = kme ? &kme->mm : 0; + a1 = kme ? &kme->mm : NULL; } else break; } @@ -484,7 +484,7 @@ void CheckEscape(void) } } } - if (display == 0) { + if (display == NULL) { display = odisplay; return; } @@ -493,7 +493,7 @@ void CheckEscape(void) odisplay->d_user->u_Esc = DefaultEsc; if (odisplay->d_user->u_MetaEsc == -1) odisplay->d_user->u_MetaEsc = DefaultMetaEsc; - display = 0; + display = NULL; Msg(0, "Warning: escape char set back to ^A"); display = odisplay; } @@ -567,7 +567,7 @@ static int addmapseq(char *seq, int k, int nr) } D_seqp = D_kmaps + 3; D_seql = 0; - D_seqh = 0; + D_seqh = NULL; evdeq(&D_mapev); if (j > 0) memmove((char *)p + 2 * k + 4, (char *)p, D_nseqs - i); @@ -625,7 +625,7 @@ static int remmapseq(char *seq, int k) D_nseqs -= 2 * k + 4; D_seqp = D_kmaps + 3; D_seql = 0; - D_seqh = 0; + D_seqh = NULL; evdeq(&D_mapev); return 0; } @@ -828,11 +828,11 @@ char *MakeTermcap(bool aflag) continue; } } - if (display == 0) + if (display == NULL) continue; switch (term[i].type) { case T_STR: - if (D_tcs[i].str == 0) + if (D_tcs[i].str == NULL) break; MakeString(term[i].tcname, buf, ARRAY_SIZE(buf), D_tcs[i].str); AddCap(buf); @@ -904,7 +904,7 @@ int CreateTransTable(char *s) char **ctable; int l, c; - if ((D_xtable = calloc(256, sizeof(char **))) == 0) { + if ((D_xtable = calloc(256, sizeof(char **))) == NULL) { Msg(0, "%s", strnomem); return -1; } @@ -918,8 +918,8 @@ int CreateTransTable(char *s) templ = s; templlen = 0; templnsub = 0; - if (D_xtable[curchar] == 0) { - if ((D_xtable[curchar] = calloc(257, sizeof(char *))) == 0) { + if (D_xtable[curchar] == NULL) { + if ((D_xtable[curchar] = calloc(257, sizeof(char *))) == NULL) { Msg(0, "%s", strnomem); FreeTransTable(); return -1; @@ -949,7 +949,7 @@ int CreateTransTable(char *s) l = copyarg(&s, (char *)0); if (c != 256) l = l * templnsub + templlen; - if ((ctable[c] = malloc(l + 1)) == 0) { + if ((ctable[c] = malloc(l + 1)) == NULL) { Msg(0, "%s", strnomem); FreeTransTable(); return -1; @@ -978,10 +978,10 @@ void FreeTransTable(void) char ***p, **q; int i, j; - if ((p = D_xtable) == 0) + if ((p = D_xtable) == NULL) return; for (i = 0; i < 256; i++, p++) { - if (*p == 0) + if (*p == NULL) continue; q = *p; for (j = 0; j < 257; j++, q++) @@ -1043,10 +1043,10 @@ static char *findcap(char *cap, char **tepp, int n) int num = 0, capl; if (!extra_incap) - return 0; + return NULL; tep = *tepp; capl = strlen(cap); - cp = 0; + cp = NULL; mode = 0; for (p = extra_incap; *p;) { if (strncmp(p, cap, capl) == 0) { @@ -1126,14 +1126,14 @@ static char *findcap(char *cap, char **tepp, int n) return tep; } } - return 0; + return NULL; } static char *e_tgetstr(char *cap, char **tepp) { char *tep; if ((tep = findcap(cap, tepp, 0))) - return (*tep == '@') ? 0 : tep; + return (*tep == '@') ? NULL : tep; return tgetstr(cap, tepp); } @@ -776,7 +776,7 @@ int TtyGrabConsole(int fd, bool on, char *rc_name) (void)fd; /* unused */ if (on) { - if (displays == 0) { + if (displays == NULL) { Msg(0, "I need a display"); return -1; } @@ -194,16 +194,16 @@ void RemoveLoginSlot(void) if (!utmpok) #endif { - D_loginslot = 0; + D_loginslot = NULL; } else { - if ((uu = getutslot(D_loginslot)) == 0) { - D_loginslot = 0; + if ((uu = getutslot(D_loginslot)) == NULL) { + D_loginslot = NULL; } else { D_utmp_logintty = *uu; u = *uu; makedead(&u); if (pututslot(D_loginslot, &u, (char *)0, (Window *)0) == 0) - D_loginslot = 0; + D_loginslot = NULL; } } if (D_loginslot == (slot_t) 0) { @@ -333,7 +333,7 @@ int RemoveUtmp(Window *win) return 0; } memset((char *)&u, 0, sizeof(struct utmpx)); - if ((uu = getutslot(slot)) == 0) { + if ((uu = getutslot(slot)) == NULL) { Msg(0, "Utmp slot not found -> not removed"); return -1; } @@ -382,7 +382,7 @@ static int pututslot(slot_t slot, struct utmpx *u, char *host, Window *win) #endif setutxent(); - return pututxline(u) != 0; + return pututxline(u) != NULL; } static void makedead(struct utmpx *u) diff --git a/src/viewport.c b/src/viewport.c index aac5d32..f6d972a 100644 --- a/src/viewport.c +++ b/src/viewport.c @@ -40,13 +40,13 @@ int RethinkDisplayViewports(void) { memset((char *)viewport, 0, sizeof(Viewport)); free(viewport); } - canvas->c_vplist = 0; + canvas->c_vplist = NULL; } display->d_vpxmin = -1; display->d_vpxmax = -1; for (Canvas *canvas = display->d_cvlist; canvas; canvas = canvas->c_next) { - if ((viewport = malloc(sizeof(Viewport))) == 0) { + if ((viewport = malloc(sizeof(Viewport))) == NULL) { return -1; } viewport->v_canvas = canvas; diff --git a/src/window.c b/src/window.c index a1d0920..8f136c1 100644 --- a/src/window.c +++ b/src/window.c @@ -116,9 +116,9 @@ struct NewWindow nwin_undef = { struct NewWindow nwin_default = { .StartAt = 0, - .aka = 0, + .aka = NULL, .args = ShellArgs, - .dir = 0, + .dir = NULL, .term = screenterm, .aflag = false, .dynamicaka = true, @@ -180,12 +180,12 @@ void nwin_compose(struct NewWindow *def, struct NewWindow *new, struct NewWindow const struct LayFuncs WinLf = { WinProcess, - 0, + NULL, WinRedisplayLine, WinClearLine, WinResize, WinRestore, - 0 + NULL }; static int DoAutolf(char *buf, size_t *lenp, int fr) @@ -414,7 +414,7 @@ int MakeWindow(struct NewWindow *newwin) pp = wtab + startat; do { - if (*pp == 0) + if (*pp == NULL) break; if (++pp == wtab + maxwin) pp = wtab; @@ -444,7 +444,7 @@ int MakeWindow(struct NewWindow *newwin) if (type == W_TYPE_GROUP) f = -1; - if ((p = calloc(1, sizeof(Window))) == 0) { + if ((p = calloc(1, sizeof(Window))) == NULL) { close(f); Msg(0, "%s", strnomem); return -1; @@ -459,14 +459,14 @@ int MakeWindow(struct NewWindow *newwin) /* save the command line so that zombies can be resurrected */ for (i = 0; nwin.args[i] && i < MAXARGS - 1; i++) p->w_cmdargs[i] = SaveStr(nwin.args[i]); - p->w_cmdargs[i] = 0; + p->w_cmdargs[i] = NULL; if (nwin.dir) p->w_dir = SaveStr(nwin.dir); if (nwin.term) p->w_term = SaveStr(nwin.term); p->w_number = n; - p->w_group = 0; + p->w_group = NULL; if (fore && fore->w_type == W_TYPE_GROUP) p->w_group = fore; else if (fore && fore->w_group) @@ -482,13 +482,13 @@ int MakeWindow(struct NewWindow *newwin) Msg(0, "%s", strnomem); return -1; } - p->w_layer.l_next = 0; + p->w_layer.l_next = NULL; p->w_layer.l_bottom = &p->w_layer; p->w_layer.l_layfn = &WinLf; p->w_layer.l_data = (char *)p; p->w_savelayer = &p->w_layer; - p->w_pdisplay = 0; - p->w_lastdisp = 0; + p->w_pdisplay = NULL; + p->w_lastdisp = NULL; if (display && !AclCheckPermWin(D_user, ACL_WRITE, p)) p->w_wlockuser = D_user; @@ -558,7 +558,7 @@ int MakeWindow(struct NewWindow *newwin) p->w_deadpid = 0; p->w_pid = 0; - p->w_pwin = 0; + p->w_pwin = NULL; #ifdef ENABLE_TELNET if (type == W_TYPE_TELNET) { @@ -640,7 +640,7 @@ int MakeWindow(struct NewWindow *newwin) evenq(&p->w_silenceev); } p->w_destroyev.type = EV_TIMEOUT; - p->w_destroyev.data = 0; + p->w_destroyev.data = NULL; p->w_destroyev.handler = win_destroyev_fn; SetForeWindow(p); @@ -754,7 +754,7 @@ void FreeWindow(Window *window) if (window == console_window) { TtyGrabConsole(-1, false, "free"); - console_window = 0; + console_window = NULL; } if (window->w_log != NULL) logfclose(window->w_log); @@ -789,7 +789,7 @@ void FreeWindow(Window *window) if ((Window *)layer->l_data != window) continue; if (canvas->c_layer == window->w_savelayer) - window->w_savelayer = 0; + window->w_savelayer = NULL; KillLayerChain(canvas->c_layer); } } @@ -798,14 +798,14 @@ void FreeWindow(Window *window) for (Canvas *canvas = window->w_layer.l_cvlist; canvas; canvas = canvas->c_lnext) { canvas->c_layer = &canvas->c_blank; canvas->c_blank.l_cvlist = canvas; - canvas->c_lnext = 0; + canvas->c_lnext = NULL; canvas->c_xoff = canvas->c_xs; canvas->c_yoff = canvas->c_ys; RethinkViewportOffsets(canvas); } - window->w_layer.l_cvlist = 0; + window->w_layer.l_cvlist = NULL; if (flayer == &window->w_layer) - flayer = 0; + flayer = NULL; LayerCleanupMemory(&window->w_layer); FreeWindowAcl(window); @@ -946,7 +946,7 @@ static int ForkWindow(Window *win, char **args, char *ttyn) } #endif proc = *args; - if (proc == 0) { + if (proc == NULL) { args = ShellArgs; proc = *args; } @@ -967,7 +967,7 @@ static int ForkWindow(Window *win, char **args, char *ttyn) xsignal(SIGXFSZ, SIG_DFL); #endif - displays = 0; /* beware of Panic() */ + displays = NULL; /* beware of Panic() */ if (setgid(real_gid) || setuid(real_uid)) Panic(errno, "Setuid/gid"); eff_uid = real_uid; @@ -1056,7 +1056,7 @@ static int ForkWindow(Window *win, char **args, char *ttyn) /* Always turn off nonblocking mode */ (void)fcntl(newfd, F_SETFL, 0); } - NewEnv[2] = MakeTermcap(display == 0 || win->w_aflag); + NewEnv[2] = MakeTermcap(display == NULL || win->w_aflag); strcpy(shellbuf, "SHELL="); strncpy(shellbuf + 6, ShellProg + (*ShellProg == '-'), ARRAY_SIZE(shellbuf) - 7); shellbuf[ARRAY_SIZE(shellbuf) - 1] = 0; @@ -1284,7 +1284,7 @@ void FreePseudowin(Window *w) evdeq(&pwin->p_readev); evdeq(&pwin->p_writeev); if (w->w_readev.condneg == (int *)&pwin->p_inlen) - w->w_readev.condpos = w->w_readev.condneg = 0; + w->w_readev.condpos = w->w_readev.condneg = NULL; evenq(&w->w_readev); free((char *)pwin); w->w_pwin = NULL; @@ -1402,7 +1402,7 @@ static void win_readev_fn(Event *event, void *data) return; } if (event->condpos) - event->condpos = event->condneg = 0; + event->condpos = event->condneg = NULL; if ((len = p->w_outlen)) { p->w_outlen = 0; @@ -1517,7 +1517,7 @@ static void pseu_readev_fn(Event *event, void *data) return; } if (event->condpos) - event->condpos = event->condneg = 0; + event->condpos = event->condneg = NULL; if ((len = p->w_outlen)) { p->w_outlen = 0; @@ -1620,9 +1620,9 @@ static int zmodem_parse(Window *p, char *bp, size_t len) if (*b2 == se) break; if (i < len) { - zmodem_abort(p, 0); + zmodem_abort(p, NULL); D_blocked = 0; - D_readev.condpos = D_readev.condneg = 0; + D_readev.condpos = D_readev.condneg = NULL; while (len-- > 0) AddChar(*bp++); Flush(0); @@ -1726,14 +1726,14 @@ void zmodem_abort(Window *p, Display *d) flayer = p->w_savelayer; ExitOverlayPage(); } - p->w_zdisplay = 0; + p->w_zdisplay = NULL; p->w_zauto = 0; LRefreshAll(&p->w_layer, 0); } if (d) { display = d; D_blocked = 0; - D_readev.condpos = D_readev.condneg = 0; + D_readev.condpos = D_readev.condneg = NULL; Activate(D_fore ? D_fore->w_norefresh : 0); } display = olddisplay; @@ -1764,7 +1764,7 @@ int SwapWindows(int old, int dest) SetUtmp(win_old); } if (p && (p->w_slot != (slot_t) - 1) && (p->w_slot != (slot_t) 0)) { - display = win_old->w_layer.l_cvlist ? win_old->w_layer.l_cvlist->c_display : 0; + display = win_old->w_layer.l_cvlist ? win_old->w_layer.l_cvlist->c_display : NULL; RemoveUtmp(p); SetUtmp(p); } @@ -1785,7 +1785,7 @@ void WindowDied(Window *p, int wstat, int wstat_valid) wstat = p->w_exitstatus; wstat_valid = 1; evdeq(&p->w_destroyev); - p->w_destroyev.data = 0; + p->w_destroyev.data = NULL; } if (!wstat_valid && p->w_pid > 0) { /* EOF on file descriptor. The process is probably also dead. @@ -1825,7 +1825,7 @@ void WindowDied(Window *p, int wstat, int wstat_valid) #ifdef ENABLE_UTMP if (p->w_slot != (slot_t) 0 && p->w_slot != (slot_t) - 1) { RemoveUtmp(p); - p->w_slot = 0; /* "detached" */ + p->w_slot = NULL; /* "detached" */ } #endif CloseDevice(p); diff --git a/src/winmsg.c b/src/winmsg.c index bd95569..bb1d738 100644 --- a/src/winmsg.c +++ b/src/winmsg.c @@ -365,7 +365,7 @@ winmsg_esc_ex(TruncPos, uint8_t perc, bool ellip) winmsg_esc_ex(WinNames, const bool hide_cur, Window *win) { - Window *oldfore = 0; + Window *oldfore = NULL; size_t max = wmbc_bytesleft(wmbc); if (display) { @@ -736,7 +736,7 @@ void WindowChanged(Window *win, WinMsgEscapeChar what) inlstr = 1; } - if (win == 0) { + if (win == NULL) { for (display = displays; display; display = display->d_next) { ox = D_x; oy = D_y; |