Fossil SCM

Fix the display of unified-diff lines on web pages when the files being compared have windows-style line endings.

drh 2014-03-14 20:49 trunk
Commit e2e8531ba76915e3db1c96b4637184ee3b5a15cb
1 file changed +4 -1
+4 -1
--- src/diff.c
+++ src/diff.c
@@ -227,18 +227,21 @@
227227
int html, /* True if generating HTML. False for plain text */
228228
ReCompiled *pRe /* Colorize only if line matches this Regex */
229229
){
230230
blob_append(pOut, &cPrefix, 1);
231231
if( html ){
232
+ int n;
232233
if( pRe && re_dline_match(pRe, pLine, 1)==0 ){
233234
cPrefix = ' ';
234235
}else if( cPrefix=='+' ){
235236
blob_append(pOut, "<span class=\"diffadd\">", -1);
236237
}else if( cPrefix=='-' ){
237238
blob_append(pOut, "<span class=\"diffrm\">", -1);
238239
}
239
- htmlize_to_blob(pOut, pLine->z, pLine->n);
240
+ n = pLine->n;
241
+ while( n>0 && (pLine->z[n-1]=='\n' || pLine->z[n-1]=='\r') ) n--;
242
+ htmlize_to_blob(pOut, pLine->z, n);
240243
if( cPrefix!=' ' ){
241244
blob_append(pOut, "</span>", -1);
242245
}
243246
}else{
244247
blob_append(pOut, pLine->z, pLine->n);
245248
--- src/diff.c
+++ src/diff.c
@@ -227,18 +227,21 @@
227 int html, /* True if generating HTML. False for plain text */
228 ReCompiled *pRe /* Colorize only if line matches this Regex */
229 ){
230 blob_append(pOut, &cPrefix, 1);
231 if( html ){
 
232 if( pRe && re_dline_match(pRe, pLine, 1)==0 ){
233 cPrefix = ' ';
234 }else if( cPrefix=='+' ){
235 blob_append(pOut, "<span class=\"diffadd\">", -1);
236 }else if( cPrefix=='-' ){
237 blob_append(pOut, "<span class=\"diffrm\">", -1);
238 }
239 htmlize_to_blob(pOut, pLine->z, pLine->n);
 
 
240 if( cPrefix!=' ' ){
241 blob_append(pOut, "</span>", -1);
242 }
243 }else{
244 blob_append(pOut, pLine->z, pLine->n);
245
--- src/diff.c
+++ src/diff.c
@@ -227,18 +227,21 @@
227 int html, /* True if generating HTML. False for plain text */
228 ReCompiled *pRe /* Colorize only if line matches this Regex */
229 ){
230 blob_append(pOut, &cPrefix, 1);
231 if( html ){
232 int n;
233 if( pRe && re_dline_match(pRe, pLine, 1)==0 ){
234 cPrefix = ' ';
235 }else if( cPrefix=='+' ){
236 blob_append(pOut, "<span class=\"diffadd\">", -1);
237 }else if( cPrefix=='-' ){
238 blob_append(pOut, "<span class=\"diffrm\">", -1);
239 }
240 n = pLine->n;
241 while( n>0 && (pLine->z[n-1]=='\n' || pLine->z[n-1]=='\r') ) n--;
242 htmlize_to_blob(pOut, pLine->z, n);
243 if( cPrefix!=' ' ){
244 blob_append(pOut, "</span>", -1);
245 }
246 }else{
247 blob_append(pOut, pLine->z, pLine->n);
248

Keyboard Shortcuts

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