]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
MINOR: buffer: align the last output line if there are less than 8 characters left
authorGodbach <nylzhaowei@gmail.com>
Thu, 21 Nov 2013 02:21:22 +0000 (10:21 +0800)
committerWilly Tarreau <w@1wt.eu>
Thu, 21 Nov 2013 07:07:04 +0000 (08:07 +0100)
Commit c08057c does the align job for buffer_dump(), but it has not fixed the
issue that less than 8 characters are left in the last line as below:

Dumping contents from byte 0 to byte 119
         0  1  2  3  4  5  6  7    8  9  a  b  c  d  e  f
  0000: 47 45 54 20 2f 69 6e 64 - 65 78 2e 68 74 6d 20 48   GET /index.htm H
  0010: 54 54 50 2f 31 2e 30 0d - 0a 55 73 65 72 2d 41 67   TTP/1.0..User-Ag
  ...
  0060: 6e 65 63 74 69 6f 6e 3a - 20 4b 65 65 70 2d 41 6c   nection: Keep-Al
  0070: 69 76 65 0d 0a 0d 0a                              ive....

The last line of the hex column is still overlapped by the text column. Since
there will be additional "- " for the output line which has no less than 8
characters, two additional spaces should be present when there is less than 8
characters in order to do alignment. The result after being fixed is as below:

Dumping contents from byte 0 to byte 119
         0  1  2  3  4  5  6  7    8  9  a  b  c  d  e  f
  0000: 47 45 54 20 2f 69 6e 64 - 65 78 2e 68 74 6d 20 48   GET /index.htm H
  0010: 54 54 50 2f 31 2e 30 0d - 0a 55 73 65 72 2d 41 67   TTP/1.0..User-Ag
  ...
  0060: 6e 65 63 74 69 6f 6e 3a - 20 4b 65 65 70 2d 41 6c   nection: Keep-Al
  0070: 69 76 65 0d 0a 0d 0a                                ive....

Signed-off-by: Godbach <nylzhaowei@gmail.com>
src/buffer.c

index c3e9d51f7c3052fee54f930b65c1424d1ada0ef9..91bee637be25a8fa71e24e7b747fc9cfca68822f 100644 (file)
@@ -216,9 +216,12 @@ void buffer_dump(FILE *o, struct buffer *b, int from, int to)
                                fprintf(o, "- ");
                }
                if (to - from < 16) {
-                       int j;
+                       int j = 0;
+
                        for (j = 0; j <  from + 16 - to; j++)
                                fprintf(o, "   ");
+                       if (j > 8)
+                               fprintf(o, "  ");
                }
                fprintf(o, "  ");
                for (i = 0; (from + i < to) && (i < 16) ; i++) {