Skip to content

Commit 35dc8dc

Browse files
authored
minor style and formatting fixes (#52)
1 parent dcff897 commit 35dc8dc

File tree

1 file changed

+14
-13
lines changed

1 file changed

+14
-13
lines changed

kirc.c

Lines changed: 14 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -119,17 +119,17 @@ static void
119119
message_wrap(char *line, size_t offset) {
120120

121121
struct winsize window_dims;
122-
122+
123123
if (ioctl(0, TIOCGWINSZ, &window_dims) < 0) {
124124
perror("ioctrl");
125125
exit(EXIT_FAILURE);
126126
}
127127

128128
unsigned short cmax = window_dims.ws_col;
129-
char *tok;
130-
size_t wordwidth, spaceleft = cmax - gutl - offset, spacewidth = 1;
129+
char *tok;
130+
size_t wordwidth, spaceleft = cmax - gutl - offset, spacewidth = 1;
131131

132-
for(tok = strtok(line, " "); tok != NULL; tok = strtok(NULL, " ")) {
132+
for (tok = strtok(line, " "); tok != NULL; tok = strtok(NULL, " ")) {
133133
wordwidth = strlen(tok);
134134
if ((wordwidth + spacewidth) > spaceleft) {
135135
printf("\n%*.s%s ", (int) gutl + 1, " ", tok);
@@ -146,7 +146,7 @@ message_wrap(char *line, size_t offset) {
146146
static void
147147
raw_parser(char *string) {
148148

149-
if (verb) printf(">> %s\n", string);
149+
if (verb) printf(">> %s", string);
150150

151151
if (!strncmp(string, "PING", 4)) {
152152
string[1] = 'O';
@@ -235,7 +235,7 @@ handle_user_input(void) {
235235

236236
if (fgets(usrin, MSG_MAX, stdin) == NULL) {
237237
perror("fgets");
238-
exit(1);
238+
exit(EXIT_FAILURE);
239239
}
240240

241241
size_t msg_len = strlen(usrin);
@@ -276,9 +276,9 @@ keyboard_hit() {
276276

277277
static void
278278
usage(void) {
279-
fputs("kirc [-s hostname] [-p port] [-c channel] [-n nick] \
280-
[-r real_name] [-u username] [-k password] [-a token] [-x init_command] \
281-
[-w columns] [-W columns] [-o path] [-e|v|V]\n", stderr);
279+
fputs("kirc [-s host] [-p port] [-c channel] [-n nick] [-r realname] \
280+
[-u username] [-k password] [-a token] [-x command] [-w columns] [-o path] \
281+
[-e|v|V]\n", stderr);
282282
exit(EXIT_FAILURE);
283283
}
284284

@@ -287,7 +287,7 @@ main(int argc, char **argv) {
287287

288288
int cval;
289289

290-
while ((cval = getopt(argc, argv, "s:p:o:n:k:c:u:r:x:w:a:hevV")) != -1) {
290+
while ((cval = getopt(argc, argv, "s:p:o:n:k:c:u:r:x:w:a:evV")) != -1) {
291291
switch (cval) {
292292
case 'V' : ++verb; break;
293293
case 'e' : ++sasl; break;
@@ -319,9 +319,10 @@ main(int argc, char **argv) {
319319
if (auth || sasl) raw("CAP REQ :sasl\r\n");
320320
raw("NICK %s\r\n", nick);
321321
raw("USER %s - - :%s\r\n", (user ? user : nick), (real ? real : nick));
322-
if (auth || sasl) raw("AUTHENTICATE %s\r\n", (sasl ? "EXTERNAL" : "PLAIN"));
323-
if (auth || sasl) raw("AUTHENTICATE %s\r\n", (sasl ? "+" : auth));
324-
if (auth || sasl) raw("CAP END\r\n");
322+
if (auth || sasl) {
323+
raw("AUTHENTICATE %s\r\n", (sasl ? "EXTERNAL" : "PLAIN"));
324+
raw("AUTHENTICATE %s\r\nCAP END\r\n", (sasl ? "+" : auth));
325+
}
325326
if (pass) raw("PASS %s\r\n", pass);
326327
if (inic) raw("%s\r\n", inic);
327328

0 commit comments

Comments
 (0)