376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
|
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
|
-
-
+
+
-
+
-
+
-
-
-
+
+
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
-
-
-
-
-
+
-
-
-
-
-
-
+
-
-
-
-
+
+
+
-
-
-
-
-
+
-
-
+
-
-
-
-
-
-
-
-
+
-
-
-
-
-
+
|
0xEF, 0xBB, 0xBF, 0x00, 0x00, 0x00
};
if( pnByte ) *pnByte = 3;
return bom;
}
/*
** This function returns non-zero if the blob starts with a UTF-8
** byte-order-mark (BOM).
** This function returns detected BOM size if the blob starts with
** a UTF-8, UTF-16le or UTF-16be byte-order-mark (BOM).
*/
int starts_with_utf8_bom(const Blob *pContent, int *pnByte){
int starts_with_bom(const Blob *pContent){
const char *z = blob_buffer(pContent);
int bomSize = 0;
int c1, bomSize = 0;
const unsigned char *bom = get_utf8_bom(&bomSize);
if( pnByte ) *pnByte = bomSize;
if( blob_size(pContent)<bomSize ) return 0;
return memcmp(z, bom, bomSize)==0;
if( (blob_size(pContent)>=bomSize)
&& (memcmp(z, bom, bomSize)==0) ){
}
/*
** This function returns non-zero if the blob starts with a UTF-16le or
** UTF-16be byte-order-mark (BOM).
*/
int starts_with_utf16_bom(const Blob *pContent, int *pnByte){
const char *z = blob_buffer(pContent);
int c1, c2;
if( pnByte ) *pnByte = 2;
if( blob_size(pContent)<2 ) return 0;
c1 = z[0]; c2 = z[1];
if( (c1==(char)0xff) && (c2==(char)0xfe) ){
return 1;
return bomSize;
}else if( (c1==(char)0xfe) && (c2==(char)0xff) ){
return 1;
}
return 0;
}
/* Only accept UTF-16 BOM if the blob has an even number of bytes */
/*
** This function returns non-zero if the blob starts with a UTF-16le
** byte-order-mark (BOM).
*/
int starts_with_utf16le_bom(const Blob *pContent, int *pnByte){
const char *z = blob_buffer(pContent);
if( (blob_size(pContent)<2) || (blob_size(pContent)&1) ) return 0;
int c1, c2;
if( pnByte ) *pnByte = 2;
if( blob_size(pContent)<2 ) return 0;
c1 = *((unsigned short *)z);
if( (c1==0xfffe) || (c1==0xfeff) ){
if( blob_size(pContent)>=4 ){
c1 = z[0]; c2 = z[1];
if( (c1==(char)0xff) && (c2==(char)0xfe) ){
return 1;
}
return 0;
/* For UTF-32 BOM, always return 0. */
}
if( ((unsigned short *)z)[1] == 0 ) return 0;
/*
** This function returns non-zero if the blob starts with a UTF-16be
** byte-order-mark (BOM).
*/
int starts_with_utf16be_bom(const Blob *pContent, int *pnByte){
const char *z = blob_buffer(pContent);
int c1, c2;
}
if( pnByte ) *pnByte = 2;
if( blob_size(pContent)<2 ) return 0;
c1 = z[0]; c2 = z[1];
if( (c1==(char)0xfe) && (c2==(char)0xff) ){
return 1;
return 2;
}
return 0;
}
/*
** Return true if two DLine elements are identical.
*/
|
2405
2406
2407
2408
2409
2410
2411
2412
2413
2414
2415
2416
2417
2418
2419
2420
2421
2422
2423
2424
2425
2426
2427
2428
2429
2430
2431
2432
2433
|
2364
2365
2366
2367
2368
2369
2370
2371
2372
2373
2374
2375
2376
2377
2378
2379
2380
2381
2382
2383
2384
2385
2386
2387
2388
2389
2390
2391
2392
|
-
+
-
+
|
zLimit = find_option("limit",0,1);
if( zLimit==0 || zLimit[0]==0 ) zLimit = "-1";
iLimit = atoi(zLimit);
showLog = find_option("log",0,0)!=0;
fileVers = find_option("filevers",0,0)!=0;
db_must_be_within_tree();
if (g.argc<3) {
if( g.argc<3 ){
usage("FILENAME");
}
file_tree_name(g.argv[2], &treename, 1);
zFilename = blob_str(&treename);
fnid = db_int(0, "SELECT fnid FROM filename WHERE name=%Q", zFilename);
if( fnid==0 ){
fossil_fatal("no such file: %s", zFilename);
}
fid = db_int(0, "SELECT rid FROM vfile WHERE pathname=%Q", zFilename);
if( fid==0 ){
fossil_fatal("not part of current checkout: %s", zFilename);
}
cid = db_lget_int("checkout", 0);
if (cid == 0){
if( cid == 0 ){
fossil_fatal("Not in a checkout");
}
if( iLimit<=0 ) iLimit = 1000000000;
compute_direct_ancestors(cid, iLimit);
mid = db_int(0, "SELECT mlink.mid FROM mlink, ancestor "
" WHERE mlink.fid=%d AND mlink.fnid=%d AND mlink.mid=ancestor.rid"
" ORDER BY ancestor.generation ASC LIMIT 1",
|