Fossil SCM

If file starts with UTF-32 BOM, always consider it binary without warning.

jan.nijtmans 2013-02-07 09:19 UTC simplify-starts-with
Commit c209105f0fded945b10ae4cdc1e8594bfaba1e9c
1 file changed +6 -2
+6 -2
--- src/diff.c
+++ src/diff.c
@@ -356,10 +356,14 @@
356356
}
357357
/* Only accept UTF-16 BOM if the blob has an even number of bytes */
358358
if( (blob_size(pContent)<2) || (blob_size(pContent)&1) ) return 0;
359359
c1 = *((unsigned short *)z);
360360
if( (c1==0xfffe) || (c1==0xfeff) ){
361
+ if( blob_size(pContent)>=4 ){
362
+ /* For UTF-32 BOM, always return 0. */
363
+ if( ((unsigned short *)z)[1] == 0 ) return 0;
364
+ }
361365
return 2;
362366
}
363367
return 0;
364368
}
365369
@@ -2324,11 +2328,11 @@
23242328
if( zLimit==0 || zLimit[0]==0 ) zLimit = "-1";
23252329
iLimit = atoi(zLimit);
23262330
showLog = find_option("log",0,0)!=0;
23272331
fileVers = find_option("filevers",0,0)!=0;
23282332
db_must_be_within_tree();
2329
- if (g.argc<3) {
2333
+ if( g.argc<3 ){
23302334
usage("FILENAME");
23312335
}
23322336
file_tree_name(g.argv[2], &treename, 1);
23332337
zFilename = blob_str(&treename);
23342338
fnid = db_int(0, "SELECT fnid FROM filename WHERE name=%Q", zFilename);
@@ -2338,11 +2342,11 @@
23382342
fid = db_int(0, "SELECT rid FROM vfile WHERE pathname=%Q", zFilename);
23392343
if( fid==0 ){
23402344
fossil_fatal("not part of current checkout: %s", zFilename);
23412345
}
23422346
cid = db_lget_int("checkout", 0);
2343
- if (cid == 0){
2347
+ if( cid == 0 ){
23442348
fossil_fatal("Not in a checkout");
23452349
}
23462350
if( iLimit<=0 ) iLimit = 1000000000;
23472351
compute_direct_ancestors(cid, iLimit);
23482352
mid = db_int(0, "SELECT mlink.mid FROM mlink, ancestor "
23492353
--- src/diff.c
+++ src/diff.c
@@ -356,10 +356,14 @@
356 }
357 /* Only accept UTF-16 BOM if the blob has an even number of bytes */
358 if( (blob_size(pContent)<2) || (blob_size(pContent)&1) ) return 0;
359 c1 = *((unsigned short *)z);
360 if( (c1==0xfffe) || (c1==0xfeff) ){
 
 
 
 
361 return 2;
362 }
363 return 0;
364 }
365
@@ -2324,11 +2328,11 @@
2324 if( zLimit==0 || zLimit[0]==0 ) zLimit = "-1";
2325 iLimit = atoi(zLimit);
2326 showLog = find_option("log",0,0)!=0;
2327 fileVers = find_option("filevers",0,0)!=0;
2328 db_must_be_within_tree();
2329 if (g.argc<3) {
2330 usage("FILENAME");
2331 }
2332 file_tree_name(g.argv[2], &treename, 1);
2333 zFilename = blob_str(&treename);
2334 fnid = db_int(0, "SELECT fnid FROM filename WHERE name=%Q", zFilename);
@@ -2338,11 +2342,11 @@
2338 fid = db_int(0, "SELECT rid FROM vfile WHERE pathname=%Q", zFilename);
2339 if( fid==0 ){
2340 fossil_fatal("not part of current checkout: %s", zFilename);
2341 }
2342 cid = db_lget_int("checkout", 0);
2343 if (cid == 0){
2344 fossil_fatal("Not in a checkout");
2345 }
2346 if( iLimit<=0 ) iLimit = 1000000000;
2347 compute_direct_ancestors(cid, iLimit);
2348 mid = db_int(0, "SELECT mlink.mid FROM mlink, ancestor "
2349
--- src/diff.c
+++ src/diff.c
@@ -356,10 +356,14 @@
356 }
357 /* Only accept UTF-16 BOM if the blob has an even number of bytes */
358 if( (blob_size(pContent)<2) || (blob_size(pContent)&1) ) return 0;
359 c1 = *((unsigned short *)z);
360 if( (c1==0xfffe) || (c1==0xfeff) ){
361 if( blob_size(pContent)>=4 ){
362 /* For UTF-32 BOM, always return 0. */
363 if( ((unsigned short *)z)[1] == 0 ) return 0;
364 }
365 return 2;
366 }
367 return 0;
368 }
369
@@ -2324,11 +2328,11 @@
2328 if( zLimit==0 || zLimit[0]==0 ) zLimit = "-1";
2329 iLimit = atoi(zLimit);
2330 showLog = find_option("log",0,0)!=0;
2331 fileVers = find_option("filevers",0,0)!=0;
2332 db_must_be_within_tree();
2333 if( g.argc<3 ){
2334 usage("FILENAME");
2335 }
2336 file_tree_name(g.argv[2], &treename, 1);
2337 zFilename = blob_str(&treename);
2338 fnid = db_int(0, "SELECT fnid FROM filename WHERE name=%Q", zFilename);
@@ -2338,11 +2342,11 @@
2342 fid = db_int(0, "SELECT rid FROM vfile WHERE pathname=%Q", zFilename);
2343 if( fid==0 ){
2344 fossil_fatal("not part of current checkout: %s", zFilename);
2345 }
2346 cid = db_lget_int("checkout", 0);
2347 if( cid == 0 ){
2348 fossil_fatal("Not in a checkout");
2349 }
2350 if( iLimit<=0 ) iLimit = 1000000000;
2351 compute_direct_ancestors(cid, iLimit);
2352 mid = db_int(0, "SELECT mlink.mid FROM mlink, ancestor "
2353

Keyboard Shortcuts

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