Fossil SCM

Create and use the blob_append_string() macro for appending string literals. Improvements to blob_append_char().

drh 2019-09-24 20:27 trunk
Commit 48c47e1eb7d3012715653a55aad2bc65ed678ed78301487e4cfa29a5a601fb25
+10 -5
--- src/blob.c
+++ src/blob.c
@@ -322,21 +322,26 @@
322322
pBlob->nUsed += nData;
323323
pBlob->aData[pBlob->nUsed] = 0;
324324
memcpy(&pBlob->aData[nUsed], aData, nData);
325325
}
326326
327
+/*
328
+** Append a string literal to a blob.
329
+*/
330
+#if INTERFACE
331
+#define blob_append_string(BLOB,STR) blob_append(BLOB,STR,sizeof(STR)-1)
332
+#endif
333
+
327334
/*
328335
** Append a single character to the blob
329336
*/
330337
void blob_append_char(Blob *pBlob, char c){
331338
if( pBlob->nUsed+1 >= pBlob->nAlloc ){
332
- pBlob->xRealloc(pBlob, pBlob->nUsed + pBlob->nAlloc + 100);
333
- if( pBlob->nUsed + 1 >= pBlob->nAlloc ){
334
- blob_panic();
335
- }
339
+ blob_append_full(pBlob, &c, 1);
340
+ }else{
341
+ pBlob->aData[pBlob->nUsed++] = c;
336342
}
337
- pBlob->aData[pBlob->nUsed++] = c;
338343
}
339344
340345
/*
341346
** Copy a blob
342347
*/
343348
--- src/blob.c
+++ src/blob.c
@@ -322,21 +322,26 @@
322 pBlob->nUsed += nData;
323 pBlob->aData[pBlob->nUsed] = 0;
324 memcpy(&pBlob->aData[nUsed], aData, nData);
325 }
326
 
 
 
 
 
 
 
327 /*
328 ** Append a single character to the blob
329 */
330 void blob_append_char(Blob *pBlob, char c){
331 if( pBlob->nUsed+1 >= pBlob->nAlloc ){
332 pBlob->xRealloc(pBlob, pBlob->nUsed + pBlob->nAlloc + 100);
333 if( pBlob->nUsed + 1 >= pBlob->nAlloc ){
334 blob_panic();
335 }
336 }
337 pBlob->aData[pBlob->nUsed++] = c;
338 }
339
340 /*
341 ** Copy a blob
342 */
343
--- src/blob.c
+++ src/blob.c
@@ -322,21 +322,26 @@
322 pBlob->nUsed += nData;
323 pBlob->aData[pBlob->nUsed] = 0;
324 memcpy(&pBlob->aData[nUsed], aData, nData);
325 }
326
327 /*
328 ** Append a string literal to a blob.
329 */
330 #if INTERFACE
331 #define blob_append_string(BLOB,STR) blob_append(BLOB,STR,sizeof(STR)-1)
332 #endif
333
334 /*
335 ** Append a single character to the blob
336 */
337 void blob_append_char(Blob *pBlob, char c){
338 if( pBlob->nUsed+1 >= pBlob->nAlloc ){
339 blob_append_full(pBlob, &c, 1);
340 }else{
341 pBlob->aData[pBlob->nUsed++] = c;
 
342 }
 
343 }
344
345 /*
346 ** Copy a blob
347 */
348
+5 -5
--- src/markdown.c
+++ src/markdown.c
@@ -238,11 +238,11 @@
238238
i++;
239239
}
240240
blob_append(id, data+beg, i-beg);
241241
242242
/* add a single space and skip all consecutive whitespace */
243
- if( i<size ) blob_append(id, " ", 1);
243
+ if( i<size ) blob_append_char(id, ' ');
244244
while( i<size && (data[i]==' ' || data[i]=='\t' || data[i]=='\n') ){ i++; }
245245
}
246246
247247
/* turn upper-case ASCII into their lower-case counterparts */
248248
id_data = blob_buffer(id);
@@ -1413,11 +1413,11 @@
14131413
break;
14141414
}
14151415
if( beg<end ){
14161416
/* verbatim copy to the working buffer, escaping entities */
14171417
if( is_empty(data + beg, end - beg) ){
1418
- blob_append(work, "\n", 1);
1418
+ blob_append_char(work, '\n');
14191419
}else{
14201420
blob_append(work, data+beg, end-beg);
14211421
}
14221422
}
14231423
beg = end;
@@ -1424,11 +1424,11 @@
14241424
}
14251425
14261426
end = blob_size(work);
14271427
while( end>0 && blob_buffer(work)[end-1]=='\n' ){ end--; }
14281428
work->nUsed = end;
1429
- blob_append(work, "\n", 1);
1429
+ blob_append_char(work, '\n');
14301430
14311431
if( work!=ob ){
14321432
if( rndr->make.blockcode ){
14331433
rndr->make.blockcode(ob, work, rndr->make.opaque);
14341434
}
@@ -1518,11 +1518,11 @@
15181518
/* joining only indented stuff after empty lines */
15191519
}else if( in_empty && i<4 && data[beg]!='\t' ){
15201520
*flags |= MKD_LI_END;
15211521
break;
15221522
}else if( in_empty ){
1523
- blob_append(work, "\n", 1);
1523
+ blob_append_char(work, '\n');
15241524
has_inside_empty = 1;
15251525
}
15261526
in_empty = 0;
15271527
15281528
/* adding the line without prefix into the working buffer */
@@ -2195,11 +2195,11 @@
21952195
while( end<blob_size(ib) && (ib_data[end]=='\n' || ib_data[end]=='\r') ){
21962196
/* add one \n per newline */
21972197
if( ib_data[end]=='\n'
21982198
|| (end+1<blob_size(ib) && ib_data[end+1]!='\n')
21992199
){
2200
- blob_append(&text, "\n", 1);
2200
+ blob_append_char(&text, '\n');
22012201
}
22022202
end += 1;
22032203
}
22042204
beg = end;
22052205
}
22062206
--- src/markdown.c
+++ src/markdown.c
@@ -238,11 +238,11 @@
238 i++;
239 }
240 blob_append(id, data+beg, i-beg);
241
242 /* add a single space and skip all consecutive whitespace */
243 if( i<size ) blob_append(id, " ", 1);
244 while( i<size && (data[i]==' ' || data[i]=='\t' || data[i]=='\n') ){ i++; }
245 }
246
247 /* turn upper-case ASCII into their lower-case counterparts */
248 id_data = blob_buffer(id);
@@ -1413,11 +1413,11 @@
1413 break;
1414 }
1415 if( beg<end ){
1416 /* verbatim copy to the working buffer, escaping entities */
1417 if( is_empty(data + beg, end - beg) ){
1418 blob_append(work, "\n", 1);
1419 }else{
1420 blob_append(work, data+beg, end-beg);
1421 }
1422 }
1423 beg = end;
@@ -1424,11 +1424,11 @@
1424 }
1425
1426 end = blob_size(work);
1427 while( end>0 && blob_buffer(work)[end-1]=='\n' ){ end--; }
1428 work->nUsed = end;
1429 blob_append(work, "\n", 1);
1430
1431 if( work!=ob ){
1432 if( rndr->make.blockcode ){
1433 rndr->make.blockcode(ob, work, rndr->make.opaque);
1434 }
@@ -1518,11 +1518,11 @@
1518 /* joining only indented stuff after empty lines */
1519 }else if( in_empty && i<4 && data[beg]!='\t' ){
1520 *flags |= MKD_LI_END;
1521 break;
1522 }else if( in_empty ){
1523 blob_append(work, "\n", 1);
1524 has_inside_empty = 1;
1525 }
1526 in_empty = 0;
1527
1528 /* adding the line without prefix into the working buffer */
@@ -2195,11 +2195,11 @@
2195 while( end<blob_size(ib) && (ib_data[end]=='\n' || ib_data[end]=='\r') ){
2196 /* add one \n per newline */
2197 if( ib_data[end]=='\n'
2198 || (end+1<blob_size(ib) && ib_data[end+1]!='\n')
2199 ){
2200 blob_append(&text, "\n", 1);
2201 }
2202 end += 1;
2203 }
2204 beg = end;
2205 }
2206
--- src/markdown.c
+++ src/markdown.c
@@ -238,11 +238,11 @@
238 i++;
239 }
240 blob_append(id, data+beg, i-beg);
241
242 /* add a single space and skip all consecutive whitespace */
243 if( i<size ) blob_append_char(id, ' ');
244 while( i<size && (data[i]==' ' || data[i]=='\t' || data[i]=='\n') ){ i++; }
245 }
246
247 /* turn upper-case ASCII into their lower-case counterparts */
248 id_data = blob_buffer(id);
@@ -1413,11 +1413,11 @@
1413 break;
1414 }
1415 if( beg<end ){
1416 /* verbatim copy to the working buffer, escaping entities */
1417 if( is_empty(data + beg, end - beg) ){
1418 blob_append_char(work, '\n');
1419 }else{
1420 blob_append(work, data+beg, end-beg);
1421 }
1422 }
1423 beg = end;
@@ -1424,11 +1424,11 @@
1424 }
1425
1426 end = blob_size(work);
1427 while( end>0 && blob_buffer(work)[end-1]=='\n' ){ end--; }
1428 work->nUsed = end;
1429 blob_append_char(work, '\n');
1430
1431 if( work!=ob ){
1432 if( rndr->make.blockcode ){
1433 rndr->make.blockcode(ob, work, rndr->make.opaque);
1434 }
@@ -1518,11 +1518,11 @@
1518 /* joining only indented stuff after empty lines */
1519 }else if( in_empty && i<4 && data[beg]!='\t' ){
1520 *flags |= MKD_LI_END;
1521 break;
1522 }else if( in_empty ){
1523 blob_append_char(work, '\n');
1524 has_inside_empty = 1;
1525 }
1526 in_empty = 0;
1527
1528 /* adding the line without prefix into the working buffer */
@@ -2195,11 +2195,11 @@
2195 while( end<blob_size(ib) && (ib_data[end]=='\n' || ib_data[end]=='\r') ){
2196 /* add one \n per newline */
2197 if( ib_data[end]=='\n'
2198 || (end+1<blob_size(ib) && ib_data[end+1]!='\n')
2199 ){
2200 blob_append_char(&text, '\n');
2201 }
2202 end += 1;
2203 }
2204 beg = end;
2205 }
2206
--- src/markdown_html.c
+++ src/markdown_html.c
@@ -32,11 +32,11 @@
3232
#endif /* INTERFACE */
3333
3434
3535
/* INTER_BLOCK -- skip a line between block level elements */
3636
#define INTER_BLOCK(ob) \
37
- do { if( blob_size(ob)>0 ) blob_append(ob, "\n", 1); } while (0)
37
+ do { if( blob_size(ob)>0 ) blob_append_char(ob, '\n'); } while (0)
3838
3939
/* BLOB_APPEND_LITERAL -- append a string literal to a blob */
4040
#define BLOB_APPEND_LITERAL(blob, literal) \
4141
blob_append((blob), "" literal, (sizeof literal)-1)
4242
/*
4343
--- src/markdown_html.c
+++ src/markdown_html.c
@@ -32,11 +32,11 @@
32 #endif /* INTERFACE */
33
34
35 /* INTER_BLOCK -- skip a line between block level elements */
36 #define INTER_BLOCK(ob) \
37 do { if( blob_size(ob)>0 ) blob_append(ob, "\n", 1); } while (0)
38
39 /* BLOB_APPEND_LITERAL -- append a string literal to a blob */
40 #define BLOB_APPEND_LITERAL(blob, literal) \
41 blob_append((blob), "" literal, (sizeof literal)-1)
42 /*
43
--- src/markdown_html.c
+++ src/markdown_html.c
@@ -32,11 +32,11 @@
32 #endif /* INTERFACE */
33
34
35 /* INTER_BLOCK -- skip a line between block level elements */
36 #define INTER_BLOCK(ob) \
37 do { if( blob_size(ob)>0 ) blob_append_char(ob, '\n'); } while (0)
38
39 /* BLOB_APPEND_LITERAL -- append a string literal to a blob */
40 #define BLOB_APPEND_LITERAL(blob, literal) \
41 blob_append((blob), "" literal, (sizeof literal)-1)
42 /*
43
+42 -42
--- src/wikiformat.c
+++ src/wikiformat.c
@@ -863,13 +863,13 @@
863863
blob_appendf(pOut, "=\"%s\"", zVal);
864864
}
865865
}
866866
}
867867
if (p->iType & MUTYPE_SINGLE){
868
- blob_append(pOut, " /", 2);
868
+ blob_append_string(pOut, " /");
869869
}
870
- blob_append(pOut, ">", 1);
870
+ blob_append_char(pOut, '>');
871871
}
872872
}
873873
874874
/*
875875
** When the markup was parsed, some "\000" may have been inserted.
@@ -1045,11 +1045,11 @@
10451045
*/
10461046
static void startAutoParagraph(Renderer *p){
10471047
if( p->wantAutoParagraph==0 ) return;
10481048
if( p->state & WIKI_LINKSONLY ) return;
10491049
if( p->wikiList==MARKUP_OL || p->wikiList==MARKUP_UL ) return;
1050
- blob_append(p->pOut, "<p>", -1);
1050
+ blob_append_string(p->pOut, "<p>");
10511051
p->wantAutoParagraph = 0;
10521052
p->inAutoParagraph = 1;
10531053
}
10541054
10551055
/*
@@ -1382,70 +1382,70 @@
13821382
}
13831383
p->state &= ~(AT_NEWLINE|AT_PARAGRAPH);
13841384
switch( tokenType ){
13851385
case TOKEN_PARAGRAPH: {
13861386
if( inlineOnly ){
1387
- /* blob_append(p->pOut, " &para; ", -1); */
1388
- blob_append(p->pOut, " &nbsp;&nbsp; ", -1);
1387
+ /* blob_append_string(p->pOut, " &para; "); */
1388
+ blob_append_string(p->pOut, " &nbsp;&nbsp; ");
13891389
}else{
13901390
if( p->wikiList ){
13911391
popStackToTag(p, p->wikiList);
13921392
p->wikiList = 0;
13931393
}
13941394
endAutoParagraph(p);
1395
- blob_append(p->pOut, "\n\n", 1);
1395
+ blob_append_string(p->pOut, "\n\n");
13961396
p->wantAutoParagraph = 1;
13971397
}
13981398
p->state |= AT_PARAGRAPH|AT_NEWLINE;
13991399
break;
14001400
}
14011401
case TOKEN_NEWLINE: {
14021402
if( p->renderFlags & WIKI_NEWLINE ){
1403
- blob_append(p->pOut, "<br>\n", 5);
1403
+ blob_append_string(p->pOut, "<br>\n");
14041404
}else{
1405
- blob_append(p->pOut, "\n", 1);
1405
+ blob_append_string(p->pOut, "\n");
14061406
}
14071407
p->state |= AT_NEWLINE;
14081408
break;
14091409
}
14101410
case TOKEN_BUL_LI: {
14111411
if( inlineOnly ){
1412
- blob_append(p->pOut, " &bull; ", -1);
1412
+ blob_append_string(p->pOut, " &bull; ");
14131413
}else{
14141414
if( p->wikiList!=MARKUP_UL ){
14151415
if( p->wikiList ){
14161416
popStackToTag(p, p->wikiList);
14171417
}
14181418
endAutoParagraph(p);
14191419
pushStack(p, MARKUP_UL);
1420
- blob_append(p->pOut, "<ul>", 4);
1420
+ blob_append_string(p->pOut, "<ul>");
14211421
p->wikiList = MARKUP_UL;
14221422
}
14231423
popStackToTag(p, MARKUP_LI);
14241424
startAutoParagraph(p);
14251425
pushStack(p, MARKUP_LI);
1426
- blob_append(p->pOut, "<li>", 4);
1426
+ blob_append_string(p->pOut, "<li>");
14271427
}
14281428
break;
14291429
}
14301430
case TOKEN_NUM_LI: {
14311431
if( inlineOnly ){
1432
- blob_append(p->pOut, " # ", -1);
1432
+ blob_append_string(p->pOut, " # ");
14331433
}else{
14341434
if( p->wikiList!=MARKUP_OL ){
14351435
if( p->wikiList ){
14361436
popStackToTag(p, p->wikiList);
14371437
}
14381438
endAutoParagraph(p);
14391439
pushStack(p, MARKUP_OL);
1440
- blob_append(p->pOut, "<ol>", 4);
1440
+ blob_append_string(p->pOut, "<ol>");
14411441
p->wikiList = MARKUP_OL;
14421442
}
14431443
popStackToTag(p, MARKUP_LI);
14441444
startAutoParagraph(p);
14451445
pushStack(p, MARKUP_LI);
1446
- blob_append(p->pOut, "<li>", 4);
1446
+ blob_append_string(p->pOut, "<li>");
14471447
}
14481448
break;
14491449
}
14501450
case TOKEN_ENUM: {
14511451
if( inlineOnly ){
@@ -1455,11 +1455,11 @@
14551455
if( p->wikiList ){
14561456
popStackToTag(p, p->wikiList);
14571457
}
14581458
endAutoParagraph(p);
14591459
pushStack(p, MARKUP_OL);
1460
- blob_append(p->pOut, "<ol>", 4);
1460
+ blob_append_string(p->pOut, "<ol>");
14611461
p->wikiList = MARKUP_OL;
14621462
}
14631463
popStackToTag(p, MARKUP_LI);
14641464
startAutoParagraph(p);
14651465
pushStack(p, MARKUP_LI);
@@ -1469,22 +1469,22 @@
14691469
}
14701470
case TOKEN_INDENT: {
14711471
if( !inlineOnly ){
14721472
assert( p->wikiList==0 );
14731473
pushStack(p, MARKUP_BLOCKQUOTE);
1474
- blob_append(p->pOut, "<blockquote>", -1);
1474
+ blob_append_string(p->pOut, "<blockquote>");
14751475
p->wantAutoParagraph = 0;
14761476
p->wikiList = MARKUP_BLOCKQUOTE;
14771477
}
14781478
break;
14791479
}
14801480
case TOKEN_CHARACTER: {
14811481
startAutoParagraph(p);
14821482
if( z[0]=='<' ){
1483
- blob_append(p->pOut, "&lt;", 4);
1483
+ blob_append_string(p->pOut, "&lt;");
14841484
}else if( z[0]=='&' ){
1485
- blob_append(p->pOut, "&amp;", 5);
1485
+ blob_append_string(p->pOut, "&amp;");
14861486
}
14871487
break;
14881488
}
14891489
case TOKEN_LINK: {
14901490
char *zTarget;
@@ -1569,11 +1569,11 @@
15691569
(iDiv = findTagWithId(p, MARKUP_DIV, zId))>=0
15701570
){
15711571
if( p->inVerbatim ){
15721572
p->inVerbatim = 0;
15731573
p->state = p->preVerbState;
1574
- blob_append(p->pOut, "</pre>", 6);
1574
+ blob_append_string(p->pOut, "</pre>");
15751575
}
15761576
while( p->nStack>iDiv+1 ) popStack(p);
15771577
if( p->aStack[iDiv].allowWiki ){
15781578
p->state |= ALLOW_WIKI;
15791579
}else{
@@ -1588,14 +1588,14 @@
15881588
*/
15891589
if( p->inVerbatim ){
15901590
if( endVerbatim(p, &markup) ){
15911591
p->inVerbatim = 0;
15921592
p->state = p->preVerbState;
1593
- blob_append(p->pOut, "</pre>", 6);
1593
+ blob_append_string(p->pOut, "</pre>");
15941594
}else{
15951595
unparseMarkup(&markup);
1596
- blob_append(p->pOut, "&lt;", 4);
1596
+ blob_append_string(p->pOut, "&lt;");
15971597
n = 1;
15981598
}
15991599
}else
16001600
16011601
/* Render invalid markup literally. The markup appears in the
@@ -1602,11 +1602,11 @@
16021602
** final output as plain text.
16031603
*/
16041604
if( markup.iCode==MARKUP_INVALID ){
16051605
unparseMarkup(&markup);
16061606
startAutoParagraph(p);
1607
- blob_append(p->pOut, "&lt;", 4);
1607
+ blob_append_string(p->pOut, "&lt;");
16081608
n = 1;
16091609
}else
16101610
16111611
/* If the markup is not font-change markup ignore it if the
16121612
** font-change-only flag is set.
@@ -1663,19 +1663,19 @@
16631663
p->state |= ALLOW_LINKS;
16641664
}
16651665
}
16661666
if( !vAttrDidAppend ) {
16671667
endAutoParagraph(p);
1668
- blob_append(p->pOut, "<pre class='verbatim'>",-1);
1668
+ blob_append_string(p->pOut, "<pre class='verbatim'>");
16691669
}
16701670
p->wantAutoParagraph = 0;
16711671
}else
16721672
if( markup.iType==MUTYPE_LI ){
16731673
if( backupToType(p, MUTYPE_LIST)==0 ){
16741674
endAutoParagraph(p);
16751675
pushStack(p, MARKUP_UL);
1676
- blob_append(p->pOut, "<ul>", 4);
1676
+ blob_append_string(p->pOut, "<ul>");
16771677
}
16781678
pushStack(p, MARKUP_LI);
16791679
renderMarkup(p->pOut, &markup);
16801680
}else
16811681
if( markup.iType==MUTYPE_TR ){
@@ -1686,11 +1686,11 @@
16861686
}else
16871687
if( markup.iType==MUTYPE_TD ){
16881688
if( backupToType(p, MUTYPE_TABLE|MUTYPE_TR) ){
16891689
if( stackTopType(p)==MUTYPE_TABLE ){
16901690
pushStack(p, MARKUP_TR);
1691
- blob_append(p->pOut, "<tr>", 4);
1691
+ blob_append_string(p->pOut, "<tr>");
16921692
}
16931693
pushStack(p, markup.iCode);
16941694
renderMarkup(p->pOut, &markup);
16951695
}
16961696
}else
@@ -1764,11 +1764,11 @@
17641764
wiki_render(&renderer, blob_str(pIn));
17651765
endAutoParagraph(&renderer);
17661766
while( renderer.nStack ){
17671767
popStack(&renderer);
17681768
}
1769
- blob_append(renderer.pOut, "\n", 1);
1769
+ blob_append_char(renderer.pOut, '\n');
17701770
free(renderer.aStack);
17711771
}
17721772
17731773
/*
17741774
** COMMAND: test-wiki-render
@@ -2204,14 +2204,14 @@
22042204
if( eTag==MARKUP_PRE ){
22052205
if( isCloseTag ){
22062206
nPre--;
22072207
blob_append(pOut, zIn, n);
22082208
zIn += n;
2209
- if( nPre==0 ){ blob_append(pOut, "\n", 1); iCur = 0; }
2209
+ if( nPre==0 ){ blob_append_char(pOut, '\n'); iCur = 0; }
22102210
continue;
22112211
}else{
2212
- if( iCur && nPre==0 ){ blob_append(pOut, "\n", 1); iCur = 0; }
2212
+ if( iCur && nPre==0 ){ blob_append_char(pOut, '\n'); iCur = 0; }
22132213
nPre++;
22142214
}
22152215
}else if( eType & (MUTYPE_BLOCK|MUTYPE_TABLE) ){
22162216
if( !isCloseTag && nPre==0 && blob_size(pOut)>0 ){
22172217
blob_append(pOut, "\n\n", 1 + (iCur>0));
@@ -2221,30 +2221,30 @@
22212221
omitSpace = 1;
22222222
}else if( (eType & (MUTYPE_LIST|MUTYPE_LI|MUTYPE_TR|MUTYPE_TD))!=0
22232223
|| eTag==MARKUP_HR
22242224
){
22252225
if( nPre==0 && (!isCloseTag || (eType&MUTYPE_LIST)!=0) && iCur>0 ){
2226
- blob_append(pOut, "\n", 1);
2226
+ blob_append_char(pOut, '\n');
22272227
iCur = 0;
22282228
}
22292229
wantSpace = 0;
22302230
omitSpace = 1;
22312231
}
22322232
if( wantSpace && nPre==0 ){
22332233
if( iCur+n+1>=80 ){
2234
- blob_append(pOut, "\n", 1);
2234
+ blob_append_char(pOut, '\n');
22352235
iCur = 0;
22362236
}else{
2237
- blob_append(pOut, " ", 1);
2237
+ blob_append_char(pOut, ' ');
22382238
iCur++;
22392239
}
22402240
}
22412241
blob_append(pOut, zIn, n);
22422242
iCur += n;
22432243
wantSpace = 0;
22442244
if( eTag==MARKUP_BR || eTag==MARKUP_HR ){
2245
- blob_append(pOut, "\n", 1);
2245
+ blob_append_char(pOut, '\n');
22462246
iCur = 0;
22472247
}
22482248
}else if( fossil_isspace(zIn[0]) ){
22492249
if( nPre ){
22502250
blob_append(pOut, zIn, n);
@@ -2252,24 +2252,24 @@
22522252
wantSpace = !omitSpace;
22532253
}
22542254
}else{
22552255
if( wantSpace && nPre==0 ){
22562256
if( iCur+n+1>=80 ){
2257
- blob_append(pOut, "\n", 1);
2257
+ blob_append_char(pOut, '\n');
22582258
iCur = 0;
22592259
}else{
2260
- blob_append(pOut, " ", 1);
2260
+ blob_append_char(pOut, ' ');
22612261
iCur++;
22622262
}
22632263
}
22642264
blob_append(pOut, zIn, n);
22652265
iCur += n;
22662266
wantSpace = omitSpace = 0;
22672267
}
22682268
zIn += n;
22692269
}
2270
- if( iCur ) blob_append(pOut, "\n", 1);
2270
+ if( iCur ) blob_append_char(pOut, '\n');
22712271
}
22722272
22732273
/*
22742274
** COMMAND: test-html-tidy
22752275
**
@@ -2332,11 +2332,11 @@
23322332
if( eTag==MARKUP_TITLE ){
23332333
inTitle = !isCloseTag;
23342334
}
23352335
if( !isCloseTag && seenText && (eType & (MUTYPE_BLOCK|MUTYPE_TABLE))!=0 ){
23362336
if( nNL==0 ){
2337
- blob_append(pOut, "\n", 1);
2337
+ blob_append_char(pOut, '\n');
23382338
nNL++;
23392339
}
23402340
nWS = 1;
23412341
}
23422342
}else if( fossil_isspace(zIn[0]) ){
@@ -2344,11 +2344,11 @@
23442344
nNL = 0;
23452345
if( !inTitle ){ /* '\n' -> ' ' within <title> */
23462346
for(i=0; i<n; i++) if( zIn[i]=='\n' ) nNL++;
23472347
}
23482348
if( !nWS ){
2349
- blob_append(pOut, nNL ? "\n" : " ", 1);
2349
+ blob_append_char(pOut, nNL ? '\n' : ' ');
23502350
nWS = 1;
23512351
}
23522352
}
23532353
}else if( zIn[0]=='&' ){
23542354
char c = '?';
@@ -2369,28 +2369,28 @@
23692369
break;
23702370
}
23712371
}
23722372
}
23732373
if( fossil_isspace(c) ){
2374
- if( nWS==0 && seenText ) blob_append(pOut, &c, 1);
2374
+ if( nWS==0 && seenText ) blob_append_char(pOut, c);
23752375
nWS = 1;
23762376
nNL = c=='\n';
23772377
}else{
2378
- if( !seenText && !inTitle ) blob_append(pOut, "\n", 1);
2378
+ if( !seenText && !inTitle ) blob_append_char(pOut, '\n');
23792379
seenText = 1;
23802380
nNL = nWS = 0;
2381
- blob_append(pOut, &c, 1);
2381
+ blob_append_char(pOut, c);
23822382
}
23832383
}else{
2384
- if( !seenText && !inTitle ) blob_append(pOut, "\n", 1);
2384
+ if( !seenText && !inTitle ) blob_append_char(pOut, '\n');
23852385
seenText = 1;
23862386
nNL = nWS = 0;
23872387
blob_append(pOut, zIn, n);
23882388
}
23892389
zIn += n;
23902390
}
2391
- if( nNL==0 ) blob_append(pOut, "\n", 1);
2391
+ if( nNL==0 ) blob_append_char(pOut, '\n');
23922392
}
23932393
23942394
/*
23952395
** COMMAND: test-html-to-text
23962396
**
23972397
--- src/wikiformat.c
+++ src/wikiformat.c
@@ -863,13 +863,13 @@
863 blob_appendf(pOut, "=\"%s\"", zVal);
864 }
865 }
866 }
867 if (p->iType & MUTYPE_SINGLE){
868 blob_append(pOut, " /", 2);
869 }
870 blob_append(pOut, ">", 1);
871 }
872 }
873
874 /*
875 ** When the markup was parsed, some "\000" may have been inserted.
@@ -1045,11 +1045,11 @@
1045 */
1046 static void startAutoParagraph(Renderer *p){
1047 if( p->wantAutoParagraph==0 ) return;
1048 if( p->state & WIKI_LINKSONLY ) return;
1049 if( p->wikiList==MARKUP_OL || p->wikiList==MARKUP_UL ) return;
1050 blob_append(p->pOut, "<p>", -1);
1051 p->wantAutoParagraph = 0;
1052 p->inAutoParagraph = 1;
1053 }
1054
1055 /*
@@ -1382,70 +1382,70 @@
1382 }
1383 p->state &= ~(AT_NEWLINE|AT_PARAGRAPH);
1384 switch( tokenType ){
1385 case TOKEN_PARAGRAPH: {
1386 if( inlineOnly ){
1387 /* blob_append(p->pOut, " &para; ", -1); */
1388 blob_append(p->pOut, " &nbsp;&nbsp; ", -1);
1389 }else{
1390 if( p->wikiList ){
1391 popStackToTag(p, p->wikiList);
1392 p->wikiList = 0;
1393 }
1394 endAutoParagraph(p);
1395 blob_append(p->pOut, "\n\n", 1);
1396 p->wantAutoParagraph = 1;
1397 }
1398 p->state |= AT_PARAGRAPH|AT_NEWLINE;
1399 break;
1400 }
1401 case TOKEN_NEWLINE: {
1402 if( p->renderFlags & WIKI_NEWLINE ){
1403 blob_append(p->pOut, "<br>\n", 5);
1404 }else{
1405 blob_append(p->pOut, "\n", 1);
1406 }
1407 p->state |= AT_NEWLINE;
1408 break;
1409 }
1410 case TOKEN_BUL_LI: {
1411 if( inlineOnly ){
1412 blob_append(p->pOut, " &bull; ", -1);
1413 }else{
1414 if( p->wikiList!=MARKUP_UL ){
1415 if( p->wikiList ){
1416 popStackToTag(p, p->wikiList);
1417 }
1418 endAutoParagraph(p);
1419 pushStack(p, MARKUP_UL);
1420 blob_append(p->pOut, "<ul>", 4);
1421 p->wikiList = MARKUP_UL;
1422 }
1423 popStackToTag(p, MARKUP_LI);
1424 startAutoParagraph(p);
1425 pushStack(p, MARKUP_LI);
1426 blob_append(p->pOut, "<li>", 4);
1427 }
1428 break;
1429 }
1430 case TOKEN_NUM_LI: {
1431 if( inlineOnly ){
1432 blob_append(p->pOut, " # ", -1);
1433 }else{
1434 if( p->wikiList!=MARKUP_OL ){
1435 if( p->wikiList ){
1436 popStackToTag(p, p->wikiList);
1437 }
1438 endAutoParagraph(p);
1439 pushStack(p, MARKUP_OL);
1440 blob_append(p->pOut, "<ol>", 4);
1441 p->wikiList = MARKUP_OL;
1442 }
1443 popStackToTag(p, MARKUP_LI);
1444 startAutoParagraph(p);
1445 pushStack(p, MARKUP_LI);
1446 blob_append(p->pOut, "<li>", 4);
1447 }
1448 break;
1449 }
1450 case TOKEN_ENUM: {
1451 if( inlineOnly ){
@@ -1455,11 +1455,11 @@
1455 if( p->wikiList ){
1456 popStackToTag(p, p->wikiList);
1457 }
1458 endAutoParagraph(p);
1459 pushStack(p, MARKUP_OL);
1460 blob_append(p->pOut, "<ol>", 4);
1461 p->wikiList = MARKUP_OL;
1462 }
1463 popStackToTag(p, MARKUP_LI);
1464 startAutoParagraph(p);
1465 pushStack(p, MARKUP_LI);
@@ -1469,22 +1469,22 @@
1469 }
1470 case TOKEN_INDENT: {
1471 if( !inlineOnly ){
1472 assert( p->wikiList==0 );
1473 pushStack(p, MARKUP_BLOCKQUOTE);
1474 blob_append(p->pOut, "<blockquote>", -1);
1475 p->wantAutoParagraph = 0;
1476 p->wikiList = MARKUP_BLOCKQUOTE;
1477 }
1478 break;
1479 }
1480 case TOKEN_CHARACTER: {
1481 startAutoParagraph(p);
1482 if( z[0]=='<' ){
1483 blob_append(p->pOut, "&lt;", 4);
1484 }else if( z[0]=='&' ){
1485 blob_append(p->pOut, "&amp;", 5);
1486 }
1487 break;
1488 }
1489 case TOKEN_LINK: {
1490 char *zTarget;
@@ -1569,11 +1569,11 @@
1569 (iDiv = findTagWithId(p, MARKUP_DIV, zId))>=0
1570 ){
1571 if( p->inVerbatim ){
1572 p->inVerbatim = 0;
1573 p->state = p->preVerbState;
1574 blob_append(p->pOut, "</pre>", 6);
1575 }
1576 while( p->nStack>iDiv+1 ) popStack(p);
1577 if( p->aStack[iDiv].allowWiki ){
1578 p->state |= ALLOW_WIKI;
1579 }else{
@@ -1588,14 +1588,14 @@
1588 */
1589 if( p->inVerbatim ){
1590 if( endVerbatim(p, &markup) ){
1591 p->inVerbatim = 0;
1592 p->state = p->preVerbState;
1593 blob_append(p->pOut, "</pre>", 6);
1594 }else{
1595 unparseMarkup(&markup);
1596 blob_append(p->pOut, "&lt;", 4);
1597 n = 1;
1598 }
1599 }else
1600
1601 /* Render invalid markup literally. The markup appears in the
@@ -1602,11 +1602,11 @@
1602 ** final output as plain text.
1603 */
1604 if( markup.iCode==MARKUP_INVALID ){
1605 unparseMarkup(&markup);
1606 startAutoParagraph(p);
1607 blob_append(p->pOut, "&lt;", 4);
1608 n = 1;
1609 }else
1610
1611 /* If the markup is not font-change markup ignore it if the
1612 ** font-change-only flag is set.
@@ -1663,19 +1663,19 @@
1663 p->state |= ALLOW_LINKS;
1664 }
1665 }
1666 if( !vAttrDidAppend ) {
1667 endAutoParagraph(p);
1668 blob_append(p->pOut, "<pre class='verbatim'>",-1);
1669 }
1670 p->wantAutoParagraph = 0;
1671 }else
1672 if( markup.iType==MUTYPE_LI ){
1673 if( backupToType(p, MUTYPE_LIST)==0 ){
1674 endAutoParagraph(p);
1675 pushStack(p, MARKUP_UL);
1676 blob_append(p->pOut, "<ul>", 4);
1677 }
1678 pushStack(p, MARKUP_LI);
1679 renderMarkup(p->pOut, &markup);
1680 }else
1681 if( markup.iType==MUTYPE_TR ){
@@ -1686,11 +1686,11 @@
1686 }else
1687 if( markup.iType==MUTYPE_TD ){
1688 if( backupToType(p, MUTYPE_TABLE|MUTYPE_TR) ){
1689 if( stackTopType(p)==MUTYPE_TABLE ){
1690 pushStack(p, MARKUP_TR);
1691 blob_append(p->pOut, "<tr>", 4);
1692 }
1693 pushStack(p, markup.iCode);
1694 renderMarkup(p->pOut, &markup);
1695 }
1696 }else
@@ -1764,11 +1764,11 @@
1764 wiki_render(&renderer, blob_str(pIn));
1765 endAutoParagraph(&renderer);
1766 while( renderer.nStack ){
1767 popStack(&renderer);
1768 }
1769 blob_append(renderer.pOut, "\n", 1);
1770 free(renderer.aStack);
1771 }
1772
1773 /*
1774 ** COMMAND: test-wiki-render
@@ -2204,14 +2204,14 @@
2204 if( eTag==MARKUP_PRE ){
2205 if( isCloseTag ){
2206 nPre--;
2207 blob_append(pOut, zIn, n);
2208 zIn += n;
2209 if( nPre==0 ){ blob_append(pOut, "\n", 1); iCur = 0; }
2210 continue;
2211 }else{
2212 if( iCur && nPre==0 ){ blob_append(pOut, "\n", 1); iCur = 0; }
2213 nPre++;
2214 }
2215 }else if( eType & (MUTYPE_BLOCK|MUTYPE_TABLE) ){
2216 if( !isCloseTag && nPre==0 && blob_size(pOut)>0 ){
2217 blob_append(pOut, "\n\n", 1 + (iCur>0));
@@ -2221,30 +2221,30 @@
2221 omitSpace = 1;
2222 }else if( (eType & (MUTYPE_LIST|MUTYPE_LI|MUTYPE_TR|MUTYPE_TD))!=0
2223 || eTag==MARKUP_HR
2224 ){
2225 if( nPre==0 && (!isCloseTag || (eType&MUTYPE_LIST)!=0) && iCur>0 ){
2226 blob_append(pOut, "\n", 1);
2227 iCur = 0;
2228 }
2229 wantSpace = 0;
2230 omitSpace = 1;
2231 }
2232 if( wantSpace && nPre==0 ){
2233 if( iCur+n+1>=80 ){
2234 blob_append(pOut, "\n", 1);
2235 iCur = 0;
2236 }else{
2237 blob_append(pOut, " ", 1);
2238 iCur++;
2239 }
2240 }
2241 blob_append(pOut, zIn, n);
2242 iCur += n;
2243 wantSpace = 0;
2244 if( eTag==MARKUP_BR || eTag==MARKUP_HR ){
2245 blob_append(pOut, "\n", 1);
2246 iCur = 0;
2247 }
2248 }else if( fossil_isspace(zIn[0]) ){
2249 if( nPre ){
2250 blob_append(pOut, zIn, n);
@@ -2252,24 +2252,24 @@
2252 wantSpace = !omitSpace;
2253 }
2254 }else{
2255 if( wantSpace && nPre==0 ){
2256 if( iCur+n+1>=80 ){
2257 blob_append(pOut, "\n", 1);
2258 iCur = 0;
2259 }else{
2260 blob_append(pOut, " ", 1);
2261 iCur++;
2262 }
2263 }
2264 blob_append(pOut, zIn, n);
2265 iCur += n;
2266 wantSpace = omitSpace = 0;
2267 }
2268 zIn += n;
2269 }
2270 if( iCur ) blob_append(pOut, "\n", 1);
2271 }
2272
2273 /*
2274 ** COMMAND: test-html-tidy
2275 **
@@ -2332,11 +2332,11 @@
2332 if( eTag==MARKUP_TITLE ){
2333 inTitle = !isCloseTag;
2334 }
2335 if( !isCloseTag && seenText && (eType & (MUTYPE_BLOCK|MUTYPE_TABLE))!=0 ){
2336 if( nNL==0 ){
2337 blob_append(pOut, "\n", 1);
2338 nNL++;
2339 }
2340 nWS = 1;
2341 }
2342 }else if( fossil_isspace(zIn[0]) ){
@@ -2344,11 +2344,11 @@
2344 nNL = 0;
2345 if( !inTitle ){ /* '\n' -> ' ' within <title> */
2346 for(i=0; i<n; i++) if( zIn[i]=='\n' ) nNL++;
2347 }
2348 if( !nWS ){
2349 blob_append(pOut, nNL ? "\n" : " ", 1);
2350 nWS = 1;
2351 }
2352 }
2353 }else if( zIn[0]=='&' ){
2354 char c = '?';
@@ -2369,28 +2369,28 @@
2369 break;
2370 }
2371 }
2372 }
2373 if( fossil_isspace(c) ){
2374 if( nWS==0 && seenText ) blob_append(pOut, &c, 1);
2375 nWS = 1;
2376 nNL = c=='\n';
2377 }else{
2378 if( !seenText && !inTitle ) blob_append(pOut, "\n", 1);
2379 seenText = 1;
2380 nNL = nWS = 0;
2381 blob_append(pOut, &c, 1);
2382 }
2383 }else{
2384 if( !seenText && !inTitle ) blob_append(pOut, "\n", 1);
2385 seenText = 1;
2386 nNL = nWS = 0;
2387 blob_append(pOut, zIn, n);
2388 }
2389 zIn += n;
2390 }
2391 if( nNL==0 ) blob_append(pOut, "\n", 1);
2392 }
2393
2394 /*
2395 ** COMMAND: test-html-to-text
2396 **
2397
--- src/wikiformat.c
+++ src/wikiformat.c
@@ -863,13 +863,13 @@
863 blob_appendf(pOut, "=\"%s\"", zVal);
864 }
865 }
866 }
867 if (p->iType & MUTYPE_SINGLE){
868 blob_append_string(pOut, " /");
869 }
870 blob_append_char(pOut, '>');
871 }
872 }
873
874 /*
875 ** When the markup was parsed, some "\000" may have been inserted.
@@ -1045,11 +1045,11 @@
1045 */
1046 static void startAutoParagraph(Renderer *p){
1047 if( p->wantAutoParagraph==0 ) return;
1048 if( p->state & WIKI_LINKSONLY ) return;
1049 if( p->wikiList==MARKUP_OL || p->wikiList==MARKUP_UL ) return;
1050 blob_append_string(p->pOut, "<p>");
1051 p->wantAutoParagraph = 0;
1052 p->inAutoParagraph = 1;
1053 }
1054
1055 /*
@@ -1382,70 +1382,70 @@
1382 }
1383 p->state &= ~(AT_NEWLINE|AT_PARAGRAPH);
1384 switch( tokenType ){
1385 case TOKEN_PARAGRAPH: {
1386 if( inlineOnly ){
1387 /* blob_append_string(p->pOut, " &para; "); */
1388 blob_append_string(p->pOut, " &nbsp;&nbsp; ");
1389 }else{
1390 if( p->wikiList ){
1391 popStackToTag(p, p->wikiList);
1392 p->wikiList = 0;
1393 }
1394 endAutoParagraph(p);
1395 blob_append_string(p->pOut, "\n\n");
1396 p->wantAutoParagraph = 1;
1397 }
1398 p->state |= AT_PARAGRAPH|AT_NEWLINE;
1399 break;
1400 }
1401 case TOKEN_NEWLINE: {
1402 if( p->renderFlags & WIKI_NEWLINE ){
1403 blob_append_string(p->pOut, "<br>\n");
1404 }else{
1405 blob_append_string(p->pOut, "\n");
1406 }
1407 p->state |= AT_NEWLINE;
1408 break;
1409 }
1410 case TOKEN_BUL_LI: {
1411 if( inlineOnly ){
1412 blob_append_string(p->pOut, " &bull; ");
1413 }else{
1414 if( p->wikiList!=MARKUP_UL ){
1415 if( p->wikiList ){
1416 popStackToTag(p, p->wikiList);
1417 }
1418 endAutoParagraph(p);
1419 pushStack(p, MARKUP_UL);
1420 blob_append_string(p->pOut, "<ul>");
1421 p->wikiList = MARKUP_UL;
1422 }
1423 popStackToTag(p, MARKUP_LI);
1424 startAutoParagraph(p);
1425 pushStack(p, MARKUP_LI);
1426 blob_append_string(p->pOut, "<li>");
1427 }
1428 break;
1429 }
1430 case TOKEN_NUM_LI: {
1431 if( inlineOnly ){
1432 blob_append_string(p->pOut, " # ");
1433 }else{
1434 if( p->wikiList!=MARKUP_OL ){
1435 if( p->wikiList ){
1436 popStackToTag(p, p->wikiList);
1437 }
1438 endAutoParagraph(p);
1439 pushStack(p, MARKUP_OL);
1440 blob_append_string(p->pOut, "<ol>");
1441 p->wikiList = MARKUP_OL;
1442 }
1443 popStackToTag(p, MARKUP_LI);
1444 startAutoParagraph(p);
1445 pushStack(p, MARKUP_LI);
1446 blob_append_string(p->pOut, "<li>");
1447 }
1448 break;
1449 }
1450 case TOKEN_ENUM: {
1451 if( inlineOnly ){
@@ -1455,11 +1455,11 @@
1455 if( p->wikiList ){
1456 popStackToTag(p, p->wikiList);
1457 }
1458 endAutoParagraph(p);
1459 pushStack(p, MARKUP_OL);
1460 blob_append_string(p->pOut, "<ol>");
1461 p->wikiList = MARKUP_OL;
1462 }
1463 popStackToTag(p, MARKUP_LI);
1464 startAutoParagraph(p);
1465 pushStack(p, MARKUP_LI);
@@ -1469,22 +1469,22 @@
1469 }
1470 case TOKEN_INDENT: {
1471 if( !inlineOnly ){
1472 assert( p->wikiList==0 );
1473 pushStack(p, MARKUP_BLOCKQUOTE);
1474 blob_append_string(p->pOut, "<blockquote>");
1475 p->wantAutoParagraph = 0;
1476 p->wikiList = MARKUP_BLOCKQUOTE;
1477 }
1478 break;
1479 }
1480 case TOKEN_CHARACTER: {
1481 startAutoParagraph(p);
1482 if( z[0]=='<' ){
1483 blob_append_string(p->pOut, "&lt;");
1484 }else if( z[0]=='&' ){
1485 blob_append_string(p->pOut, "&amp;");
1486 }
1487 break;
1488 }
1489 case TOKEN_LINK: {
1490 char *zTarget;
@@ -1569,11 +1569,11 @@
1569 (iDiv = findTagWithId(p, MARKUP_DIV, zId))>=0
1570 ){
1571 if( p->inVerbatim ){
1572 p->inVerbatim = 0;
1573 p->state = p->preVerbState;
1574 blob_append_string(p->pOut, "</pre>");
1575 }
1576 while( p->nStack>iDiv+1 ) popStack(p);
1577 if( p->aStack[iDiv].allowWiki ){
1578 p->state |= ALLOW_WIKI;
1579 }else{
@@ -1588,14 +1588,14 @@
1588 */
1589 if( p->inVerbatim ){
1590 if( endVerbatim(p, &markup) ){
1591 p->inVerbatim = 0;
1592 p->state = p->preVerbState;
1593 blob_append_string(p->pOut, "</pre>");
1594 }else{
1595 unparseMarkup(&markup);
1596 blob_append_string(p->pOut, "&lt;");
1597 n = 1;
1598 }
1599 }else
1600
1601 /* Render invalid markup literally. The markup appears in the
@@ -1602,11 +1602,11 @@
1602 ** final output as plain text.
1603 */
1604 if( markup.iCode==MARKUP_INVALID ){
1605 unparseMarkup(&markup);
1606 startAutoParagraph(p);
1607 blob_append_string(p->pOut, "&lt;");
1608 n = 1;
1609 }else
1610
1611 /* If the markup is not font-change markup ignore it if the
1612 ** font-change-only flag is set.
@@ -1663,19 +1663,19 @@
1663 p->state |= ALLOW_LINKS;
1664 }
1665 }
1666 if( !vAttrDidAppend ) {
1667 endAutoParagraph(p);
1668 blob_append_string(p->pOut, "<pre class='verbatim'>");
1669 }
1670 p->wantAutoParagraph = 0;
1671 }else
1672 if( markup.iType==MUTYPE_LI ){
1673 if( backupToType(p, MUTYPE_LIST)==0 ){
1674 endAutoParagraph(p);
1675 pushStack(p, MARKUP_UL);
1676 blob_append_string(p->pOut, "<ul>");
1677 }
1678 pushStack(p, MARKUP_LI);
1679 renderMarkup(p->pOut, &markup);
1680 }else
1681 if( markup.iType==MUTYPE_TR ){
@@ -1686,11 +1686,11 @@
1686 }else
1687 if( markup.iType==MUTYPE_TD ){
1688 if( backupToType(p, MUTYPE_TABLE|MUTYPE_TR) ){
1689 if( stackTopType(p)==MUTYPE_TABLE ){
1690 pushStack(p, MARKUP_TR);
1691 blob_append_string(p->pOut, "<tr>");
1692 }
1693 pushStack(p, markup.iCode);
1694 renderMarkup(p->pOut, &markup);
1695 }
1696 }else
@@ -1764,11 +1764,11 @@
1764 wiki_render(&renderer, blob_str(pIn));
1765 endAutoParagraph(&renderer);
1766 while( renderer.nStack ){
1767 popStack(&renderer);
1768 }
1769 blob_append_char(renderer.pOut, '\n');
1770 free(renderer.aStack);
1771 }
1772
1773 /*
1774 ** COMMAND: test-wiki-render
@@ -2204,14 +2204,14 @@
2204 if( eTag==MARKUP_PRE ){
2205 if( isCloseTag ){
2206 nPre--;
2207 blob_append(pOut, zIn, n);
2208 zIn += n;
2209 if( nPre==0 ){ blob_append_char(pOut, '\n'); iCur = 0; }
2210 continue;
2211 }else{
2212 if( iCur && nPre==0 ){ blob_append_char(pOut, '\n'); iCur = 0; }
2213 nPre++;
2214 }
2215 }else if( eType & (MUTYPE_BLOCK|MUTYPE_TABLE) ){
2216 if( !isCloseTag && nPre==0 && blob_size(pOut)>0 ){
2217 blob_append(pOut, "\n\n", 1 + (iCur>0));
@@ -2221,30 +2221,30 @@
2221 omitSpace = 1;
2222 }else if( (eType & (MUTYPE_LIST|MUTYPE_LI|MUTYPE_TR|MUTYPE_TD))!=0
2223 || eTag==MARKUP_HR
2224 ){
2225 if( nPre==0 && (!isCloseTag || (eType&MUTYPE_LIST)!=0) && iCur>0 ){
2226 blob_append_char(pOut, '\n');
2227 iCur = 0;
2228 }
2229 wantSpace = 0;
2230 omitSpace = 1;
2231 }
2232 if( wantSpace && nPre==0 ){
2233 if( iCur+n+1>=80 ){
2234 blob_append_char(pOut, '\n');
2235 iCur = 0;
2236 }else{
2237 blob_append_char(pOut, ' ');
2238 iCur++;
2239 }
2240 }
2241 blob_append(pOut, zIn, n);
2242 iCur += n;
2243 wantSpace = 0;
2244 if( eTag==MARKUP_BR || eTag==MARKUP_HR ){
2245 blob_append_char(pOut, '\n');
2246 iCur = 0;
2247 }
2248 }else if( fossil_isspace(zIn[0]) ){
2249 if( nPre ){
2250 blob_append(pOut, zIn, n);
@@ -2252,24 +2252,24 @@
2252 wantSpace = !omitSpace;
2253 }
2254 }else{
2255 if( wantSpace && nPre==0 ){
2256 if( iCur+n+1>=80 ){
2257 blob_append_char(pOut, '\n');
2258 iCur = 0;
2259 }else{
2260 blob_append_char(pOut, ' ');
2261 iCur++;
2262 }
2263 }
2264 blob_append(pOut, zIn, n);
2265 iCur += n;
2266 wantSpace = omitSpace = 0;
2267 }
2268 zIn += n;
2269 }
2270 if( iCur ) blob_append_char(pOut, '\n');
2271 }
2272
2273 /*
2274 ** COMMAND: test-html-tidy
2275 **
@@ -2332,11 +2332,11 @@
2332 if( eTag==MARKUP_TITLE ){
2333 inTitle = !isCloseTag;
2334 }
2335 if( !isCloseTag && seenText && (eType & (MUTYPE_BLOCK|MUTYPE_TABLE))!=0 ){
2336 if( nNL==0 ){
2337 blob_append_char(pOut, '\n');
2338 nNL++;
2339 }
2340 nWS = 1;
2341 }
2342 }else if( fossil_isspace(zIn[0]) ){
@@ -2344,11 +2344,11 @@
2344 nNL = 0;
2345 if( !inTitle ){ /* '\n' -> ' ' within <title> */
2346 for(i=0; i<n; i++) if( zIn[i]=='\n' ) nNL++;
2347 }
2348 if( !nWS ){
2349 blob_append_char(pOut, nNL ? '\n' : ' ');
2350 nWS = 1;
2351 }
2352 }
2353 }else if( zIn[0]=='&' ){
2354 char c = '?';
@@ -2369,28 +2369,28 @@
2369 break;
2370 }
2371 }
2372 }
2373 if( fossil_isspace(c) ){
2374 if( nWS==0 && seenText ) blob_append_char(pOut, c);
2375 nWS = 1;
2376 nNL = c=='\n';
2377 }else{
2378 if( !seenText && !inTitle ) blob_append_char(pOut, '\n');
2379 seenText = 1;
2380 nNL = nWS = 0;
2381 blob_append_char(pOut, c);
2382 }
2383 }else{
2384 if( !seenText && !inTitle ) blob_append_char(pOut, '\n');
2385 seenText = 1;
2386 nNL = nWS = 0;
2387 blob_append(pOut, zIn, n);
2388 }
2389 zIn += n;
2390 }
2391 if( nNL==0 ) blob_append_char(pOut, '\n');
2392 }
2393
2394 /*
2395 ** COMMAND: test-html-to-text
2396 **
2397

Keyboard Shortcuts

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