Fossil SCM
Fix the display of unified-diff lines on web pages when the files being compared have windows-style line endings.
Commit
e2e8531ba76915e3db1c96b4637184ee3b5a15cb
Parent
625297ab91063d8…
1 file changed
+4
-1
+4
-1
| --- src/diff.c | ||
| +++ src/diff.c | ||
| @@ -227,18 +227,21 @@ | ||
| 227 | 227 | int html, /* True if generating HTML. False for plain text */ |
| 228 | 228 | ReCompiled *pRe /* Colorize only if line matches this Regex */ |
| 229 | 229 | ){ |
| 230 | 230 | blob_append(pOut, &cPrefix, 1); |
| 231 | 231 | if( html ){ |
| 232 | + int n; | |
| 232 | 233 | if( pRe && re_dline_match(pRe, pLine, 1)==0 ){ |
| 233 | 234 | cPrefix = ' '; |
| 234 | 235 | }else if( cPrefix=='+' ){ |
| 235 | 236 | blob_append(pOut, "<span class=\"diffadd\">", -1); |
| 236 | 237 | }else if( cPrefix=='-' ){ |
| 237 | 238 | blob_append(pOut, "<span class=\"diffrm\">", -1); |
| 238 | 239 | } |
| 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); | |
| 240 | 243 | if( cPrefix!=' ' ){ |
| 241 | 244 | blob_append(pOut, "</span>", -1); |
| 242 | 245 | } |
| 243 | 246 | }else{ |
| 244 | 247 | blob_append(pOut, pLine->z, pLine->n); |
| 245 | 248 |
| --- 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 |