Fossil SCM

Back out [a402dd2a888d6d74] (wiki title search), as it causes all searches to fail for reasons as yet undetermined.

stephan 2024-01-07 17:26 trunk
Commit 48af08bd48a83f92f00fd65c60e034eb78c67b12ab2fe17cac489da45da1373f
1 file changed +26 -28
+26 -28
--- src/search.c
+++ src/search.c
@@ -1229,52 +1229,50 @@
12291229
12301230
/*
12311231
** This is a helper function for search_stext(). Writing into pOut
12321232
** the search text obtained from pIn according to zMimetype.
12331233
**
1234
-** If a title is not specified in zTitle (e.g. for wiki pages that do not
1235
-** include the title in the body), it is determined from the page content.
1236
-**
12371234
** The title of the document is the first line of text. All subsequent
12381235
** lines are the body. If the document has no title, the first line
12391236
** is blank.
12401237
*/
12411238
static void get_stext_by_mimetype(
12421239
Blob *pIn,
12431240
const char *zMimetype,
1244
- const char *zTitle,
12451241
Blob *pOut
12461242
){
12471243
Blob html, title;
1248
- Blob *pHtml = &html;
12491244
blob_init(&html, 0, 0);
1250
- if( zTitle==0 ){
1251
- blob_init(&title, 0, 0);
1252
- }else{
1253
- blob_init(&title, zTitle, -1);
1254
- }
1245
+ blob_init(&title, 0, 0);
12551246
if( zMimetype==0 ) zMimetype = "text/plain";
12561247
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);
1248
+ Blob tail;
1249
+ blob_init(&tail, 0, 0);
1250
+ if( wiki_find_title(pIn, &title, &tail) ){
1251
+ blob_appendf(pOut, "%s\n", blob_str(&title));
12631252
wiki_convert(&tail, &html, 0);
12641253
blob_reset(&tail);
1254
+ }else{
1255
+ blob_append(pOut, "\n", 1);
1256
+ wiki_convert(pIn, &html, 0);
12651257
}
1258
+ html_to_plaintext(blob_str(&html), pOut);
12661259
}else if( fossil_strcmp(zMimetype,"text/x-markdown")==0 ){
1267
- markdown_to_html(pIn, blob_size(&title) ? NULL : &title, &html);
1260
+ markdown_to_html(pIn, &title, &html);
1261
+ if( blob_size(&title) ){
1262
+ blob_appendf(pOut, "%s\n", blob_str(&title));
1263
+ }else{
1264
+ blob_append(pOut, "\n", 1);
1265
+ }
1266
+ html_to_plaintext(blob_str(&html), pOut);
12681267
}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);
1268
+ if( doc_is_embedded_html(pIn, &title) ){
1269
+ blob_appendf(pOut, "%s\n", blob_str(&title));
1270
+ }
1271
+ html_to_plaintext(blob_str(pIn), pOut);
12751272
}else{
1273
+ blob_append(pOut, "\n", 1);
12761274
blob_append(pOut, blob_buffer(pIn), blob_size(pIn));
12771275
}
12781276
blob_reset(&html);
12791277
blob_reset(&title);
12801278
}
@@ -1307,11 +1305,11 @@
13071305
blob_appendf(pAccum, "%s: %s |\n", zColName, db_column_text(pQuery,i));
13081306
}else{
13091307
Blob txt;
13101308
blob_init(&txt, db_column_text(pQuery,i), -1);
13111309
blob_appendf(pAccum, "%s: ", zColName);
1312
- get_stext_by_mimetype(&txt, zMime, NULL, pAccum);
1310
+ get_stext_by_mimetype(&txt, zMime, pAccum);
13131311
blob_append(pAccum, " |", 2);
13141312
blob_reset(&txt);
13151313
}
13161314
}
13171315
}
@@ -1346,11 +1344,11 @@
13461344
switch( cType ){
13471345
case 'd': { /* Documents */
13481346
Blob doc;
13491347
content_get(rid, &doc);
13501348
blob_to_utf8_no_bom(&doc, 0);
1351
- get_stext_by_mimetype(&doc, mimetype_from_name(zName), NULL, pOut);
1349
+ get_stext_by_mimetype(&doc, mimetype_from_name(zName), pOut);
13521350
blob_reset(&doc);
13531351
break;
13541352
}
13551353
case 'f': /* Forum messages */
13561354
case 'e': /* Tech Notes */
@@ -1368,11 +1366,11 @@
13681366
blob_appendf(&wiki, "From %s:\n\n%s", pWiki->zUser, pWiki->zWiki);
13691367
}else{
13701368
blob_init(&wiki, pWiki->zWiki, -1);
13711369
}
13721370
get_stext_by_mimetype(&wiki, wiki_filter_mimetypes(pWiki->zMimetype),
1373
- cType=='w' ? pWiki->zWikiTitle : NULL, pOut);
1371
+ pOut);
13741372
blob_reset(&wiki);
13751373
manifest_destroy(pWiki);
13761374
break;
13771375
}
13781376
case 'c': { /* Check-in Comments */
@@ -1398,11 +1396,11 @@
13981396
db_column_blob(&q, 0, pOut);
13991397
}else{
14001398
Blob x;
14011399
blob_init(&x,0,0);
14021400
db_column_blob(&q, 0, &x);
1403
- get_stext_by_mimetype(&x, "text/x-fossil-wiki", NULL, pOut);
1401
+ get_stext_by_mimetype(&x, "text/x-fossil-wiki", pOut);
14041402
blob_reset(&x);
14051403
}
14061404
}
14071405
db_reset(&q);
14081406
break;
@@ -1509,11 +1507,11 @@
15091507
Blob in, out;
15101508
db_find_and_open_repository(0,0);
15111509
if( g.argc!=4 ) usage("FILENAME MIMETYPE");
15121510
blob_read_from_file(&in, g.argv[2], ExtFILE);
15131511
blob_init(&out, 0, 0);
1514
- get_stext_by_mimetype(&in, g.argv[3], NULL, &out);
1512
+ get_stext_by_mimetype(&in, g.argv[3], &out);
15151513
fossil_print("%s\n",blob_str(&out));
15161514
blob_reset(&in);
15171515
blob_reset(&out);
15181516
}
15191517
15201518
--- src/search.c
+++ src/search.c
@@ -1229,52 +1229,50 @@
1229
1230 /*
1231 ** This is a helper function for search_stext(). Writing into pOut
1232 ** the search text obtained from pIn according to zMimetype.
1233 **
1234 ** If a title is not specified in zTitle (e.g. for wiki pages that do not
1235 ** include the title in the body), it is determined from the page content.
1236 **
1237 ** The title of the document is the first line of text. All subsequent
1238 ** lines are the body. If the document has no title, the first line
1239 ** is blank.
1240 */
1241 static void get_stext_by_mimetype(
1242 Blob *pIn,
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 }
@@ -1307,11 +1305,11 @@
1307 blob_appendf(pAccum, "%s: %s |\n", zColName, db_column_text(pQuery,i));
1308 }else{
1309 Blob txt;
1310 blob_init(&txt, db_column_text(pQuery,i), -1);
1311 blob_appendf(pAccum, "%s: ", zColName);
1312 get_stext_by_mimetype(&txt, zMime, NULL, pAccum);
1313 blob_append(pAccum, " |", 2);
1314 blob_reset(&txt);
1315 }
1316 }
1317 }
@@ -1346,11 +1344,11 @@
1346 switch( cType ){
1347 case 'd': { /* Documents */
1348 Blob doc;
1349 content_get(rid, &doc);
1350 blob_to_utf8_no_bom(&doc, 0);
1351 get_stext_by_mimetype(&doc, mimetype_from_name(zName), NULL, pOut);
1352 blob_reset(&doc);
1353 break;
1354 }
1355 case 'f': /* Forum messages */
1356 case 'e': /* Tech Notes */
@@ -1368,11 +1366,11 @@
1368 blob_appendf(&wiki, "From %s:\n\n%s", pWiki->zUser, pWiki->zWiki);
1369 }else{
1370 blob_init(&wiki, pWiki->zWiki, -1);
1371 }
1372 get_stext_by_mimetype(&wiki, wiki_filter_mimetypes(pWiki->zMimetype),
1373 cType=='w' ? pWiki->zWikiTitle : NULL, pOut);
1374 blob_reset(&wiki);
1375 manifest_destroy(pWiki);
1376 break;
1377 }
1378 case 'c': { /* Check-in Comments */
@@ -1398,11 +1396,11 @@
1398 db_column_blob(&q, 0, pOut);
1399 }else{
1400 Blob x;
1401 blob_init(&x,0,0);
1402 db_column_blob(&q, 0, &x);
1403 get_stext_by_mimetype(&x, "text/x-fossil-wiki", NULL, pOut);
1404 blob_reset(&x);
1405 }
1406 }
1407 db_reset(&q);
1408 break;
@@ -1509,11 +1507,11 @@
1509 Blob in, out;
1510 db_find_and_open_repository(0,0);
1511 if( g.argc!=4 ) usage("FILENAME MIMETYPE");
1512 blob_read_from_file(&in, g.argv[2], ExtFILE);
1513 blob_init(&out, 0, 0);
1514 get_stext_by_mimetype(&in, g.argv[3], NULL, &out);
1515 fossil_print("%s\n",blob_str(&out));
1516 blob_reset(&in);
1517 blob_reset(&out);
1518 }
1519
1520
--- src/search.c
+++ src/search.c
@@ -1229,52 +1229,50 @@
1229
1230 /*
1231 ** This is a helper function for search_stext(). Writing into pOut
1232 ** the search text obtained from pIn according to zMimetype.
1233 **
 
 
 
1234 ** The title of the document is the first line of text. All subsequent
1235 ** lines are the body. If the document has no title, the first line
1236 ** is blank.
1237 */
1238 static void get_stext_by_mimetype(
1239 Blob *pIn,
1240 const char *zMimetype,
 
1241 Blob *pOut
1242 ){
1243 Blob html, title;
 
1244 blob_init(&html, 0, 0);
1245 blob_init(&title, 0, 0);
 
 
 
 
1246 if( zMimetype==0 ) zMimetype = "text/plain";
1247 if( fossil_strcmp(zMimetype,"text/x-fossil-wiki")==0 ){
1248 Blob tail;
1249 blob_init(&tail, 0, 0);
1250 if( wiki_find_title(pIn, &title, &tail) ){
1251 blob_appendf(pOut, "%s\n", blob_str(&title));
 
 
1252 wiki_convert(&tail, &html, 0);
1253 blob_reset(&tail);
1254 }else{
1255 blob_append(pOut, "\n", 1);
1256 wiki_convert(pIn, &html, 0);
1257 }
1258 html_to_plaintext(blob_str(&html), pOut);
1259 }else if( fossil_strcmp(zMimetype,"text/x-markdown")==0 ){
1260 markdown_to_html(pIn, &title, &html);
1261 if( blob_size(&title) ){
1262 blob_appendf(pOut, "%s\n", blob_str(&title));
1263 }else{
1264 blob_append(pOut, "\n", 1);
1265 }
1266 html_to_plaintext(blob_str(&html), pOut);
1267 }else if( fossil_strcmp(zMimetype,"text/html")==0 ){
1268 if( doc_is_embedded_html(pIn, &title) ){
1269 blob_appendf(pOut, "%s\n", blob_str(&title));
1270 }
1271 html_to_plaintext(blob_str(pIn), pOut);
 
 
1272 }else{
1273 blob_append(pOut, "\n", 1);
1274 blob_append(pOut, blob_buffer(pIn), blob_size(pIn));
1275 }
1276 blob_reset(&html);
1277 blob_reset(&title);
1278 }
@@ -1307,11 +1305,11 @@
1305 blob_appendf(pAccum, "%s: %s |\n", zColName, db_column_text(pQuery,i));
1306 }else{
1307 Blob txt;
1308 blob_init(&txt, db_column_text(pQuery,i), -1);
1309 blob_appendf(pAccum, "%s: ", zColName);
1310 get_stext_by_mimetype(&txt, zMime, pAccum);
1311 blob_append(pAccum, " |", 2);
1312 blob_reset(&txt);
1313 }
1314 }
1315 }
@@ -1346,11 +1344,11 @@
1344 switch( cType ){
1345 case 'd': { /* Documents */
1346 Blob doc;
1347 content_get(rid, &doc);
1348 blob_to_utf8_no_bom(&doc, 0);
1349 get_stext_by_mimetype(&doc, mimetype_from_name(zName), pOut);
1350 blob_reset(&doc);
1351 break;
1352 }
1353 case 'f': /* Forum messages */
1354 case 'e': /* Tech Notes */
@@ -1368,11 +1366,11 @@
1366 blob_appendf(&wiki, "From %s:\n\n%s", pWiki->zUser, pWiki->zWiki);
1367 }else{
1368 blob_init(&wiki, pWiki->zWiki, -1);
1369 }
1370 get_stext_by_mimetype(&wiki, wiki_filter_mimetypes(pWiki->zMimetype),
1371 pOut);
1372 blob_reset(&wiki);
1373 manifest_destroy(pWiki);
1374 break;
1375 }
1376 case 'c': { /* Check-in Comments */
@@ -1398,11 +1396,11 @@
1396 db_column_blob(&q, 0, pOut);
1397 }else{
1398 Blob x;
1399 blob_init(&x,0,0);
1400 db_column_blob(&q, 0, &x);
1401 get_stext_by_mimetype(&x, "text/x-fossil-wiki", pOut);
1402 blob_reset(&x);
1403 }
1404 }
1405 db_reset(&q);
1406 break;
@@ -1509,11 +1507,11 @@
1507 Blob in, out;
1508 db_find_and_open_repository(0,0);
1509 if( g.argc!=4 ) usage("FILENAME MIMETYPE");
1510 blob_read_from_file(&in, g.argv[2], ExtFILE);
1511 blob_init(&out, 0, 0);
1512 get_stext_by_mimetype(&in, g.argv[3], &out);
1513 fossil_print("%s\n",blob_str(&out));
1514 blob_reset(&in);
1515 blob_reset(&out);
1516 }
1517
1518

Keyboard Shortcuts

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