Fossil SCM
Add support for detecting standalone carriage-return characters via the looks_like_utf*() functions.
Commit
6c7185d9baa3bce7bbbf9cc121a61225966cba5a
Parent
30e4e3e25d12507…
1 file changed
+10
-4
+10
-4
| --- src/diff.c | ||
| +++ src/diff.c | ||
| @@ -69,14 +69,15 @@ | ||
| 69 | 69 | ** Output flags for the looks_like_utf8() and looks_like_utf16() routines used |
| 70 | 70 | ** to convey status information about the blob content. |
| 71 | 71 | */ |
| 72 | 72 | #define LOOK_NONE ((int)0x00000000) /* Nothing special was found. */ |
| 73 | 73 | #define LOOK_NUL ((int)0x00000001) /* One or more NUL chars were found. */ |
| 74 | -#define LOOK_LF ((int)0x00000002) /* One or more LF chars were found. */ | |
| 75 | -#define LOOK_CRLF ((int)0x00000004) /* One or more CR/LF pairs were found. */ | |
| 76 | -#define LOOK_LENGTH ((int)0x00000008) /* An over length line was found. */ | |
| 77 | -#define LOOK_ODD ((int)0x00000010) /* An odd number of bytes was found. */ | |
| 74 | +#define LOOK_CR ((int)0x00000002) /* One or more CR chars were found. */ | |
| 75 | +#define LOOK_LF ((int)0x00000004) /* One or more LF chars were found. */ | |
| 76 | +#define LOOK_CRLF ((int)0x00000008) /* One or more CR/LF pairs were found. */ | |
| 77 | +#define LOOK_LENGTH ((int)0x00000010) /* An over length line was found. */ | |
| 78 | +#define LOOK_ODD ((int)0x00000020) /* An odd number of bytes was found. */ | |
| 78 | 79 | #endif /* INTERFACE */ |
| 79 | 80 | |
| 80 | 81 | /* |
| 81 | 82 | ** Maximum length of a line in a text file, in bytes. (2**13 = 8192 bytes) |
| 82 | 83 | */ |
| @@ -256,10 +257,12 @@ | ||
| 256 | 257 | if( j>LENGTH_MASK ){ |
| 257 | 258 | if( pFlags ) *pFlags |= LOOK_LENGTH; |
| 258 | 259 | result = 0; /* Very long line -> binary */ |
| 259 | 260 | } |
| 260 | 261 | j = 0; |
| 262 | + }else if( c=='\r' ){ | |
| 263 | + if( pFlags ) *pFlags |= LOOK_CR; | |
| 261 | 264 | } |
| 262 | 265 | } |
| 263 | 266 | if( j>LENGTH_MASK ){ |
| 264 | 267 | if( pFlags ) *pFlags |= LOOK_LENGTH; |
| 265 | 268 | result = 0; /* Very long line -> binary */ |
| @@ -357,10 +360,12 @@ | ||
| 357 | 360 | if( j>UTF16_LENGTH_MASK ){ |
| 358 | 361 | if( pFlags ) *pFlags |= LOOK_LENGTH; |
| 359 | 362 | result = 0; /* Very long line -> binary */ |
| 360 | 363 | } |
| 361 | 364 | j = 0; |
| 365 | + }else if( c==UTF16BE_CR || c==UTF16LE_CR ){ | |
| 366 | + if( pFlags ) *pFlags |= LOOK_CR; | |
| 362 | 367 | } |
| 363 | 368 | } |
| 364 | 369 | if( j>UTF16_LENGTH_MASK ){ |
| 365 | 370 | if( pFlags ) *pFlags |= LOOK_LENGTH; |
| 366 | 371 | result = 0; /* Very long line -> binary */ |
| @@ -2487,11 +2492,12 @@ | ||
| 2487 | 2492 | fossil_print("File \"%s\" has %d bytes.\n",g.argv[2],blob_size(&blob)); |
| 2488 | 2493 | fossil_print("Starts with UTF-8 BOM: %s\n",fUtf8?"yes":"no"); |
| 2489 | 2494 | fossil_print("Starts with UTF-16 BOM: %s\n",fUtf16?"yes":"no"); |
| 2490 | 2495 | fossil_print("Looks like UTF-%s: %s\n",fUtf16?"16":"8",eType?"yes":"no"); |
| 2491 | 2496 | fossil_print("Has flag LOOK_NUL: %s\n",(lookFlags&LOOK_NUL)?"yes":"no"); |
| 2497 | + fossil_print("Has flag LOOK_CR: %s\n",(lookFlags&LOOK_CR)?"yes":"no"); | |
| 2492 | 2498 | fossil_print("Has flag LOOK_LF: %s\n",(lookFlags&LOOK_LF)?"yes":"no"); |
| 2493 | 2499 | fossil_print("Has flag LOOK_CRLF: %s\n",(lookFlags&LOOK_CRLF)?"yes":"no"); |
| 2494 | 2500 | fossil_print("Has flag LOOK_LENGTH: %s\n",(lookFlags&LOOK_LENGTH)?"yes":"no"); |
| 2495 | 2501 | fossil_print("Has flag LOOK_ODD: %s\n",(lookFlags&LOOK_ODD)?"yes":"no"); |
| 2496 | 2502 | blob_reset(&blob); |
| 2497 | 2503 | } |
| 2498 | 2504 |
| --- src/diff.c | |
| +++ src/diff.c | |
| @@ -69,14 +69,15 @@ | |
| 69 | ** Output flags for the looks_like_utf8() and looks_like_utf16() routines used |
| 70 | ** to convey status information about the blob content. |
| 71 | */ |
| 72 | #define LOOK_NONE ((int)0x00000000) /* Nothing special was found. */ |
| 73 | #define LOOK_NUL ((int)0x00000001) /* One or more NUL chars were found. */ |
| 74 | #define LOOK_LF ((int)0x00000002) /* One or more LF chars were found. */ |
| 75 | #define LOOK_CRLF ((int)0x00000004) /* One or more CR/LF pairs were found. */ |
| 76 | #define LOOK_LENGTH ((int)0x00000008) /* An over length line was found. */ |
| 77 | #define LOOK_ODD ((int)0x00000010) /* An odd number of bytes was found. */ |
| 78 | #endif /* INTERFACE */ |
| 79 | |
| 80 | /* |
| 81 | ** Maximum length of a line in a text file, in bytes. (2**13 = 8192 bytes) |
| 82 | */ |
| @@ -256,10 +257,12 @@ | |
| 256 | if( j>LENGTH_MASK ){ |
| 257 | if( pFlags ) *pFlags |= LOOK_LENGTH; |
| 258 | result = 0; /* Very long line -> binary */ |
| 259 | } |
| 260 | j = 0; |
| 261 | } |
| 262 | } |
| 263 | if( j>LENGTH_MASK ){ |
| 264 | if( pFlags ) *pFlags |= LOOK_LENGTH; |
| 265 | result = 0; /* Very long line -> binary */ |
| @@ -357,10 +360,12 @@ | |
| 357 | if( j>UTF16_LENGTH_MASK ){ |
| 358 | if( pFlags ) *pFlags |= LOOK_LENGTH; |
| 359 | result = 0; /* Very long line -> binary */ |
| 360 | } |
| 361 | j = 0; |
| 362 | } |
| 363 | } |
| 364 | if( j>UTF16_LENGTH_MASK ){ |
| 365 | if( pFlags ) *pFlags |= LOOK_LENGTH; |
| 366 | result = 0; /* Very long line -> binary */ |
| @@ -2487,11 +2492,12 @@ | |
| 2487 | fossil_print("File \"%s\" has %d bytes.\n",g.argv[2],blob_size(&blob)); |
| 2488 | fossil_print("Starts with UTF-8 BOM: %s\n",fUtf8?"yes":"no"); |
| 2489 | fossil_print("Starts with UTF-16 BOM: %s\n",fUtf16?"yes":"no"); |
| 2490 | fossil_print("Looks like UTF-%s: %s\n",fUtf16?"16":"8",eType?"yes":"no"); |
| 2491 | fossil_print("Has flag LOOK_NUL: %s\n",(lookFlags&LOOK_NUL)?"yes":"no"); |
| 2492 | fossil_print("Has flag LOOK_LF: %s\n",(lookFlags&LOOK_LF)?"yes":"no"); |
| 2493 | fossil_print("Has flag LOOK_CRLF: %s\n",(lookFlags&LOOK_CRLF)?"yes":"no"); |
| 2494 | fossil_print("Has flag LOOK_LENGTH: %s\n",(lookFlags&LOOK_LENGTH)?"yes":"no"); |
| 2495 | fossil_print("Has flag LOOK_ODD: %s\n",(lookFlags&LOOK_ODD)?"yes":"no"); |
| 2496 | blob_reset(&blob); |
| 2497 | } |
| 2498 |
| --- src/diff.c | |
| +++ src/diff.c | |
| @@ -69,14 +69,15 @@ | |
| 69 | ** Output flags for the looks_like_utf8() and looks_like_utf16() routines used |
| 70 | ** to convey status information about the blob content. |
| 71 | */ |
| 72 | #define LOOK_NONE ((int)0x00000000) /* Nothing special was found. */ |
| 73 | #define LOOK_NUL ((int)0x00000001) /* One or more NUL chars were found. */ |
| 74 | #define LOOK_CR ((int)0x00000002) /* One or more CR chars were found. */ |
| 75 | #define LOOK_LF ((int)0x00000004) /* One or more LF chars were found. */ |
| 76 | #define LOOK_CRLF ((int)0x00000008) /* One or more CR/LF pairs were found. */ |
| 77 | #define LOOK_LENGTH ((int)0x00000010) /* An over length line was found. */ |
| 78 | #define LOOK_ODD ((int)0x00000020) /* An odd number of bytes was found. */ |
| 79 | #endif /* INTERFACE */ |
| 80 | |
| 81 | /* |
| 82 | ** Maximum length of a line in a text file, in bytes. (2**13 = 8192 bytes) |
| 83 | */ |
| @@ -256,10 +257,12 @@ | |
| 257 | if( j>LENGTH_MASK ){ |
| 258 | if( pFlags ) *pFlags |= LOOK_LENGTH; |
| 259 | result = 0; /* Very long line -> binary */ |
| 260 | } |
| 261 | j = 0; |
| 262 | }else if( c=='\r' ){ |
| 263 | if( pFlags ) *pFlags |= LOOK_CR; |
| 264 | } |
| 265 | } |
| 266 | if( j>LENGTH_MASK ){ |
| 267 | if( pFlags ) *pFlags |= LOOK_LENGTH; |
| 268 | result = 0; /* Very long line -> binary */ |
| @@ -357,10 +360,12 @@ | |
| 360 | if( j>UTF16_LENGTH_MASK ){ |
| 361 | if( pFlags ) *pFlags |= LOOK_LENGTH; |
| 362 | result = 0; /* Very long line -> binary */ |
| 363 | } |
| 364 | j = 0; |
| 365 | }else if( c==UTF16BE_CR || c==UTF16LE_CR ){ |
| 366 | if( pFlags ) *pFlags |= LOOK_CR; |
| 367 | } |
| 368 | } |
| 369 | if( j>UTF16_LENGTH_MASK ){ |
| 370 | if( pFlags ) *pFlags |= LOOK_LENGTH; |
| 371 | result = 0; /* Very long line -> binary */ |
| @@ -2487,11 +2492,12 @@ | |
| 2492 | fossil_print("File \"%s\" has %d bytes.\n",g.argv[2],blob_size(&blob)); |
| 2493 | fossil_print("Starts with UTF-8 BOM: %s\n",fUtf8?"yes":"no"); |
| 2494 | fossil_print("Starts with UTF-16 BOM: %s\n",fUtf16?"yes":"no"); |
| 2495 | fossil_print("Looks like UTF-%s: %s\n",fUtf16?"16":"8",eType?"yes":"no"); |
| 2496 | fossil_print("Has flag LOOK_NUL: %s\n",(lookFlags&LOOK_NUL)?"yes":"no"); |
| 2497 | fossil_print("Has flag LOOK_CR: %s\n",(lookFlags&LOOK_CR)?"yes":"no"); |
| 2498 | fossil_print("Has flag LOOK_LF: %s\n",(lookFlags&LOOK_LF)?"yes":"no"); |
| 2499 | fossil_print("Has flag LOOK_CRLF: %s\n",(lookFlags&LOOK_CRLF)?"yes":"no"); |
| 2500 | fossil_print("Has flag LOOK_LENGTH: %s\n",(lookFlags&LOOK_LENGTH)?"yes":"no"); |
| 2501 | fossil_print("Has flag LOOK_ODD: %s\n",(lookFlags&LOOK_ODD)?"yes":"no"); |
| 2502 | blob_reset(&blob); |
| 2503 | } |
| 2504 |