Fossil SCM
Generate output at the end of get_stext_by_mimetype() instead of within conditional branches.
Commit
3105a0c5c3a5201e7116fc23ce52aa0371e22aa62f7b3a25e744c3354c490870
Parent
e6b8cc9f71f8991…
1 file changed
+10
-17
+10
-17
| --- src/search.c | ||
| +++ src/search.c | ||
| @@ -1243,45 +1243,38 @@ | ||
| 1243 | 1243 | const char *zMimetype, |
| 1244 | 1244 | const char *zTitle, |
| 1245 | 1245 | Blob *pOut |
| 1246 | 1246 | ){ |
| 1247 | 1247 | Blob html, title; |
| 1248 | + Blob *pHtml = &html; | |
| 1248 | 1249 | blob_init(&html, 0, 0); |
| 1249 | 1250 | if( zTitle==0 ){ |
| 1250 | 1251 | blob_init(&title, 0, 0); |
| 1251 | 1252 | }else{ |
| 1252 | 1253 | blob_init(&title, zTitle, -1); |
| 1253 | 1254 | } |
| 1254 | 1255 | if( zMimetype==0 ) zMimetype = "text/plain"; |
| 1255 | 1256 | if( fossil_strcmp(zMimetype,"text/x-fossil-wiki")==0 ){ |
| 1256 | - Blob tail; | |
| 1257 | - blob_init(&tail, 0, 0); | |
| 1258 | 1257 | if( blob_size(&title) ){ |
| 1259 | 1258 | wiki_convert(pIn, &html, 0); |
| 1260 | - }else if( wiki_find_title(pIn, &title, &tail) ){ | |
| 1261 | - blob_appendf(pOut, "%s\n", blob_str(&title)); | |
| 1259 | + }else{ | |
| 1260 | + Blob tail; | |
| 1261 | + blob_init(&tail, 0, 0); | |
| 1262 | + wiki_find_title(pIn, &title, &tail); | |
| 1262 | 1263 | wiki_convert(&tail, &html, 0); |
| 1263 | 1264 | blob_reset(&tail); |
| 1264 | - }else{ | |
| 1265 | - blob_append(pOut, "\n", 1); | |
| 1266 | - wiki_convert(pIn, &html, 0); | |
| 1267 | 1265 | } |
| 1268 | - html_to_plaintext(blob_str(&html), pOut); | |
| 1269 | 1266 | }else if( fossil_strcmp(zMimetype,"text/x-markdown")==0 ){ |
| 1270 | 1267 | markdown_to_html(pIn, blob_size(&title) ? NULL : &title, &html); |
| 1271 | - if( blob_size(&title) ){ | |
| 1272 | - blob_appendf(pOut, "%s\n", blob_str(&title)); | |
| 1273 | - }else{ | |
| 1274 | - blob_append(pOut, "\n", 1); | |
| 1275 | - } | |
| 1276 | - html_to_plaintext(blob_str(&html), pOut); | |
| 1277 | 1268 | }else if( fossil_strcmp(zMimetype,"text/html")==0 ){ |
| 1278 | 1269 | if( blob_size(&title)==0 ) doc_is_embedded_html(pIn, &title); |
| 1279 | - blob_appendf(pOut, "%s\n", blob_str(&title)); | |
| 1280 | - html_to_plaintext(blob_str(pIn), pOut); | |
| 1270 | + pHtml = pIn; | |
| 1271 | + } | |
| 1272 | + blob_appendf(pOut, "%s\n", blob_str(&title)); | |
| 1273 | + if( blob_size(pHtml) ){ | |
| 1274 | + html_to_plaintext(blob_str(pHtml), pOut); | |
| 1281 | 1275 | }else{ |
| 1282 | - blob_append(pOut, "\n", 1); | |
| 1283 | 1276 | blob_append(pOut, blob_buffer(pIn), blob_size(pIn)); |
| 1284 | 1277 | } |
| 1285 | 1278 | blob_reset(&html); |
| 1286 | 1279 | blob_reset(&title); |
| 1287 | 1280 | } |
| 1288 | 1281 |
| --- src/search.c | |
| +++ src/search.c | |
| @@ -1243,45 +1243,38 @@ | |
| 1243 | const char *zMimetype, |
| 1244 | const char *zTitle, |
| 1245 | Blob *pOut |
| 1246 | ){ |
| 1247 | Blob html, title; |
| 1248 | blob_init(&html, 0, 0); |
| 1249 | if( zTitle==0 ){ |
| 1250 | blob_init(&title, 0, 0); |
| 1251 | }else{ |
| 1252 | blob_init(&title, zTitle, -1); |
| 1253 | } |
| 1254 | if( zMimetype==0 ) zMimetype = "text/plain"; |
| 1255 | if( fossil_strcmp(zMimetype,"text/x-fossil-wiki")==0 ){ |
| 1256 | Blob tail; |
| 1257 | blob_init(&tail, 0, 0); |
| 1258 | if( blob_size(&title) ){ |
| 1259 | wiki_convert(pIn, &html, 0); |
| 1260 | }else if( wiki_find_title(pIn, &title, &tail) ){ |
| 1261 | blob_appendf(pOut, "%s\n", blob_str(&title)); |
| 1262 | wiki_convert(&tail, &html, 0); |
| 1263 | blob_reset(&tail); |
| 1264 | }else{ |
| 1265 | blob_append(pOut, "\n", 1); |
| 1266 | wiki_convert(pIn, &html, 0); |
| 1267 | } |
| 1268 | html_to_plaintext(blob_str(&html), pOut); |
| 1269 | }else if( fossil_strcmp(zMimetype,"text/x-markdown")==0 ){ |
| 1270 | markdown_to_html(pIn, blob_size(&title) ? NULL : &title, &html); |
| 1271 | if( blob_size(&title) ){ |
| 1272 | blob_appendf(pOut, "%s\n", blob_str(&title)); |
| 1273 | }else{ |
| 1274 | blob_append(pOut, "\n", 1); |
| 1275 | } |
| 1276 | html_to_plaintext(blob_str(&html), pOut); |
| 1277 | }else if( fossil_strcmp(zMimetype,"text/html")==0 ){ |
| 1278 | if( blob_size(&title)==0 ) doc_is_embedded_html(pIn, &title); |
| 1279 | blob_appendf(pOut, "%s\n", blob_str(&title)); |
| 1280 | html_to_plaintext(blob_str(pIn), pOut); |
| 1281 | }else{ |
| 1282 | blob_append(pOut, "\n", 1); |
| 1283 | blob_append(pOut, blob_buffer(pIn), blob_size(pIn)); |
| 1284 | } |
| 1285 | blob_reset(&html); |
| 1286 | blob_reset(&title); |
| 1287 | } |
| 1288 |
| --- src/search.c | |
| +++ src/search.c | |
| @@ -1243,45 +1243,38 @@ | |
| 1243 | const char *zMimetype, |
| 1244 | const char *zTitle, |
| 1245 | Blob *pOut |
| 1246 | ){ |
| 1247 | Blob html, title; |
| 1248 | Blob *pHtml = &html; |
| 1249 | blob_init(&html, 0, 0); |
| 1250 | if( zTitle==0 ){ |
| 1251 | blob_init(&title, 0, 0); |
| 1252 | }else{ |
| 1253 | blob_init(&title, zTitle, -1); |
| 1254 | } |
| 1255 | if( zMimetype==0 ) zMimetype = "text/plain"; |
| 1256 | if( fossil_strcmp(zMimetype,"text/x-fossil-wiki")==0 ){ |
| 1257 | if( blob_size(&title) ){ |
| 1258 | wiki_convert(pIn, &html, 0); |
| 1259 | }else{ |
| 1260 | Blob tail; |
| 1261 | blob_init(&tail, 0, 0); |
| 1262 | wiki_find_title(pIn, &title, &tail); |
| 1263 | wiki_convert(&tail, &html, 0); |
| 1264 | blob_reset(&tail); |
| 1265 | } |
| 1266 | }else if( fossil_strcmp(zMimetype,"text/x-markdown")==0 ){ |
| 1267 | markdown_to_html(pIn, blob_size(&title) ? NULL : &title, &html); |
| 1268 | }else if( fossil_strcmp(zMimetype,"text/html")==0 ){ |
| 1269 | if( blob_size(&title)==0 ) doc_is_embedded_html(pIn, &title); |
| 1270 | pHtml = pIn; |
| 1271 | } |
| 1272 | blob_appendf(pOut, "%s\n", blob_str(&title)); |
| 1273 | if( blob_size(pHtml) ){ |
| 1274 | html_to_plaintext(blob_str(pHtml), pOut); |
| 1275 | }else{ |
| 1276 | blob_append(pOut, blob_buffer(pIn), blob_size(pIn)); |
| 1277 | } |
| 1278 | blob_reset(&html); |
| 1279 | blob_reset(&title); |
| 1280 | } |
| 1281 |