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.

mistachkin 2014-06-17 22:15 trunk
Commit 54cc57e7a34785a9b71c03005b1c3749e733d9d9
1 file changed +18
--- src/comformat.c
+++ src/comformat.c
@@ -25,10 +25,19 @@
2525
# include <windows.h>
2626
#else
2727
# include <termios.h>
2828
#endif
2929
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
+
3039
/*
3140
** Given a comment string zText, format that string for printing
3241
** on a TTY. Assume that the output cursors is indent spaces from
3342
** the left margin and that a single line can contain no more than
3443
** lineLength characters. Indent all subsequent lines by indent.
@@ -57,10 +66,19 @@
5766
memset(&w, 0, sizeof(struct winsize));
5867
if( ioctl(0, TIOCGWINSZ, &w)!=-1 ){
5968
tlen = w.ws_col - indent;
6069
}
6170
}
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
+ }
6280
#endif
6381
if( zText==0 ) zText = "(NULL)";
6482
if( tlen<=0 ){
6583
tlen = strlen(zText);
6684
}
6785
--- 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

Keyboard Shortcuts

Open search /
Next entry (timeline) j
Previous entry (timeline) k
Open focused entry Enter
Show this help ?
Toggle theme Top nav button