Skip to content

Commit 57d4c33

Browse files
Formating of mux.c is fixed to be aligned with the rest of the project
1 parent 7b763aa commit 57d4c33

File tree

1 file changed

+20
-20
lines changed

1 file changed

+20
-20
lines changed

mux.c

+20-20
Original file line numberDiff line numberDiff line change
@@ -215,34 +215,34 @@ static int do_subneg(struct ios_ops *ios, unsigned char *buf, int len)
215215
static int logfd = -1;
216216
char *answerback;
217217

218-
static void write_receive_buf(const unsigned char *buf, int len) {
218+
static void write_receive_buf(const unsigned char *buf, int len)
219+
{
219220
if (!len) return;
220221
if (timestamps) {
221-
if (buf[0] == '\n' || buf[0] == '\r') {
222-
new_line = true;
223-
write(STDOUT_FILENO, buf, len);
224-
} else {
225-
if (new_line) {
226-
new_line = false;
227-
char tbuf[30];
228-
memset(tbuf, 0, sizeof(tbuf));
229-
gettimeofday(&now, NULL);
230-
timeinfo = gmtime(&now.tv_sec);
231-
snprintf(tbuf, sizeof(tbuf),
232-
"[%02d-%02d-%02d %02d:%02d:%02d:%03d] ",
233-
timeinfo->tm_mday, timeinfo->tm_mon + 1,
234-
timeinfo->tm_year + 1900, timeinfo->tm_hour,
235-
timeinfo->tm_min, timeinfo->tm_sec, now.tv_usec / 1000);
236-
write(STDOUT_FILENO, tbuf, strlen(tbuf));
222+
if (buf[len - 1] == '\n' || buf[len -1] == '\r') {
223+
new_line = true;
237224
write(STDOUT_FILENO, buf, len);
238225
} else {
239-
write(STDOUT_FILENO, buf, len);
226+
if (new_line) {
227+
new_line = false;
228+
char tbuf[30];
229+
memset(tbuf, 0, sizeof(tbuf));
230+
gettimeofday(&now, NULL);
231+
timeinfo = gmtime(&now.tv_sec);
232+
snprintf(tbuf, sizeof(tbuf),
233+
"[%02d-%02d-%02d %02d:%02d:%02d:%03d] ",
234+
timeinfo->tm_mday, timeinfo->tm_mon + 1,
235+
timeinfo->tm_year + 1900, timeinfo->tm_hour,
236+
timeinfo->tm_min, timeinfo->tm_sec, now.tv_usec / 1000);
237+
write(STDOUT_FILENO, tbuf, strlen(tbuf));
238+
write(STDOUT_FILENO, buf, len);
239+
} else {
240+
write(STDOUT_FILENO, buf, len);
241+
}
240242
}
241-
}
242243
} else {
243244
write(STDOUT_FILENO, buf, len);
244245
}
245-
246246
if (logfd >= 0) write(logfd, buf, len);
247247
}
248248

0 commit comments

Comments
 (0)