Fossil SCM
Fix the display of all web-pages which contain annotation- or diff-like sections for the case windows-style line endings are used: The CR's should be stripped in those cases.
Commit
1472cd811f29b1a5ebd8050b2d135fa50208b59f
Parent
0652717eb050ba5…
2 files changed
+8
-7
+1
-1
+8
-7
| --- src/diff.c | ||
| +++ src/diff.c | ||
| @@ -40,10 +40,11 @@ | ||
| 40 | 40 | #define DIFF_LINENO ((u64)0x40000000) /* Show line numbers */ |
| 41 | 41 | #define DIFF_NOOPT (((u64)0x01)<<32) /* Suppress optimizations (debug) */ |
| 42 | 42 | #define DIFF_INVERT (((u64)0x02)<<32) /* Invert the diff (debug) */ |
| 43 | 43 | #define DIFF_CONTEXT_EX (((u64)0x04)<<32) /* Use context even if zero */ |
| 44 | 44 | #define DIFF_NOTTOOBIG (((u64)0x08)<<32) /* Only display if not too big */ |
| 45 | +#define DIFF_STRIP_EOLCR (((u64)0x10)<<32) /* Strip trailing CR */ | |
| 45 | 46 | |
| 46 | 47 | /* |
| 47 | 48 | ** These error messages are shared in multiple locations. They are defined |
| 48 | 49 | ** here for consistency. |
| 49 | 50 | */ |
| @@ -165,10 +166,13 @@ | ||
| 165 | 166 | |
| 166 | 167 | /* Fill in the array */ |
| 167 | 168 | for(i=0; i<nLine; i++){ |
| 168 | 169 | for(j=0; z[j] && z[j]!='\n'; j++){} |
| 169 | 170 | a[i].z = z; |
| 171 | + if( diffFlags & DIFF_STRIP_EOLCR ){ | |
| 172 | + if( k>0 && z[k-1]=='\r' ){ k--; } | |
| 173 | + } | |
| 170 | 174 | a[i].n = k = j; |
| 171 | 175 | s = 0; |
| 172 | 176 | if( diffFlags & DIFF_IGNORE_EOLWS ){ |
| 173 | 177 | while( k>0 && fossil_isspace(z[k-1]) ){ k--; } |
| 174 | 178 | } |
| @@ -227,21 +231,18 @@ | ||
| 227 | 231 | int html, /* True if generating HTML. False for plain text */ |
| 228 | 232 | ReCompiled *pRe /* Colorize only if line matches this Regex */ |
| 229 | 233 | ){ |
| 230 | 234 | blob_append(pOut, &cPrefix, 1); |
| 231 | 235 | if( html ){ |
| 232 | - int n; | |
| 233 | 236 | if( pRe && re_dline_match(pRe, pLine, 1)==0 ){ |
| 234 | 237 | cPrefix = ' '; |
| 235 | 238 | }else if( cPrefix=='+' ){ |
| 236 | 239 | blob_append(pOut, "<span class=\"diffadd\">", -1); |
| 237 | 240 | }else if( cPrefix=='-' ){ |
| 238 | 241 | blob_append(pOut, "<span class=\"diffrm\">", -1); |
| 239 | 242 | } |
| 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 | + htmlize_to_blob(pOut, pLine->z, pLine->n); | |
| 243 | 244 | if( cPrefix!=' ' ){ |
| 244 | 245 | blob_append(pOut, "</span>", -1); |
| 245 | 246 | } |
| 246 | 247 | }else{ |
| 247 | 248 | blob_append(pOut, pLine->z, pLine->n); |
| @@ -1957,11 +1958,11 @@ | ||
| 1957 | 1958 | typedef struct Annotator Annotator; |
| 1958 | 1959 | struct Annotator { |
| 1959 | 1960 | DContext c; /* The diff-engine context */ |
| 1960 | 1961 | struct AnnLine { /* Lines of the original files... */ |
| 1961 | 1962 | const char *z; /* The text of the line */ |
| 1962 | - short int n; /* Number of bytes (omitting trailing space and \n) */ | |
| 1963 | + short int n; /* Number of bytes (omitting trailing \n) */ | |
| 1963 | 1964 | short int iVers; /* Level at which tag was set */ |
| 1964 | 1965 | } *aOrig; |
| 1965 | 1966 | int nOrig; /* Number of elements in aOrig[] */ |
| 1966 | 1967 | int nVers; /* Number of versions analyzed */ |
| 1967 | 1968 | int bLimit; /* True if the iLimit was reached */ |
| @@ -2171,11 +2172,11 @@ | ||
| 2171 | 2172 | void annotation_page(void){ |
| 2172 | 2173 | int mid; |
| 2173 | 2174 | int fnid; |
| 2174 | 2175 | int i; |
| 2175 | 2176 | int iLimit; /* Depth limit */ |
| 2176 | - u64 annFlags = ANN_FILE_ANCEST; | |
| 2177 | + u64 annFlags = (ANN_FILE_ANCEST|DIFF_STRIP_EOLCR); | |
| 2177 | 2178 | int showLog = 0; /* True to display the log */ |
| 2178 | 2179 | int ignoreWs = 0; /* Ignore whitespace */ |
| 2179 | 2180 | const char *zFilename; /* Name of file to annotate */ |
| 2180 | 2181 | const char *zCI; /* The check-in containing zFilename */ |
| 2181 | 2182 | Annotator ann; |
| @@ -2407,11 +2408,11 @@ | ||
| 2407 | 2408 | " ORDER BY ancestor.generation ASC LIMIT 1", |
| 2408 | 2409 | fid, fnid); |
| 2409 | 2410 | if( mid==0 ){ |
| 2410 | 2411 | fossil_fatal("unable to find manifest"); |
| 2411 | 2412 | } |
| 2412 | - annFlags |= ANN_FILE_ANCEST; | |
| 2413 | + annFlags |= (ANN_FILE_ANCEST|DIFF_STRIP_EOLCR); | |
| 2413 | 2414 | annotate_file(&ann, fnid, mid, iLimit, annFlags); |
| 2414 | 2415 | if( showLog ){ |
| 2415 | 2416 | struct AnnVers *p; |
| 2416 | 2417 | for(p=ann.aVers, i=0; i<ann.nVers; i++, p++){ |
| 2417 | 2418 | fossil_print("version %3d: %s %.10s file %.10s\n", |
| 2418 | 2419 |
| --- src/diff.c | |
| +++ src/diff.c | |
| @@ -40,10 +40,11 @@ | |
| 40 | #define DIFF_LINENO ((u64)0x40000000) /* Show line numbers */ |
| 41 | #define DIFF_NOOPT (((u64)0x01)<<32) /* Suppress optimizations (debug) */ |
| 42 | #define DIFF_INVERT (((u64)0x02)<<32) /* Invert the diff (debug) */ |
| 43 | #define DIFF_CONTEXT_EX (((u64)0x04)<<32) /* Use context even if zero */ |
| 44 | #define DIFF_NOTTOOBIG (((u64)0x08)<<32) /* Only display if not too big */ |
| 45 | |
| 46 | /* |
| 47 | ** These error messages are shared in multiple locations. They are defined |
| 48 | ** here for consistency. |
| 49 | */ |
| @@ -165,10 +166,13 @@ | |
| 165 | |
| 166 | /* Fill in the array */ |
| 167 | for(i=0; i<nLine; i++){ |
| 168 | for(j=0; z[j] && z[j]!='\n'; j++){} |
| 169 | a[i].z = z; |
| 170 | a[i].n = k = j; |
| 171 | s = 0; |
| 172 | if( diffFlags & DIFF_IGNORE_EOLWS ){ |
| 173 | while( k>0 && fossil_isspace(z[k-1]) ){ k--; } |
| 174 | } |
| @@ -227,21 +231,18 @@ | |
| 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); |
| @@ -1957,11 +1958,11 @@ | |
| 1957 | typedef struct Annotator Annotator; |
| 1958 | struct Annotator { |
| 1959 | DContext c; /* The diff-engine context */ |
| 1960 | struct AnnLine { /* Lines of the original files... */ |
| 1961 | const char *z; /* The text of the line */ |
| 1962 | short int n; /* Number of bytes (omitting trailing space and \n) */ |
| 1963 | short int iVers; /* Level at which tag was set */ |
| 1964 | } *aOrig; |
| 1965 | int nOrig; /* Number of elements in aOrig[] */ |
| 1966 | int nVers; /* Number of versions analyzed */ |
| 1967 | int bLimit; /* True if the iLimit was reached */ |
| @@ -2171,11 +2172,11 @@ | |
| 2171 | void annotation_page(void){ |
| 2172 | int mid; |
| 2173 | int fnid; |
| 2174 | int i; |
| 2175 | int iLimit; /* Depth limit */ |
| 2176 | u64 annFlags = ANN_FILE_ANCEST; |
| 2177 | int showLog = 0; /* True to display the log */ |
| 2178 | int ignoreWs = 0; /* Ignore whitespace */ |
| 2179 | const char *zFilename; /* Name of file to annotate */ |
| 2180 | const char *zCI; /* The check-in containing zFilename */ |
| 2181 | Annotator ann; |
| @@ -2407,11 +2408,11 @@ | |
| 2407 | " ORDER BY ancestor.generation ASC LIMIT 1", |
| 2408 | fid, fnid); |
| 2409 | if( mid==0 ){ |
| 2410 | fossil_fatal("unable to find manifest"); |
| 2411 | } |
| 2412 | annFlags |= ANN_FILE_ANCEST; |
| 2413 | annotate_file(&ann, fnid, mid, iLimit, annFlags); |
| 2414 | if( showLog ){ |
| 2415 | struct AnnVers *p; |
| 2416 | for(p=ann.aVers, i=0; i<ann.nVers; i++, p++){ |
| 2417 | fossil_print("version %3d: %s %.10s file %.10s\n", |
| 2418 |
| --- src/diff.c | |
| +++ src/diff.c | |
| @@ -40,10 +40,11 @@ | |
| 40 | #define DIFF_LINENO ((u64)0x40000000) /* Show line numbers */ |
| 41 | #define DIFF_NOOPT (((u64)0x01)<<32) /* Suppress optimizations (debug) */ |
| 42 | #define DIFF_INVERT (((u64)0x02)<<32) /* Invert the diff (debug) */ |
| 43 | #define DIFF_CONTEXT_EX (((u64)0x04)<<32) /* Use context even if zero */ |
| 44 | #define DIFF_NOTTOOBIG (((u64)0x08)<<32) /* Only display if not too big */ |
| 45 | #define DIFF_STRIP_EOLCR (((u64)0x10)<<32) /* Strip trailing CR */ |
| 46 | |
| 47 | /* |
| 48 | ** These error messages are shared in multiple locations. They are defined |
| 49 | ** here for consistency. |
| 50 | */ |
| @@ -165,10 +166,13 @@ | |
| 166 | |
| 167 | /* Fill in the array */ |
| 168 | for(i=0; i<nLine; i++){ |
| 169 | for(j=0; z[j] && z[j]!='\n'; j++){} |
| 170 | a[i].z = z; |
| 171 | if( diffFlags & DIFF_STRIP_EOLCR ){ |
| 172 | if( k>0 && z[k-1]=='\r' ){ k--; } |
| 173 | } |
| 174 | a[i].n = k = j; |
| 175 | s = 0; |
| 176 | if( diffFlags & DIFF_IGNORE_EOLWS ){ |
| 177 | while( k>0 && fossil_isspace(z[k-1]) ){ k--; } |
| 178 | } |
| @@ -227,21 +231,18 @@ | |
| 231 | int html, /* True if generating HTML. False for plain text */ |
| 232 | ReCompiled *pRe /* Colorize only if line matches this Regex */ |
| 233 | ){ |
| 234 | blob_append(pOut, &cPrefix, 1); |
| 235 | if( html ){ |
| 236 | if( pRe && re_dline_match(pRe, pLine, 1)==0 ){ |
| 237 | cPrefix = ' '; |
| 238 | }else if( cPrefix=='+' ){ |
| 239 | blob_append(pOut, "<span class=\"diffadd\">", -1); |
| 240 | }else if( cPrefix=='-' ){ |
| 241 | blob_append(pOut, "<span class=\"diffrm\">", -1); |
| 242 | } |
| 243 | htmlize_to_blob(pOut, pLine->z, pLine->n); |
| 244 | if( cPrefix!=' ' ){ |
| 245 | blob_append(pOut, "</span>", -1); |
| 246 | } |
| 247 | }else{ |
| 248 | blob_append(pOut, pLine->z, pLine->n); |
| @@ -1957,11 +1958,11 @@ | |
| 1958 | typedef struct Annotator Annotator; |
| 1959 | struct Annotator { |
| 1960 | DContext c; /* The diff-engine context */ |
| 1961 | struct AnnLine { /* Lines of the original files... */ |
| 1962 | const char *z; /* The text of the line */ |
| 1963 | short int n; /* Number of bytes (omitting trailing \n) */ |
| 1964 | short int iVers; /* Level at which tag was set */ |
| 1965 | } *aOrig; |
| 1966 | int nOrig; /* Number of elements in aOrig[] */ |
| 1967 | int nVers; /* Number of versions analyzed */ |
| 1968 | int bLimit; /* True if the iLimit was reached */ |
| @@ -2171,11 +2172,11 @@ | |
| 2172 | void annotation_page(void){ |
| 2173 | int mid; |
| 2174 | int fnid; |
| 2175 | int i; |
| 2176 | int iLimit; /* Depth limit */ |
| 2177 | u64 annFlags = (ANN_FILE_ANCEST|DIFF_STRIP_EOLCR); |
| 2178 | int showLog = 0; /* True to display the log */ |
| 2179 | int ignoreWs = 0; /* Ignore whitespace */ |
| 2180 | const char *zFilename; /* Name of file to annotate */ |
| 2181 | const char *zCI; /* The check-in containing zFilename */ |
| 2182 | Annotator ann; |
| @@ -2407,11 +2408,11 @@ | |
| 2408 | " ORDER BY ancestor.generation ASC LIMIT 1", |
| 2409 | fid, fnid); |
| 2410 | if( mid==0 ){ |
| 2411 | fossil_fatal("unable to find manifest"); |
| 2412 | } |
| 2413 | annFlags |= (ANN_FILE_ANCEST|DIFF_STRIP_EOLCR); |
| 2414 | annotate_file(&ann, fnid, mid, iLimit, annFlags); |
| 2415 | if( showLog ){ |
| 2416 | struct AnnVers *p; |
| 2417 | for(p=ann.aVers, i=0; i<ann.nVers; i++, p++){ |
| 2418 | fossil_print("version %3d: %s %.10s file %.10s\n", |
| 2419 |
+1
-1
| --- src/info.c | ||
| +++ src/info.c | ||
| @@ -470,11 +470,11 @@ | ||
| 470 | 470 | diffFlags += x; |
| 471 | 471 | |
| 472 | 472 | /* The "noopt" parameter disables diff optimization */ |
| 473 | 473 | if( PD("noopt",0)!=0 ) diffFlags |= DIFF_NOOPT; |
| 474 | 474 | } |
| 475 | - return diffFlags; | |
| 475 | + return diffFlags|DIFF_STRIP_EOLCR; | |
| 476 | 476 | } |
| 477 | 477 | |
| 478 | 478 | /* |
| 479 | 479 | ** WEBPAGE: vinfo |
| 480 | 480 | ** WEBPAGE: ci |
| 481 | 481 |
| --- src/info.c | |
| +++ src/info.c | |
| @@ -470,11 +470,11 @@ | |
| 470 | diffFlags += x; |
| 471 | |
| 472 | /* The "noopt" parameter disables diff optimization */ |
| 473 | if( PD("noopt",0)!=0 ) diffFlags |= DIFF_NOOPT; |
| 474 | } |
| 475 | return diffFlags; |
| 476 | } |
| 477 | |
| 478 | /* |
| 479 | ** WEBPAGE: vinfo |
| 480 | ** WEBPAGE: ci |
| 481 |
| --- src/info.c | |
| +++ src/info.c | |
| @@ -470,11 +470,11 @@ | |
| 470 | diffFlags += x; |
| 471 | |
| 472 | /* The "noopt" parameter disables diff optimization */ |
| 473 | if( PD("noopt",0)!=0 ) diffFlags |= DIFF_NOOPT; |
| 474 | } |
| 475 | return diffFlags|DIFF_STRIP_EOLCR; |
| 476 | } |
| 477 | |
| 478 | /* |
| 479 | ** WEBPAGE: vinfo |
| 480 | ** WEBPAGE: ci |
| 481 |