Fossil SCM

don't forget to compensate for the line-length check

jan.nijtmans 2012-11-02 14:22 improve_commit_warning
Commit 9011fe122662ecb25c79e7bcd7038d1f489897e6
1 file changed +7 -7
+7 -7
--- src/diff.c
+++ src/diff.c
@@ -202,36 +202,36 @@
202202
203203
/* Check individual lines.
204204
*/
205205
if( n==0 ) return result; /* Empty file -> text */
206206
c = *z;
207
+ j = (c!='\n');
207208
if( c<0x80 ){
208209
if( c==0 ) return 0; /* Zero byte in a file -> binary */
209210
}else if( c<0xC0 ){
210211
result = -2; /* Invalid UTF-8, continue */
211212
}else if( c<0xE0 ){
212213
if( n<2 || ((z[1]&0xC0)!=0x80) ){
213214
result = -2; /* Invalid 2-byte UTF-8, continue */
214215
}else{
215
- --n; ++z;
216
+ --n; ++j; ++z;
216217
}
217218
}else if( c<0xF0 ){
218219
if( n<3 || ((z[1]&0xC0)!=0x80) || ((z[2]&0xC0)!=0x80) ){
219220
result = -2; /* Invalid 3-byte UTF-8, continue */
220221
}else{
221
- n-=2; z+=2;
222
+ n-=2; j+=2; z+=2;
222223
}
223224
}else if( c<0xF8 ){
224225
if( n<4 || ((z[1]&0xC0)!=0x80) || ((z[2]&0xC0)!=0x80) || ((z[3]&0xC0)!=0x80) ){
225226
result = -2; /* Invalid 4-byte UTF-8, continue */
226227
}else{
227
- n-=3; z+=3;
228
+ n-=3; j+=3; z+=3;
228229
}
229230
}else{
230231
result = -2; /* Invalid multi-byte UTF-8, continue */
231232
}
232
- j = (c!='\n');
233233
while( --n>0 ){
234234
c = *++z; ++j;
235235
if( c<0x80 ){
236236
if( c==0 ) return 0; /* Zero byte in a file -> binary */
237237
if( c=='\n' ){
@@ -248,21 +248,21 @@
248248
result = -2; /* Invalid UTF-8, continue */
249249
}else if( c<0xE0 ){
250250
if( n<2 || ((z[1]&0xC0)!=0x80) ){
251251
result = -2; continue; /* Invalid 2-byte UTF-8, continue */
252252
}
253
- --n; ++z;
253
+ --n; ++j; ++z;
254254
}else if( c<0xF0 ){
255255
if( n<3 || ((z[1]&0xC0)!=0x80) || ((z[2]&0xC0)!=0x80) ){
256256
result = -2; continue; /* Invalid 3-byte UTF-8, continue */
257257
}
258
- n-=2; z+=2;
258
+ n-=2; j+=2; z+=2;
259259
}else if( c<0xF8 ){
260260
if( n<4 || ((z[1]&0xC0)!=0x80) || ((z[2]&0xC0)!=0x80) || ((z[3]&0xC0)!=0x80) ){
261261
result = -2; continue; /* Invalid 4-byte UTF-8, continue */
262262
}
263
- n-=3; z+=3;
263
+ n-=3; j+=3; z+=3;
264264
}else{
265265
result = -2; /* Invalid multi-byte UTF-8, continue */
266266
}
267267
}
268268
if( j>LENGTH_MASK ){
269269
--- src/diff.c
+++ src/diff.c
@@ -202,36 +202,36 @@
202
203 /* Check individual lines.
204 */
205 if( n==0 ) return result; /* Empty file -> text */
206 c = *z;
 
207 if( c<0x80 ){
208 if( c==0 ) return 0; /* Zero byte in a file -> binary */
209 }else if( c<0xC0 ){
210 result = -2; /* Invalid UTF-8, continue */
211 }else if( c<0xE0 ){
212 if( n<2 || ((z[1]&0xC0)!=0x80) ){
213 result = -2; /* Invalid 2-byte UTF-8, continue */
214 }else{
215 --n; ++z;
216 }
217 }else if( c<0xF0 ){
218 if( n<3 || ((z[1]&0xC0)!=0x80) || ((z[2]&0xC0)!=0x80) ){
219 result = -2; /* Invalid 3-byte UTF-8, continue */
220 }else{
221 n-=2; z+=2;
222 }
223 }else if( c<0xF8 ){
224 if( n<4 || ((z[1]&0xC0)!=0x80) || ((z[2]&0xC0)!=0x80) || ((z[3]&0xC0)!=0x80) ){
225 result = -2; /* Invalid 4-byte UTF-8, continue */
226 }else{
227 n-=3; z+=3;
228 }
229 }else{
230 result = -2; /* Invalid multi-byte UTF-8, continue */
231 }
232 j = (c!='\n');
233 while( --n>0 ){
234 c = *++z; ++j;
235 if( c<0x80 ){
236 if( c==0 ) return 0; /* Zero byte in a file -> binary */
237 if( c=='\n' ){
@@ -248,21 +248,21 @@
248 result = -2; /* Invalid UTF-8, continue */
249 }else if( c<0xE0 ){
250 if( n<2 || ((z[1]&0xC0)!=0x80) ){
251 result = -2; continue; /* Invalid 2-byte UTF-8, continue */
252 }
253 --n; ++z;
254 }else if( c<0xF0 ){
255 if( n<3 || ((z[1]&0xC0)!=0x80) || ((z[2]&0xC0)!=0x80) ){
256 result = -2; continue; /* Invalid 3-byte UTF-8, continue */
257 }
258 n-=2; z+=2;
259 }else if( c<0xF8 ){
260 if( n<4 || ((z[1]&0xC0)!=0x80) || ((z[2]&0xC0)!=0x80) || ((z[3]&0xC0)!=0x80) ){
261 result = -2; continue; /* Invalid 4-byte UTF-8, continue */
262 }
263 n-=3; z+=3;
264 }else{
265 result = -2; /* Invalid multi-byte UTF-8, continue */
266 }
267 }
268 if( j>LENGTH_MASK ){
269
--- src/diff.c
+++ src/diff.c
@@ -202,36 +202,36 @@
202
203 /* Check individual lines.
204 */
205 if( n==0 ) return result; /* Empty file -> text */
206 c = *z;
207 j = (c!='\n');
208 if( c<0x80 ){
209 if( c==0 ) return 0; /* Zero byte in a file -> binary */
210 }else if( c<0xC0 ){
211 result = -2; /* Invalid UTF-8, continue */
212 }else if( c<0xE0 ){
213 if( n<2 || ((z[1]&0xC0)!=0x80) ){
214 result = -2; /* Invalid 2-byte UTF-8, continue */
215 }else{
216 --n; ++j; ++z;
217 }
218 }else if( c<0xF0 ){
219 if( n<3 || ((z[1]&0xC0)!=0x80) || ((z[2]&0xC0)!=0x80) ){
220 result = -2; /* Invalid 3-byte UTF-8, continue */
221 }else{
222 n-=2; j+=2; z+=2;
223 }
224 }else if( c<0xF8 ){
225 if( n<4 || ((z[1]&0xC0)!=0x80) || ((z[2]&0xC0)!=0x80) || ((z[3]&0xC0)!=0x80) ){
226 result = -2; /* Invalid 4-byte UTF-8, continue */
227 }else{
228 n-=3; j+=3; z+=3;
229 }
230 }else{
231 result = -2; /* Invalid multi-byte UTF-8, continue */
232 }
 
233 while( --n>0 ){
234 c = *++z; ++j;
235 if( c<0x80 ){
236 if( c==0 ) return 0; /* Zero byte in a file -> binary */
237 if( c=='\n' ){
@@ -248,21 +248,21 @@
248 result = -2; /* Invalid UTF-8, continue */
249 }else if( c<0xE0 ){
250 if( n<2 || ((z[1]&0xC0)!=0x80) ){
251 result = -2; continue; /* Invalid 2-byte UTF-8, continue */
252 }
253 --n; ++j; ++z;
254 }else if( c<0xF0 ){
255 if( n<3 || ((z[1]&0xC0)!=0x80) || ((z[2]&0xC0)!=0x80) ){
256 result = -2; continue; /* Invalid 3-byte UTF-8, continue */
257 }
258 n-=2; j+=2; z+=2;
259 }else if( c<0xF8 ){
260 if( n<4 || ((z[1]&0xC0)!=0x80) || ((z[2]&0xC0)!=0x80) || ((z[3]&0xC0)!=0x80) ){
261 result = -2; continue; /* Invalid 4-byte UTF-8, continue */
262 }
263 n-=3; j+=3; z+=3;
264 }else{
265 result = -2; /* Invalid multi-byte UTF-8, continue */
266 }
267 }
268 if( j>LENGTH_MASK ){
269

Keyboard Shortcuts

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