Booleanify more variables. - sam - An updated version of the sam text editor.
(HTM) git clone git://vernunftzentrum.de/sam.git
(DIR) Log
(DIR) Files
(DIR) Refs
(DIR) LICENSE
---
(DIR) commit 2ca4fc9ee587dd03cc3c33277e2154b8994f1f7a
(DIR) parent 07fee62f4bb6be463c3af403648b53b7b181db92
(HTM) Author: Rob King <jking@deadpixi.com>
Date: Tue, 4 Oct 2016 10:09:37 -0500
Booleanify more variables.
Diffstat:
libXg/xtbinit.c | 14 +++++++-------
sam/mesg.c | 2 +-
sam/multi.c | 2 +-
sam/sam.c | 6 +++---
sam/sam.h | 4 ++--
sam/shell.c | 4 ++--
samterm/flayer.c | 2 +-
samterm/flayer.h | 2 +-
samterm/main.c | 58 +++++++++++++++---------------
samterm/mesg.c | 16 ++++++++--------
samterm/rasp.c | 4 ++--
samterm/samterm.h | 6 +++---
12 files changed, 60 insertions(+), 60 deletions(-)
---
(DIR) diff --git a/libXg/xtbinit.c b/libXg/xtbinit.c
@@ -98,7 +98,7 @@ static void gotmouse(Gwinmouse *);
static int ilog2(int);
static Ebuf *ebread(Esrc *);
-static Ebuf *ebadd(Esrc *, int);
+static Ebuf *ebadd(Esrc *, bool);
static void focinit(Widget);
static void wmproto(Widget, XEvent *, String *, Cardinal *);
static void waitevent(void);
@@ -283,7 +283,7 @@ reshaped(int minx, int miny, int maxx, int maxy)
* Cause a mouse event, so programs like sam
* will get out of eread and REALLY do the reshape
*/
- eb = ebadd(&esrc[Smouse], 0);
+ eb = ebadd(&esrc[Smouse], false);
if (eb == 0)
berror("eballoc can't malloc");
memcpy((void*)eb->buf, (void*)&lastmouse, sizeof lastmouse);
@@ -299,7 +299,7 @@ gotchar(int c, int kind, int target, int x, int y, const char *arg)
if(!einitcalled || Skeyboard == -1)
return;
- eb = ebadd(&esrc[Skeyboard], 0);
+ eb = ebadd(&esrc[Skeyboard], false);
if (eb == NULL)
berror("eballoc can't malloc");
k.c = c;
@@ -324,7 +324,7 @@ gotmouse(Gwinmouse *gm)
m.xy.y = gm->xy.y;
m.msec = gm->msec;
lastmouse = m;
- eb = ebadd(&esrc[Smouse], 0);
+ eb = ebadd(&esrc[Smouse], false);
if (eb == 0)
berror("eballoc can't malloc");
memcpy((void*)eb->buf, (void*)&m, sizeof m);
@@ -344,7 +344,7 @@ gotinput(XtPointer cldata, int *pfd, XtInputId *id)
if (es->count >= MAXINPUT)
return;
lasttail = es->tail;
- eb = ebadd(es, 0);
+ eb = ebadd(es, false);
if (eb == 0)
return;
if(es->size){
@@ -576,7 +576,7 @@ pushkbd(int c)
if(!einitcalled || Skeyboard == -1)
return;
- eb = ebadd(&esrc[Skeyboard], 1);
+ eb = ebadd(&esrc[Skeyboard], true);
if (eb == 0)
berror("eballoc can't malloc");
k.c = c;
@@ -661,7 +661,7 @@ ebprepend(Ebuf *b, Esrc *s)
}
static Ebuf*
-ebadd(Esrc *s, int prepend)
+ebadd(Esrc *s, bool prepend)
{
Ebuf *eb;
int m;
(DIR) diff --git a/sam/mesg.c b/sam/mesg.c
@@ -497,7 +497,7 @@ inmesg(Tmesg type)
}
void
-snarf(File *f, Posn p1, Posn p2, Buffer *buf, int emptyok)
+snarf(File *f, Posn p1, Posn p2, Buffer *buf, bool emptyok)
{
Posn l;
int i;
(DIR) diff --git a/sam/multi.c b/sam/multi.c
@@ -82,7 +82,7 @@ state(File *f, int cleandirty)
}
File *
-lookfile(String *s, int fuzzy)
+lookfile(String *s, bool fuzzy)
{
int i;
File *b = NULL;
(DIR) diff --git a/sam/sam.c b/sam/sam.c
@@ -579,7 +579,7 @@ readflist(int readall, int delete)
break;
genstr.s[i] = 0;
t = tmprstr(genstr.s, i+1);
- f = lookfile(t, 0);
+ f = lookfile(t, false);
if(delete){
if(f == 0)
warn_S(Wfile, t);
@@ -600,10 +600,10 @@ tofile(String *s)
error(Eblank);
if (loadflist(s) == 0)
- f = lookfile(&genstr, 0);
+ f = lookfile(&genstr, false);
if (f == NULL)
- f = lookfile(&genstr, 1);
+ f = lookfile(&genstr, true);
if (f == NULL)
f = readflist(false, false);
(DIR) diff --git a/sam/sam.h b/sam/sam.h
@@ -216,7 +216,7 @@ void inslist(List*, int, int64_t);
Address lineaddr(Posn, Address, int);
void listfree(List*);
void load(File*);
-File *lookfile(String*, int);
+File *lookfile(String*, bool);
void lookorigin(File*, Posn, Posn, int64_t);
int lookup(int);
void move(File*, Address);
@@ -240,7 +240,7 @@ void rgrow(List*, Posn, Posn);
void samerr(char*);
void settempfile(void);
int skipbl(void);
-void snarf(File*, Posn, Posn, Buffer*, int);
+void snarf(File*, Posn, Posn, Buffer*, bool);
void sortname(File*);
void startup(char*, int, char**, char**);
void state(File*, int);
(DIR) diff --git a/sam/shell.c b/sam/shell.c
@@ -31,7 +31,7 @@ plan9(File *f, int type, String *s, int nest)
if(type!='!' && pipe(pipe1)==-1)
error(Epipe);
if(type=='|')
- snarf(f, addr.r.p1, addr.r.p2, plan9buf, 1);
+ snarf(f, addr.r.p1, addr.r.p2, plan9buf, true);
if(downloaded)
remove(errfile);
if((pid=fork()) == 0){
@@ -104,7 +104,7 @@ plan9(File *f, int type, String *s, int nest)
bool nulls;
if(downloaded && addr.r.p1 != addr.r.p2)
outTl(Hsnarflen, addr.r.p2-addr.r.p1);
- snarf(f, addr.r.p1, addr.r.p2, snarfbuf, 0);
+ snarf(f, addr.r.p1, addr.r.p2, snarfbuf, false);
Fdelete(f, addr.r.p1, addr.r.p2);
close(pipe1[1]);
io = pipe1[0];
(DIR) diff --git a/samterm/flayer.c b/samterm/flayer.c
@@ -93,7 +93,7 @@ flclose(Flayer *l)
}
void
-flborder(Flayer *l, int wide)
+flborder(Flayer *l, bool wide)
{
if(flprepare(l)){
border(l->f.b, l->entire, FLMARGIN, 0, l->bg);
(DIR) diff --git a/samterm/flayer.h b/samterm/flayer.h
@@ -30,7 +30,7 @@ struct Flayer
Vis visible;
};
-void flborder(Flayer*, int);
+void flborder(Flayer*, bool);
void flclose(Flayer*);
void fldelete(Flayer*, int64_t, int64_t);
void flfp0p1(Flayer*, uint64_t*, uint64_t*);
(DIR) diff --git a/samterm/main.c b/samterm/main.c
@@ -116,7 +116,7 @@ main(int argc, char *argv[])
nwhich = flwhich(mouse.xy);
scr = which && ptinrect(mouse.xy, which->scroll);
if(mouse.buttons)
- flushtyping(1);
+ flushtyping(true);
if(mouse.buttons&1){
if(nwhich){
if(nwhich!=which)
@@ -168,11 +168,11 @@ current(Flayer *nw)
Text *t;
if(which)
- flborder(which, 0);
+ flborder(which, false);
if(nw){
- flushtyping(1);
+ flushtyping(true);
flupfront(nw);
- flborder(nw, 1);
+ flborder(nw, true);
buttons(Up);
t = (Text *)nw->user1;
t->front = nw-&t->l[0];
@@ -422,7 +422,7 @@ XDisplay(Display *);
extern Display * _dpy;
void
-flushtyping(int clearesc)
+flushtyping(bool clearesc)
{
Text *t;
uint64_t n;
@@ -451,7 +451,7 @@ flushtyping(int clearesc)
static int64_t
cmdscrolldown(Flayer *l, int64_t a, Text *t, const char *arg)
{
- flushtyping(0);
+ flushtyping(false);
center(l, l->origin + l->f.nchars + 1);
return a;
}
@@ -459,7 +459,7 @@ cmdscrolldown(Flayer *l, int64_t a, Text *t, const char *arg)
static int64_t
cmdscrollup(Flayer *l, int64_t a, Text *t, const char *arg)
{
- flushtyping(0);
+ flushtyping(false);
outTslll(Torigin, t->tag, l->origin, l->f.maxlines + 1, getlayer(l, t));
return a;
}
@@ -468,7 +468,7 @@ static int64_t
cmdcharleft(Flayer *l, int64_t a, Text *t, const char *arg)
{
flsetselect(l, a, a);
- flushtyping(0);
+ flushtyping(false);
if (a > 0)
a--;
flsetselect(l, a, a);
@@ -481,7 +481,7 @@ static int64_t
cmdcharright(Flayer *l, int64_t a, Text *t, const char *arg)
{
flsetselect(l, a, a);
- flushtyping(0);
+ flushtyping(false);
if (a < t->rasp.nrunes)
a++;
flsetselect(l, a, a);
@@ -494,7 +494,7 @@ static int64_t
cmdeol(Flayer *l, int64_t a, Text *t, const char *arg)
{
flsetselect(l, a, a);
- flushtyping(1);
+ flushtyping(true);
while(a < t->rasp.nrunes)
if(raspc(&t->rasp, a++) == '\n') {
a--;
@@ -511,7 +511,7 @@ static int64_t
cmdbol(Flayer *l, int64_t a, Text *t, const char *arg)
{
flsetselect(l, a, a);
- flushtyping(1);
+ flushtyping(true);
while (a > 0){
if (raspc(&t->rasp, --a) == '\n'){
a++;
@@ -552,7 +552,7 @@ static int64_t
cmdlineup(Flayer *l, int64_t a, Text *t, const char *arg)
{
flsetselect(l, a, a);
- flushtyping(1);
+ flushtyping(true);
if (a > 0){
int64_t n0, n1, count = 0;
while (a > 0 && raspc(&t->rasp, a - 1) != '\n'){
@@ -579,7 +579,7 @@ static int64_t
cmdlinedown(Flayer *l, int64_t a, Text *t, const char *arg)
{
flsetselect(l, a, a);
- flushtyping(1);
+ flushtyping(true);
if (a < t->rasp.nrunes){
int64_t p0, count = 0;
@@ -621,7 +621,7 @@ cmdjump(Flayer *l, int64_t a, Text *u, const char *arg)
t = (Text *)l->user1;
flast = which;
current(l);
- flushtyping(0);
+ flushtyping(false);
flsetselect(l, t->rasp.nrunes, t->rasp.nrunes);
center(l, a);
}
@@ -666,7 +666,7 @@ cmdescape(Flayer *l, int64_t a, Text *t, const char *arg)
if (typeesc >= 0){
l->p0 = typeesc;
l->p1 = a;
- flushtyping(1);
+ flushtyping(true);
}
for (l = t->l; l < &t->l[NL]; l++)
@@ -690,7 +690,7 @@ cmddelword(Flayer *l, int64_t a, Text *t, const char *arg)
/* hcheck is local because we know rasp is contiguous */
hcheck(t->tag);
}else{
- flushtyping(0);
+ flushtyping(false);
cut(t, t->front, 0, 1);
}
}
@@ -712,7 +712,7 @@ cmddelbol(Flayer *l, int64_t a, Text *t, const char *arg)
/* hcheck is local because we know rasp is contiguous */
hcheck(t->tag);
}else{
- flushtyping(0);
+ flushtyping(false);
cut(t, t->front, 0, 1);
}
}
@@ -734,7 +734,7 @@ cmddelbs(Flayer *l, int64_t a, Text *t, const char *arg)
/* hcheck is local because we know rasp is contiguous */
hcheck(t->tag);
}else{
- flushtyping(0);
+ flushtyping(false);
cut(t, t->front, 0, 1);
}
}
@@ -755,7 +755,7 @@ cmddel(Flayer *l, int64_t a, Text *t, const char *arg)
/* hcheck is local because we know rasp is contiguous */
hcheck(t->tag);
}else{
- flushtyping(0);
+ flushtyping(false);
cut(t, t->front, 0, 1);
}
}
@@ -791,7 +791,7 @@ cmdexchange(Flayer *l, int64_t a, Text *t, const char *arg)
static int64_t
cmdsnarf(Flayer *l, int64_t a, Text *t, const char *arg)
{
- flushtyping(0);
+ flushtyping(false);
int w = getlayer(l, t);
if (w >= 0)
@@ -803,7 +803,7 @@ cmdsnarf(Flayer *l, int64_t a, Text *t, const char *arg)
static int64_t
cmdcut(Flayer *l, int64_t a, Text *t, const char *arg)
{
- flushtyping(0);
+ flushtyping(false);
int w = getlayer(l, t);
if (w >= 0)
@@ -815,7 +815,7 @@ cmdcut(Flayer *l, int64_t a, Text *t, const char *arg)
static int64_t
cmdpaste(Flayer *l, int64_t a, Text *t, const char *arg)
{
- flushtyping(0);
+ flushtyping(false);
int w = getlayer(l, t);
if (w >= 0)
@@ -827,7 +827,7 @@ cmdpaste(Flayer *l, int64_t a, Text *t, const char *arg)
static int64_t
cmdtab(Flayer *l, int64_t a, Text *t, const char *arg)
{
- flushtyping(0);
+ flushtyping(false);
if (!expandtabs)
pushkbd('\t');
@@ -850,18 +850,18 @@ cmdsend(Flayer *l, int64_t a, Text *t, const char *arg)
{
bool dojump = (t != &cmd);
- flushtyping(0);
+ flushtyping(false);
if (dojump)
cmdjump(l, a, t, NULL);
for (const char *c = arg; *c; c++){
pushkbd(*c);
type(&cmd.l[cmd.front]);
- flushtyping(0);
+ flushtyping(false);
}
pushkbd('\n');
type(&cmd.l[cmd.front]);
- flushtyping(0);
+ flushtyping(false);
if (dojump)
cmdjump(l, a, t, NULL);
@@ -930,7 +930,7 @@ type(Flayer *l) /* what a bloody mess this is -- but it's getting better! */
k = qpeekc();
a = l->p0;
if (a != l->p1 && (k.k != Kcommand || commands[k.c].docut)){
- flushtyping(1);
+ flushtyping(true);
cut(t, t->front, 1, 1);
return; /* it may now be locked */
}
@@ -945,7 +945,7 @@ type(Flayer *l) /* what a bloody mess this is -- but it's getting better! */
}
if (k.k == Kcommand){
- flushtyping(0);
+ flushtyping(false);
if (k.c < 0 || k.c >= Cmax || commands[k.c].f == NULL)
panic("command table miss");
@@ -976,7 +976,7 @@ type(Flayer *l) /* what a bloody mess this is -- but it's getting better! */
l->p1 = a;
typeend = a;
if (k.c == '\n' || typeend - typestart > 100)
- flushtyping(0);
+ flushtyping(false);
onethird(l, a);
}
(DIR) diff --git a/samterm/mesg.c b/samterm/mesg.c
@@ -169,7 +169,7 @@ inmesg(Hmesg type, int count)
case Hgrow:
if(whichmenu(m) >= 0)
- hgrow(m, l, inlong(10), 1);
+ hgrow(m, l, inlong(10), true);
break;
case Hnewname:
@@ -237,7 +237,7 @@ inmesg(Hmesg type, int count)
case Hgrowdata:
if(whichmenu(m)<0)
break;
- hgrow(m, l, inlong(10), 0);
+ hgrow(m, l, inlong(10), false);
whichtext(m)->lock++; /* fake the request */
l += hdata(m, l, indata+18, count-18);
goto Checkscroll;
@@ -506,7 +506,7 @@ hsetdot(int m, int64_t p0, int64_t p1)
Text *t = whichtext(m);
Flayer *l = &t->l[t->front];
- flushtyping(1);
+ flushtyping(true);
flsetselect(l, p0, p1);
}
@@ -571,7 +571,7 @@ hcheck(int m)
is fixed */
continue;
a = t->l[i].origin;
- n = rcontig(&t->rasp, a, a+l->f.nchars, 1);
+ n = rcontig(&t->rasp, a, a+l->f.nchars, true);
if(n<l->f.nchars) /* text missing in middle of screen */
a+=n;
else{ /* text missing at end of screen? */
@@ -584,7 +584,7 @@ hcheck(int m)
goto Checksel;
if(n>TBLOCKSIZE)
n = TBLOCKSIZE;
- n = rcontig(&t->rasp, a, a+n, 1);
+ n = rcontig(&t->rasp, a, a+n, true);
if(n>0){
rload(&t->rasp, a, a+n, 0);
nl = l->f.nchars;
@@ -596,7 +596,7 @@ hcheck(int m)
}
}
if(!reqd){
- n = rcontig(&t->rasp, a, a+TBLOCKSIZE, 0);
+ n = rcontig(&t->rasp, a, a+TBLOCKSIZE, false);
if(n <= 0)
panic("hcheck request==0");
outTsls(Trequest, m, a, (int)n);
@@ -651,7 +651,7 @@ hsetsnarf(int nc)
}
void
-hgrow(int m, int64_t a, int64_t new, int req)
+hgrow(int m, int64_t a, int64_t new, bool req)
{
int i;
Flayer *l;
@@ -680,7 +680,7 @@ hgrow(int m, int64_t a, int64_t new, int req)
new = TBLOCKSIZE;
outTsls(Trequest, m, a, (int)new);
t->lock++;
- req = 0;
+ req = false;
}
}
(DIR) diff --git a/samterm/rasp.c b/samterm/rasp.c
@@ -232,7 +232,7 @@ rmissing(Rasp *r, uint64_t p0, uint64_t p1)
}
int
-rcontig(Rasp *r, uint64_t p0, uint64_t p1, int text)
+rcontig(Rasp *r, uint64_t p0, uint64_t p1, bool text)
{
Section *s;
int64_t p, n;
@@ -240,7 +240,7 @@ rcontig(Rasp *r, uint64_t p0, uint64_t p1, int text)
for(p=0,s=r->sect; s && p+s->nrunes<=p0; s=s->next)
p += s->nrunes;
- while(p<p1 && s && (text? (s->text!=0) : (s->text==0))){
+ while(p<p1 && s && (text ? (s->text!=0) : (s->text==0))){
n = s->nrunes-(p0-p);
if(n > p1-p0) /* all in this section */
n = p1-p0;
(DIR) diff --git a/samterm/samterm.h b/samterm/samterm.h
@@ -142,7 +142,7 @@ void rclear(Rasp*);
int whichmenu(int);
void hcut(int, int64_t, int64_t);
void horigin(int, int64_t, Flayer *);
-void hgrow(int, int64_t, int64_t, int);
+void hgrow(int, int64_t, int64_t, bool);
int hdata(int, int64_t, uint8_t*, int);
int hdatarune(int, int64_t, wchar_t*, int);
wchar_t *rload(Rasp*, uint64_t, uint64_t, uint64_t*);
@@ -152,7 +152,7 @@ Text *sweeptext(int, int);
void setpat(char*);
bool haspat(void);
void scrdraw(Flayer*, int64_t tot);
-int rcontig(Rasp*, uint64_t, uint64_t, int);
+int rcontig(Rasp*, uint64_t, uint64_t, bool);
int rmissing(Rasp*, uint64_t, uint64_t);
void rresize(Rasp *, int64_t, int64_t, int64_t);
void rdata(Rasp*, int64_t, int64_t, wchar_t*);
@@ -163,7 +163,7 @@ void flnewlyvisible(Flayer*);
char *rcvstring(void);
void Strcpy(wchar_t*, wchar_t*);
void Strncpy(wchar_t*, wchar_t*, int64_t);
-void flushtyping(int);
+void flushtyping(bool);
void dumperrmsg(int, int, int, int);
int screensize(int*,int*);