Fossil SCM

Add 'decode' option to the 'test-comment-format' test command.

mistachkin 2014-06-19 01:19 trunk
Commit 8da0f344629240023e30f5619d2aea6b5ce3481c
1 file changed +17 -3
+17 -3
--- src/comformat.c
+++ src/comformat.c
@@ -129,23 +129,36 @@
129129
lineCnt++;
130130
}
131131
}
132132
133133
/*
134
-** Test the comment printing
135134
**
136135
** COMMAND: test-comment-format
136
+**
137
+** Usage: %fossil test-comment-format ?OPTIONS? PREFIX TEXT ?WIDTH?
138
+**
139
+** Test comment formatting and printing. Use for testing only.
140
+**
141
+** Options:
142
+** --decode Decode the text using the same method used when
143
+** handling the value of a C-card from a manifest.
137144
*/
138145
void test_comment_format(void){
139146
const char *zPrefix;
140
- const char *zText;
147
+ char *zText;
141148
int indent, width;
149
+ int decode = find_option("decode", 0, 0)!=0;
142150
if( g.argc!=4 && g.argc!=5 ){
143151
usage("PREFIX TEXT ?WIDTH?");
144152
}
145153
zPrefix = g.argv[2];
146
- zText = g.argv[3];
154
+ if( decode ){
155
+ zText = mprintf("%s", g.argv[3]);
156
+ defossilize(zText);
157
+ }else{
158
+ zText = g.argv[3];
159
+ }
147160
indent = strlen(zPrefix);
148161
if( g.argc==5 ){
149162
width = atoi(g.argv[4]);
150163
}else{
151164
width = -1; /* automatic */
@@ -152,6 +165,7 @@
152165
}
153166
if( indent>0 ){
154167
fossil_print("%s", zPrefix);
155168
}
156169
fossil_print("(%d lines output)\n", comment_print(zText, indent, width));
170
+ if( zText!=g.argv[3] ) fossil_free(zText);
157171
}
158172
--- src/comformat.c
+++ src/comformat.c
@@ -129,23 +129,36 @@
129 lineCnt++;
130 }
131 }
132
133 /*
134 ** Test the comment printing
135 **
136 ** COMMAND: test-comment-format
 
 
 
 
 
 
 
 
137 */
138 void test_comment_format(void){
139 const char *zPrefix;
140 const char *zText;
141 int indent, width;
 
142 if( g.argc!=4 && g.argc!=5 ){
143 usage("PREFIX TEXT ?WIDTH?");
144 }
145 zPrefix = g.argv[2];
146 zText = g.argv[3];
 
 
 
 
 
147 indent = strlen(zPrefix);
148 if( g.argc==5 ){
149 width = atoi(g.argv[4]);
150 }else{
151 width = -1; /* automatic */
@@ -152,6 +165,7 @@
152 }
153 if( indent>0 ){
154 fossil_print("%s", zPrefix);
155 }
156 fossil_print("(%d lines output)\n", comment_print(zText, indent, width));
 
157 }
158
--- src/comformat.c
+++ src/comformat.c
@@ -129,23 +129,36 @@
129 lineCnt++;
130 }
131 }
132
133 /*
 
134 **
135 ** COMMAND: test-comment-format
136 **
137 ** Usage: %fossil test-comment-format ?OPTIONS? PREFIX TEXT ?WIDTH?
138 **
139 ** Test comment formatting and printing. Use for testing only.
140 **
141 ** Options:
142 ** --decode Decode the text using the same method used when
143 ** handling the value of a C-card from a manifest.
144 */
145 void test_comment_format(void){
146 const char *zPrefix;
147 char *zText;
148 int indent, width;
149 int decode = find_option("decode", 0, 0)!=0;
150 if( g.argc!=4 && g.argc!=5 ){
151 usage("PREFIX TEXT ?WIDTH?");
152 }
153 zPrefix = g.argv[2];
154 if( decode ){
155 zText = mprintf("%s", g.argv[3]);
156 defossilize(zText);
157 }else{
158 zText = g.argv[3];
159 }
160 indent = strlen(zPrefix);
161 if( g.argc==5 ){
162 width = atoi(g.argv[4]);
163 }else{
164 width = -1; /* automatic */
@@ -152,6 +165,7 @@
165 }
166 if( indent>0 ){
167 fossil_print("%s", zPrefix);
168 }
169 fossil_print("(%d lines output)\n", comment_print(zText, indent, width));
170 if( zText!=g.argv[3] ) fossil_free(zText);
171 }
172

Keyboard Shortcuts

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