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].

drh 2016-09-29 11:59 trunk
Commit 1438be02d02f27e78690560bca2d5985ad49bba6
1 file changed +4 -3
+4 -3
--- src/diff.c
+++ src/diff.c
@@ -142,21 +142,22 @@
142142
int nLine, i, k, nn, s, x;
143143
unsigned int h, h2;
144144
DLine *a;
145145
const char *zNL, *z2;
146146
147
- /* Early-out for the degenerate case */
148
- if( n==0 ) return 0;
149
-
150147
/* Count the number of lines in the input file. Include the last line
151148
** in the count even if it lacks the \n terminator
152149
*/
153150
for(nLine=0, z2=z; (zNL = strchr(z2,'\n'))!=0; z2=zNL+1, nLine++){}
154151
if( z2[0]!=0 ) nLine++;
155152
156153
a = fossil_malloc( sizeof(a[0])*nLine );
157154
memset(a, 0, sizeof(a[0])*nLine);
155
+ if( nLine==0 ){
156
+ *pnLine = 0;
157
+ return a;
158
+ }
158159
i = 0;
159160
do{
160161
zNL = strchr(z,'\n');
161162
if( zNL==0 ) zNL = z+strlen(z);
162163
nn = (int)(zNL - z);
163164
--- 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

Keyboard Shortcuts

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