Download raw body.
tog: fix display of lines ending in \r\n
Stefan Sperling: > You've lost me a bit. Could you write a patch to demonstrate this? Currently tog treats a control character as having zero width and passes it directly to curses. Curses internally uses wunctrl() to replace the control character with a printable representation ('^' notation for 0x00..0x1F, 0x7F; '~' notation for 0x80..0x9F). This makes the string two columns wider and breaks the screen formatting. I like this printable representation. I do not want to replace all control characters with '?'. I see two approaches to fix the screen formatting: (1) tog converts the control characters into a printable replacement itself, maybe using wunctrl(), before passing the resultant string to curses. Alternatively, (2) tog continues to pass the control character to curses, but when calculating the column width, tog takes into account that curses will change the character into a printable representation. Below is a quick proof-of-concept that uses approach (2). I don't really know how to get from wchar_t to cchar_t, this is the first thing I found. ... Hmm, looks like I use setcchar() incorrectly. Anyway, you get the idea. I have also attached an updated copy of my evil test repository, now with commit messages that have ^L and 0x9B control characters. diff 9f6bb280654be7061fc00305743f6ace71f9a1cb /home/naddy/got blob - 99232045ade1a4d37286e512dd4999368a1b89b5 file + tog/tog.c --- tog/tog.c +++ tog/tog.c @@ -1193,6 +1193,13 @@ format_line(wchar_t **wlinep, int *widthp, const char if (cols + width > wlimit) break; cols += width; + } else { + cchar_t cc; + setcchar(&cc, &wline[i], 0, 0, NULL); + width = wcslen(wunctrl(&cc)); + if (cols + width > wlimit) + break; + cols += width; } i++; } else { -- Christian "naddy" Weisgerber naddy@mips.inka.de
tog: fix display of lines ending in \r\n