Fossil SCM
Distinguish between a deleted file and a binary file in the side-by-side diff generator. Fix for a bug introduced by check-in [233e9328ee639b].
Commit
1438be02d02f27e78690560bca2d5985ad49bba6
Parent
caea288c2df6f80…
1 file changed
+4
-3
+4
-3
| --- src/diff.c | ||
| +++ src/diff.c | ||
| @@ -142,21 +142,22 @@ | ||
| 142 | 142 | int nLine, i, k, nn, s, x; |
| 143 | 143 | unsigned int h, h2; |
| 144 | 144 | DLine *a; |
| 145 | 145 | const char *zNL, *z2; |
| 146 | 146 | |
| 147 | - /* Early-out for the degenerate case */ | |
| 148 | - if( n==0 ) return 0; | |
| 149 | - | |
| 150 | 147 | /* Count the number of lines in the input file. Include the last line |
| 151 | 148 | ** in the count even if it lacks the \n terminator |
| 152 | 149 | */ |
| 153 | 150 | for(nLine=0, z2=z; (zNL = strchr(z2,'\n'))!=0; z2=zNL+1, nLine++){} |
| 154 | 151 | if( z2[0]!=0 ) nLine++; |
| 155 | 152 | |
| 156 | 153 | a = fossil_malloc( sizeof(a[0])*nLine ); |
| 157 | 154 | memset(a, 0, sizeof(a[0])*nLine); |
| 155 | + if( nLine==0 ){ | |
| 156 | + *pnLine = 0; | |
| 157 | + return a; | |
| 158 | + } | |
| 158 | 159 | i = 0; |
| 159 | 160 | do{ |
| 160 | 161 | zNL = strchr(z,'\n'); |
| 161 | 162 | if( zNL==0 ) zNL = z+strlen(z); |
| 162 | 163 | nn = (int)(zNL - z); |
| 163 | 164 |
| --- src/diff.c | |
| +++ src/diff.c | |
| @@ -142,21 +142,22 @@ | |
| 142 | int nLine, i, k, nn, s, x; |
| 143 | unsigned int h, h2; |
| 144 | DLine *a; |
| 145 | const char *zNL, *z2; |
| 146 | |
| 147 | /* Early-out for the degenerate case */ |
| 148 | if( n==0 ) return 0; |
| 149 | |
| 150 | /* Count the number of lines in the input file. Include the last line |
| 151 | ** in the count even if it lacks the \n terminator |
| 152 | */ |
| 153 | for(nLine=0, z2=z; (zNL = strchr(z2,'\n'))!=0; z2=zNL+1, nLine++){} |
| 154 | if( z2[0]!=0 ) nLine++; |
| 155 | |
| 156 | a = fossil_malloc( sizeof(a[0])*nLine ); |
| 157 | memset(a, 0, sizeof(a[0])*nLine); |
| 158 | i = 0; |
| 159 | do{ |
| 160 | zNL = strchr(z,'\n'); |
| 161 | if( zNL==0 ) zNL = z+strlen(z); |
| 162 | nn = (int)(zNL - z); |
| 163 |
| --- src/diff.c | |
| +++ src/diff.c | |
| @@ -142,21 +142,22 @@ | |
| 142 | int nLine, i, k, nn, s, x; |
| 143 | unsigned int h, h2; |
| 144 | DLine *a; |
| 145 | const char *zNL, *z2; |
| 146 | |
| 147 | /* Count the number of lines in the input file. Include the last line |
| 148 | ** in the count even if it lacks the \n terminator |
| 149 | */ |
| 150 | for(nLine=0, z2=z; (zNL = strchr(z2,'\n'))!=0; z2=zNL+1, nLine++){} |
| 151 | if( z2[0]!=0 ) nLine++; |
| 152 | |
| 153 | a = fossil_malloc( sizeof(a[0])*nLine ); |
| 154 | memset(a, 0, sizeof(a[0])*nLine); |
| 155 | if( nLine==0 ){ |
| 156 | *pnLine = 0; |
| 157 | return a; |
| 158 | } |
| 159 | i = 0; |
| 160 | do{ |
| 161 | zNL = strchr(z,'\n'); |
| 162 | if( zNL==0 ) zNL = z+strlen(z); |
| 163 | nn = (int)(zNL - z); |
| 164 |