Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Minor style-related improvements are made. #68

Open
wants to merge 31 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
31 commits
Select commit Hold shift + click to select a range
1da4f13
src/http.c: s/k == false/!k/
varikvalefor Aug 26, 2021
aaeb990
src/css.c: Some unnecessary parentheses are deleted.
varikvalefor Aug 26, 2021
eea0405
src/main.c: An unused definition is deleted.
varikvalefor Aug 26, 2021
0e35a9f
src/main.c: Some "if" statements are combined.
varikvalefor Aug 26, 2021
2be72b8
src/main.c: A "switch" statement replaces several "if" statements. W…
varikvalefor Aug 26, 2021
68028bc
src/main.c: s/\t /\t\t/
varikvalefor Aug 26, 2021
919b328
src/main.c: Some unnecessary curly brackets are deleted.
varikvalefor Aug 26, 2021
f291ba8
src/css.c: s/\t /\t/
varikvalefor Aug 26, 2021
e0772bd
src/sendmail.c: Some "if" statements are combined.
varikvalefor Aug 26, 2021
1e62945
src/sendmail.c: Some unnecessary curly brackets are deleted... again.
varikvalefor Aug 26, 2021
7b7fd31
src/buffers.c: Some unnecessary curly brackets are deleted... again.
varikvalefor Aug 26, 2021
06fdc41
src/buffers.c: Indentation is improved.
varikvalefor Aug 26, 2021
0a97403
src/buffers.c: A "switch" thing replaces a series of "if" statements.
varikvalefor Aug 26, 2021
a2d844b
src/buffers.c: A thing is shortened.
varikvalefor Aug 26, 2021
3b5dfbe
src/buffers.c: Some unnecessary curly brackets are deleted.
varikvalefor Aug 26, 2021
35205d0
src/buffers.c: Some "if" statements are combined.
varikvalefor Aug 26, 2021
9390d6f
src/buffers.c: Some "if" statements are combined.
varikvalefor Aug 26, 2021
d8ed6ff
src/buffers.c: s/while \(true\)/while ([REAL CONDITION])/
varikvalefor Aug 26, 2021
0c5f12b
src/buffers.c: Some "if" statements are combined.
varikvalefor Aug 26, 2021
d8f1fe3
src/buffers.c: Some unnecessary curly brackets are deleted.
varikvalefor Aug 26, 2021
9c97523
src/buffers.c: Indentation is improved.
varikvalefor Aug 26, 2021
aa5c358
src/buffers.c: Some "if" statements are combined.
varikvalefor Aug 26, 2021
7819653
src/buffers.c: Some lines are combined.
varikvalefor Aug 26, 2021
d039fa9
src/buffers.c: Some redundant stuff is deleted.
varikvalefor Aug 26, 2021
c936b3d
src/buffers.c: Some unnecessary curly brackets are deleted.
varikvalefor Aug 26, 2021
a4a6309
src/buffers.c: Some "if" statements are combined.
varikvalefor Aug 26, 2021
c56bd65
src/buffers.c: Some unnecessary curly brackets are deleted.
varikvalefor Aug 26, 2021
595b541
src/buffers.c: Some "if" statements are combined.
varikvalefor Aug 26, 2021
d5371f1
src/buffers.c: Some "if" statements are combined.
varikvalefor Aug 26, 2021
d79a8ff
src/buffers.c: Some "if" statements are combined. Unnecessary bracke…
varikvalefor Aug 26, 2021
4ad6318
src/buffers.c: Tabs replace some spaces.
varikvalefor Aug 26, 2021
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
122 changes: 47 additions & 75 deletions src/buffers.c
Original file line number Diff line number Diff line change
Expand Up @@ -1132,10 +1132,9 @@ bool addTextToBuffer(const pst inbuf, int length, int destl, bool showtrail)
for (i = 0; i < length; ++i)
if (inbuf[i] == '\n') {
++linecount;
if (sizeof(int) == 4) {
if (sizeof(int) == 4)
if (linecount + cw->dol > MAXLINES)
i_printfExit(MSG_LineLimit);
}
}

if (destl == cw->dol)
Expand Down Expand Up @@ -1779,10 +1778,10 @@ static int dircmp(const void *s, const void *t)
rc = 1;
if(!rc) {
// Honor sub-second timestamp precision if the operating system supports it.
if (q->u.spec.tv_nsec < r->u.spec.tv_nsec)
rc = -1;
if (q->u.spec.tv_nsec > r->u.spec.tv_nsec)
rc = 1;
if (q->u.spec.tv_nsec < r->u.spec.tv_nsec)
rc = -1;
if (q->u.spec.tv_nsec > r->u.spec.tv_nsec)
rc = 1;
}
#else
if (q->u.t < r->u.t)
Expand Down Expand Up @@ -1871,16 +1870,18 @@ static bool readDirectory(const char *filename)
}
ftype = tolower(ftype);
c = 0;
if (ftype == 'd')
c = '/';
if (ftype == 's')
c = '^';
if (ftype == 'c')
c = '<';
if (ftype == 'b')
c = '*';
if (ftype == 'p')
c = '|';
switch (ftype) {
case 'd':
c = '/';
case 's':
c = '^';
case 'c':
c = '<';
case 'b':
c = '*';
case 'p':
c = '|';
}
if (c) {
if (!cw->dirMode)
*t = c, *++t = '\n';
Expand Down Expand Up @@ -2729,13 +2730,11 @@ static void debrowseSuffix(char *s)
{
if (!s)
return;
while (*s) {
for(; s++; s)
if (*s == '.' && stringEqual(s, ".browse")) {
*s = 0;
return;
}
++s;
}
} /* debrowseSuffix */

// macro substitutions within the command line.
Expand Down Expand Up @@ -3030,12 +3029,11 @@ regexpCheck(const char *line, bool isleft, bool ebmuck,
*e++ = '\\';
}

if (c == '$' && !isleft && isdigitByte(d)) {
if (c == '$' && !isleft && isdigitByte(d))
if (d == '0' || isdigitByte(line[2])) {
setError(MSG_RexpDollar);
return false;
}
}
/* dollar digit on the right */
if (!isleft && c == '&' && ebmuck) {
*e++ = '$';
Expand Down Expand Up @@ -3152,18 +3150,16 @@ static void regexpCompile(const char *re, bool ci)
if (ci)
re_opt |= PCRE_CASELESS;

if (re_utf8) {
if (cons_utf8 && !cw->binMode && try8 >= 0) {
if (try8 == 0) {
const char *s = getenv("PCREUTF8");
if (s && stringEqual(s, "off")) {
try8 = -1;
goto top;
}
if (re_utf8 && cons_utf8 && !cw->binMode && try8 >= 0) {
if (try8 == 0) {
const char *s = getenv("PCREUTF8");
if (s && stringEqual(s, "off")) {
try8 = -1;
goto top;
}
try8 = 1;
re_opt |= PCRE_UTF8;
}
try8 = 1;
re_opt |= PCRE_UTF8;
}

re_cc = pcre_compile(re, re_opt, &re_error, &re_offset, 0);
Expand Down Expand Up @@ -3594,12 +3590,7 @@ replaceText(const char *line, int len, const char *rhs,
break;
} /* loop matching the regular expression */

if (!instance) {
nzFree(r);
return false;
}

if (!global &&instance < nth) {
if (!instance || (!global && instance < nth) {
nzFree(r);
return false;
}
Expand Down Expand Up @@ -3724,15 +3715,13 @@ findField(const char *line, int ftype, int n,
/* Second time through, maybe the url is in plain text. */
nmh = 0;
s = line;
while (true) {
while (c != '\n') {
/* skip past weird characters */
while ((c = *s) != '\n') {
if (strchr(urlok, c))
break;
++s;
}
if (c == '\n')
break;
ss = s;
while (strchr(urlok, *s))
++s;
Expand Down Expand Up @@ -4089,10 +4078,8 @@ static int substituteText(const char *line)
}

if (!lastSubst) {
if (!globSub) {
if (!errorMsg[0])
setError(bl_mode ? MSG_NoChange : MSG_NoMatch);
}
if (!globSub && !errorMsg[0])
setError(bl_mode ? MSG_NoChange : MSG_NoMatch);
return false;
}
cw->dot = lastSubst;
Expand Down Expand Up @@ -4510,11 +4497,10 @@ static int twoLetter(const char *line, const char **runThis)
if (stringEqual(line, "config")) {
readConfigFile();
setupEdbrowseCache();
if (curlActive) {
if (curlActive)
if (cookieFile)
curl_easy_setopt(global_http_handle,
CURLOPT_COOKIEJAR, cookieFile);
}
return true;
}

Expand All @@ -4529,7 +4515,7 @@ static int twoLetter(const char *line, const char **runThis)
setError(MSG_NoBrowse);
return false;
}
return showHeaders(cw->dot);
return showHeaders(cw->dot);
}
showColumns();
return true;
Expand Down Expand Up @@ -5351,16 +5337,12 @@ static bool balanceLine(const char *line)
direction = -1;
}
unbalanced(c, d, endRange, &backward, &forward);
if (direction > 0) {
if ((level = forward) == 0) {
setError(MSG_BalanceNoOpen, c);
return false;
}
} else {
if ((level = backward) == 0) {
setError(MSG_BalanceNoOpen, d);
return false;
}
if (direction > 0 && (level = forward) == 0) {
setError(MSG_BalanceNoOpen, c);
return false;
} else if ((level = backward) == 0) {
setError(MSG_BalanceNoOpen, d);
return false;
}
} else {

Expand Down Expand Up @@ -5812,9 +5794,6 @@ Should the newly entered row be unfolded? idk
}
for(i = startRange; i <= endRange; ++i)
if((w = line2tr(i)))
w->inur = false;
for(i = startRange; i <= endRange; ++i)
if((w = line2tr(i)) && !w->inur)
w->inur = true, w->ur ^= 1;
rerender(true);
return true;
Expand Down Expand Up @@ -6004,13 +5983,12 @@ Should the newly entered row be unfolded? idk
line = configFile;

/* env variable and wild card expansion */
if (strchr("brewf", cmd) && first && !isURL(line) && !isSQL(line)) {
if (strchr("brewf", cmd) && first && !isURL(line) && !isSQL(line))
if (cmd != 'r' || !cw->sqlMode) {
if (!envFile(line, &line))
return false;
first = *line;
}
}

if (cmd == 'z') {
if (isdigitByte(first)) {
Expand Down Expand Up @@ -6124,12 +6102,9 @@ Should the newly entered row be unfolded? idk
}

if (cmd == 'q') {
if (cx) {
if (!cxCompare(cx))
return false;
if (!cxActive(cx))
return false;
} else {
if (cx && (!cxCompare(cx) || !cxActive(cx)))
return false;
else {
cx = context;
if (first) {
setError(MSG_QAfter);
Expand Down Expand Up @@ -6160,9 +6135,7 @@ Should the newly entered row be unfolded? idk
if (cmd == 'f') {
selfFrame();
if (cx) {
if (!cxCompare(cx))
return false;
if (!cxActive(cx))
if (!cxCompare(cx) || !cxActive(cx))
return false;
s = sessionList[cx].lw->f0.fileName;
if (s)
Expand Down Expand Up @@ -6330,10 +6303,9 @@ Should the newly entered row be unfolded? idk
setError(MSG_NoBackup);
return false;
}
if (cx) {
if (!cxCompare(cx))
return false;
} else {
if (cx && !cxCompare(cx))
return false;
else {
cx = sideBuffer(0, emptyString, 0, NULL);
if (cx == 0)
return false;
Expand Down
4 changes: 2 additions & 2 deletions src/css.c
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ static int closeString(char *s, char delim)
int pc = 0; // paren count
if (delim == '"' || delim == '\'')
qc = delim;
for (i = 0; (c = s[i]); ++i) {
for (i = 0; c = s[i]; ++i) {
if (c == qc) { // close quote
if (delim == qc)
return i + 1;
Expand Down Expand Up @@ -812,7 +812,7 @@ static struct desc *cssPieces(char *s)
nzFree(g.buffer);
if (debugLevel >= 3)
i_printf(MSG_GetCSS,
g.url, g.code);
g.url, g.code);
}
} else {
if (debugLevel >= 3)
Expand Down
2 changes: 1 addition & 1 deletion src/http.c
Original file line number Diff line number Diff line change
Expand Up @@ -2053,7 +2053,7 @@ static bool ftpConnect(struct i_get *g, char *creds_buf)
ftp_transfer_fail:
if (h)
curl_easy_cleanup(h);
if (transfer_success == false) {
if (!transfer_success) {
if (curlret != CURLE_OK)
ebcurl_setError(curlret, g->urlcopy,
(g->foreground ? 0 : 1), g->error);
Expand Down
Loading