mirror of
https://git.tartarus.org/simon/putty.git
synced 2025-07-18 19:41:01 -05:00
Whitespace rationalisation of entire code base.
The number of people has been steadily increasing who read our source code with an editor that thinks tab stops are 4 spaces apart, as opposed to the traditional tty-derived 8 that the PuTTY code expects. So I've been wondering for ages about just fixing it, and switching to a spaces-only policy throughout the code. And I recently found out about 'git blame -w', which should make this change not too disruptive for the purposes of source-control archaeology; so perhaps now is the time. While I'm at it, I've also taken the opportunity to remove all the trailing spaces from source lines (on the basis that git dislikes them, and is the only thing that seems to have a strong opinion one way or the other). Apologies to anyone downstream of this code who has complicated patch sets to rebase past this change. I don't intend it to be needed again.
This commit is contained in:
@ -19,7 +19,7 @@ bool agent_exists(void)
|
||||
{
|
||||
const char *p = getenv("SSH_AUTH_SOCK");
|
||||
if (p && *p)
|
||||
return true;
|
||||
return true;
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -37,9 +37,9 @@ static int agent_conncmp(void *av, void *bv)
|
||||
agent_pending_query *a = (agent_pending_query *) av;
|
||||
agent_pending_query *b = (agent_pending_query *) bv;
|
||||
if (a->fd < b->fd)
|
||||
return -1;
|
||||
return -1;
|
||||
if (a->fd > b->fd)
|
||||
return +1;
|
||||
return +1;
|
||||
return 0;
|
||||
}
|
||||
static int agent_connfind(void *av, void *bv)
|
||||
@ -47,9 +47,9 @@ static int agent_connfind(void *av, void *bv)
|
||||
int afd = *(int *) av;
|
||||
agent_pending_query *b = (agent_pending_query *) bv;
|
||||
if (afd < b->fd)
|
||||
return -1;
|
||||
return -1;
|
||||
if (afd > b->fd)
|
||||
return +1;
|
||||
return +1;
|
||||
return 0;
|
||||
}
|
||||
|
||||
@ -66,26 +66,26 @@ static bool agent_try_read(agent_pending_query *conn)
|
||||
ret = read(conn->fd, conn->retbuf+conn->retlen,
|
||||
conn->retsize-conn->retlen);
|
||||
if (ret <= 0) {
|
||||
if (conn->retbuf != conn->sizebuf) sfree(conn->retbuf);
|
||||
conn->retbuf = NULL;
|
||||
conn->retlen = 0;
|
||||
if (conn->retbuf != conn->sizebuf) sfree(conn->retbuf);
|
||||
conn->retbuf = NULL;
|
||||
conn->retlen = 0;
|
||||
return true;
|
||||
}
|
||||
conn->retlen += ret;
|
||||
if (conn->retsize == 4 && conn->retlen == 4) {
|
||||
conn->retsize = toint(GET_32BIT_MSB_FIRST(conn->retbuf) + 4);
|
||||
if (conn->retsize <= 0) {
|
||||
conn->retbuf = NULL;
|
||||
conn->retlen = 0;
|
||||
conn->retsize = toint(GET_32BIT_MSB_FIRST(conn->retbuf) + 4);
|
||||
if (conn->retsize <= 0) {
|
||||
conn->retbuf = NULL;
|
||||
conn->retlen = 0;
|
||||
return true; /* way too large */
|
||||
}
|
||||
assert(conn->retbuf == conn->sizebuf);
|
||||
conn->retbuf = snewn(conn->retsize, char);
|
||||
memcpy(conn->retbuf, conn->sizebuf, 4);
|
||||
}
|
||||
assert(conn->retbuf == conn->sizebuf);
|
||||
conn->retbuf = snewn(conn->retsize, char);
|
||||
memcpy(conn->retbuf, conn->sizebuf, 4);
|
||||
}
|
||||
|
||||
if (conn->retlen < conn->retsize)
|
||||
return false; /* more data to come */
|
||||
return false; /* more data to come */
|
||||
|
||||
return true;
|
||||
}
|
||||
@ -108,12 +108,12 @@ static void agent_select_result(int fd, int event)
|
||||
|
||||
conn = find234(agent_pending_queries, &fd, agent_connfind);
|
||||
if (!conn) {
|
||||
uxsel_del(fd);
|
||||
return;
|
||||
uxsel_del(fd);
|
||||
return;
|
||||
}
|
||||
|
||||
if (!agent_try_read(conn))
|
||||
return; /* more data to come */
|
||||
return; /* more data to come */
|
||||
|
||||
/*
|
||||
* We have now completed the agent query. Do the callback.
|
||||
@ -137,12 +137,12 @@ agent_pending_query *agent_query(
|
||||
|
||||
name = getenv("SSH_AUTH_SOCK");
|
||||
if (!name || strlen(name) >= sizeof(addr.sun_path))
|
||||
goto failure;
|
||||
goto failure;
|
||||
|
||||
sock = socket(PF_UNIX, SOCK_STREAM, 0);
|
||||
if (sock < 0) {
|
||||
perror("socket(PF_UNIX)");
|
||||
exit(1);
|
||||
perror("socket(PF_UNIX)");
|
||||
exit(1);
|
||||
}
|
||||
|
||||
cloexec(sock);
|
||||
@ -150,20 +150,20 @@ agent_pending_query *agent_query(
|
||||
addr.sun_family = AF_UNIX;
|
||||
strcpy(addr.sun_path, name);
|
||||
if (connect(sock, (struct sockaddr *)&addr, sizeof(addr)) < 0) {
|
||||
close(sock);
|
||||
goto failure;
|
||||
close(sock);
|
||||
goto failure;
|
||||
}
|
||||
|
||||
strbuf_finalise_agent_query(query);
|
||||
|
||||
for (done = 0; done < query->len ;) {
|
||||
int ret = write(sock, query->s + done,
|
||||
int ret = write(sock, query->s + done,
|
||||
query->len - done);
|
||||
if (ret <= 0) {
|
||||
close(sock);
|
||||
goto failure;
|
||||
}
|
||||
done += ret;
|
||||
if (ret <= 0) {
|
||||
close(sock);
|
||||
goto failure;
|
||||
}
|
||||
done += ret;
|
||||
}
|
||||
|
||||
conn = snew(agent_pending_query);
|
||||
@ -200,7 +200,7 @@ agent_pending_query *agent_query(
|
||||
* select_result comes back to us.
|
||||
*/
|
||||
if (!agent_pending_queries)
|
||||
agent_pending_queries = newtree234(agent_conncmp);
|
||||
agent_pending_queries = newtree234(agent_conncmp);
|
||||
add234(agent_pending_queries, conn);
|
||||
|
||||
uxsel_set(sock, SELECT_R, agent_select_result);
|
||||
|
Reference in New Issue
Block a user