Fossil SCM
Add 'decode' option to the 'test-comment-format' test command.
Commit
8da0f344629240023e30f5619d2aea6b5ce3481c
Parent
6a3b39a06be586f…
1 file changed
+17
-3
+17
-3
| --- src/comformat.c | ||
| +++ src/comformat.c | ||
| @@ -129,23 +129,36 @@ | ||
| 129 | 129 | lineCnt++; |
| 130 | 130 | } |
| 131 | 131 | } |
| 132 | 132 | |
| 133 | 133 | /* |
| 134 | -** Test the comment printing | |
| 135 | 134 | ** |
| 136 | 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. | |
| 137 | 144 | */ |
| 138 | 145 | void test_comment_format(void){ |
| 139 | 146 | const char *zPrefix; |
| 140 | - const char *zText; | |
| 147 | + char *zText; | |
| 141 | 148 | int indent, width; |
| 149 | + int decode = find_option("decode", 0, 0)!=0; | |
| 142 | 150 | if( g.argc!=4 && g.argc!=5 ){ |
| 143 | 151 | usage("PREFIX TEXT ?WIDTH?"); |
| 144 | 152 | } |
| 145 | 153 | 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 | + } | |
| 147 | 160 | indent = strlen(zPrefix); |
| 148 | 161 | if( g.argc==5 ){ |
| 149 | 162 | width = atoi(g.argv[4]); |
| 150 | 163 | }else{ |
| 151 | 164 | width = -1; /* automatic */ |
| @@ -152,6 +165,7 @@ | ||
| 152 | 165 | } |
| 153 | 166 | if( indent>0 ){ |
| 154 | 167 | fossil_print("%s", zPrefix); |
| 155 | 168 | } |
| 156 | 169 | fossil_print("(%d lines output)\n", comment_print(zText, indent, width)); |
| 170 | + if( zText!=g.argv[3] ) fossil_free(zText); | |
| 157 | 171 | } |
| 158 | 172 |
| --- 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 |