Fossil SCM

Initial draft of the ability to break a multi-line comment on word boundaries using the new algorithm.

mistachkin 2014-06-20 03:56 experimental
Commit 10b47cc35082b1a9102af5b6425e66e5b38dc54c
+1 -1
--- src/bisect.c
+++ src/bisect.c
@@ -390,11 +390,11 @@
390390
for(i=0; i<sizeof(aBisectOption)/sizeof(aBisectOption[0]); i++){
391391
char *z = mprintf("bisect-%s", aBisectOption[i].zName);
392392
fossil_print(" %-15s %-6s ", aBisectOption[i].zName,
393393
db_lget(z, (char*)aBisectOption[i].zDefault));
394394
fossil_free(z);
395
- comment_print(aBisectOption[i].zDesc, 27, -1);
395
+ comment_print(aBisectOption[i].zDesc, 27, -1, COMMENT_PRINT_DEFAULT);
396396
}
397397
}else if( g.argc==4 || g.argc==5 ){
398398
unsigned int i;
399399
n = strlen(g.argv[3]);
400400
for(i=0; i<sizeof(aBisectOption)/sizeof(aBisectOption[0]); i++){
401401
--- src/bisect.c
+++ src/bisect.c
@@ -390,11 +390,11 @@
390 for(i=0; i<sizeof(aBisectOption)/sizeof(aBisectOption[0]); i++){
391 char *z = mprintf("bisect-%s", aBisectOption[i].zName);
392 fossil_print(" %-15s %-6s ", aBisectOption[i].zName,
393 db_lget(z, (char*)aBisectOption[i].zDefault));
394 fossil_free(z);
395 comment_print(aBisectOption[i].zDesc, 27, -1);
396 }
397 }else if( g.argc==4 || g.argc==5 ){
398 unsigned int i;
399 n = strlen(g.argv[3]);
400 for(i=0; i<sizeof(aBisectOption)/sizeof(aBisectOption[0]); i++){
401
--- src/bisect.c
+++ src/bisect.c
@@ -390,11 +390,11 @@
390 for(i=0; i<sizeof(aBisectOption)/sizeof(aBisectOption[0]); i++){
391 char *z = mprintf("bisect-%s", aBisectOption[i].zName);
392 fossil_print(" %-15s %-6s ", aBisectOption[i].zName,
393 db_lget(z, (char*)aBisectOption[i].zDefault));
394 fossil_free(z);
395 comment_print(aBisectOption[i].zDesc, 27, -1, COMMENT_PRINT_DEFAULT);
396 }
397 }else if( g.argc==4 || g.argc==5 ){
398 unsigned int i;
399 n = strlen(g.argv[3]);
400 for(i=0; i<sizeof(aBisectOption)/sizeof(aBisectOption[0]); i++){
401
+53 -4
--- src/comformat.c
+++ src/comformat.c
@@ -25,10 +25,16 @@
2525
# include <windows.h>
2626
#else
2727
# include <termios.h>
2828
#endif
2929
30
+#if INTERFACE
31
+#define COMMENT_PRINT_NONE ((u32)0x00000000) /* No flags. */
32
+#define COMMENT_PRINT_WORD_BREAK ((u32)0x00000001) /* Break lines on words. */
33
+#define COMMENT_PRINT_DEFAULT COMMENT_PRINT_NONE /* Default flags. */
34
+#endif
35
+
3036
/*
3137
** This is the previous value used by most external callers when they
3238
** needed to specify a default maximum line length to be used with the
3339
** comment_print() function.
3440
*/
@@ -49,11 +55,16 @@
4955
** the left margin and that a single line can contain no more than
5056
** width characters. Indent all subsequent lines by indent.
5157
**
5258
** Return the number of newlines that are output.
5359
*/
54
-int comment_print(const char *zText, int indent, int width){
60
+int comment_print(
61
+ const char *zText, /* The comment text to be printed. */
62
+ int indent, /* Number of spaces to indent each non-initial line. */
63
+ int width, /* Maximum number of characters per line. */
64
+ int flags /* Zero or more "COMMENT_PRINT_*" flags, see above. */
65
+){
5566
int maxChars = width - indent;
5667
int lineCnt = 0;
5768
const char *zLine;
5869
5970
#if defined(_WIN32)
@@ -92,12 +103,13 @@
92103
lineCnt++;
93104
return lineCnt;
94105
}
95106
zLine = zText;
96107
for(;;){
97
- comment_print_line(zLine, zLine>zText ? indent : 0,
98
- maxChars, &lineCnt, &zLine);
108
+ comment_print_line(zLine, zLine>zText ? indent : 0, maxChars,
109
+ flags & COMMENT_PRINT_WORD_BREAK, &lineCnt,
110
+ &zLine);
99111
if( !zLine || !zLine[0] ) break;
100112
}
101113
return lineCnt;
102114
}
103115
@@ -107,10 +119,11 @@
107119
*/
108120
void comment_print_line(
109121
const char *zLine, /* [in] The comment line to print. */
110122
int indent, /* [in] Number of spaces to indent, zero for none. */
111123
int lineChars, /* [in] Maximum number of characters to print. */
124
+ int wordBreak, /* [in] Non-zero to try breaking on word boundaries. */
112125
int *pLineCnt, /* [in/out] Pointer to the total line count. */
113126
const char **pzLine /* [out] Pointer to the end of the logical line. */
114127
){
115128
int index = 0, charCnt = 0, lineCnt = 0, maxChars;
116129
if( !zLine ) return;
@@ -132,10 +145,17 @@
132145
if( maxChars<COMMENT_TAB_WIDTH ){
133146
fossil_print(" ");
134147
break;
135148
}
136149
maxChars -= COMMENT_TAB_WIDTH;
150
+ }else if( wordBreak && fossil_isspace(c) ){
151
+ int nextIndex = comment_next_space(zLine, index);
152
+ if( nextIndex<=0 || (nextIndex-index)>maxChars ){
153
+ break;
154
+ }
155
+ charCnt++;
156
+ maxChars--;
137157
}else{
138158
charCnt++;
139159
maxChars--;
140160
}
141161
fossil_print("%c", c);
@@ -170,10 +190,33 @@
170190
while( fossil_isspace(zLine[index]) ){ index++; }
171191
*piIndex = index;
172192
}
173193
}
174194
}
195
+
196
+/*
197
+** This function scans the specified comment line starting just after the
198
+** initial index and returns the index of the next spacing character -OR-
199
+** zero if such a character cannot be found.
200
+*/
201
+int comment_next_space(
202
+ const char *zLine, /* [in] The comment line being printed. */
203
+ int index /* [in] The current character index being handled. */
204
+){
205
+ int nextIndex = index + 1;
206
+ for(;;){
207
+ char c = zLine[nextIndex];
208
+ if( c==0 ){
209
+ return 0;
210
+ }
211
+ if( fossil_isspace(c) ){
212
+ return nextIndex;
213
+ }
214
+ nextIndex++;
215
+ }
216
+ return 0; /* NOT REACHED */
217
+}
175218
176219
/*
177220
**
178221
** COMMAND: test-comment-format
179222
**
@@ -182,16 +225,21 @@
182225
** Test comment formatting and printing. Use for testing only.
183226
**
184227
** Options:
185228
** --decode Decode the text using the same method used when
186229
** handling the value of a C-card from a manifest.
230
+** --wordbreak Attempt to break lines on word boundaries.
187231
*/
188232
void test_comment_format(void){
189233
const char *zPrefix;
190234
char *zText;
191235
int indent, width;
192236
int decode = find_option("decode", 0, 0)!=0;
237
+ int flags = COMMENT_PRINT_DEFAULT;
238
+ if( find_option("wordbreak", 0, 0) ){
239
+ flags |= COMMENT_PRINT_WORD_BREAK;
240
+ }
193241
if( g.argc!=4 && g.argc!=5 ){
194242
usage("PREFIX TEXT ?WIDTH?");
195243
}
196244
zPrefix = g.argv[2];
197245
if( decode ){
@@ -207,8 +255,9 @@
207255
width = -1; /* automatic */
208256
}
209257
if( indent>0 ){
210258
fossil_print("%s", zPrefix);
211259
}
212
- fossil_print("(%d lines output)\n", comment_print(zText, indent, width));
260
+ fossil_print("(%d lines output)\n",
261
+ comment_print(zText, indent, width, flags));
213262
if( zText!=g.argv[3] ) fossil_free(zText);
214263
}
215264
--- src/comformat.c
+++ src/comformat.c
@@ -25,10 +25,16 @@
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 */
@@ -49,11 +55,16 @@
49 ** the left margin and that a single line can contain no more than
50 ** width characters. Indent all subsequent lines by indent.
51 **
52 ** Return the number of newlines that are output.
53 */
54 int comment_print(const char *zText, int indent, int width){
 
 
 
 
 
55 int maxChars = width - indent;
56 int lineCnt = 0;
57 const char *zLine;
58
59 #if defined(_WIN32)
@@ -92,12 +103,13 @@
92 lineCnt++;
93 return lineCnt;
94 }
95 zLine = zText;
96 for(;;){
97 comment_print_line(zLine, zLine>zText ? indent : 0,
98 maxChars, &lineCnt, &zLine);
 
99 if( !zLine || !zLine[0] ) break;
100 }
101 return lineCnt;
102 }
103
@@ -107,10 +119,11 @@
107 */
108 void comment_print_line(
109 const char *zLine, /* [in] The comment line to print. */
110 int indent, /* [in] Number of spaces to indent, zero for none. */
111 int lineChars, /* [in] Maximum number of characters to print. */
 
112 int *pLineCnt, /* [in/out] Pointer to the total line count. */
113 const char **pzLine /* [out] Pointer to the end of the logical line. */
114 ){
115 int index = 0, charCnt = 0, lineCnt = 0, maxChars;
116 if( !zLine ) return;
@@ -132,10 +145,17 @@
132 if( maxChars<COMMENT_TAB_WIDTH ){
133 fossil_print(" ");
134 break;
135 }
136 maxChars -= COMMENT_TAB_WIDTH;
 
 
 
 
 
 
 
137 }else{
138 charCnt++;
139 maxChars--;
140 }
141 fossil_print("%c", c);
@@ -170,10 +190,33 @@
170 while( fossil_isspace(zLine[index]) ){ index++; }
171 *piIndex = index;
172 }
173 }
174 }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
175
176 /*
177 **
178 ** COMMAND: test-comment-format
179 **
@@ -182,16 +225,21 @@
182 ** Test comment formatting and printing. Use for testing only.
183 **
184 ** Options:
185 ** --decode Decode the text using the same method used when
186 ** handling the value of a C-card from a manifest.
 
187 */
188 void test_comment_format(void){
189 const char *zPrefix;
190 char *zText;
191 int indent, width;
192 int decode = find_option("decode", 0, 0)!=0;
 
 
 
 
193 if( g.argc!=4 && g.argc!=5 ){
194 usage("PREFIX TEXT ?WIDTH?");
195 }
196 zPrefix = g.argv[2];
197 if( decode ){
@@ -207,8 +255,9 @@
207 width = -1; /* automatic */
208 }
209 if( indent>0 ){
210 fossil_print("%s", zPrefix);
211 }
212 fossil_print("(%d lines output)\n", comment_print(zText, indent, width));
 
213 if( zText!=g.argv[3] ) fossil_free(zText);
214 }
215
--- src/comformat.c
+++ src/comformat.c
@@ -25,10 +25,16 @@
25 # include <windows.h>
26 #else
27 # include <termios.h>
28 #endif
29
30 #if INTERFACE
31 #define COMMENT_PRINT_NONE ((u32)0x00000000) /* No flags. */
32 #define COMMENT_PRINT_WORD_BREAK ((u32)0x00000001) /* Break lines on words. */
33 #define COMMENT_PRINT_DEFAULT COMMENT_PRINT_NONE /* Default flags. */
34 #endif
35
36 /*
37 ** This is the previous value used by most external callers when they
38 ** needed to specify a default maximum line length to be used with the
39 ** comment_print() function.
40 */
@@ -49,11 +55,16 @@
55 ** the left margin and that a single line can contain no more than
56 ** width characters. Indent all subsequent lines by indent.
57 **
58 ** Return the number of newlines that are output.
59 */
60 int comment_print(
61 const char *zText, /* The comment text to be printed. */
62 int indent, /* Number of spaces to indent each non-initial line. */
63 int width, /* Maximum number of characters per line. */
64 int flags /* Zero or more "COMMENT_PRINT_*" flags, see above. */
65 ){
66 int maxChars = width - indent;
67 int lineCnt = 0;
68 const char *zLine;
69
70 #if defined(_WIN32)
@@ -92,12 +103,13 @@
103 lineCnt++;
104 return lineCnt;
105 }
106 zLine = zText;
107 for(;;){
108 comment_print_line(zLine, zLine>zText ? indent : 0, maxChars,
109 flags & COMMENT_PRINT_WORD_BREAK, &lineCnt,
110 &zLine);
111 if( !zLine || !zLine[0] ) break;
112 }
113 return lineCnt;
114 }
115
@@ -107,10 +119,11 @@
119 */
120 void comment_print_line(
121 const char *zLine, /* [in] The comment line to print. */
122 int indent, /* [in] Number of spaces to indent, zero for none. */
123 int lineChars, /* [in] Maximum number of characters to print. */
124 int wordBreak, /* [in] Non-zero to try breaking on word boundaries. */
125 int *pLineCnt, /* [in/out] Pointer to the total line count. */
126 const char **pzLine /* [out] Pointer to the end of the logical line. */
127 ){
128 int index = 0, charCnt = 0, lineCnt = 0, maxChars;
129 if( !zLine ) return;
@@ -132,10 +145,17 @@
145 if( maxChars<COMMENT_TAB_WIDTH ){
146 fossil_print(" ");
147 break;
148 }
149 maxChars -= COMMENT_TAB_WIDTH;
150 }else if( wordBreak && fossil_isspace(c) ){
151 int nextIndex = comment_next_space(zLine, index);
152 if( nextIndex<=0 || (nextIndex-index)>maxChars ){
153 break;
154 }
155 charCnt++;
156 maxChars--;
157 }else{
158 charCnt++;
159 maxChars--;
160 }
161 fossil_print("%c", c);
@@ -170,10 +190,33 @@
190 while( fossil_isspace(zLine[index]) ){ index++; }
191 *piIndex = index;
192 }
193 }
194 }
195
196 /*
197 ** This function scans the specified comment line starting just after the
198 ** initial index and returns the index of the next spacing character -OR-
199 ** zero if such a character cannot be found.
200 */
201 int comment_next_space(
202 const char *zLine, /* [in] The comment line being printed. */
203 int index /* [in] The current character index being handled. */
204 ){
205 int nextIndex = index + 1;
206 for(;;){
207 char c = zLine[nextIndex];
208 if( c==0 ){
209 return 0;
210 }
211 if( fossil_isspace(c) ){
212 return nextIndex;
213 }
214 nextIndex++;
215 }
216 return 0; /* NOT REACHED */
217 }
218
219 /*
220 **
221 ** COMMAND: test-comment-format
222 **
@@ -182,16 +225,21 @@
225 ** Test comment formatting and printing. Use for testing only.
226 **
227 ** Options:
228 ** --decode Decode the text using the same method used when
229 ** handling the value of a C-card from a manifest.
230 ** --wordbreak Attempt to break lines on word boundaries.
231 */
232 void test_comment_format(void){
233 const char *zPrefix;
234 char *zText;
235 int indent, width;
236 int decode = find_option("decode", 0, 0)!=0;
237 int flags = COMMENT_PRINT_DEFAULT;
238 if( find_option("wordbreak", 0, 0) ){
239 flags |= COMMENT_PRINT_WORD_BREAK;
240 }
241 if( g.argc!=4 && g.argc!=5 ){
242 usage("PREFIX TEXT ?WIDTH?");
243 }
244 zPrefix = g.argv[2];
245 if( decode ){
@@ -207,8 +255,9 @@
255 width = -1; /* automatic */
256 }
257 if( indent>0 ){
258 fossil_print("%s", zPrefix);
259 }
260 fossil_print("(%d lines output)\n",
261 comment_print(zText, indent, width, flags));
262 if( zText!=g.argv[3] ) fossil_free(zText);
263 }
264
--- src/descendants.c
+++ src/descendants.c
@@ -393,11 +393,11 @@
393393
}
394394
n++;
395395
sqlite3_snprintf(sizeof(zLineNo), zLineNo, "(%d)", n);
396396
fossil_print("%6s ", zLineNo);
397397
z = mprintf("%s [%.10s] %s", zDate, zId, zCom);
398
- comment_print(z, 7, width);
398
+ comment_print(z, 7, width, COMMENT_PRINT_DEFAULT);
399399
fossil_free(z);
400400
}
401401
fossil_free(zLastBr);
402402
db_finalize(&q);
403403
}
404404
--- src/descendants.c
+++ src/descendants.c
@@ -393,11 +393,11 @@
393 }
394 n++;
395 sqlite3_snprintf(sizeof(zLineNo), zLineNo, "(%d)", n);
396 fossil_print("%6s ", zLineNo);
397 z = mprintf("%s [%.10s] %s", zDate, zId, zCom);
398 comment_print(z, 7, width);
399 fossil_free(z);
400 }
401 fossil_free(zLastBr);
402 db_finalize(&q);
403 }
404
--- src/descendants.c
+++ src/descendants.c
@@ -393,11 +393,11 @@
393 }
394 n++;
395 sqlite3_snprintf(sizeof(zLineNo), zLineNo, "(%d)", n);
396 fossil_print("%6s ", zLineNo);
397 z = mprintf("%s [%.10s] %s", zDate, zId, zCom);
398 comment_print(z, 7, width, COMMENT_PRINT_DEFAULT);
399 fossil_free(z);
400 }
401 fossil_free(zLastBr);
402 db_finalize(&q);
403 }
404
+2 -2
--- src/finfo.c
+++ src/finfo.c
@@ -201,20 +201,20 @@
201201
if( iBrief ){
202202
fossil_print("%s ", zDate);
203203
zOut = sqlite3_mprintf(
204204
"[%.10s] %s (user: %s, artifact: [%.10s], branch: %s)",
205205
zCiUuid, zCom, zUser, zFileUuid, zBr);
206
- comment_print(zOut, 11, iWidth);
206
+ comment_print(zOut, 11, iWidth, COMMENT_PRINT_DEFAULT);
207207
sqlite3_free(zOut);
208208
}else{
209209
blob_reset(&line);
210210
blob_appendf(&line, "%.10s ", zCiUuid);
211211
blob_appendf(&line, "%.10s ", zDate);
212212
blob_appendf(&line, "%8.8s ", zUser);
213213
blob_appendf(&line, "%8.8s ", zBr);
214214
blob_appendf(&line,"%-39.39s", zCom );
215
- comment_print(blob_str(&line), 0, iWidth);
215
+ comment_print(blob_str(&line), 0, iWidth, COMMENT_PRINT_DEFAULT);
216216
}
217217
}
218218
db_finalize(&q);
219219
blob_reset(&fname);
220220
}
221221
--- src/finfo.c
+++ src/finfo.c
@@ -201,20 +201,20 @@
201 if( iBrief ){
202 fossil_print("%s ", zDate);
203 zOut = sqlite3_mprintf(
204 "[%.10s] %s (user: %s, artifact: [%.10s], branch: %s)",
205 zCiUuid, zCom, zUser, zFileUuid, zBr);
206 comment_print(zOut, 11, iWidth);
207 sqlite3_free(zOut);
208 }else{
209 blob_reset(&line);
210 blob_appendf(&line, "%.10s ", zCiUuid);
211 blob_appendf(&line, "%.10s ", zDate);
212 blob_appendf(&line, "%8.8s ", zUser);
213 blob_appendf(&line, "%8.8s ", zBr);
214 blob_appendf(&line,"%-39.39s", zCom );
215 comment_print(blob_str(&line), 0, iWidth);
216 }
217 }
218 db_finalize(&q);
219 blob_reset(&fname);
220 }
221
--- src/finfo.c
+++ src/finfo.c
@@ -201,20 +201,20 @@
201 if( iBrief ){
202 fossil_print("%s ", zDate);
203 zOut = sqlite3_mprintf(
204 "[%.10s] %s (user: %s, artifact: [%.10s], branch: %s)",
205 zCiUuid, zCom, zUser, zFileUuid, zBr);
206 comment_print(zOut, 11, iWidth, COMMENT_PRINT_DEFAULT);
207 sqlite3_free(zOut);
208 }else{
209 blob_reset(&line);
210 blob_appendf(&line, "%.10s ", zCiUuid);
211 blob_appendf(&line, "%.10s ", zDate);
212 blob_appendf(&line, "%8.8s ", zUser);
213 blob_appendf(&line, "%8.8s ", zBr);
214 blob_appendf(&line,"%-39.39s", zCom );
215 comment_print(blob_str(&line), 0, iWidth, COMMENT_PRINT_DEFAULT);
216 }
217 }
218 db_finalize(&q);
219 blob_reset(&fname);
220 }
221
+1 -1
--- src/info.c
+++ src/info.c
@@ -132,11 +132,11 @@
132132
fossil_print("tags: %s\n", zTags);
133133
}
134134
free(zTags);
135135
if( zComment ){
136136
fossil_print("comment: ");
137
- comment_print(zComment, 14, -1);
137
+ comment_print(zComment, 14, -1, COMMENT_PRINT_DEFAULT);
138138
free(zComment);
139139
}
140140
}
141141
142142
/*
143143
--- src/info.c
+++ src/info.c
@@ -132,11 +132,11 @@
132 fossil_print("tags: %s\n", zTags);
133 }
134 free(zTags);
135 if( zComment ){
136 fossil_print("comment: ");
137 comment_print(zComment, 14, -1);
138 free(zComment);
139 }
140 }
141
142 /*
143
--- src/info.c
+++ src/info.c
@@ -132,11 +132,11 @@
132 fossil_print("tags: %s\n", zTags);
133 }
134 free(zTags);
135 if( zComment ){
136 fossil_print("comment: ");
137 comment_print(zComment, 14, -1, COMMENT_PRINT_DEFAULT);
138 free(zComment);
139 }
140 }
141
142 /*
143
+2 -2
--- src/merge.c
+++ src/merge.c
@@ -47,11 +47,11 @@
4747
indent-1, zLabel,
4848
db_column_text(&q, 3),
4949
db_column_text(&q, 1),
5050
db_column_text(&q, 0),
5151
indent, "");
52
- comment_print(zCom, indent, -1);
52
+ comment_print(zCom, indent, -1, COMMENT_PRINT_DEFAULT);
5353
fossil_free(zCom);
5454
}
5555
db_finalize(&q);
5656
}
5757
@@ -210,11 +210,11 @@
210210
);
211211
if( db_step(&q)==SQLITE_ROW ){
212212
char *zCom = mprintf("Merging fork [%S] at %s by %s: \"%s\"",
213213
db_column_text(&q, 0), db_column_text(&q, 1),
214214
db_column_text(&q, 3), db_column_text(&q, 2));
215
- comment_print(zCom, 0, -1);
215
+ comment_print(zCom, 0, -1, COMMENT_PRINT_DEFAULT);
216216
fossil_free(zCom);
217217
}
218218
db_finalize(&q);
219219
}else{
220220
usage("?OPTIONS? ?VERSION?");
221221
--- src/merge.c
+++ src/merge.c
@@ -47,11 +47,11 @@
47 indent-1, zLabel,
48 db_column_text(&q, 3),
49 db_column_text(&q, 1),
50 db_column_text(&q, 0),
51 indent, "");
52 comment_print(zCom, indent, -1);
53 fossil_free(zCom);
54 }
55 db_finalize(&q);
56 }
57
@@ -210,11 +210,11 @@
210 );
211 if( db_step(&q)==SQLITE_ROW ){
212 char *zCom = mprintf("Merging fork [%S] at %s by %s: \"%s\"",
213 db_column_text(&q, 0), db_column_text(&q, 1),
214 db_column_text(&q, 3), db_column_text(&q, 2));
215 comment_print(zCom, 0, -1);
216 fossil_free(zCom);
217 }
218 db_finalize(&q);
219 }else{
220 usage("?OPTIONS? ?VERSION?");
221
--- src/merge.c
+++ src/merge.c
@@ -47,11 +47,11 @@
47 indent-1, zLabel,
48 db_column_text(&q, 3),
49 db_column_text(&q, 1),
50 db_column_text(&q, 0),
51 indent, "");
52 comment_print(zCom, indent, -1, COMMENT_PRINT_DEFAULT);
53 fossil_free(zCom);
54 }
55 db_finalize(&q);
56 }
57
@@ -210,11 +210,11 @@
210 );
211 if( db_step(&q)==SQLITE_ROW ){
212 char *zCom = mprintf("Merging fork [%S] at %s by %s: \"%s\"",
213 db_column_text(&q, 0), db_column_text(&q, 1),
214 db_column_text(&q, 3), db_column_text(&q, 2));
215 comment_print(zCom, 0, -1, COMMENT_PRINT_DEFAULT);
216 fossil_free(zCom);
217 }
218 db_finalize(&q);
219 }else{
220 usage("?OPTIONS? ?VERSION?");
221
+3 -3
--- src/name.c
+++ src/name.c
@@ -582,11 +582,11 @@
582582
default: zType = "Unknown"; break;
583583
}
584584
fossil_print("type: %s by %s on %s\n", zType, db_column_text(&q,2),
585585
db_column_text(&q, 1));
586586
fossil_print("comment: ");
587
- comment_print(db_column_text(&q,3), 12, -1);
587
+ comment_print(db_column_text(&q,3), 12, -1, COMMENT_PRINT_DEFAULT);
588588
}
589589
db_finalize(&q);
590590
591591
/* Check to see if this object is used as a file in a check-in */
592592
db_prepare(&q,
@@ -604,11 +604,11 @@
604604
fossil_print(" part of [%.10s] by %s on %s\n",
605605
db_column_text(&q, 1),
606606
db_column_text(&q, 3),
607607
db_column_text(&q, 2));
608608
fossil_print(" ");
609
- comment_print(db_column_text(&q,4), 12, -1);
609
+ comment_print(db_column_text(&q,4), 12, -1, COMMENT_PRINT_DEFAULT);
610610
}
611611
db_finalize(&q);
612612
613613
/* Check to see if this object is used as an attachment */
614614
db_prepare(&q,
@@ -639,11 +639,11 @@
639639
db_column_text(&q,7));
640640
}
641641
fossil_print(" by user %s on %s\n",
642642
db_column_text(&q,2), db_column_text(&q,3));
643643
fossil_print(" ");
644
- comment_print(db_column_text(&q,1), 12, -1);
644
+ comment_print(db_column_text(&q,1), 12, -1, COMMENT_PRINT_DEFAULT);
645645
}
646646
db_finalize(&q);
647647
}
648648
649649
/*
650650
--- src/name.c
+++ src/name.c
@@ -582,11 +582,11 @@
582 default: zType = "Unknown"; break;
583 }
584 fossil_print("type: %s by %s on %s\n", zType, db_column_text(&q,2),
585 db_column_text(&q, 1));
586 fossil_print("comment: ");
587 comment_print(db_column_text(&q,3), 12, -1);
588 }
589 db_finalize(&q);
590
591 /* Check to see if this object is used as a file in a check-in */
592 db_prepare(&q,
@@ -604,11 +604,11 @@
604 fossil_print(" part of [%.10s] by %s on %s\n",
605 db_column_text(&q, 1),
606 db_column_text(&q, 3),
607 db_column_text(&q, 2));
608 fossil_print(" ");
609 comment_print(db_column_text(&q,4), 12, -1);
610 }
611 db_finalize(&q);
612
613 /* Check to see if this object is used as an attachment */
614 db_prepare(&q,
@@ -639,11 +639,11 @@
639 db_column_text(&q,7));
640 }
641 fossil_print(" by user %s on %s\n",
642 db_column_text(&q,2), db_column_text(&q,3));
643 fossil_print(" ");
644 comment_print(db_column_text(&q,1), 12, -1);
645 }
646 db_finalize(&q);
647 }
648
649 /*
650
--- src/name.c
+++ src/name.c
@@ -582,11 +582,11 @@
582 default: zType = "Unknown"; break;
583 }
584 fossil_print("type: %s by %s on %s\n", zType, db_column_text(&q,2),
585 db_column_text(&q, 1));
586 fossil_print("comment: ");
587 comment_print(db_column_text(&q,3), 12, -1, COMMENT_PRINT_DEFAULT);
588 }
589 db_finalize(&q);
590
591 /* Check to see if this object is used as a file in a check-in */
592 db_prepare(&q,
@@ -604,11 +604,11 @@
604 fossil_print(" part of [%.10s] by %s on %s\n",
605 db_column_text(&q, 1),
606 db_column_text(&q, 3),
607 db_column_text(&q, 2));
608 fossil_print(" ");
609 comment_print(db_column_text(&q,4), 12, -1, COMMENT_PRINT_DEFAULT);
610 }
611 db_finalize(&q);
612
613 /* Check to see if this object is used as an attachment */
614 db_prepare(&q,
@@ -639,11 +639,11 @@
639 db_column_text(&q,7));
640 }
641 fossil_print(" by user %s on %s\n",
642 db_column_text(&q,2), db_column_text(&q,3));
643 fossil_print(" ");
644 comment_print(db_column_text(&q,1), 12, -1, COMMENT_PRINT_DEFAULT);
645 }
646 db_finalize(&q);
647 }
648
649 /*
650
+1 -1
--- src/stash.c
+++ src/stash.c
@@ -552,11 +552,11 @@
552552
db_column_text(&q, 3)
553553
);
554554
zCom = db_column_text(&q, 2);
555555
if( zCom && zCom[0] ){
556556
fossil_print(" ");
557
- comment_print(zCom, 7, width);
557
+ comment_print(zCom, 7, width, COMMENT_PRINT_DEFAULT);
558558
}
559559
if( verboseFlag ){
560560
db_bind_int(&q2, "$id", stashid);
561561
while( db_step(&q2)==SQLITE_ROW ){
562562
int isAdded = db_column_int(&q2, 0);
563563
--- src/stash.c
+++ src/stash.c
@@ -552,11 +552,11 @@
552 db_column_text(&q, 3)
553 );
554 zCom = db_column_text(&q, 2);
555 if( zCom && zCom[0] ){
556 fossil_print(" ");
557 comment_print(zCom, 7, width);
558 }
559 if( verboseFlag ){
560 db_bind_int(&q2, "$id", stashid);
561 while( db_step(&q2)==SQLITE_ROW ){
562 int isAdded = db_column_int(&q2, 0);
563
--- src/stash.c
+++ src/stash.c
@@ -552,11 +552,11 @@
552 db_column_text(&q, 3)
553 );
554 zCom = db_column_text(&q, 2);
555 if( zCom && zCom[0] ){
556 fossil_print(" ");
557 comment_print(zCom, 7, width, COMMENT_PRINT_DEFAULT);
558 }
559 if( verboseFlag ){
560 db_bind_int(&q2, "$id", stashid);
561 while( db_step(&q2)==SQLITE_ROW ){
562 int isAdded = db_column_int(&q2, 0);
563
+2 -1
--- src/timeline.c
+++ src/timeline.c
@@ -1610,11 +1610,12 @@
16101610
if( fossil_strcmp(zCurrentUuid,zId)==0 ){
16111611
sqlite3_snprintf(sizeof(zPrefix)-n, &zPrefix[n], "*CURRENT* ");
16121612
n += strlen(zPrefix);
16131613
}
16141614
zFree = sqlite3_mprintf("[%.10s] %s%s", zUuid, zPrefix, zCom);
1615
- nLine += comment_print(zFree, 9, width); /* record another X lines */
1615
+ /* record another X lines */
1616
+ nLine += comment_print(zFree, 9, width, COMMENT_PRINT_DEFAULT);
16161617
sqlite3_free(zFree);
16171618
16181619
if(verboseFlag){
16191620
if( !fchngQueryInit ){
16201621
db_prepare(&fchngQuery,
16211622
--- src/timeline.c
+++ src/timeline.c
@@ -1610,11 +1610,12 @@
1610 if( fossil_strcmp(zCurrentUuid,zId)==0 ){
1611 sqlite3_snprintf(sizeof(zPrefix)-n, &zPrefix[n], "*CURRENT* ");
1612 n += strlen(zPrefix);
1613 }
1614 zFree = sqlite3_mprintf("[%.10s] %s%s", zUuid, zPrefix, zCom);
1615 nLine += comment_print(zFree, 9, width); /* record another X lines */
 
1616 sqlite3_free(zFree);
1617
1618 if(verboseFlag){
1619 if( !fchngQueryInit ){
1620 db_prepare(&fchngQuery,
1621
--- src/timeline.c
+++ src/timeline.c
@@ -1610,11 +1610,12 @@
1610 if( fossil_strcmp(zCurrentUuid,zId)==0 ){
1611 sqlite3_snprintf(sizeof(zPrefix)-n, &zPrefix[n], "*CURRENT* ");
1612 n += strlen(zPrefix);
1613 }
1614 zFree = sqlite3_mprintf("[%.10s] %s%s", zUuid, zPrefix, zCom);
1615 /* record another X lines */
1616 nLine += comment_print(zFree, 9, width, COMMENT_PRINT_DEFAULT);
1617 sqlite3_free(zFree);
1618
1619 if(verboseFlag){
1620 if( !fchngQueryInit ){
1621 db_prepare(&fchngQuery,
1622
+1 -1
--- src/tkt.c
+++ src/tkt.c
@@ -1264,11 +1264,11 @@
12641264
fossil_print(" Change ");
12651265
}
12661266
fossil_print("%h: ",z);
12671267
if( blob_size(&val)>50 || contains_newline(&val)) {
12681268
fossil_print("\n ",blob_str(&val));
1269
- comment_print(blob_str(&val),4,-1);
1269
+ comment_print(blob_str(&val),4,-1,COMMENT_PRINT_DEFAULT);
12701270
}else{
12711271
fossil_print("%s\n",blob_str(&val));
12721272
}
12731273
blob_reset(&val);
12741274
}
12751275
--- src/tkt.c
+++ src/tkt.c
@@ -1264,11 +1264,11 @@
1264 fossil_print(" Change ");
1265 }
1266 fossil_print("%h: ",z);
1267 if( blob_size(&val)>50 || contains_newline(&val)) {
1268 fossil_print("\n ",blob_str(&val));
1269 comment_print(blob_str(&val),4,-1);
1270 }else{
1271 fossil_print("%s\n",blob_str(&val));
1272 }
1273 blob_reset(&val);
1274 }
1275
--- src/tkt.c
+++ src/tkt.c
@@ -1264,11 +1264,11 @@
1264 fossil_print(" Change ");
1265 }
1266 fossil_print("%h: ",z);
1267 if( blob_size(&val)>50 || contains_newline(&val)) {
1268 fossil_print("\n ",blob_str(&val));
1269 comment_print(blob_str(&val),4,-1,COMMENT_PRINT_DEFAULT);
1270 }else{
1271 fossil_print("%s\n",blob_str(&val));
1272 }
1273 blob_reset(&val);
1274 }
1275
--- test/comment.test
+++ test/comment.test
@@ -78,5 +78,15 @@
7878
7979
###############################################################################
8080
8181
fossil test-comment-format "*TEST* " "this\tis a test." 26
8282
test comment-13 {$RESULT eq "*TEST* this\tis a te\n st.\n(2 lines output)"}
83
+
84
+###############################################################################
85
+
86
+fossil test-comment-format "*TEST* " "this is a test......................................................................................................................." 60
87
+test comment-14 {$RESULT eq "*TEST* this is a test.......................................\n .....................................................\n ...........................\n(3 lines output)"}
88
+
89
+###############################################################################
90
+
91
+fossil test-comment-format --wordbreak "*TEST* " "this is a test......................................................................................................................." 60
92
+test comment-15 {$RESULT eq "*TEST* this is a\n test.................................................\n .....................................................\n .................\n(4 lines output)"}
8393
--- test/comment.test
+++ test/comment.test
@@ -78,5 +78,15 @@
78
79 ###############################################################################
80
81 fossil test-comment-format "*TEST* " "this\tis a test." 26
82 test comment-13 {$RESULT eq "*TEST* this\tis a te\n st.\n(2 lines output)"}
 
 
 
 
 
 
 
 
 
 
83
--- test/comment.test
+++ test/comment.test
@@ -78,5 +78,15 @@
78
79 ###############################################################################
80
81 fossil test-comment-format "*TEST* " "this\tis a test." 26
82 test comment-13 {$RESULT eq "*TEST* this\tis a te\n st.\n(2 lines output)"}
83
84 ###############################################################################
85
86 fossil test-comment-format "*TEST* " "this is a test......................................................................................................................." 60
87 test comment-14 {$RESULT eq "*TEST* this is a test.......................................\n .....................................................\n ...........................\n(3 lines output)"}
88
89 ###############################################################################
90
91 fossil test-comment-format --wordbreak "*TEST* " "this is a test......................................................................................................................." 60
92 test comment-15 {$RESULT eq "*TEST* this is a\n test.................................................\n .....................................................\n .................\n(4 lines output)"}
93

Keyboard Shortcuts

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