Fossil SCM
On non-Windows systems that appear to lack the TIOCGWINSZ define, fallback to using the legacy behavior of hard-coding a reasonable default maximum line length.
Commit
54cc57e7a34785a9b71c03005b1c3749e733d9d9
Parent
2d8f311cc056900…
1 file changed
+18
+18
| --- src/comformat.c | ||
| +++ src/comformat.c | ||
| @@ -25,10 +25,19 @@ | ||
| 25 | 25 | # include <windows.h> |
| 26 | 26 | #else |
| 27 | 27 | # include <termios.h> |
| 28 | 28 | #endif |
| 29 | 29 | |
| 30 | +/* | |
| 31 | +** This is the previous value used by most external callers when they | |
| 32 | +** needed to specify a default maximum line length to be used with the | |
| 33 | +** comment_print() function. | |
| 34 | +*/ | |
| 35 | +#ifndef COMMENT_LEGACY_LINE_LENGTH | |
| 36 | +# define COMMENT_LEGACY_LINE_LENGTH (78) | |
| 37 | +#endif | |
| 38 | + | |
| 30 | 39 | /* |
| 31 | 40 | ** Given a comment string zText, format that string for printing |
| 32 | 41 | ** on a TTY. Assume that the output cursors is indent spaces from |
| 33 | 42 | ** the left margin and that a single line can contain no more than |
| 34 | 43 | ** lineLength characters. Indent all subsequent lines by indent. |
| @@ -57,10 +66,19 @@ | ||
| 57 | 66 | memset(&w, 0, sizeof(struct winsize)); |
| 58 | 67 | if( ioctl(0, TIOCGWINSZ, &w)!=-1 ){ |
| 59 | 68 | tlen = w.ws_col - indent; |
| 60 | 69 | } |
| 61 | 70 | } |
| 71 | +#else | |
| 72 | + if( lineLength<0 ){ | |
| 73 | + /* | |
| 74 | + ** Fallback to using more-or-less the "legacy semantics" of hard-coding | |
| 75 | + ** the maximum line length to a value reasonable for the vast majority | |
| 76 | + ** of supported systems. | |
| 77 | + */ | |
| 78 | + tlen = COMMENT_LEGACY_LINE_LENGTH - indent; | |
| 79 | + } | |
| 62 | 80 | #endif |
| 63 | 81 | if( zText==0 ) zText = "(NULL)"; |
| 64 | 82 | if( tlen<=0 ){ |
| 65 | 83 | tlen = strlen(zText); |
| 66 | 84 | } |
| 67 | 85 |
| --- src/comformat.c | |
| +++ src/comformat.c | |
| @@ -25,10 +25,19 @@ | |
| 25 | # include <windows.h> |
| 26 | #else |
| 27 | # include <termios.h> |
| 28 | #endif |
| 29 | |
| 30 | /* |
| 31 | ** Given a comment string zText, format that string for printing |
| 32 | ** on a TTY. Assume that the output cursors is indent spaces from |
| 33 | ** the left margin and that a single line can contain no more than |
| 34 | ** lineLength characters. Indent all subsequent lines by indent. |
| @@ -57,10 +66,19 @@ | |
| 57 | memset(&w, 0, sizeof(struct winsize)); |
| 58 | if( ioctl(0, TIOCGWINSZ, &w)!=-1 ){ |
| 59 | tlen = w.ws_col - indent; |
| 60 | } |
| 61 | } |
| 62 | #endif |
| 63 | if( zText==0 ) zText = "(NULL)"; |
| 64 | if( tlen<=0 ){ |
| 65 | tlen = strlen(zText); |
| 66 | } |
| 67 |
| --- src/comformat.c | |
| +++ src/comformat.c | |
| @@ -25,10 +25,19 @@ | |
| 25 | # include <windows.h> |
| 26 | #else |
| 27 | # include <termios.h> |
| 28 | #endif |
| 29 | |
| 30 | /* |
| 31 | ** This is the previous value used by most external callers when they |
| 32 | ** needed to specify a default maximum line length to be used with the |
| 33 | ** comment_print() function. |
| 34 | */ |
| 35 | #ifndef COMMENT_LEGACY_LINE_LENGTH |
| 36 | # define COMMENT_LEGACY_LINE_LENGTH (78) |
| 37 | #endif |
| 38 | |
| 39 | /* |
| 40 | ** Given a comment string zText, format that string for printing |
| 41 | ** on a TTY. Assume that the output cursors is indent spaces from |
| 42 | ** the left margin and that a single line can contain no more than |
| 43 | ** lineLength characters. Indent all subsequent lines by indent. |
| @@ -57,10 +66,19 @@ | |
| 66 | memset(&w, 0, sizeof(struct winsize)); |
| 67 | if( ioctl(0, TIOCGWINSZ, &w)!=-1 ){ |
| 68 | tlen = w.ws_col - indent; |
| 69 | } |
| 70 | } |
| 71 | #else |
| 72 | if( lineLength<0 ){ |
| 73 | /* |
| 74 | ** Fallback to using more-or-less the "legacy semantics" of hard-coding |
| 75 | ** the maximum line length to a value reasonable for the vast majority |
| 76 | ** of supported systems. |
| 77 | */ |
| 78 | tlen = COMMENT_LEGACY_LINE_LENGTH - indent; |
| 79 | } |
| 80 | #endif |
| 81 | if( zText==0 ) zText = "(NULL)"; |
| 82 | if( tlen<=0 ){ |
| 83 | tlen = strlen(zText); |
| 84 | } |
| 85 |