Fossil SCM

Remove unneeded variable: Since could_be_utf16() calls starts_with_utf16_bom() it can be deduced that for Unicode text, bRevUnicode always has the same value as bRevUtf16. The comments on the variables already suggested that.

jan.nijtmans 2014-04-28 12:24 trunk
Commit 09f23863286bdcf73f60d5b9d3d84adf496f36d3
1 file changed +2 -3
+2 -3
--- src/lookslike.c
+++ src/lookslike.c
@@ -377,11 +377,10 @@
377377
int fUtf8; /* return value of starts_with_utf8_bom() */
378378
int fUtf16; /* return value of starts_with_utf16_bom() */
379379
int fUnicode; /* return value of could_be_utf16() */
380380
int lookFlags; /* output flags from looks_like_utf8/utf16() */
381381
int bRevUtf16 = 0; /* non-zero -> UTF-16 byte order reversed */
382
- int bRevUnicode = 0; /* non-zero -> UTF-16 byte order reversed */
383382
int fForceUtf8 = find_option("utf8",0,0)!=0;
384383
int fForceUtf16 = find_option("utf16",0,0)!=0;
385384
const char *zCount = find_option("limit","n",1);
386385
int nRepeat = 1;
387386
@@ -394,14 +393,14 @@
394393
fUtf8 = starts_with_utf8_bom(&blob, 0);
395394
fUtf16 = starts_with_utf16_bom(&blob, 0, &bRevUtf16);
396395
if( fForceUtf8 ){
397396
fUnicode = 0;
398397
}else{
399
- fUnicode = could_be_utf16(&blob, &bRevUnicode) || fForceUtf16;
398
+ fUnicode = could_be_utf16(&blob, 0) || fForceUtf16;
400399
}
401400
if( fUnicode ){
402
- lookFlags = looks_like_utf16(&blob, bRevUnicode, 0);
401
+ lookFlags = looks_like_utf16(&blob, bRevUtf16, 0);
403402
}else{
404403
lookFlags = looks_like_utf8(&blob, 0)|invalid_utf8(&blob);
405404
}
406405
}
407406
fossil_print("File \"%s\" has %d bytes.\n",g.argv[2],blob_size(&blob));
408407
--- src/lookslike.c
+++ src/lookslike.c
@@ -377,11 +377,10 @@
377 int fUtf8; /* return value of starts_with_utf8_bom() */
378 int fUtf16; /* return value of starts_with_utf16_bom() */
379 int fUnicode; /* return value of could_be_utf16() */
380 int lookFlags; /* output flags from looks_like_utf8/utf16() */
381 int bRevUtf16 = 0; /* non-zero -> UTF-16 byte order reversed */
382 int bRevUnicode = 0; /* non-zero -> UTF-16 byte order reversed */
383 int fForceUtf8 = find_option("utf8",0,0)!=0;
384 int fForceUtf16 = find_option("utf16",0,0)!=0;
385 const char *zCount = find_option("limit","n",1);
386 int nRepeat = 1;
387
@@ -394,14 +393,14 @@
394 fUtf8 = starts_with_utf8_bom(&blob, 0);
395 fUtf16 = starts_with_utf16_bom(&blob, 0, &bRevUtf16);
396 if( fForceUtf8 ){
397 fUnicode = 0;
398 }else{
399 fUnicode = could_be_utf16(&blob, &bRevUnicode) || fForceUtf16;
400 }
401 if( fUnicode ){
402 lookFlags = looks_like_utf16(&blob, bRevUnicode, 0);
403 }else{
404 lookFlags = looks_like_utf8(&blob, 0)|invalid_utf8(&blob);
405 }
406 }
407 fossil_print("File \"%s\" has %d bytes.\n",g.argv[2],blob_size(&blob));
408
--- src/lookslike.c
+++ src/lookslike.c
@@ -377,11 +377,10 @@
377 int fUtf8; /* return value of starts_with_utf8_bom() */
378 int fUtf16; /* return value of starts_with_utf16_bom() */
379 int fUnicode; /* return value of could_be_utf16() */
380 int lookFlags; /* output flags from looks_like_utf8/utf16() */
381 int bRevUtf16 = 0; /* non-zero -> UTF-16 byte order reversed */
 
382 int fForceUtf8 = find_option("utf8",0,0)!=0;
383 int fForceUtf16 = find_option("utf16",0,0)!=0;
384 const char *zCount = find_option("limit","n",1);
385 int nRepeat = 1;
386
@@ -394,14 +393,14 @@
393 fUtf8 = starts_with_utf8_bom(&blob, 0);
394 fUtf16 = starts_with_utf16_bom(&blob, 0, &bRevUtf16);
395 if( fForceUtf8 ){
396 fUnicode = 0;
397 }else{
398 fUnicode = could_be_utf16(&blob, 0) || fForceUtf16;
399 }
400 if( fUnicode ){
401 lookFlags = looks_like_utf16(&blob, bRevUtf16, 0);
402 }else{
403 lookFlags = looks_like_utf8(&blob, 0)|invalid_utf8(&blob);
404 }
405 }
406 fossil_print("File \"%s\" has %d bytes.\n",g.argv[2],blob_size(&blob));
407

Keyboard Shortcuts

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