Skip to content

Commit 8ab514f

Browse files
committed
make hexdump send CRLF
1 parent 08ad2c3 commit 8ab514f

File tree

2 files changed

+6
-4
lines changed

2 files changed

+6
-4
lines changed

mongoose.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3104,7 +3104,8 @@ void mg_hexdump(const void *buf, size_t len) {
31043104
for (i = 0; i < len; i++) {
31053105
if ((i % 16) == 0) {
31063106
// Print buffered ascii chars
3107-
if (i > 0) logs(" ", 2), logs((char *) ascii, 16), logc('\n'), alen = 0;
3107+
if (i > 0)
3108+
logs(" ", 2), logs((char *) ascii, 16), logs("\r\n", 2), alen = 0;
31083109
// Print hex address, then \t
31093110
logc(nibble((i >> 12) & 15)), logc(nibble((i >> 8) & 15)),
31103111
logc(nibble((i >> 4) & 15)), logc('0'), logs(" ", 3);
@@ -3114,7 +3115,7 @@ void mg_hexdump(const void *buf, size_t len) {
31143115
ascii[alen++] = ISPRINT(p[i]) ? p[i] : '.'; // Add to the ascii buf
31153116
}
31163117
while (alen < 16) logs(" ", 3), ascii[alen++] = ' ';
3117-
logs(" ", 2), logs((char *) ascii, 16), logc('\n');
3118+
logs(" ", 2), logs((char *) ascii, 16), logs("\r\n", 2);
31183119
}
31193120

31203121
#ifdef MG_ENABLE_LINES

src/log.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,8 @@ void mg_hexdump(const void *buf, size_t len) {
5757
for (i = 0; i < len; i++) {
5858
if ((i % 16) == 0) {
5959
// Print buffered ascii chars
60-
if (i > 0) logs(" ", 2), logs((char *) ascii, 16), logc('\n'), alen = 0;
60+
if (i > 0)
61+
logs(" ", 2), logs((char *) ascii, 16), logs("\r\n", 2), alen = 0;
6162
// Print hex address, then \t
6263
logc(nibble((i >> 12) & 15)), logc(nibble((i >> 8) & 15)),
6364
logc(nibble((i >> 4) & 15)), logc('0'), logs(" ", 3);
@@ -67,5 +68,5 @@ void mg_hexdump(const void *buf, size_t len) {
6768
ascii[alen++] = ISPRINT(p[i]) ? p[i] : '.'; // Add to the ascii buf
6869
}
6970
while (alen < 16) logs(" ", 3), ascii[alen++] = ' ';
70-
logs(" ", 2), logs((char *) ascii, 16), logc('\n');
71+
logs(" ", 2), logs((char *) ascii, 16), logs("\r\n", 2);
7172
}

0 commit comments

Comments
 (0)